Accept getelementptr starting at GV with all 0 indices as a
legitimate way of representing global variable GV in debug info.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46565 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/MachineModuleInfo.cpp b/lib/CodeGen/MachineModuleInfo.cpp
index 8aa4c44..c182394 100644
--- a/lib/CodeGen/MachineModuleInfo.cpp
+++ b/lib/CodeGen/MachineModuleInfo.cpp
@@ -104,6 +104,13 @@
} 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 @@
} 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;