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
commit8a55262c76a26db7908f8641340a3ca3c58a62e8 (patch)
treea820d10c6ba25ae7861fb1620060f565afbb395c
parent04f11631487c7ed214b9a6c2f69fcfc16bde82d2 (diff)
downloadllvm-8a55262c76a26db7908f8641340a3ca3c58a62e8.zip
llvm-8a55262c76a26db7908f8641340a3ca3c58a62e8.tar.gz
llvm-8a55262c76a26db7908f8641340a3ca3c58a62e8.tar.bz2
Fix bug: instcombine/2003-10-23-InstcombineNullFail.ll
llvm-svn: 9403
-rw-r--r--llvm/lib/VMCore/Constants.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp
index b755c6f..bc1e9d2 100644
--- a/llvm/lib/VMCore/Constants.cpp
+++ b/llvm/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);
}