[Openmp-commits] [clang] [llvm] [openmp] [OpenMP][clang] Indirect and Virtual function call mapping from host to device (PR #159857)
Alexey Bataev via Openmp-commits
openmp-commits at lists.llvm.org
Fri Jan 9 13:49:59 PST 2026
================
@@ -6350,6 +6367,16 @@ void CGOpenMPRuntime::emitTargetOutlinedFunctionHelper(
[&CGF, &D, &CodeGen](StringRef EntryFnName) {
const CapturedStmt &CS = *D.getCapturedStmt(OMPD_target);
+ // Search Clang AST within "omp target" region for CallExprs.
+ // Store them in the set OMPTargetCalls (kept by CodeGenModule).
+ // This is used for the translation of indirect function calls.
+ const auto &LangOpts = CGF.getLangOpts();
+ if (LangOpts.OpenMPIsTargetDevice) {
+ // Search AST for target "CallExpr"s of "OMPTargetAutoLookup".
+ OMPTargetCallCollector Visitor(CGF.CGM.OMPTargetCalls);
+ Visitor.TraverseStmt(const_cast<Stmt *>(CS.getCapturedStmt()));
----------------
alexey-bataev wrote:
Why need a const_cast here? Use Const visitor.
Also, not sure a visitor is the best solution here. It may skip lambdas, some other constants. Better to mark them by a special attribute during sema analysis, possibly
https://github.com/llvm/llvm-project/pull/159857
More information about the Openmp-commits
mailing list