Fix PR4206 - crash in simplify lib calls
authorChris Lattner <sabre@nondot.org>
Wed, 13 May 2009 06:26:11 +0000 (06:26 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 13 May 2009 06:26:11 +0000 (06:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71644 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/SimplifyLibCalls.cpp
test/Transforms/SimplifyLibCalls/FFS.ll

index d53bc3f0cccd205260bfb8e0003b8f4e51f6fe15..8c41c728c06a466a0b8346be2a62d9f1b6b6b08f 100644 (file)
@@ -1116,7 +1116,7 @@ struct VISIBILITY_HIDDEN FFSOpt : public LibCallOptimization {
     Value *F = Intrinsic::getDeclaration(Callee->getParent(),
                                          Intrinsic::cttz, &ArgType, 1);
     Value *V = B.CreateCall(F, Op, "cttz");
-    V = B.CreateAdd(V, ConstantInt::get(Type::Int32Ty, 1), "tmp");
+    V = B.CreateAdd(V, ConstantInt::get(V->getType(), 1), "tmp");
     V = B.CreateIntCast(V, Type::Int32Ty, false, "tmp");
     
     Value *Cond = B.CreateICmpNE(Op, Constant::getNullValue(ArgType), "tmp");
index bdf43ef69f7a52d5fe022b3a85c39b88fa1384bb..d6a504af867d80268eed6a70b814eb7865d7b616 100644 (file)
@@ -28,3 +28,9 @@ define i32 @main() {
        ret i32 %rslt5
 }
 
+
+; PR4206
+define i32 @a(i64) nounwind {
+        %2 = call i32 @ffsll(i64 %0)            ; <i32> [#uses=1]
+        ret i32 %2
+}