1 ; This is a regression test for a bug in the AMDGPU Propagate Attributes pass
2 ; where a call instruction's callee could be replaced with a function pointer
3 ; passed to the original call instruction as an argument.
6 ; `call void @f(void ()* @g)`
8 ; `call void @g(void ()* @g.1)`
11 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -amdgpu-propagate-attributes-late %s | FileCheck %s
13 ; CHECK-LABEL: define amdgpu_kernel void @thiswasabug() #0
14 ; CHECK-NOT: call void @g(void ()* @g.1)
15 ; CHECK-DAG: call void @f(void ()* @g.1)
16 ; CHECK-DAG: call void @g()
17 define amdgpu_kernel void @thiswasabug() #0 {
18 ; no replacement, but @g should be renamed to @g.1
19 call void @f(void ()* @g)
21 ; this should call the clone, which takes the name @g
26 define private void @f(void ()* nocapture %0) #0 {
30 ; In order to expose this bug, it is necessary that `g` have one of the
31 ; propagated attributes, so that a clone and substitution would take place if g
32 ; were actually the function being called.
33 ; CHECK-DAG: define private void @g.1() #1
34 ; CHECK-DAG: define internal void @g() #2
35 define private void @g() #1 {
39 attributes #0 = { noinline }
40 attributes #1 = { noinline "amdgpu-waves-per-eu"="1,10" }