Add instructions in the beginning of a function

Marios Pomonis mpomonis@cs.columbia.edu
Sun Oct 4 20:53:00 GMT 2015


Hi,

I'm trying to add some instructions in the beginning of each function 
using a gcc plugin in RTL (after "vartrack").
I am currently doing this by iterating the instructions in the first 
basic block and calling `emit_insn_before()' when reaching the first 
"real" instruction (one that has INSN, CALL or JUMP as code).

This works ok if the first "real" instruction is not part of a loop, 
because in this case the additional instructions are also executed as well.
I know that this happens because there is at least one CODE_LABEL rtx 
before the first "real" instruction, however all my attempts to fix this 
(e.g. by adding the additional instructions before the labels and 
splitting the basic block) failed.

Does anyone have a suggestion on how this should be fixed properly?

Thanks!



More information about the Gcc-help mailing list