[LLVMdev] Could insert a label into basic block?

Misha Brukman brukman at uiuc.edu
Thu Aug 19 15:10:03 PDT 2004


On Thu, Aug 19, 2004 at 12:33:41PM -0700, Zhang Qiuyu wrote:
> I am trying to get the memory address  of each basic block. So far I
> am trying to add the label into each basic block, actually I need add
> the label at front of each basic block and then I can use command 'nm'
> to find the memory address for each basic block. That's the way I got.
> I don't know if there is another way to do it.  Thanks.
> 
> So now I need add label to each basic block, I don't know how to do
> it.  Thanks for any response.

Do you mean you want the [1] memory location of each LLVM basic block as
it becomes code-generated to assembly?  Or do you mean [2] address of
each native code basic block?

If you mean [1], the problem is that LLVM basic blocks may not correlate
one-to-one with native code basic blocks, due to instruction selection
which may introduce basic blocks or combine basic blocks, etc.

Note that [2] doesn't really have 'labels', textual labels are just a
programming convenience, in native object code, all branches are jumps
to some integer offset, so you would have to parse the native object
file and find where all the native code jumps to.

What is it that you are trying to achieve as your goal?  Maybe it can be
done differently without BB addresses.

-- 
Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu




More information about the llvm-dev mailing list