De-constify Types in FunctionType::get().
[oota-llvm.git] / lib / Transforms / Scalar / SimplifyLibCalls.cpp
index 0c08c5e9228be731019b25161b93951ad22cb415..66c302844144334dd392e8d3301474648a97b24d 100644 (file)
@@ -992,7 +992,7 @@ struct FFSOpt : public LibCallOptimization {
     }
 
     // ffs(x) -> x != 0 ? (i32)llvm.cttz(x)+1 : 0
-    const Type *ArgType = Op->getType();
+    Type *ArgType = Op->getType();
     Value *F = Intrinsic::getDeclaration(Callee->getParent(),
                                          Intrinsic::cttz, &ArgType, 1);
     Value *V = B.CreateCall(F, Op, "cttz");
@@ -1251,7 +1251,7 @@ struct SPrintFOpt : public LibCallOptimization {
       return V;
     }
 
-    // sprintf(str, format, ...) -> iprintf(str, format, ...) if no floating
+    // sprintf(str, format, ...) -> siprintf(str, format, ...) if no floating
     // point arguments.
     if (TLI->has(LibFunc::siprintf) && !CallHasFloatingPointArgument(CI)) {
       Module *M = B.GetInsertBlock()->getParent()->getParent();
@@ -1616,6 +1616,9 @@ bool SimplifyLibCalls::runOnFunction(Function &F) {
       // Set the builder to the instruction after the call.
       Builder.SetInsertPoint(BB, I);
 
+      // Use debug location of CI for all new instructions.
+      Builder.SetCurrentDebugLocation(CI->getDebugLoc());
+
       // Try to optimize this call.
       Value *Result = LCO->OptimizeCall(CI, TD, TLI, Builder);
       if (Result == 0) continue;