[LLVMdev] Is there a path from MachineInstr to the associated Instruction

John Criswell jtcriswel at gmail.com
Sun Nov 16 09:44:18 PST 2014


On 11/14/14, 6:53 AM, Qingan Li wrote:
> Hi,
>
> Recently, I am working on some information collection on the machine 
> instruction (MachineInstr) level.
> But, sometimes, I need check the corresponding IR level instruction of 
> the a machine instruction.
>
> When visiting a machine instruction which is a call 
> (MachineInstr::isCall()), I need to check the arguments of this call site.
> I know that the CallSite class provides good facility for this work, 
> but the CallSite can be constructed only fromInstruction rather than 
> MachineInstr.
>
> Is there any workaround?

If you're working on MachineInstr's, then you can probably examine the 
MachineIntr's operands to determine which function is being called.  
This probably won't be target independent, but if you're working at the 
MachineInstr level, you're not doing target independent work, anyway.

Alternatively, you should check to see if the MachineBasicBlock has a 
method to fetch the BasicBlock from which it was generated.  Using that, 
you could potentially scan the BasicBlock looking for a CallInst or 
InvokeInst that is likely to match the MachineInstr.

Regards,

John Criswell

>
> Thanks.
>
> -- 
> Best regards,
>
> Li Qingan
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


-- 
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
http://www.cs.rochester.edu/u/criswell

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


More information about the llvm-dev mailing list