================
@@ -5627,10 +5627,27 @@ void OpenMPOpt::registerAAs(bool IsModulePass) {
     }
   }
 
+  // Seed the generic noalias deduction for callback-mapped pointer arguments
+  // in host regions. It will inspect every callback and direct call site 
before
+  // manifesting the attribute.
+  if (!isOpenMPDevice(M)) {
+    for (Function *F : SCC) {
+      if (F->isDeclaration())
+        continue;
+      for (Use &U : F->uses()) {
+        AbstractCallSite ACS(&U);
----------------
kiranchandramohan wrote:

F->uses() can include operand-bundle inputs, which AbstractCallSite does not 
currently handle safely. For example, a function referenced in a "deopt" bundle 
on __kmpc_fork_call reaches getArgOperandNo() and triggers the assertion “Arg 
operand # out of range!” before the !ACS check.
 
AI tool reproduced this with verifier-valid IR under both openmp-opt and 
openmp-opt-cgscc; the unchanged build accepts it.

Could we make AbstractCallSite reject non-argument/non-callee uses and add a 
regression test?

```
define void @run() {
  call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr null, i32 0, ptr 
@outlined) [ "deopt"(ptr @unrelated) ]
  ret void
}
define internal void @outlined(ptr %gtid, ptr %btid) {
  call void @opaque()
  ret void
}
define void @unrelated() {
  ret void
}

declare !callback !0 void @__kmpc_fork_call(ptr, i32, ptr, ...)
declare void @opaque()
!0 = !{!1}
!1 = !{i64 2, i64 -1, i64 -1, i1 true}
!llvm.module.flags = !{!2}
!2 = !{i32 7, !"openmp", i32 51}
```

Note: This is an AI assisted review.

https://github.com/llvm/llvm-project/pull/218453
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to