From 001d688855776dccbb2b4484738acfa0bfd34d47 Mon Sep 17 00:00:00 2001 From: Sanjoy Das Date: Sat, 30 Apr 2016 00:17:47 +0000 Subject: [PATCH] [LowerGuardIntrinsics] Preserve calling conv when lowering git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268142 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/LowerGuardIntrinsic.cpp | 2 ++ test/Transforms/LowerGuardIntrinsic/with-calling-conv.ll | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 test/Transforms/LowerGuardIntrinsic/with-calling-conv.ll diff --git a/lib/Transforms/Scalar/LowerGuardIntrinsic.cpp b/lib/Transforms/Scalar/LowerGuardIntrinsic.cpp index 5f5dd197b44..a58346c2b1c 100644 --- a/lib/Transforms/Scalar/LowerGuardIntrinsic.cpp +++ b/lib/Transforms/Scalar/LowerGuardIntrinsic.cpp @@ -66,6 +66,7 @@ static void MakeGuardControlFlowExplicit(Function *DeoptIntrinsic, B.CreateRet(DeoptCall); } + DeoptCall->setCallingConv(CI->getCallingConv()); DeoptBlockTerm->eraseFromParent(); } @@ -89,6 +90,7 @@ bool LowerGuardIntrinsic::runOnFunction(Function &F) { auto *DeoptIntrinsic = Intrinsic::getDeclaration( F.getParent(), Intrinsic::experimental_deoptimize, {F.getReturnType()}); + DeoptIntrinsic->setCallingConv(GuardDecl->getCallingConv()); for (auto *CI : ToLower) { MakeGuardControlFlowExplicit(DeoptIntrinsic, CI); diff --git a/test/Transforms/LowerGuardIntrinsic/with-calling-conv.ll b/test/Transforms/LowerGuardIntrinsic/with-calling-conv.ll new file mode 100644 index 00000000000..9dce54ce604 --- /dev/null +++ b/test/Transforms/LowerGuardIntrinsic/with-calling-conv.ll @@ -0,0 +1,15 @@ +; RUN: opt -S -lower-guard-intrinsic < %s | FileCheck %s + +declare cc99 void @llvm.experimental.guard(i1, ...) + +define i8 @f_basic(i1* %c_ptr) { +; CHECK-LABEL: @f_basic( +; CHECK: br i1 %c, label %guarded, label %deopt +; CHECK: deopt: +; CHECK-NEXT: %deoptcall = call cc99 i8 (...) @llvm.experimental.deoptimize.i8() [ "deopt"() ] +; CHECK-NEXT: ret i8 %deoptcall + + %c = load volatile i1, i1* %c_ptr + call cc99 void(i1, ...) @llvm.experimental.guard(i1 %c) [ "deopt"() ] + ret i8 6 +} -- 2.11.0