[llvm] r261258 - [IR] Straighten out bundle overload of IRBuilder::CreateCall

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 18 13:15:21 PST 2016


Let's have it bake in the tree for a while, and then I'll merge it.

Thanks,
Hans

On Thu, Feb 18, 2016 at 1:11 PM, Reid Kleckner <rnk at google.com> wrote:
> We should, the bug is easy to trigger at -O2:
> #include <stdio.h>
> int main() {
>   try {
>     throw 1;
>   } catch (int) {
>     fprintf(stderr, "asdf\n");
>   }
> }
>
> On Thu, Feb 18, 2016 at 1:07 PM, David Majnemer <david.majnemer at gmail.com>
> wrote:
>>
>> Can this be merged into 3.8?
>>
>> On Thu, Feb 18, 2016 at 12:57 PM, Reid Kleckner via llvm-commits
>> <llvm-commits at lists.llvm.org> wrote:
>>>
>>> Author: rnk
>>> Date: Thu Feb 18 14:57:41 2016
>>> New Revision: 261258
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=261258&view=rev
>>> Log:
>>> [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.
>>>
>>> Modified:
>>>     llvm/trunk/include/llvm/IR/IRBuilder.h
>>>     llvm/trunk/test/Transforms/InstCombine/fprintf-1.ll
>>>
>>> Modified: llvm/trunk/include/llvm/IR/IRBuilder.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/IRBuilder.h?rev=261258&r1=261257&r2=261258&view=diff
>>>
>>> ==============================================================================
>>> --- llvm/trunk/include/llvm/IR/IRBuilder.h (original)
>>> +++ llvm/trunk/include/llvm/IR/IRBuilder.h Thu Feb 18 14:57:41 2016
>>> @@ -1547,16 +1547,7 @@ public:
>>>    }
>>>
>>>    CallInst *CreateCall(Value *Callee, ArrayRef<Value *> Args = None,
>>> -                       ArrayRef<OperandBundleDef> OpBundles = None,
>>>                         const Twine &Name = "", MDNode *FPMathTag =
>>> nullptr) {
>>> -    CallInst *CI = CallInst::Create(Callee, Args, OpBundles);
>>> -    if (isa<FPMathOperator>(CI))
>>> -      CI = cast<CallInst>(AddFPMathAttributes(CI, FPMathTag, FMF));
>>> -    return Insert(CI, Name);
>>> -  }
>>> -
>>> -  CallInst *CreateCall(Value *Callee, ArrayRef<Value *> Args,
>>> -                       const Twine &Name, MDNode *FPMathTag = nullptr) {
>>>      PointerType *PTy = cast<PointerType>(Callee->getType());
>>>      FunctionType *FTy = cast<FunctionType>(PTy->getElementType());
>>>      return CreateCall(FTy, Callee, Args, Name, FPMathTag);
>>> @@ -1569,6 +1560,15 @@ public:
>>>      if (isa<FPMathOperator>(CI))
>>>        CI = cast<CallInst>(AddFPMathAttributes(CI, FPMathTag, FMF));
>>>      return Insert(CI, Name);
>>> +  }
>>> +
>>> +  CallInst *CreateCall(Value *Callee, ArrayRef<Value *> Args,
>>> +                       ArrayRef<OperandBundleDef> OpBundles,
>>> +                       const Twine &Name = "", MDNode *FPMathTag =
>>> nullptr) {
>>> +    CallInst *CI = CallInst::Create(Callee, Args, OpBundles);
>>> +    if (isa<FPMathOperator>(CI))
>>> +      CI = cast<CallInst>(AddFPMathAttributes(CI, FPMathTag, FMF));
>>> +    return Insert(CI, Name);
>>>    }
>>>
>>>    CallInst *CreateCall(Function *Callee, ArrayRef<Value *> Args,
>>>
>>> Modified: llvm/trunk/test/Transforms/InstCombine/fprintf-1.ll
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fprintf-1.ll?rev=261258&r1=261257&r2=261258&view=diff
>>>
>>> ==============================================================================
>>> --- llvm/trunk/test/Transforms/InstCombine/fprintf-1.ll (original)
>>> +++ llvm/trunk/test/Transforms/InstCombine/fprintf-1.ll Thu Feb 18
>>> 14:57:41 2016
>>> @@ -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
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>>
>


More information about the llvm-commits mailing list