fix PR8983, a broken assertion.
authorChris Lattner <sabre@nondot.org>
Sun, 16 Jan 2011 03:43:53 +0000 (03:43 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 16 Jan 2011 03:43:53 +0000 (03:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123562 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ConstantFolding.cpp
test/Transforms/InstCombine/crash.ll

index 300821026a7e8f1e7ed6964a78ffa174b68a2e8c..55a10d716b95503c59e0a8c5791198d4f88394e2 100644 (file)
@@ -581,7 +581,7 @@ static Constant *SymbolicallyEvaluateGEP(Constant *const *Ops, unsigned NumOps,
       if (NumOps == 2 &&
           cast<PointerType>(ResultTy)->getElementType()->isIntegerTy(8)) {
         ConstantExpr *CE = dyn_cast<ConstantExpr>(Ops[1]);
-        assert(CE->getType() == IntPtrTy &&
+        assert((CE == 0 || CE->getType() == IntPtrTy) &&
                "CastGEPIndices didn't canonicalize index types!");
         if (CE && CE->getOpcode() == Instruction::Sub &&
             CE->getOperand(0)->isNullValue()) {
index e87a30254e680339cffc8e4d332a701a8999adf6..e8babc3a1ee39ccf83fd3d6503552648cf4e4a13 100644 (file)
@@ -341,3 +341,15 @@ define double @test16(i32 %a) nounwind {
   %select = select i1 %cmp, double 2.000000e+00, double 3.141592e+00
   ret double %select
 }
+
+
+; PR8983
+%struct.basic_ios = type { i8 }
+
+define %struct.basic_ios *@test17() ssp {
+entry:
+  %add.ptr.i = getelementptr i8* null, i64 undef
+  %0 = bitcast i8* %add.ptr.i to %struct.basic_ios*
+  ret %struct.basic_ios* %0
+}
+