[flang-commits] [flang] [Flang][OpenMp] Fix to threadprivate not working with host-association. (PR #74966)

via flang-commits flang-commits at lists.llvm.org
Wed Dec 20 20:32:04 PST 2023


================
@@ -3528,8 +3530,16 @@ void Fortran::lower::genThreadprivateOp(
     // variable in main program, and it has implicit SAVE attribute. Take it as
     // with SAVE attribute, so to create GlobalOp for it to simplify the
     // translation to LLVM IR.
-    fir::GlobalOp global = globalInitialization(converter, firOpBuilder, sym,
-                                                var, currentLocation);
+    fir::GlobalOp global;
+    // Avoids performing multiple globalInitializations.
+    auto module = converter.getModuleOp();
+    std::string globalName = converter.mangleName(sym);
+    if (module.lookupSymbol<fir::GlobalOp>(globalName)) {
----------------
NimishMishra wrote:

Can drop enclosing curly braces?

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


More information about the flang-commits mailing list