How to get the symbol of MachineInst ?

Hi

I want to get the symbol of MachineInst

I found that there is getSymbol () in the MachineBasicBlock class
http://llvm.org/doxygen/classllvm_1_1MachineBasicBlock.html

And also, there is CurrentFnSym in AsmPrinter , CurrentFnSym can let us get the symbol of MachineFunction

But, how to get the symbol/MCSymbol of a MachineInst ?

I want to write some address of instruction to a section ( in the program ) by MCStreamer::EmitLabel

So I need to get the symbol/MCSymbol of MachineInst , right?

Thank you.

Hi,

Hi

I want to get the symbol of MachineInst

I found that there is getSymbol () in the MachineBasicBlock class
http://llvm.org/doxygen/classllvm_1_1MachineBasicBlock.html

And also, there is CurrentFnSym in AsmPrinter , CurrentFnSym can let us get the symbol of MachineFunction

But, how to get the symbol/MCSymbol of a MachineInst ?

We don’t emit a symbol for every MI. In order to get that you might need to modify the AsmPrinter to emit a label before lowering every single MI. You might be interested into looking in lib/CodeGen/AsmPrinter/AsmPrinter.cpp:EmitFunctionBody. Before EmitInstruction gets called, you can insert a label that you can reference later in your section.

I want to write some address of instruction to a section ( in the program ) by MCStreamer::EmitLabel

You need to use EmitValue instead of EmitLabel.

Cheers,