[llvm] 7bed58d - [Inliner] Copy attributes when deoptimize intrinsic is inlined
Serguei Katkov via llvm-commits
llvm-commits at lists.llvm.org
Mon May 17 20:09:23 PDT 2021
Author: Serguei Katkov
Date: 2021-05-18T10:08:37+07:00
New Revision: 7bed58d28fd0ec476d5cb5ec2d73416207f250bc
URL: https://github.com/llvm/llvm-project/commit/7bed58d28fd0ec476d5cb5ec2d73416207f250bc
DIFF: https://github.com/llvm/llvm-project/commit/7bed58d28fd0ec476d5cb5ec2d73416207f250bc.diff
LOG: [Inliner] Copy attributes when deoptimize intrinsic is inlined
During inlining of call-site with deoptimize intrinsic callee we miss
attributes set on this call site. As a result attributes like deopt-lowering are
disappeared resulting in inefficient behavior of register allocator in codegen.
Just copy attributes for deoptimize call like we do for others calls.
Reviewers: reames, apilipenko
Reviewed By: reames
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D102602
Added:
llvm/test/Transforms/Inline/deoptimize-intrinsic-attrs.ll
Modified:
llvm/lib/Transforms/Utils/InlineFunction.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index 49be8bb9e412f..d848b1fe193c3 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -2374,6 +2374,7 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
SmallVector<OperandBundleDef, 1> OpBundles;
DeoptCall->getOperandBundlesAsDefs(OpBundles);
+ auto DeoptAttributes = DeoptCall->getAttributes();
DeoptCall->eraseFromParent();
assert(!OpBundles.empty() &&
"Expected at least the deopt operand bundle");
@@ -2382,6 +2383,7 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
CallInst *NewDeoptCall =
Builder.CreateCall(NewDeoptIntrinsic, CallArgs, OpBundles);
NewDeoptCall->setCallingConv(CallingConv);
+ NewDeoptCall->setAttributes(DeoptAttributes);
if (NewDeoptCall->getType()->isVoidTy())
Builder.CreateRetVoid();
else
diff --git a/llvm/test/Transforms/Inline/deoptimize-intrinsic-attrs.ll b/llvm/test/Transforms/Inline/deoptimize-intrinsic-attrs.ll
new file mode 100644
index 0000000000000..fa92ce2fda539
--- /dev/null
+++ b/llvm/test/Transforms/Inline/deoptimize-intrinsic-attrs.ll
@@ -0,0 +1,22 @@
+; RUN: opt -S -always-inline < %s | FileCheck %s
+
+declare cc42 i32 @llvm.experimental.deoptimize.i32(...)
+
+define i32 @callee_with_coldcc() alwaysinline {
+ %v0 = call cc42 i32(...) @llvm.experimental.deoptimize.i32(i32 1) #0 [ "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) #1 [ "deopt"() ]
+; CHECK-NEXT: ret void
+
+ %val = call i32 @callee_with_coldcc()
+ ret void
+}
+
+attributes #0 = { "deopt-lowering"="live-in" }
+
+; CHECK: declare cc42 void @llvm.experimental.deoptimize.isVoid(...)
+; CHECK: attributes #1 = { "deopt-lowering"="live-in" }
\ No newline at end of file
More information about the llvm-commits
mailing list