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
This commit is contained in:
Dale Johannesen
2008-01-30 19:00:21 +00:00
parent c60141ba43
commit 7757fff6ae
2 changed files with 278 additions and 0 deletions

View File

@ -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;