[flang-commits] [flang] [Flang] mark safe external globals as dso_local (PR #189709)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Tue Mar 31 12:53:46 PDT 2026
================
@@ -197,6 +197,35 @@ 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))
+ return static_cast<llvm::Reloc::Model>(attr.getInt());
----------------
eugeneepshteyn wrote:
Is there a way to do a range check before doing `static_cast`?
https://github.com/llvm/llvm-project/pull/189709
More information about the flang-commits
mailing list