xref: /llvm-project/llvm/test/CodeGen/AMDGPU/opencl-printf-pipeline.ll (revision 215cfa01f2ba6f11d0ca0a2da87038aa81244b73)
1*215cfa01SJuan Manuel MARTINEZ CAAMAÑO; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2*215cfa01SJuan Manuel MARTINEZ CAAMAÑO; RUN: opt -mtriple=amdgcn--amdhsa -passes=amdgpu-printf-runtime-binding -S < %s | FileCheck %s
3*215cfa01SJuan Manuel MARTINEZ CAAMAÑO; RUN: opt -mtriple=amdgcn--amdhsa -O0 -S < %s | FileCheck %s
4*215cfa01SJuan Manuel MARTINEZ CAAMAÑO
5*215cfa01SJuan Manuel MARTINEZ CAAMAÑO; Check that the call to printf is removed when AMDGPUPrintfRuntimeBindingPass is executed
6*215cfa01SJuan Manuel MARTINEZ CAAMAÑO;   And that this pass is executed in the -O0 and -OX pipelines
7*215cfa01SJuan Manuel MARTINEZ CAAMAÑO
8*215cfa01SJuan Manuel MARTINEZ CAAMAÑO@.str = private unnamed_addr addrspace(4) constant [7 x i8] c"hello\0A\00", align 1
9*215cfa01SJuan Manuel MARTINEZ CAAMAÑO
10*215cfa01SJuan Manuel MARTINEZ CAAMAÑOdefine void @foo() {
11*215cfa01SJuan Manuel MARTINEZ CAAMAÑO; CHECK-LABEL: define void @foo() {
12*215cfa01SJuan Manuel MARTINEZ CAAMAÑO; CHECK-NEXT:    [[PRINTF_ALLOC_FN:%.*]] = call ptr addrspace(1) @__printf_alloc(i32 4)
13*215cfa01SJuan Manuel MARTINEZ CAAMAÑO; CHECK-NEXT:    br label [[DOTSPLIT:%.*]]
14*215cfa01SJuan Manuel MARTINEZ CAAMAÑO; CHECK:       .split:
15*215cfa01SJuan Manuel MARTINEZ CAAMAÑO; CHECK-NEXT:    [[TMP1:%.*]] = icmp ne ptr addrspace(1) [[PRINTF_ALLOC_FN]], null
16*215cfa01SJuan Manuel MARTINEZ CAAMAÑO; CHECK-NEXT:    br i1 [[TMP1]], label [[TMP2:%.*]], label [[TMP3:%.*]]
17*215cfa01SJuan Manuel MARTINEZ CAAMAÑO; CHECK:       2:
18*215cfa01SJuan Manuel MARTINEZ CAAMAÑO; CHECK-NEXT:    [[PRINTBUFFID:%.*]] = getelementptr i8, ptr addrspace(1) [[PRINTF_ALLOC_FN]], i32 0
19*215cfa01SJuan Manuel MARTINEZ CAAMAÑO; CHECK-NEXT:    [[PRINTBUFFIDCAST:%.*]] = bitcast ptr addrspace(1) [[PRINTBUFFID]] to ptr addrspace(1)
20*215cfa01SJuan Manuel MARTINEZ CAAMAÑO; CHECK-NEXT:    store i32 1, ptr addrspace(1) [[PRINTBUFFIDCAST]], align 4
21*215cfa01SJuan Manuel MARTINEZ CAAMAÑO; CHECK-NEXT:    [[PRINTBUFFGEP:%.*]] = getelementptr i8, ptr addrspace(1) [[PRINTF_ALLOC_FN]], i32 4
22*215cfa01SJuan Manuel MARTINEZ CAAMAÑO; CHECK-NEXT:    br label [[TMP3]]
23*215cfa01SJuan Manuel MARTINEZ CAAMAÑO; CHECK:       3:
24*215cfa01SJuan Manuel MARTINEZ CAAMAÑO; CHECK-NEXT:    ret void
25*215cfa01SJuan Manuel MARTINEZ CAAMAÑO;
26*215cfa01SJuan Manuel MARTINEZ CAAMAÑO  %call = call i32 @printf(ptr addrspace(4) @.str)
27*215cfa01SJuan Manuel MARTINEZ CAAMAÑO  ret void
28*215cfa01SJuan Manuel MARTINEZ CAAMAÑO}
29*215cfa01SJuan Manuel MARTINEZ CAAMAÑO
30*215cfa01SJuan Manuel MARTINEZ CAAMAÑOdeclare hidden i32 @printf(ptr addrspace(4), ...)
31