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