aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorjeanPerier <jperier@nvidia.com>2023-09-08 10:43:55 +0200
committerGitHub <noreply@github.com>2023-09-08 10:43:55 +0200
commit6ffea74f7c2cda7de91879a771daa6d45da198d9 (patch)
tree48653c394ba564b27ad652787b6f8ea4adb8dfe0 /flang/lib/Frontend/CompilerInvocation.cpp
parentd4d0b5eaab763abf04e99d96ff5bbc6e2d8fdb13 (diff)
downloadllvm-6ffea74f7c2cda7de91879a771daa6d45da198d9.zip
llvm-6ffea74f7c2cda7de91879a771daa6d45da198d9.tar.gz
llvm-6ffea74f7c2cda7de91879a771daa6d45da198d9.tar.bz2
[flang] Use BIND name, if any, when consolidating common blocks (#65613)
This patch changes how common blocks are aggregated and named in lowering in order to: * fix one obvious issue where BIND(C) and non BIND(C) with the same Fortran name were "merged" * go further and deal with a derivative where the BIND(C) C name matches the assembly name of a Fortran common block. This is a bit unspecified IMHO, but gfortran, ifort, and nvfortran "merge" the common block without complaints as a linker would have done. This required getting rid of all the common block mangling early in FIR (\_QC) instead of leaving that to the phase that emits LLVM from FIR because BIND(C) common blocks did not have mangled names. Care has to be taken to deal with the underscoring option of flang-new. See added flang/test/Lower/HLFIR/common-block-bindc-conflicts.f90 for an illustration.
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--flang/lib/Frontend/CompilerInvocation.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 81bf89b..dba2ac1 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -1237,7 +1237,8 @@ void CompilerInvocation::setSemanticsOpts(
.set_searchDirectories(fortranOptions.searchDirectories)
.set_intrinsicModuleDirectories(fortranOptions.intrinsicModuleDirectories)
.set_warningsAreErrors(getWarnAsErr())
- .set_moduleFileSuffix(getModuleFileSuffix());
+ .set_moduleFileSuffix(getModuleFileSuffix())
+ .set_underscoring(getCodeGenOpts().Underscoring);
llvm::Triple targetTriple{llvm::Triple(this->targetOpts.triple)};
// FIXME: Handle real(3) ?
@@ -1262,6 +1263,7 @@ void CompilerInvocation::setLoweringOptions() {
// Lower TRANSPOSE as a runtime call under -O0.
loweringOpts.setOptimizeTranspose(codegenOpts.OptimizationLevel > 0);
+ loweringOpts.setUnderscoring(codegenOpts.Underscoring);
const LangOptions &langOptions = getLangOpts();
Fortran::common::MathOptionsBase &mathOpts = loweringOpts.getMathOptions();