[flang-commits] [flang] [flang][acc][lowering] Declare undeclared acc routine bind(name) targets (PR #203088)
Andre Kuhlenschmidt via flang-commits
flang-commits at lists.llvm.org
Thu Jun 11 12:00:25 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());
+ });
----------------
akuhlens wrote:
We can't create the process acc `bind` clauses until all procedure declarations / definitions have been scanned to create target `fun.func`s. Currently, the `acc.routine` declarations are generated in the same scan that creates `fun.func`s, I assume this was done because there is a need to know all of them somewhere in the lowering of program units, but I am not absolutely certain about this. This was the simplest approach to making sure binds were not processed before finishing processing all procedure declarations but there are a few more options I could explore to avoid this traversal. The cleanest would be to process routines while processing translation units, but that would only be possible if my assumption about knowing the full set of routines is wrong, the second would be to fold the lowering of bind clauses into the lowering of program units, which could absolutely be done, the only reason I didn't initially was for simplicity of understanding the phase ordering.
https://github.com/llvm/llvm-project/pull/203088
More information about the flang-commits
mailing list