[LLVMdev] Re:About the address of Basic Block

Chris Lattner sabre at nondot.org
Fri Aug 20 17:34:04 PDT 2004


On Fri, 20 Aug 2004, Zhang Qiuyu wrote:
> There is application i.e decoder.c . I compile it using llvm and get
> excutable file/object file ( named decoder.out/decoder.o ) and
> decoder.s. And I wrote another code loader.c which is trying to find the
> entry of decoder.out, actually I guess it is the first basic block we
> need run. If I got the address of entry basic block, I want to copy the

Are you trying to do trace based optimizations like dynamo or daisy does?
Is there any reason where normal JIT compilation won't work for you?  If
you're interested in this type of thing, talking to Brian and Vikram about
the reoptimizer is the best bet.

> Actually, I want to simulate the procedure of excuting program by using
> my loader to excute it. And I can do some statistic and operation such
> as cache miss, basic block clustering, compress etc ( these are just my
> guess :). I know some tools like simplescalar can do lots stuff but it
> is not what I want.

Depending on what you want, have you considered using simple
instrumentation to do this?  If you look at the various profiling
implementations we have, you'll see that it's very easy to add arbitrary
instrumentation passes to LLVM, then have llvm-prof digest the info
produced.  You should be able to do this without hacking on the code
generators or machine code basic blocks at all.

> So I am not sure how I could get the address of each basic block in
> decoder.out/decoder.o? and I am not sure it is available to implement
> what I want either?

I don't think there is a good way to do this.  If you use the SparcV9
backend, it currently maintains a 1-1 mapping between LLVM basic blocks
and machine code basic blocks, but I don't know how long this will be true
(an optimization named modulo scheduling is being worked on, which will
break this).

> Originally I browser the decoder.s file and see there is a label at the
> front of basic block, so I thought maybe after compiling the decoder.s,
> I can use nm to exact the address from label information. But I failed
> :-( (someone told me it is possible to get the address of memory if
> there is a label in your code).

Yup, those labels are private to avoid filling up the symbol table for the
.o and .exe files, sorry!

-Chris

-- 
http://llvm.org/
http://nondot.org/sabre/




More information about the llvm-dev mailing list