[llvm-dev] How to get the symbol of MachineInst ?

Francis Visoiu Mistrih via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 30 11:32:03 PDT 2018


Hi,

> On 19 Jul 2018, at 03:34, PenYiWang via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> 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 <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,

— 
Francis

> 
> So I need to get the symbol/MCSymbol of MachineInst , right?
> 
> Thank you. 
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180730/d772cacd/attachment.html>


More information about the llvm-dev mailing list