[llvm] 6998fd5 - [AMDGPU] Print max-BB inline rejections

via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 20 07:37:30 PDT 2026


Author: Yaxun (Sam) Liu
Date: 2026-07-20T10:37:25-04:00
New Revision: 6998fd59e16026a00fee8e83243c0ec91047fee3

URL: https://github.com/llvm/llvm-project/commit/6998fd59e16026a00fee8e83243c0ec91047fee3
DIFF: https://github.com/llvm/llvm-project/commit/6998fd59e16026a00fee8e83243c0ec91047fee3.diff

LOG: [AMDGPU] Print max-BB inline rejections

Added: 
    llvm/test/Transforms/Inline/AMDGPU/inline-max-bb-debug.ll

Modified: 
    llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
index 5125735faddd6..1d8c1ce0fb747 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
@@ -1570,7 +1570,14 @@ bool GCNTTIImpl::areInlineCompatible(const Function *Caller,
     if (Callee->size() == 1)
       return true;
     size_t BBSize = Caller->size() + Callee->size() - 1;
-    return BBSize <= InlineMaxBB;
+    if (BBSize > InlineMaxBB) {
+      LLVM_DEBUG(dbgs() << "AMDGPU inline max-BB rejected inlining "
+                        << Callee->getName() << " into " << Caller->getName()
+                        << ": caller BBs=" << Caller->size() << ", callee BBs="
+                        << Callee->size() << ", combined BBs=" << BBSize
+                        << ", max BBs=" << InlineMaxBB << '\n');
+      return false;
+    }
   }
 
   return true;

diff  --git a/llvm/test/Transforms/Inline/AMDGPU/inline-max-bb-debug.ll b/llvm/test/Transforms/Inline/AMDGPU/inline-max-bb-debug.ll
new file mode 100644
index 0000000000000..3aa603762fbcc
--- /dev/null
+++ b/llvm/test/Transforms/Inline/AMDGPU/inline-max-bb-debug.ll
@@ -0,0 +1,34 @@
+; REQUIRES: asserts
+; RUN: opt -mtriple=amdgcn-amd-amdhsa -passes=inline -disable-output -amdgpu-inline-max-bb=3 -debug-only=AMDGPUtti < %s 2>&1 | FileCheck %s
+
+; CHECK: AMDGPU inline max-BB rejected inlining callee into caller: caller BBs=3, callee BBs=4, combined BBs=6, max BBs=3
+
+define i32 @callee(i32 %x) {
+entry:
+  %cmp = icmp eq i32 %x, 0
+  br i1 %cmp, label %then, label %else
+
+then:
+  br label %exit
+
+else:
+  br label %exit
+
+exit:
+  %value = phi i32 [ 1, %then ], [ 2, %else ]
+  ret i32 %value
+}
+
+define amdgpu_kernel void @caller(ptr addrspace(1) %out, i32 %x) {
+entry:
+  %cmp = icmp slt i32 %x, 0
+  br i1 %cmp, label %call, label %exit
+
+call:
+  %value = call i32 @callee(i32 %x)
+  store i32 %value, ptr addrspace(1) %out, align 4
+  br label %exit
+
+exit:
+  ret void
+}


        


More information about the llvm-commits mailing list