Re: A working GIMPLE simple IPA case to run?

2021-02-20 Thread Shuai Wang via Gcc
source1.c called function bar in source2.c. How can I cross analyze foo then bar? Thank you! Best, Shuai On Wed, Feb 17, 2021 at 4:04 PM Martin Liška wrote: > On 2/17/21 5:21 AM, Shuai Wang via Gcc wrote: > > Could anyone shed some light on this? Thank you very much! > > Hel

Re: How to decide the what type is currently being used in tree_node?

2021-02-19 Thread Shuai Wang via Gcc
2021 at 10:31, Shuai Wang via Gcc wrote: > > > > Hello, > > > > I noticed that tree_node is implemented as a union ( > > https://code.woboq.org/gcc/gcc/tree-core.h.html#tree_node). However, I > > cannot find a way of checking whether the current tree_node

How to decide the what type is currently being used in tree_node?

2021-02-18 Thread Shuai Wang via Gcc
Hello, I noticed that tree_node is implemented as a union ( https://code.woboq.org/gcc/gcc/tree-core.h.html#tree_node). However, I cannot find a way of checking whether the current tree_node is really a base or type. For instance, currently when I am using: is_gimple_constant(v) Given `v` as a

Re: Performing inter-procedural dataflow analysis

2021-02-17 Thread Shuai Wang via Gcc
By saying a_2(D) originated from parameter "a", what I mean is that I obtain the tree pointer of "a" given the tree pointer of a_2(D). Is that possible? I can somehow image to first get the string name of these variables and do a clumsy (?) comparison. But that seems not very handy... Thank you!

Performing inter-procedural dataflow analysis

2021-02-17 Thread Shuai Wang via Gcc
Hello, I am doing interprocedural dataflow analysis and countered the following issue. Suppose I have an GIMPLE IR code as follows, which is after the "simdclone" pass while before my own SIMPLE IPA pass: foo (int a, int b) { int c; int d; int D.2425; int _5; : * c_4 = a_2(D) + b_3(

Re: Get struct function* from function declaration

2021-02-16 Thread Shuai Wang via Gcc
Thank you again for the help. I think the root cause is that instead of using GIMPLE_PASS, my analysis requires to do IPA. I am struggling in switching to SIMPLE_IPA_PASS now Best, Shuai On Wed, Feb 17, 2021 at 8:41 AM Shuai Wang wrote: > I think the gist is that the recovered pointer itsel

A working GIMPLE simple IPA case to run?

2021-02-16 Thread Shuai Wang via Gcc
Hello, I am writing to inquire if there was any working example of GIMPLE SIMPLE_IPA_PASS that I can follow and extend. I am familiar with doing GIMPLE_PASS for intra-procedural analysis. I tried to follow these threads: https://www.cse.iitb.ac.in/grc/gcc-workshop-10/sources/slides/gccw10-gimple

Re: Get struct function* from function declaration

2021-02-16 Thread Shuai Wang via Gcc
I think the gist is that the recovered pointer itself is somehow NULL: tree current_fn_decl = gimple_call_fndecl(stmt); if (!current_fn_decl) return false; // *this won't execute* struct function* fs0 = DECL_STRUCT_FUNCTION(current_fn_decl); if (!f

Re: Get struct function* from function declaration

2021-02-16 Thread Shuai Wang via Gcc
Hello Martin, Thanks for the information. I tried but it's the same error. Is it possibly due to some bugs or something? I use gcc 10.1.0. Best, Shuai On Wed, Feb 17, 2021 at 2:36 AM Martin Liška wrote: > On 2/16/21 1:13 PM, Shuai Wang wrote: > > std::cerr << get_name(f->decl) << std::endl; >

Re: Get struct function* from function declaration

2021-02-16 Thread Shuai Wang via Gcc
(a_6, d_2); And trigger the above procedure. Function `foo` has been traversed before this statement which means the corresponding function* should have been created already? Best, Shuai On Tue, Feb 16, 2021 at 9:23 PM Shubham Narlawar wrote: > > > On Tue, 16 Feb, 2021, 5:55 PM Shua

Re: Get struct function* from function declaration

2021-02-16 Thread Shuai Wang via Gcc
ws an exception as follows: during GIMPLE pass: XXX // here XXX is my pass name internal compiler error: Segmentation fault ... That seems strange. Does that seem familiar to you by any chance? Thank you! Best, Shuai On Tue, Feb 16, 2021 at 7:52 PM Martin Liška wrote: > On 2/16/21 9:51

Get struct function* from function declaration

2021-02-16 Thread Shuai Wang via Gcc
Hello, I am doing some inter-procedural analysis and suppose I have encountered the following function calls: int a = foo(b, c); And I have accessed a tree representing foo as follows: tree func_decl = gimple_call_fndecl(stmt); // stmt is the function call statement where func_de

Define __attribute__((no_instrument_function)) but still got instrumented

2020-08-06 Thread Shuai Wang via Gcc
Hello! I am working on a ARM GCC plugin which instruments each GIMPLE function with some new function calls. Currently I want to skip certain functions by adding the no_instrument_function attribute. However, I do see that in the disassembled code, all functions are still instrumented. Am I miss

Re: Loading plugins with arm-none-eabi-gcc

2020-07-23 Thread Shuai Wang via Gcc
rm compilation (on Ubuntu x86), I am >> anticipating to NOT directly compile my plugin (as a typical .so shared >> library) into an ARM library, right? Otherwise it cannot be loaded and >> executed on x86 Ubuntu, right? >> > >> > 4. Then it seems to me that sti

Re: Loading plugins with arm-none-eabi-gcc

2020-07-22 Thread Shuai Wang via Gcc
hen somewhat use the arm-none-eabi-gcc to load the plugin > during cross architecture compilation? > > > > Best, > > Shuai > > > > > > > > On Wed, Jul 22, 2020 at 3:20 PM Andrew Pinski wrote: > >> > >> On Tue, Jul 21, 2020 at

Re: Loading plugins with arm-none-eabi-gcc

2020-07-22 Thread Shuai Wang via Gcc
; On Tue, Jul 21, 2020 at 11:25 PM Shuai Wang via Gcc > wrote: > > > > Hello, > > > > I am currently trying to migrate a gcc plugin that has been well > developed > > for x86 code to ARM platform (for arm-none-eabi-gcc). > > > > Currently I did the fol

Loading plugins with arm-none-eabi-gcc

2020-07-21 Thread Shuai Wang via Gcc
Hello, I am currently trying to migrate a gcc plugin that has been well developed for x86 code to ARM platform (for arm-none-eabi-gcc). Currently I did the following steps: 1. write a hello world program t.c 2. compile with the following commands: ➜ arm-none-eabi-gcc -v ..

Re: Crash at gimple_code(gimple* )

2020-07-15 Thread Shuai Wang via Gcc
cy of _314...? Thanks a lot! Best, Shuai On Wed, Jul 15, 2020 at 6:49 PM Martin Jambor wrote: > Hi, > > On Wed, Jul 15 2020, Shuai Wang via Gcc wrote: > > Hello, > > > > I am using the following code to iterate different gimple statements: > > > > .

Crash at gimple_code(gimple* )

2020-07-15 Thread Shuai Wang via Gcc
Hello, I am using the following code to iterate different gimple statements: ... gimple* stmt = gsi_stmt(gsi); if (gimple_assign_load_p(stmt)) { tree rhs = gimple_assign_rhs1 (stmt); if (!rhs) return; gimple* def_stmt = SSA_NAME_DEF_STMT(rhs); if (!def_stmt) return; s

Re: Understand pointer deferences in GIMPLE

2020-07-14 Thread Shuai Wang via Gcc
Thank you. Yes, I think gimple_store_p and gimple_assign_load_p should be what I am looking for. Best, Shuai On Tue, Jul 14, 2020 at 5:38 PM Richard Biener wrote: > On Tue, Jul 14, 2020 at 9:17 AM Shuai Wang via Gcc > wrote: > > > > Hello, > > > > I am trying to

Understand pointer deferences in GIMPLE

2020-07-14 Thread Shuai Wang via Gcc
Hello, I am trying to traverse the GIMPlE statements and identify all pointer differences (i.e., memory load and store). For instance, something like: **_4* = 0; ... _108 = (signed char *) _107; _109 = **_108*; After some quick searches in the GCC codebase, I am thinking to use the foll

Re: Passing an string argument to a GIMPLE call

2020-06-27 Thread Shuai Wang via Gcc
ing? Can I somehow get the name of the C file? I don't find a corresponding pointer in the function struct. Best, Shuai On Sat, Jun 27, 2020 at 9:12 PM Richard Biener wrote: > On June 27, 2020 6:21:12 AM GMT+02:00, Shuai Wang via Gcc > wrote: > >Hello, > > > >I am wr

Passing an string argument to a GIMPLE call

2020-06-26 Thread Shuai Wang via Gcc
Hello, I am writing the following statement to make a GIMPLE call: tree function_fn_type = build_function_type_list(void_type_node, void_type_node, integer_type_node, NULL_TREE); tree sancov_fndecl = build_fn_decl("my_instrumentation_function", function_fn_type); auto gcall = gi

Re: Customized coverage instrumentation for multiple C files

2020-06-26 Thread Shuai Wang via Gcc
Any idea on that? I just cannot find a way of using GIMPLE to analyze multiple .C files. All my analysis is still start from the following function: virtual unsigned int execute(function *fun) override which has no idea about the .C file information. In LLVM all .C files are roughly maintained in

Customized coverage instrumentation for multiple C files

2020-06-25 Thread Shuai Wang via Gcc
Hello, I am working on a basic block coverage counter which mimics -fsanitize-coverage=trace-pc but has more features. My problem is that when instrumenting multiple C files (e.g., test1.c test2.c test3.c), I want to generate correspondingly three coverage logs (test1.log, test2.log, test3.log), s

Re: Exception at "need_ssa_update_p" during GIMPLE instrumentation

2020-06-21 Thread Shuai Wang via Gcc
OK, I think I know how to solve it. Just return TODO_update_ssa . On Sun, Jun 21, 2020 at 5:34 PM Shuai Wang wrote: > Hello, > > I am doing instrumentation of GIMPLE code by adding extra coverage > counters at each basic block. Basically it's

Exception at "need_ssa_update_p" during GIMPLE instrumentation

2020-06-21 Thread Shuai Wang via Gcc
Hello, I am doing instrumentation of GIMPLE code by adding extra coverage counters at each basic block. Basically it's mimicking -fsanitize-coverage=trace-pc, where the only difference is that __sanitizer_cov_trace_pc (the default hander of fsanitize-coverage=trace-pc) has no input parameters, bu

Any implementation of `__sanitizer_cov_trace_basic_block` in GCC?

2020-06-20 Thread Shuai Wang via Gcc
Hello, I am writing to inquire about the availability of any "__sanitizer_cov_trace_basic_block" implementations in gcc. I somewhat learned from the following mail discussion ( https://gcc.gnu.org/pipermail/gcc-patches/2015-December/437137.html) that `__sanitizer_cov_trace_basic_block` is provided

Re: Use gcov for line coverage info of GIMPLE code

2020-06-17 Thread Shuai Wang via Gcc
Enable coverage-guided fuzzing code instrumentation. Inserts > a call to "__sanitizer_cov_trace_pc" into every basic block. > > And put corresponding builtins to the true/false branches in the > instrumented code. > > Martin > > > > > Best, > > Shuai &

Re: Re-optimize instrumented GIMPLE code

2020-06-17 Thread Shuai Wang via Gcc
> wrapped within .ASAN_CHECK). > > Can you please explain which ASAN_CHECKs are you trying to modify? We can > probably find a proper > place where to implement your plugin-in functionality. > > Martin > > > > > Best, > > Shuai > > > > On Wed, Jun

Re: Re-optimize instrumented GIMPLE code

2020-06-17 Thread Shuai Wang via Gcc
nd it (it's somewhat wrapped within .ASAN_CHECK). Best, Shuai On Wed, Jun 17, 2020 at 2:49 PM Martin Liška wrote: > On 6/17/20 4:10 AM, Shuai Wang via Gcc wrote: > > Hello, > > > > Suppose I have changed certain if condition in the GIMPLE code (generated > > by

Re: Use gcov for line coverage info of GIMPLE code

2020-06-16 Thread Shuai Wang via Gcc
Hello Martin, The issue is that I want to count the coverage of "true/false" branches taken in sanitizer's if conditions.. Best, Shuai On Wed, Jun 17, 2020 at 2:52 PM Martin Liška wrote: > On 6/17/20 5:40 AM, Shuai Wang via Gcc wrote: > > Hello, > > >

Use gcov for line coverage info of GIMPLE code

2020-06-16 Thread Shuai Wang via Gcc
Hello, I am aware of how to use gcov for c code line coverage collection. However, currently I am working on a piece of GIMPLE code (did some instrumentation on the GIMPLE code and therefore is more complex compared to the original C code)l, and would like to collect the line coverage info of GIMP

Re-optimize instrumented GIMPLE code

2020-06-16 Thread Shuai Wang via Gcc
Hello, Suppose I have changed certain if condition in the GIMPLE code (generated by the `sanopt` pass) into the following format: if (0 == 1) { } Then, in order to completely remove this unnecessary if condition and the guarded true branch, I want to leverage the dead code elimination op

Re: SSA_NAME_DEF_STMT or print_gimple_stmt for MEM_REF seems mal-functional

2020-06-15 Thread Shuai Wang via Gcc
_17 = (signed char *) _16 printed out? Thank you >> >very >> >much. >> > >> >Best, >> >Shuai >> > >> >On Tue, Jun 16, 2020 at 12:52 AM Richard Biener >> > >> >wrote: >> > >> >> On June 15, 2020 6:31:38 PM GMT+02

Re: SSA_NAME_DEF_STMT or print_gimple_stmt for MEM_REF seems mal-functional

2020-06-15 Thread Shuai Wang via Gcc
ery > >much. > > > >Best, > >Shuai > > > >On Tue, Jun 16, 2020 at 12:52 AM Richard Biener > > > >wrote: > > > >> On June 15, 2020 6:31:38 PM GMT+02:00, Shuai Wang via Gcc > > > >> wrote: > >> >Hello, > >> >

Re: SSA_NAME_DEF_STMT or print_gimple_stmt for MEM_REF seems mal-functional

2020-06-15 Thread Shuai Wang via Gcc
Could you please shed some light on where "non-ssa name" comes in this scenario, and how exactly can I get _17 = (signed char *) _16 printed out? Thank you very much. Best, Shuai On Tue, Jun 16, 2020 at 12:52 AM Richard Biener wrote: > On June 15, 2020 6:31:38 PM GMT+02:00, Shua

SSA_NAME_DEF_STMT or print_gimple_stmt for MEM_REF seems mal-functional

2020-06-15 Thread Shuai Wang via Gcc
Hello, Suppose given the following SSA statement generated by the `sanopt` pass: _17 = (signed char *) _16; _18 = *_17; I am using the following code to identify that _17 depends on _16: // def_stmt refers to _18 = &_17; for (unsigned i = 1; i < gimple_num_ops(def_stmt); i++) { o

Re: How to get the data dependency of GIMPLE variables?

2020-06-14 Thread Shuai Wang via Gcc
} Sorry for such naive questions.. I actually searched the documents and GIMPLE pretty print for a while but couldn't find such a way of accessing arbitrary numbers of operands... Best, Shuai On Mon, Jun 15, 2020 at 12:10 PM Marc Glisse wrote: > On Mon, 15 Jun 2020, Shuai Wang via Gcc

How to get the data dependency of GIMPLE variables?

2020-06-14 Thread Shuai Wang via Gcc
Hello, I am trying to analyze the following gimple statements, where the data dependency of _23 is a tree, whose leave nodes are three constant values {13, 4, 14}. Could anyone shed some light on how such a backward traversal can be implemented? Given _22 used in the last assignment, I have no id

Write plugin for `sanopt` or `asan0` passes

2020-06-14 Thread Shuai Wang via Gcc
Hello, I am writing to inquire the procedure (or any tutorial) to write plugins for the `sanopt` pass. Basically I am doing some analysis of ASan/UBSan checks. I use the following command to dump all passes in IR format: gcc -fdump-tree-all -fsanitize=address test.c To me, I think the following

Re: Inquire a potential bug when printing out GIMPLE ASAN statements

2020-06-09 Thread Shuai Wang via Gcc
can iterate all GIMPLE call statements, but how >> to exactly figure out ASAN_MARK seems quite obscure. >> >> Thank you! >> >> Best, >> Shuai >> >> On Tue, Jun 9, 2020 at 3:48 PM Richard Biener >> wrote: >> >>> On Tue, Jun 9, 2020 at 3:38

Re: Inquire a potential bug when printing out GIMPLE ASAN statements

2020-06-09 Thread Shuai Wang via Gcc
ance that I can still pinpoint this special > function call? Currently I can iterate all GIMPLE call statements, but how > to exactly figure out ASAN_MARK seems quite obscure. > > Thank you! > > Best, > Shuai > > On Tue, Jun 9, 2020 at 3:48 PM Richard Biener > w

Re: Inquire a potential bug when printing out GIMPLE ASAN statements

2020-06-09 Thread Shuai Wang via Gcc
, Shuai On Tue, Jun 9, 2020 at 3:48 PM Richard Biener wrote: > On Tue, Jun 9, 2020 at 3:38 AM Shuai Wang via Gcc wrote: > > > > Hello! > > > > I am writing to report a potential bug I encountered when playing with > the > > GIMPLE IR. I enabled the ASan and w

Inquire a potential bug when printing out GIMPLE ASAN statements

2020-06-08 Thread Shuai Wang via Gcc
Hello! I am writing to report a potential bug I encountered when playing with the GIMPLE IR. I enabled the ASan and would like to print out all ASAN_MARK statements for the following simple code: int main(int argc ,char **argv) { int stack_array[100]; stack_array[1] = 100; stack_array[arg