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. 4; 5; Example: 6; `call void @f(void ()* @g)` 7; could become 8; `call void @g(void ()* @g.1)` 9; which is invalid IR. 10 11; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -amdgpu-propagate-attributes-late %s | FileCheck %s 12 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() 17define amdgpu_kernel void @thiswasabug() #0 { 18 ; no replacement, but @g should be renamed to @g.1 19 call void @f(void ()* @g) 20 21 ; this should call the clone, which takes the name @g 22 call void @g() 23 ret void 24} 25 26define private void @f(void ()* nocapture %0) #0 { 27 ret void 28} 29 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 35define private void @g() #1 { 36 ret void 37} 38 39attributes #0 = { noinline } 40attributes #1 = { noinline "amdgpu-waves-per-eu"="1,10" } 41