[flang-commits] [flang] [Flang] mark safe external globals as dso_local (PR #189709)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Mon Apr 6 13:08:58 PDT 2026
================
@@ -197,6 +197,38 @@ llvm::StringRef fir::getCommandline(mlir::ModuleOp mod) {
return {};
}
+static constexpr const char *relocationModelName = "fir.relocation_model";
+
+void fir::setRelocationModel(mlir::ModuleOp mod, llvm::Reloc::Model rm) {
+ auto *ctx = mod.getContext();
+ mod->setAttr(relocationModelName,
+ mlir::IntegerAttr::get(mlir::IntegerType::get(ctx, 32),
+ static_cast<unsigned>(rm)));
+}
+
+llvm::Reloc::Model fir::getRelocationModel(mlir::ModuleOp mod) {
+ if (auto attr = mod->getAttrOfType<mlir::IntegerAttr>(relocationModelName)) {
+ auto val = attr.getInt();
+ if (val >= llvm::Reloc::Static && val <= llvm::Reloc::ROPI_RWPI)
+ return static_cast<llvm::Reloc::Model>(val);
+ }
+ return llvm::Reloc::PIC_;
----------------
eugeneepshteyn wrote:
Is this a reasonable default for bad model value? Maybe some sort of compiler error would be better?
https://github.com/llvm/llvm-project/pull/189709
More information about the flang-commits
mailing list