[flang-commits] [flang] [flang][acc][lowering] Declare undeclared acc routine bind(name) targets (PR #203088)

via flang-commits flang-commits at lists.llvm.org
Thu Jun 11 01:05:00 PDT 2026


================
@@ -597,6 +597,16 @@ class FirConverter : public Fortran::lower::AbstractConverter {
           u);
     }
 
+    // Declare any `acc routine` bind(name) targets not otherwise declared, so a
+    // live symbol exists for later passes. No-op for targets already lowered in
+    // this unit.
+    if (getFoldingContext().languageFeatures().IsEnabled(
+            Fortran::common::LanguageFeature::OpenACC))
+      createBuilderOutsideOfFuncOpAndDo([&]() {
+        Fortran::lower::materializeOpenACCRoutineBindTargets(
+            *this, bridge.getSemanticsContext());
+      });
----------------
jeanPerier wrote:

Instead of visiting all the scopes, could the bind targets be generated when processing/generating the func.func for the decorated procedure / when creating the related acc.routine operation?

Your approach is robust, it is just that a full visit of all symbols is not cheap in big apps (although it should be OK relatively to the rest, so I am not asking you to do crazy things to optimize, but if we can do it on the fly when generating acc.routine, that would be best/cheaper).

https://github.com/llvm/llvm-project/pull/203088


More information about the flang-commits mailing list