mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-22 20:26:31 +00:00
Fix bug: instcombine/2003-10-23-InstcombineNullFail.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9403 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5e845c5444
commit
653de272c2
@ -975,6 +975,17 @@ Constant *ConstantExpr::getGetElementPtr(Constant *C,
|
||||
const Type *Ty = GetElementPtrInst::getIndexedType(C->getType(), VIdxList,
|
||||
true);
|
||||
assert(Ty && "GEP indices invalid!");
|
||||
|
||||
if (C->isNullValue()) {
|
||||
bool isNull = true;
|
||||
for (unsigned i = 0, e = IdxList.size(); i != e; ++i)
|
||||
if (!IdxList[i]->isNullValue()) {
|
||||
isNull = false;
|
||||
break;
|
||||
}
|
||||
if (isNull) return ConstantPointerNull::get(PointerType::get(Ty));
|
||||
}
|
||||
|
||||
return getGetElementPtrTy(PointerType::get(Ty), C, IdxList);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user