From 7757fff6aebdca376a46412c8dfb3fab7d8ad411 Mon Sep 17 00:00:00 2001 From: Dale Johannesen Date: Wed, 30 Jan 2008 19:00:21 +0000 Subject: 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 --- lib/CodeGen/MachineModuleInfo.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/CodeGen/MachineModuleInfo.cpp') 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(V)) { if (CE->getOpcode() == Instruction::BitCast) { return dyn_cast(CE->getOperand(0)); + } else if (CE->getOpcode() == Instruction::GetElementPtr) { + for (unsigned int i=1; igetNumOperands(); i++) { + Constant* CI = cast(CE->getOperand(i)); + if (!CI || !CI->isNullValue()) + return NULL; + } + return dyn_cast(CE->getOperand(0)); } } return NULL; @@ -117,6 +124,13 @@ static bool isGlobalVariable(Value *V) { } else if (ConstantExpr *CE = dyn_cast(V)) { if (CE->getOpcode() == Instruction::BitCast) { return isa(CE->getOperand(0)); + } else if (CE->getOpcode() == Instruction::GetElementPtr) { + for (unsigned int i=1; igetNumOperands(); i++) { + Constant* CI = cast(CE->getOperand(i)); + if (!CI || !CI->isNullValue()) + return false; + } + return isa(CE->getOperand(0)); } } return false; -- cgit v1.2.3-18-g5258