diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPropagateAttributes.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPropagateAttributes.cpp
--- a/llvm/lib/Target/AMDGPU/AMDGPUPropagateAttributes.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUPropagateAttributes.cpp
@@ -249,7 +249,7 @@
         if (!I)
           continue;
         CallBase *CI = dyn_cast<CallBase>(I);
-        if (!CI)
+        if (!CI || CI->getCalledFunction() != &F)
           continue;
         Function *Caller = CI->getCaller();
         if (!Caller || !Visited.insert(CI).second)
diff --git a/llvm/test/CodeGen/AMDGPU/propagate-attributes-function-pointer-argument.ll b/llvm/test/CodeGen/AMDGPU/propagate-attributes-function-pointer-argument.ll
new file mode 100644
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/propagate-attributes-function-pointer-argument.ll
@@ -0,0 +1,32 @@
+; This is a regression test for a bug in the AMDGPU Propagate Attributes pass
+; where a call instruction's callee could be replaced with a function pointer
+; passed to the original call instruction as an argument.
+;
+; Example:
+; `call void @f(void ()* @g)`
+; could become
+; `call void @g(void ()* @g.1)`
+; which is invalid IR.
+
+; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -amdgpu-propagate-attributes-late %s | FileCheck %s
+
+; CHECK: define amdgpu_kernel void @thiswasabug() #0
+; CHECK: call void @f(void ()* @g)
+define amdgpu_kernel void @thiswasabug() #0 {
+    call void @f(void ()* @g)
+    ret void
+}
+
+define private void @f(void ()* nocapture %0) #0 {
+    ret void
+}
+
+; In order to expose this bug, it is necessary that `g` have one of the
+; propagated attributes, so that a clone and substitution would take place if g
+; were actually the function being called.
+define private void @g() #1 {
+    ret void
+}
+
+attributes #0 = { noinline }
+attributes #1 = { noinline "amdgpu-waves-per-eu"="1,10" }