From: Hans Wennborg Date: Fri, 19 Feb 2016 00:08:56 +0000 (+0000) Subject: Merging r261258: X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=6f28d52e9d3f87875732a0f2c1f3b03ef56be2db;hp=6e961aa243f223ddb704ce708056238d7c1d7e24 Merging r261258: ------------------------------------------------------------------------ r261258 | rnk | 2016-02-18 12:57:41 -0800 (Thu, 18 Feb 2016) | 14 lines [IR] Straighten out bundle overload of IRBuilder::CreateCall IRBuilder has two ways of putting bundle operands on calls: the default operand bundle, and an overload of CreateCall that takes an operand bundle list. Previously, this overload used a default argument of None. This made it impossible to distinguish between the case were the caller doesn't care about bundles, and the case where the caller explicitly wants no bundles. We behaved as if they wanted the latter behavior rather than the former, which led to problems with simplifylibcalls and WinEH. This change fixes it by making the parameter non-optional, so we can distinguish these two cases. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_38@261282 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/IR/IRBuilder.h b/include/llvm/IR/IRBuilder.h index 1b75c60631b..2f8c3c49929 100644 --- a/include/llvm/IR/IRBuilder.h +++ b/include/llvm/IR/IRBuilder.h @@ -1539,16 +1539,7 @@ public: } CallInst *CreateCall(Value *Callee, ArrayRef Args = None, - ArrayRef OpBundles = None, const Twine &Name = "", MDNode *FPMathTag = nullptr) { - CallInst *CI = CallInst::Create(Callee, Args, OpBundles); - if (isa(CI)) - CI = cast(AddFPMathAttributes(CI, FPMathTag, FMF)); - return Insert(CI, Name); - } - - CallInst *CreateCall(Value *Callee, ArrayRef Args, - const Twine &Name, MDNode *FPMathTag = nullptr) { PointerType *PTy = cast(Callee->getType()); FunctionType *FTy = cast(PTy->getElementType()); return CreateCall(FTy, Callee, Args, Name, FPMathTag); @@ -1563,6 +1554,15 @@ public: return Insert(CI, Name); } + CallInst *CreateCall(Value *Callee, ArrayRef Args, + ArrayRef OpBundles, + const Twine &Name = "", MDNode *FPMathTag = nullptr) { + CallInst *CI = CallInst::Create(Callee, Args, OpBundles); + if (isa(CI)) + CI = cast(AddFPMathAttributes(CI, FPMathTag, FMF)); + return Insert(CI, Name); + } + CallInst *CreateCall(Function *Callee, ArrayRef Args, const Twine &Name = "", MDNode *FPMathTag = nullptr) { return CreateCall(Callee->getFunctionType(), Callee, Args, Name, FPMathTag); diff --git a/test/Transforms/InstCombine/fprintf-1.ll b/test/Transforms/InstCombine/fprintf-1.ll index 6d21f39d4fd..cb364102c7f 100644 --- a/test/Transforms/InstCombine/fprintf-1.ll +++ b/test/Transforms/InstCombine/fprintf-1.ll @@ -61,6 +61,15 @@ define void @test_simplify4(%FILE* %fp) { ; CHECK-IPRINTF-NEXT: ret void } +define void @test_simplify5(%FILE* %fp) { +; CHECK-LABEL: @test_simplify5( + %fmt = getelementptr [13 x i8], [13 x i8]* @hello_world, i32 0, i32 0 + call i32 (%FILE*, i8*, ...) @fprintf(%FILE* %fp, i8* %fmt) [ "deopt"() ] +; CHECK-NEXT: call i32 @fwrite(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @hello_world, i32 0, i32 0), i32 12, i32 1, %FILE* %fp) [ "deopt"() ] + ret void +; CHECK-NEXT: ret void +} + define void @test_no_simplify1(%FILE* %fp) { ; CHECK-IPRINTF-LABEL: @test_no_simplify1( %fmt = getelementptr [3 x i8], [3 x i8]* @percent_f, i32 0, i32 0