diff options
author | Dale Johannesen <dalej@apple.com> | 2008-01-30 19:00:21 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@apple.com> | 2008-01-30 19:00:21 +0000 |
commit | 7757fff6aebdca376a46412c8dfb3fab7d8ad411 (patch) | |
tree | c9764fb99093bfbf546adbc8ab370aa417c16617 /lib/CodeGen/MachineModuleInfo.cpp | |
parent | c60141ba4345b1c8db0f518380ca84d9797eb1d9 (diff) |
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
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; |