Re:About the address of Basic Block

I really appreciated for you guys' help and thanks all you guys, Misha Brukman, Vikram S. Adve, Michael McCracken, Chris Lattner and Brian R. Gaeke .

I hope I can make it clear :-). I am trying ...

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 basic block in the decoder.out to a segment of memory, and the loader jump the start of the memory segment and run the code. Then after running the entry basic block, the loader can load the next basic block and running it. keeping doing it. Of course, we know some of basic blocks can never be used.

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.

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?

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 :frowning: (someone told me it is possible to get the address of memory if there is a label in your code).

I am not sure it is clear or not. Any reply is welcome.

Thanks

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
:frowning: (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