This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Inserting named labels through a GCC plugin


Hi,
I'm writing a gcc plugin to find out target basic blocks to branch
instructions, and need to match instructions and basic blocks with
compiled binaries, so I decided to explicitly annotate all the branch
instructions and basic blocks with named labels, then from the
compiler plugin I assign named labels to branch instructions and basic
blocks, and from symbol table I can get offset to these instructions
and basic blocks. Is this the right way to do it, or I shouldn't do
this task in compiling phase?

When I was trying with this method, I wrote a plugin with some code like this:

unsigned int
first_rtl_exec(void)
{
  rtx insn, bb_start, bb_end;
  basic_block bb;
  FOR_EACH_BB(bb)
  {
    bb_start = gen_label_rtx();
    LABEL_NAME(bb_start) = "BB Start";
    LABEL_NUSES(bb_start) = 1;
    bb_end = gen_label_rtx();
    LABEL_NAME(bb_end) = "BB End";
    LABEL_NUSES(bb_end) = 1;

    emit_label_before(bb_start, BB_HEAD(bb));
    emit_label_after(bb_end, BB_END(bb));
  }

  return 0;
}

I insert this pass before final pass.

But when compiling C program with this plugin, I got error:

foo.c:7:1: internal compiler error: in final, at final.c:1958
 }
 ^

It seems this is not the correct way to insert labels. Am I using
emit_label_* in a wrong way, at wrong time, or I'm totally in the
wrong direction?

Thanks,
Yue Liu


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]