Write plugin for `sanopt` or `asan0` passes
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 two outputs: test.c.228t.asan0 test.c.230t.sanopt Seems both useful. I am relatively familiar with GIMPLE plugins; however, I note that in the GIMPLE code (e.g., test.c.005t.gimple), I just cannot find the corresponding ASAN check function calls, like .ASAN_CHECK. Therefore, it seems that I cannot do GIMPLE-level plugin, although that seems easy for my tasks. Basically I will need to pinpoint either (in test.c.228t.asan0): : .ASAN_MARK (UNPOISON, &stack_array, 400); _10 = &stack_array[1]; * .ASAN_CHECK (7, _10, 4, 4); <--* stack_array[1] = 100; _1 = argc_5(D) + 12; _11 = &stack_array[_1]; * .ASAN_CHECK (6, _11, 4, 4); <--* c_6 = stack_array[_1]; Or (in test.c.230t.sanopt): _20 = _14 & 7; _21 = (signed char) _20; _22 = _21 + 3; _23 = _22 >= _18; _24 = _19 & _23; if (_24 != 0) goto ; [0.05%] else goto ; [99.95%] : * __builtin___asan_report_store4 (_14); <-* Could anyone shed some lights on how to write analysis passes/plugins for the outputs of either `sanopt` or `asan0`; I would prefer `sanopt` but any suggestion would be appreciated. Thank you very much. Best, Shuai
Re: Is it very hard to implement Zero-overhead deterministic exceptions: Throwing values??
sotrdg sotrdg via Gcc writes: > http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0709r0.pdf > > I really want this feature. How, it looks like this requires changes > on RTL, gimple and C++ front-end. Is that very hard to implement it? If you're asking about setjmp/longjmp exceptions, you can already configure with --enable-sjlj-exceptions and then use -fsjlj-exceptions to enable them. It would be a new ABI and likely break some existing libraries. -Andi
Re: Is it very hard to implement Zero-overhead deterministic exceptions: Throwing values??
On Sun, Jun 14, 2020 at 2:27 PM Andi Kleen via Gcc wrote: > > sotrdg sotrdg via Gcc writes: > > > http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0709r0.pdf > > > > I really want this feature. How, it looks like this requires changes > > on RTL, gimple and C++ front-end. Is that very hard to implement it? > > If you're asking about setjmp/longjmp exceptions, you can already > configure with --enable-sjlj-exceptions and then use -fsjlj-exceptions > to enable them. > > It would be a new ABI and likely break some existing libraries. NOTE Setjmp/longjump is much much slower if exceptions are not used at all. Because there will be many many setjump locations. Thanks, Andrew Pinski > > -Andi
gcc-11-20200614 is now available
Snapshot gcc-11-20200614 is now available on https://gcc.gnu.org/pub/gcc/snapshots/11-20200614/ and on various mirrors, see http://gcc.gnu.org/mirrors.html for details. This snapshot has been generated from the GCC 11 git branch with the following options: git://gcc.gnu.org/git/gcc.git branch master revision 3de12cc548c7a37bb68ea10937709dc6385a3b2b You'll find: gcc-11-20200614.tar.xz Complete GCC SHA256=40635ce0e16ad628ea195270923b2bcbbcb6e1e552e0a18dfc1a9c49f286a741 SHA1=2bc464e5658a1312b4fa938dbfc16952cb6c61fe Diffs from 11-20200607 are available in the diffs/ subdirectory. When a particular snapshot is ready for public consumption the LATEST-11 link is updated and a message is sent to the gcc list. Please do not use a snapshot before it has been announced that way.
How to get the data dependency of GIMPLE variables?
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 idea of how to trace back to its definition on the fourth statement... Thank you very much! _13 = 13; _14 = _13 + 4; _15 = 14; _22 = (unsigned long) _15; _23 = _22 + _14; Best regards
Re: How to get the data dependency of GIMPLE variables?
On Mon, 15 Jun 2020, Shuai Wang via Gcc wrote: 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 idea of how to trace back to its definition on the fourth statement... Thank you very much! SSA_NAME_DEF_STMT _13 = 13; _14 = _13 + 4; _15 = 14; _22 = (unsigned long) _15; _23 = _22 + _14; -- Marc Glisse
Re: How to get the data dependency of GIMPLE variables?
Dear Marc, Thank you very much! Just another quick question.. Can I iterate the operands of a GIMPLE statement, like how I iterate a LLVM instruction in the following way? Instruction* instr; for (size_t i=0; i< instr->getNumOperands();i++) { instr->getOperand(i)) } 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 wrote: > > > 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 idea of how > > to trace back to its definition on the fourth statement... Thank you > > very much! > > SSA_NAME_DEF_STMT > > > _13 = 13; > > _14 = _13 + 4; > > _15 = 14; > > _22 = (unsigned long) _15; > > _23 = _22 + _14; > > -- > Marc Glisse >