How can I check if an operand is a static variable in the IR?
I've read that their linkage type should be marked as "internal" in the .s file, but I can't find a way to test if an Instruction has static variables as operands.
Can you help me?
Thank you in advance,
Niko
Hi Niko,
How can I check if an operand is a static variable in the IR?
get the operand, for example:
Value *Op = Instr->getOperand(0);
You probably want to get rid of any type casts:
Op = Op->stripPointerCasts();
You can test if it is a global variable using:
if (isa<GlobalVariable>(Op)) { ... }
If it is, you can cast it to a global variable and test the linkage:
GlobalVariable *GV = cast<GlobalVariable>(Op);
if (GV->hasLocalLinkage()) { ... }
Ciao, Duncan.