[PATCH] D63337: [AMDGPU] Don't constrain callees with inlinehint from inlining on MaxBB check to prevent link failure
Valery Pykhtin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 14 08:54:53 PDT 2019
vpykhtin created this revision.
vpykhtin added reviewers: rampitec, arsenm.
Herald added subscribers: llvm-commits, hiraditya, t-tye, Anastasia, tpr, dstuttard, yaxunl, nhaehnle, wdng, jvesely, kzhuravl.
Herald added a project: LLVM.
Function bodies marked inline in an opencl source are eliminated but MaxBB check may prevent inlining them leaving undefined references.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D63337
Files:
llvm/lib/Target/AMDGPU/AMDGPUInline.cpp
llvm/test/CodeGen/AMDGPU/inline-maxbb.ll
Index: llvm/test/CodeGen/AMDGPU/inline-maxbb.ll
===================================================================
--- llvm/test/CodeGen/AMDGPU/inline-maxbb.ll
+++ llvm/test/CodeGen/AMDGPU/inline-maxbb.ll
@@ -31,3 +31,38 @@
store volatile i32 %res, i32 addrspace(1)* undef
ret void
}
+
+
+; inlinehint
+define i32 @callee_hint(i32 %x) #0 {
+entry:
+ %cc = icmp eq i32 %x, 1
+ br i1 %cc, label %ret_res, label %mulx
+
+mulx:
+ %mul1 = mul i32 %x, %x
+ %mul2 = mul i32 %mul1, %x
+ %mul3 = mul i32 %mul1, %mul2
+ %mul4 = mul i32 %mul3, %mul2
+ %mul5 = mul i32 %mul4, %mul3
+ br label %ret_res
+
+ret_res:
+ %r = phi i32 [ %mul5, %mulx ], [ %x, %entry ]
+ ret i32 %r
+}
+
+; INL-LABEL: @caller_hint
+; NOINL-LABEL: @caller_hint
+; INL: mul i32
+; INL-NOT: call i32
+; NOINL: mul i32
+; NOINL-NOT: call i32
+
+define amdgpu_kernel void @caller_hint(i32 %x) {
+ %res = call i32 @callee_hint(i32 %x)
+ store volatile i32 %res, i32 addrspace(1)* undef
+ ret void
+}
+
+attributes #0 = { inlinehint }
Index: llvm/lib/Target/AMDGPU/AMDGPUInline.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUInline.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUInline.cpp
@@ -218,7 +218,8 @@
LocalParams, TTI, GetAssumptionCache, None, PSI,
RemarksEnabled ? &ORE : nullptr);
- if (IC && !IC.isAlways()) {
+ // Don't constrain callees with inlinehint as it may result in link failure
+ if (IC && !IC.isAlways() && !Callee->hasFnAttribute(Attribute::InlineHint)) {
// Single BB does not increase total BB amount, thus subtract 1
size_t Size = Caller->size() + Callee->size() - 1;
if (MaxBB && Size > MaxBB)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63337.204778.patch
Type: text/x-patch
Size: 1729 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190614/6e775f49/attachment.bin>
More information about the llvm-commits
mailing list