Vikram S. Adve
2004-Aug-19 22:39 UTC
[LLVMdev] How could I get memory address for each basic block?
Qiuyu, The dynamic optimization project (an internal research project in our group) uses some way to map LLVM basic blocks to native code addresses. If this is what you want, perhaps you can ask Brian Gaeke (gaeke at uiuc.edu) to give you some information about how that is done. --Vikram http://www.cs.uiuc.edu/~vadve http://llvm.cs.uiuc.edu/ On Aug 19, 2004, at 5:11 PM, Misha Brukman wrote:> On Thu, Aug 19, 2004 at 01:13:42PM -0700, Zhang Qiuyu wrote: >> On the pervious mail, I am trying to add label for each basic basic >> because I think I could get address by using nm if nm can show the >> address of each label, but it seems not . so do you guys have some >> idea how to get address for each basic block? Thanks. > > LLVM does not have a notion of C-style 'labels' that you can address > and > use as parameters. LLVM labels are simply NAMES of basic blocks, and > they are printed out as `labels'. > > You can 'set' a name for a BasicBlock, but that's not what you are > looking for, please see my other email for more details. > > -- > Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev
Michael McCracken
2004-Aug-19 22:47 UTC
[LLVMdev] How could I get memory address for each basic block?
I'd be interested to hear how that's being done - if Brian would reply to the list about it, I'd appreciate it. -mike On Aug 19, 2004, at 3:39 PM, Vikram S. Adve wrote:> Qiuyu, > > The dynamic optimization project (an internal research project in our > group) uses some way to map LLVM basic blocks to native code > addresses. If this is what you want, perhaps you can ask Brian Gaeke > (gaeke at uiuc.edu) to give you some information about how that is done. > > --Vikram > http://www.cs.uiuc.edu/~vadve > http://llvm.cs.uiuc.edu/ > > On Aug 19, 2004, at 5:11 PM, Misha Brukman wrote: > >> On Thu, Aug 19, 2004 at 01:13:42PM -0700, Zhang Qiuyu wrote: >>> On the pervious mail, I am trying to add label for each basic basic >>> because I think I could get address by using nm if nm can show the >>> address of each label, but it seems not . so do you guys have some >>> idea how to get address for each basic block? Thanks. >> >> LLVM does not have a notion of C-style 'labels' that you can address >> and >> use as parameters. LLVM labels are simply NAMES of basic blocks, and >> they are printed out as `labels'. >> >> You can 'set' a name for a BasicBlock, but that's not what you are >> looking for, please see my other email for more details. >> >> -- >> Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev >
Chris Lattner
2004-Aug-20 00:27 UTC
[LLVMdev] How could I get memory address for each basic block?
On Thu, 19 Aug 2004, Vikram S. Adve wrote:> The dynamic optimization project (an internal research project in our > group) uses some way to map LLVM basic blocks to native code addresses. > If this is what you want, perhaps you can ask Brian Gaeke > (gaeke at uiuc.edu) to give you some information about how that is done.I'm still quite curious why you want to do this. If you want to get the machine code address of particular places in the code, you could always insert an intrinsic function that the code generator handles specially. Why do you think you need the address of a basic block? What are you trying to do? -Chris> On Aug 19, 2004, at 5:11 PM, Misha Brukman wrote: > > > On Thu, Aug 19, 2004 at 01:13:42PM -0700, Zhang Qiuyu wrote: > >> On the pervious mail, I am trying to add label for each basic basic > >> because I think I could get address by using nm if nm can show the > >> address of each label, but it seems not . so do you guys have some > >> idea how to get address for each basic block? Thanks. > > > > LLVM does not have a notion of C-style 'labels' that you can address > > and > > use as parameters. LLVM labels are simply NAMES of basic blocks, and > > they are printed out as `labels'. > > > > You can 'set' a name for a BasicBlock, but that's not what you are > > looking for, please see my other email for more details. > > > > -- > > Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu > > > > _______________________________________________ > > LLVM Developers mailing list > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev >-Chris -- http://llvm.org/ http://nondot.org/sabre/
Brian R. Gaeke
2004-Aug-20 03:57 UTC
[LLVMdev] How could I get memory address for each basic block?
Note: The way we currently map LLVM basic blocks to native code addresses only works with the SparcV9 target. It's turned on by passing the "-march=sparcv9 -enable-maps" options to llc. In the SparcV9 target, we rely on having a one-to-one correspondence between MachineBasicBlocks and LLVM BasicBlocks. The MappingInfo.cpp pass (in lib/Target/SparcV9) stores a table of tuples of the form <block number, starting machine instr, number of machine instrs> in a global variable called FunctionBB, such that there is one tuple for each basic block in each function. Since each SparcV9 machine instruction is 4 bytes, the "starting machine instr" and "number of machine instrs" can be trivially translated into addresses, given that you know the address of the function, and assuming that the "block number" uniquely identifies and orders both LLVM BasicBlocks and SparcV9 MachineBasicBlocks within a function. Now, Qiuyu can probably accomplish his stated task more simply: just make the target-specific AsmPrinter pass output a global symbol for each basic block. In SparcV9AsmPrinter.cpp, for example, you'd add it to SparcV9AsmPrinter::emitBasicBlock(). Then you could get the addresses using nm(1) or dlsym(3). But the question remains: why get the address of each basic block? Is there some problem we're not solving at a higher level? -Brian> I'd be interested to hear how that's being done - if Brian would reply > to the list about it, I'd appreciate it. > > On Aug 19, 2004, at 3:39 PM, Vikram S. Adve wrote: > >The dynamic optimization project (an internal research project in our > >group) uses some way to map LLVM basic blocks to native code > >addresses. If this is what you want, perhaps you can ask Brian Gaeke > >(gaeke at uiuc.edu) to give you some information about how that is done. > > > >On Aug 19, 2004, at 5:11 PM, Misha Brukman wrote: > >>On Thu, Aug 19, 2004 at 01:13:42PM -0700, Zhang Qiuyu wrote: > >>>On the pervious mail, I am trying to add label for each basic basic > >>>because I think I could get address by using nm if nm can show the > >>>address of each label, but it seems not . so do you guys have some > >>>idea how to get address for each basic block? Thanks. > >> > >>LLVM does not have a notion of C-style 'labels' that you can address > >>and > >>use as parameters. LLVM labels are simply NAMES of basic blocks, and > >>they are printed out as `labels'. > >> > >>You can 'set' a name for a BasicBlock, but that's not what you are > >>looking for, please see my other email for more details.-- gaeke at uiuc.edu
Reasonably Related Threads
- [LLVMdev] How could I get memory address for each basic block?
- [LLVMdev] How could I get memory address for each basic block?
- [LLVMdev] How could I get memory address for each basic block?
- [LLVMdev] Re:About the address of Basic Block
- [LLVMdev] Re: LLVMdev digest, Vol 1 #292 - 4 msgs