Maintain calling convention when inling calls to llvm.deoptimize

The behavior here was buggy -- we'd forget the calling convention after
inlining a callsite calling llvm.deoptimize.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265867 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sanjoy Das 2016-04-09 00:22:59 +00:00
parent 5bb9d06dac
commit 5ff00d9679
2 changed files with 18 additions and 1 deletions

View File

@ -1843,6 +1843,7 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
continue;
}
auto CallingConv = DeoptCall->getCallingConv();
auto *CurBB = RI->getParent();
RI->eraseFromParent();
@ -1856,8 +1857,9 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
"Expected at least the deopt operand bundle");
IRBuilder<> Builder(CurBB);
Value *NewDeoptCall =
CallInst *NewDeoptCall =
Builder.CreateCall(NewDeoptIntrinsic, CallArgs, OpBundles);
NewDeoptCall->setCallingConv(CallingConv);
if (NewDeoptCall->getType()->isVoidTy())
Builder.CreateRetVoid();
else

View File

@ -1,6 +1,7 @@
; RUN: opt -S -always-inline < %s | FileCheck %s
declare i8 @llvm.experimental.deoptimize.i8(...)
declare cc42 i32 @llvm.experimental.deoptimize.i32(...)
define i8 @callee(i1* %c) alwaysinline {
%c0 = load volatile i1, i1* %c
@ -120,3 +121,17 @@ define void @caller_with_stacksaverestore(i32 %n) {
call i8 @callee_with_dynamic_alloca(i32 %n)
ret void
}
define i32 @callee_with_coldcc() alwaysinline {
%v0 = call cc42 i32(...) @llvm.experimental.deoptimize.i32(i32 1) [ "deopt"() ]
ret i32 %v0
}
define void @caller_with_coldcc() {
; CHECK-LABEL: @caller_with_coldcc(
; CHECK-NEXT: call cc42 void (...) @llvm.experimental.deoptimize.isVoid(i32 1) [ "deopt"() ]
; CHECK-NEXT: ret void
%val = call i32 @callee_with_coldcc()
ret void
}