1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-globals
2 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes=amdgpu-attributor %s | FileCheck --check-prefixes=CHECK,OW %s
3 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes='amdgpu-attributor<closed-world>' %s | FileCheck --check-prefixes=CHECK,CW %s
4 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes='amdgpu-attributor<closed-world>' -amdgpu-indirect-call-specialization-threshold=0 %s | FileCheck --check-prefixes=CHECK,NO %s
6 target datalayout = "A5"
8 @G = global i32 0, align 4
11 ; CHECK: @G = global i32 0, align 4
14 ; CHECK-LABEL: define {{[^@]+}}@bar1
15 ; CHECK-SAME: () #[[ATTR0:[0-9]+]] {
17 ; CHECK-NEXT: store i32 1, ptr @G, align 4
18 ; CHECK-NEXT: ret void
21 store i32 1, ptr @G, align 4
26 ; CHECK-LABEL: define {{[^@]+}}@bar2
27 ; CHECK-SAME: () #[[ATTR0]] {
29 ; CHECK-NEXT: store i32 2, ptr @G, align 4
30 ; CHECK-NEXT: ret void
33 store i32 2, ptr @G, align 4
37 define ptr @helper1() {
38 ; CHECK-LABEL: define {{[^@]+}}@helper1
39 ; CHECK-SAME: () #[[ATTR0]] {
41 ; CHECK-NEXT: ret ptr @bar1
47 define ptr @helper2() {
48 ; CHECK-LABEL: define {{[^@]+}}@helper2
49 ; CHECK-SAME: () #[[ATTR0]] {
51 ; CHECK-NEXT: ret ptr @bar2
57 define amdgpu_kernel void @foo(ptr noundef %fp) {
58 ; OW-LABEL: define {{[^@]+}}@foo
59 ; OW-SAME: (ptr noundef [[FP:%.*]]) #[[ATTR1:[0-9]+]] {
61 ; OW-NEXT: [[FP_ADDR:%.*]] = alloca ptr, align 8, addrspace(5)
62 ; OW-NEXT: store ptr [[FP]], ptr addrspace(5) [[FP_ADDR]], align 8
63 ; OW-NEXT: call void [[FP]]()
66 ; CW-LABEL: define {{[^@]+}}@foo
67 ; CW-SAME: (ptr noundef [[FP:%.*]]) #[[ATTR1:[0-9]+]] {
69 ; CW-NEXT: [[FP_ADDR:%.*]] = alloca ptr, align 8, addrspace(5)
70 ; CW-NEXT: store ptr [[FP]], ptr addrspace(5) [[FP_ADDR]], align 8
71 ; CW-NEXT: [[TMP0:%.*]] = icmp eq ptr [[FP]], @bar1
72 ; CW-NEXT: br i1 [[TMP0]], label [[TMP1:%.*]], label [[TMP2:%.*]]
74 ; CW-NEXT: call void @bar1()
75 ; CW-NEXT: br label [[TMP5:%.*]]
77 ; CW-NEXT: br i1 true, label [[TMP3:%.*]], label [[TMP4:%.*]]
79 ; CW-NEXT: call void @bar2()
80 ; CW-NEXT: br label [[TMP5]]
82 ; CW-NEXT: unreachable
86 ; NO-LABEL: define {{[^@]+}}@foo
87 ; NO-SAME: (ptr noundef [[FP:%.*]]) #[[ATTR1:[0-9]+]] {
89 ; NO-NEXT: [[FP_ADDR:%.*]] = alloca ptr, align 8, addrspace(5)
90 ; NO-NEXT: store ptr [[FP]], ptr addrspace(5) [[FP_ADDR]], align 8
91 ; NO-NEXT: call void [[FP]](), !callees [[META0:![0-9]+]]
95 %fp.addr = alloca ptr, addrspace(5)
96 store ptr %fp, ptr addrspace(5) %fp.addr
97 %load = load ptr, ptr addrspace(5) %fp.addr
103 ; NO: attributes #[[ATTR0]] = { "amdgpu-no-agpr" "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-flat-scratch-init" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "uniform-work-group-size"="false" }
104 ; NO: attributes #[[ATTR1]] = { "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-flat-scratch-init" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "uniform-work-group-size"="false" }
106 ; OW: attributes #[[ATTR0]] = { "amdgpu-no-agpr" "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-flat-scratch-init" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "uniform-work-group-size"="false" }
107 ; OW: attributes #[[ATTR1]] = { "uniform-work-group-size"="false" }
109 ; CW: attributes #[[ATTR0]] = { "amdgpu-no-agpr" "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-flat-scratch-init" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "uniform-work-group-size"="false" }
110 ; CW: attributes #[[ATTR1]] = { "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-flat-scratch-init" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "uniform-work-group-size"="false" }
112 ; NO: [[META0]] = !{ptr @bar1, ptr @bar2}