[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu Oct 23 00:22:01 PDT 2003


Changes in directory llvm/lib/VMCore:

Constants.cpp updated: 1.59 -> 1.60

---
Log message:

Fix bug: instcombine/2003-10-23-InstcombineNullFail.ll



---
Diffs of the changes:  (+11 -0)

Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.59 llvm/lib/VMCore/Constants.cpp:1.60
--- llvm/lib/VMCore/Constants.cpp:1.59	Tue Oct 21 12:39:59 2003
+++ llvm/lib/VMCore/Constants.cpp	Thu Oct 23 00:21:48 2003
@@ -975,6 +975,17 @@
   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);
 }
 





More information about the llvm-commits mailing list