diff options
author | Chris Lattner <sabre@nondot.org> | 2003-10-23 05:21:48 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-10-23 05:21:48 +0000 |
commit | 8a55262c76a26db7908f8641340a3ca3c58a62e8 (patch) | |
tree | a820d10c6ba25ae7861fb1620060f565afbb395c | |
parent | 04f11631487c7ed214b9a6c2f69fcfc16bde82d2 (diff) | |
download | bcm5719-llvm-8a55262c76a26db7908f8641340a3ca3c58a62e8.tar.gz bcm5719-llvm-8a55262c76a26db7908f8641340a3ca3c58a62e8.zip |
Fix bug: instcombine/2003-10-23-InstcombineNullFail.ll
llvm-svn: 9403
-rw-r--r-- | llvm/lib/VMCore/Constants.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp index b755c6f913a..bc1e9d2c1c8 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); } |