Get underlying object for Machine level memory operation

Hi,

I am writing a pass that works at machine level and runs as last pass in llc (just before converting llvm specific machine instructions into target specific instructions)
In this pass I am trying to get underlying object for memory operations.
It turns out that due to various optimizations on machine instructions, the memory operand in the operation is not always getelementptr (for e.g., it can be phi node/bitcast/inttoptr instruction)
Can someone suggest best way to get the underlying object??

You can use the GetUnderlyingObjects function (notice the S at the end of the name) to collect zero or more underlying objects. This method is similar to GetUnderlyingObject except that it can look through phi and select instructions and return multiple objects.

Hi,

Thanks for suggestion :slight_smile:
Since I am using llvm-3.1, I didn’t find method "GetUnderlyingObjects "(available in llvm-3.2).
I was writing my own function to handle various memory operands. But I guess, this should help me out.

Thanks,
Rahul