aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-10-23 05:21:48 +0000
committerChris Lattner <sabre@nondot.org>2003-10-23 05:21:48 +0000
commit653de272c21eb532294a3a3c6a39ebfd15165ee5 (patch)
tree1f769567983fc786e7c5ba74abd48b86e110b381
parent5e845c5444637158f4779ac9058c6001d79b1bcc (diff)
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
-rw-r--r--lib/VMCore/Constants.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index b755c6f913..bc1e9d2c1c 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -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);
}