[flang-commits] [PATCH] D121471: [flang] Add support for linkonce_odr in FIR

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Mon Mar 14 02:25:23 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG30a0fbf51f4f: [flang] Add support for linkonce_odr in FIR (authored by jeanPerier).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121471/new/

https://reviews.llvm.org/D121471

Files:
  flang/include/flang/Optimizer/Builder/FIRBuilder.h
  flang/lib/Optimizer/CodeGen/CodeGen.cpp
  flang/lib/Optimizer/Dialect/FIROps.cpp
  flang/test/Fir/fir-ops.fir


Index: flang/test/Fir/fir-ops.fir
===================================================================
--- flang/test/Fir/fir-ops.fir
+++ flang/test/Fir/fir-ops.fir
@@ -432,6 +432,15 @@
   fir.has_value %0 : !fir.type<minez>
 }
 
+// CHECK-LABEL: fir.global linkonce_odr @global_linkonce_odr : i32 {
+// CHECK: [[VAL_130:%.*]] = arith.constant 1 : i32
+// CHECK: fir.has_value [[VAL_130]] : i32
+// CHECK: }
+fir.global linkonce_odr @global_linkonce_odr : i32 {
+  %0 = arith.constant 1 : i32
+  fir.has_value %0 : i32
+}
+
 // CHECK-LABEL: fir.dispatch_table @dispatch_tbl {
 // CHECK: fir.dt_entry "method", @method_impl
 // CHECK: }
Index: flang/lib/Optimizer/Dialect/FIROps.cpp
===================================================================
--- flang/lib/Optimizer/Dialect/FIROps.cpp
+++ flang/lib/Optimizer/Dialect/FIROps.cpp
@@ -1321,7 +1321,8 @@
 
 mlir::ParseResult fir::GlobalOp::verifyValidLinkage(StringRef linkage) {
   // Supporting only a subset of the LLVM linkage types for now
-  static const char *validNames[] = {"common", "internal", "linkonce", "weak"};
+  static const char *validNames[] = {"common", "internal", "linkonce",
+                                     "linkonce_odr", "weak"};
   return mlir::success(llvm::is_contained(validNames, linkage));
 }
 
Index: flang/lib/Optimizer/CodeGen/CodeGen.cpp
===================================================================
--- flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -2647,6 +2647,8 @@
         return mlir::LLVM::Linkage::Internal;
       if (name == "linkonce")
         return mlir::LLVM::Linkage::Linkonce;
+      if (name == "linkonce_odr")
+        return mlir::LLVM::Linkage::LinkonceODR;
       if (name == "common")
         return mlir::LLVM::Linkage::Common;
       if (name == "weak")
Index: flang/include/flang/Optimizer/Builder/FIRBuilder.h
===================================================================
--- flang/include/flang/Optimizer/Builder/FIRBuilder.h
+++ flang/include/flang/Optimizer/Builder/FIRBuilder.h
@@ -212,6 +212,10 @@
 
   mlir::StringAttr createLinkOnceLinkage() { return getStringAttr("linkonce"); }
 
+  mlir::StringAttr createLinkOnceODRLinkage() {
+    return getStringAttr("linkonce_odr");
+  }
+
   mlir::StringAttr createWeakLinkage() { return getStringAttr("weak"); }
 
   /// Get a function by name. If the function exists in the current module, it


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121471.415032.patch
Type: text/x-patch
Size: 2419 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220314/9c8a70be/attachment.bin>


More information about the flang-commits mailing list