[PATCH] D146720: [AMDGPU][printf] Run AMDGPUPrintfRuntimeBindingPass in -O0

Juan Manuel Martinez CaamaƱo via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 24 08:28:23 PDT 2023


jmmartinez updated this revision to Diff 508109.
jmmartinez added a comment.

- Removed the opt-pipeline.ll test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146720/new/

https://reviews.llvm.org/D146720

Files:
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/test/CodeGen/AMDGPU/opencl-printf-pipeline.ll


Index: llvm/test/CodeGen/AMDGPU/opencl-printf-pipeline.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/AMDGPU/opencl-printf-pipeline.ll
@@ -0,0 +1,18 @@
+; RUN: opt -mtriple=amdgcn--amdhsa -passes=amdgpu-printf-runtime-binding -S < %s | FileCheck %s
+; RUN: opt -mtriple=amdgcn--amdhsa -O0 -S < %s | FileCheck %s
+; RUN: opt -mtriple=amdgcn--amdhsa -O1 -S < %s | FileCheck %s
+; RUN: opt -mtriple=amdgcn--amdhsa -O2 -S < %s | FileCheck %s
+; RUN: opt -mtriple=amdgcn--amdhsa -O3 -S < %s | FileCheck %s
+
+ at .str = private unnamed_addr addrspace(4) constant [7 x i8] c"hello\0A\00", align 1
+
+; Check that the call to printf is removed when AMDGPUPrintfRuntimeBindingPass is executed
+;   And that this pass is executed in the -O0 and -OX pipelines
+; CHECK-LABEL: define void @foo
+; CHECK-NOT: call i32{{.*}}@printf
+define void @foo() {
+  %call = call i32 (ptr addrspace(4), ...) @printf(ptr addrspace(4) noundef @.str)
+  ret void
+}
+
+declare hidden i32 @printf(ptr addrspace(4) noundef, ...)
Index: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -682,11 +682,12 @@
 
   PB.registerPipelineEarlySimplificationEPCallback(
       [this](ModulePassManager &PM, OptimizationLevel Level) {
+        PM.addPass(AMDGPUPrintfRuntimeBindingPass());
+
         if (Level == OptimizationLevel::O0)
           return;
 
         PM.addPass(AMDGPUUnifyMetadataPass());
-        PM.addPass(AMDGPUPrintfRuntimeBindingPass());
 
         if (InternalizeSymbols) {
           PM.addPass(InternalizePass(mustPreserveGV));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146720.508109.patch
Type: text/x-patch
Size: 1742 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230324/b71c8e8b/attachment.bin>


More information about the llvm-commits mailing list