diff options
Diffstat (limited to 'lib/CodeGen/MachineModuleInfo.cpp')
-rw-r--r-- | lib/CodeGen/MachineModuleInfo.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/CodeGen/MachineModuleInfo.cpp b/lib/CodeGen/MachineModuleInfo.cpp index 8aa4c4456a..c1823947b1 100644 --- a/lib/CodeGen/MachineModuleInfo.cpp +++ b/lib/CodeGen/MachineModuleInfo.cpp @@ -104,6 +104,13 @@ static GlobalVariable *getGlobalVariable(Value *V) { } else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) { if (CE->getOpcode() == Instruction::BitCast) { return dyn_cast<GlobalVariable>(CE->getOperand(0)); + } else if (CE->getOpcode() == Instruction::GetElementPtr) { + for (unsigned int i=1; i<CE->getNumOperands(); i++) { + Constant* CI = cast<Constant>(CE->getOperand(i)); + if (!CI || !CI->isNullValue()) + return NULL; + } + return dyn_cast<GlobalVariable>(CE->getOperand(0)); } } return NULL; @@ -117,6 +124,13 @@ static bool isGlobalVariable(Value *V) { } else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) { if (CE->getOpcode() == Instruction::BitCast) { return isa<GlobalVariable>(CE->getOperand(0)); + } else if (CE->getOpcode() == Instruction::GetElementPtr) { + for (unsigned int i=1; i<CE->getNumOperands(); i++) { + Constant* CI = cast<Constant>(CE->getOperand(i)); + if (!CI || !CI->isNullValue()) + return false; + } + return isa<GlobalVariable>(CE->getOperand(0)); } } return false; |