forked from OSchip/llvm-project
Fix bug: instcombine/2003-10-23-InstcombineNullFail.ll
llvm-svn: 9403
This commit is contained in:
parent
04f1163148
commit
8a55262c76
|
@ -975,6 +975,17 @@ Constant *ConstantExpr::getGetElementPtr(Constant *C,
|
||||||
const Type *Ty = GetElementPtrInst::getIndexedType(C->getType(), VIdxList,
|
const Type *Ty = GetElementPtrInst::getIndexedType(C->getType(), VIdxList,
|
||||||
true);
|
true);
|
||||||
assert(Ty && "GEP indices invalid!");
|
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);
|
return getGetElementPtrTy(PointerType::get(Ty), C, IdxList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue