aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Frontend
diff options
context:
space:
mode:
authorDominik Adamski <dominik.adamski@amd.com>2023-11-28 13:13:23 -0600
committerDominik Adamski <dominik.adamski@amd.com>2023-11-28 13:18:46 -0600
commitf00ffcdb58d6db902a8f86b0ce83a03874d113ad (patch)
tree8c44b0bf98ea44542a107954796aa5e840f8be5a /flang/lib/Frontend
parent19fa27605ca63c0d60ffd532f41de004a57a455f (diff)
downloadllvm-f00ffcdb58d6db902a8f86b0ce83a03874d113ad.zip
llvm-f00ffcdb58d6db902a8f86b0ce83a03874d113ad.tar.gz
llvm-f00ffcdb58d6db902a8f86b0ce83a03874d113ad.tar.bz2
Revert "[Flang] Add code-object-version option (#72638)"
This commit causes test errors on buildbots. This reverts commit a8ac930b99d93b2a539ada7e566993d148899144.
Diffstat (limited to 'flang/lib/Frontend')
-rw-r--r--flang/lib/Frontend/CompilerInvocation.cpp11
-rw-r--r--flang/lib/Frontend/FrontendActions.cpp71
2 files changed, 4 insertions, 78 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 0dc11ab..1c09ae9 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -268,17 +268,6 @@ static void parseCodeGenArgs(Fortran::frontend::CodeGenOptions &opts,
opts.PrepareForThinLTO = true;
}
- if (const llvm::opt::Arg *a = args.getLastArg(
- clang::driver::options::OPT_mcode_object_version_EQ)) {
- llvm::StringRef s = a->getValue();
- if (s == "5")
- opts.CodeObjectVersion = llvm::CodeObjectVersionKind::COV_5;
- if (s == "4")
- opts.CodeObjectVersion = llvm::CodeObjectVersionKind::COV_4;
- if (s == "none")
- opts.CodeObjectVersion = llvm::CodeObjectVersionKind::COV_None;
- }
-
// -f[no-]save-optimization-record[=<format>]
if (const llvm::opt::Arg *a =
args.getLastArg(clang::driver::options::OPT_opt_record_file))
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index 6663548..f573ac8 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -244,7 +244,8 @@ static void setMLIRDataLayout(mlir::ModuleOp &mlirModule,
mlirModule->setAttr(mlir::DLTIDialect::kDataLayoutAttrName, dlSpec);
}
-static void addDependentLibs(mlir::ModuleOp &mlirModule, CompilerInstance &ci) {
+static void addDepdendentLibs(mlir::ModuleOp &mlirModule,
+ CompilerInstance &ci) {
const std::vector<std::string> &libs =
ci.getInvocation().getCodeGenOpts().DependentLibs;
if (libs.empty()) {
@@ -263,68 +264,6 @@ static void addDependentLibs(mlir::ModuleOp &mlirModule, CompilerInstance &ci) {
}
}
-// Add to MLIR code target specific items which are dependent on target
-// configuration specified by the user.
-// Clang equivalent function: AMDGPUTargetCodeGenInfo::emitTargetGlobals
-static void addAMDGPUSpecificMLIRItems(mlir::ModuleOp &mlirModule,
- CompilerInstance &ci) {
- const TargetOptions &targetOpts = ci.getInvocation().getTargetOpts();
- const llvm::Triple triple(targetOpts.triple);
- const llvm::StringRef codeObjectVersionGlobalOpName = "__oclc_ABI_version";
-
- // TODO: Share address spaces enumeration between Clang and Flang.
- // Currently this enumeration is defined in Clang specific class
- // defined in file: clang/lib/Basic/Targets/AMDGPU.h .
- // and we need to move it to LLVM directory.
- const int constantAddressSpace = 4;
-
- if (!triple.isAMDGPU()) {
- return;
- }
- const CodeGenOptions &codeGenOpts = ci.getInvocation().getCodeGenOpts();
- if (codeGenOpts.CodeObjectVersion == llvm::CodeObjectVersionKind::COV_None) {
- return;
- }
-
- mlir::ConversionPatternRewriter builder(mlirModule.getContext());
- unsigned oclcABIVERsion = codeGenOpts.CodeObjectVersion;
- auto int32Type = builder.getI32Type();
-
- std::optional<mlir::LLVM::GlobalOp> originalGV;
-
- mlirModule.walk([&originalGV, codeObjectVersionGlobalOpName](
- mlir::LLVM::GlobalOp globalOp) {
- if (globalOp.getName() == codeObjectVersionGlobalOpName)
- originalGV = globalOp;
- });
- if (originalGV.has_value()) {
- mlir::LLVM::GlobalOp originalGVOp = originalGV.value();
- if (originalGVOp.getLinkage() != mlir::LLVM::Linkage::External) {
- return;
- }
- // Update the variable if it is already present in MLIR but it was marked
- // as external linkage variable
- originalGVOp.setLinkage(mlir::LLVM::Linkage::WeakODR);
- originalGVOp.setValueAttr(
- builder.getIntegerAttr(int32Type, oclcABIVERsion));
- originalGVOp.setUnnamedAddr(mlir::LLVM::UnnamedAddr::Local);
- originalGVOp.setAddrSpace(constantAddressSpace);
- originalGVOp.setVisibility_(mlir::LLVM::Visibility::Hidden);
- return;
- }
-
- mlir::LLVM::GlobalOp covInfo = builder.create<mlir::LLVM::GlobalOp>(
- /* Location */ mlirModule.getLoc(), /* Type */ int32Type,
- /* IsConstant */ true, /* Linkage */ mlir::LLVM::Linkage::WeakODR,
- /* Name */ codeObjectVersionGlobalOpName,
- /* Value */ builder.getIntegerAttr(int32Type, oclcABIVERsion));
- covInfo.setUnnamedAddr(mlir::LLVM::UnnamedAddr::Local);
- covInfo.setAddrSpace(constantAddressSpace);
- covInfo.setVisibility_(mlir::LLVM::Visibility::Hidden);
- builder.setInsertionPointToStart(mlirModule.getBody());
- builder.insert(covInfo);
-}
-
bool CodeGenAction::beginSourceFileAction() {
llvmCtx = std::make_unique<llvm::LLVMContext>();
CompilerInstance &ci = this->getInstance();
@@ -426,10 +365,8 @@ bool CodeGenAction::beginSourceFileAction() {
Fortran::parser::Program &parseTree{*ci.getParsing().parseTree()};
lb.lower(parseTree, ci.getInvocation().getSemanticsContext());
- // Add target specific items like dependent libraries, target specific
- // constants etc.
- addDependentLibs(*mlirModule, ci);
- addAMDGPUSpecificMLIRItems(*mlirModule, ci);
+ // Add dependent libraries
+ addDepdendentLibs(*mlirModule, ci);
// run the default passes.
mlir::PassManager pm((*mlirModule)->getName(),