[flang-commits] [flang] 6ffea74 - [flang] Use BIND name, if any, when consolidating common blocks (#65613)
via flang-commits
flang-commits at lists.llvm.org
Fri Sep 8 01:44:00 PDT 2023
Author: jeanPerier
Date: 2023-09-08T10:43:55+02:00
New Revision: 6ffea74f7c2cda7de91879a771daa6d45da198d9
URL: https://github.com/llvm/llvm-project/commit/6ffea74f7c2cda7de91879a771daa6d45da198d9
DIFF: https://github.com/llvm/llvm-project/commit/6ffea74f7c2cda7de91879a771daa6d45da198d9.diff
LOG: [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.
Added:
flang/test/Lower/HLFIR/common-block-bindc-conflicts.f90
Modified:
flang/include/flang/Common/Fortran.h
flang/include/flang/Lower/LoweringOptions.def
flang/include/flang/Lower/Mangler.h
flang/include/flang/Semantics/semantics.h
flang/include/flang/Semantics/tools.h
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Lower/Bridge.cpp
flang/lib/Lower/Mangler.cpp
flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
flang/lib/Semantics/semantics.cpp
flang/lib/Semantics/tools.cpp
flang/test/Lower/OpenMP/copyin.f90
flang/test/Lower/OpenMP/declare-target-data.f90
flang/test/Lower/OpenMP/firstprivate-commonblock.f90
flang/test/Lower/OpenMP/lastprivate-commonblock.f90
flang/test/Lower/OpenMP/private-commonblock.f90
flang/test/Lower/OpenMP/threadprivate-common-block-hlfir.f90
flang/test/Lower/OpenMP/threadprivate-commonblock.f90
flang/test/Lower/OpenMP/threadprivate-use-association.f90
flang/test/Lower/array.f90
flang/test/Lower/common-block-2.f90
flang/test/Lower/common-block.f90
flang/test/Lower/equivalence-2.f90
flang/test/Lower/explicit-interface-results-2.f90
flang/test/Lower/host-associated-globals.f90
flang/test/Lower/module_definition.f90
flang/test/Lower/module_use.f90
flang/test/Lower/module_use_in_same_file.f90
flang/test/Lower/namelist-common-block.f90
flang/test/Lower/pointer-assignments.f90
flang/test/Lower/pointer-initial-target-2.f90
Removed:
################################################################################
diff --git a/flang/include/flang/Common/Fortran.h b/flang/include/flang/Common/Fortran.h
index 59d82744fea7111..df47e98150ce6e1 100644
--- a/flang/include/flang/Common/Fortran.h
+++ b/flang/include/flang/Common/Fortran.h
@@ -109,5 +109,7 @@ std::string AsFortran(IgnoreTKRSet);
bool AreCompatibleCUDADataAttrs(
std::optional<CUDADataAttr>, std::optional<CUDADataAttr>, IgnoreTKRSet);
+static constexpr char blankCommonObjectName[] = "__BLNK__";
+
} // namespace Fortran::common
#endif // FORTRAN_COMMON_FORTRAN_H_
diff --git a/flang/include/flang/Lower/LoweringOptions.def b/flang/include/flang/Lower/LoweringOptions.def
index 0ab7c5220d24c43..7fb75f79bfc160a 100644
--- a/flang/include/flang/Lower/LoweringOptions.def
+++ b/flang/include/flang/Lower/LoweringOptions.def
@@ -34,5 +34,8 @@ ENUM_LOWERINGOPT(LowerToHighLevelFIR, unsigned, 1, 0)
/// If true, reverse PowerPC native vector element order.
ENUM_LOWERINGOPT(NoPPCNativeVecElemOrder, unsigned, 1, 0)
+/// If true, assume external names will be suffixed with an underscore. On by default.
+ENUM_LOWERINGOPT(Underscoring, unsigned, 1, 1)
+
#undef LOWERINGOPT
#undef ENUM_LOWERINGOPT
diff --git a/flang/include/flang/Lower/Mangler.h b/flang/include/flang/Lower/Mangler.h
index 1f3109b3541918d..9eb4e3e853a9e48 100644
--- a/flang/include/flang/Lower/Mangler.h
+++ b/flang/include/flang/Lower/Mangler.h
@@ -43,9 +43,11 @@ using ScopeBlockIdMap =
/// a symbol where all the Fortran context is needed. Otherwise, external
/// symbols are mangled outside of any scope.
std::string mangleName(const semantics::Symbol &, ScopeBlockIdMap &,
- bool keepExternalInScope = false);
+ bool keepExternalInScope = false,
+ bool underscoring = true);
std::string mangleName(const semantics::Symbol &,
- bool keepExternalInScope = false);
+ bool keepExternalInScope = false,
+ bool underscoring = true);
/// Convert a derived type instance to an internal name.
std::string mangleName(const semantics::DerivedTypeSpec &, ScopeBlockIdMap &);
diff --git a/flang/include/flang/Semantics/semantics.h b/flang/include/flang/Semantics/semantics.h
index 7808eb6c79c07c7..4e8b71fa652f5c7 100644
--- a/flang/include/flang/Semantics/semantics.h
+++ b/flang/include/flang/Semantics/semantics.h
@@ -93,6 +93,7 @@ class SemanticsContext {
}
const std::string &moduleDirectory() const { return moduleDirectory_; }
const std::string &moduleFileSuffix() const { return moduleFileSuffix_; }
+ bool underscoring() const { return underscoring_; }
bool warningsAreErrors() const { return warningsAreErrors_; }
bool debugModuleWriter() const { return debugModuleWriter_; }
const evaluate::IntrinsicProcTable &intrinsics() const { return intrinsics_; }
@@ -130,6 +131,10 @@ class SemanticsContext {
moduleFileSuffix_ = x;
return *this;
}
+ SemanticsContext &set_underscoring(bool x) {
+ underscoring_ = x;
+ return *this;
+ }
SemanticsContext &set_warnOnNonstandardUsage(bool x) {
warnOnNonstandardUsage_ = x;
return *this;
@@ -262,6 +267,7 @@ class SemanticsContext {
std::vector<std::string> intrinsicModuleDirectories_;
std::string moduleDirectory_{"."s};
std::string moduleFileSuffix_{".mod"};
+ bool underscoring_{true};
bool warnOnNonstandardUsage_{false};
bool warningsAreErrors_{false};
bool debugModuleWriter_{false};
diff --git a/flang/include/flang/Semantics/tools.h b/flang/include/flang/Semantics/tools.h
index 02d1a40a03c955b..5bcb96e6050fa08 100644
--- a/flang/include/flang/Semantics/tools.h
+++ b/flang/include/flang/Semantics/tools.h
@@ -683,5 +683,8 @@ std::optional<R> GetConstExpr(
// Returns "m" for a module, "m:sm" for a submodule.
std::string GetModuleOrSubmoduleName(const Symbol &);
+// Return the assembly name emitted for a common block.
+std::string GetCommonBlockObjectName(const Symbol &, bool underscoring);
+
} // namespace Fortran::semantics
#endif // FORTRAN_SEMANTICS_TOOLS_H_
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 81bf89b1a44e5ae..dba2ac1a335f972 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();
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 6e896c7a10784d8..75784f4e5a72be2 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -836,7 +836,9 @@ class FirConverter : public Fortran::lower::AbstractConverter {
}
std::string
mangleName(const Fortran::semantics::Symbol &symbol) override final {
- return Fortran::lower::mangle::mangleName(symbol, scopeBlockIdMap);
+ return Fortran::lower::mangle::mangleName(
+ symbol, scopeBlockIdMap, /*keepExternalInScope=*/false,
+ getLoweringOptions().getUnderscoring());
}
std::string mangleName(
const Fortran::semantics::DerivedTypeSpec &derivedType) override final {
diff --git a/flang/lib/Lower/Mangler.cpp b/flang/lib/Lower/Mangler.cpp
index 4ea6238eded0026..8e94ccfa70498e3 100644
--- a/flang/lib/Lower/Mangler.cpp
+++ b/flang/lib/Lower/Mangler.cpp
@@ -83,10 +83,9 @@ Fortran::lower::mangle::mangleName(std::string &name,
}
// Mangle the name of \p symbol to make it globally unique.
-std::string
-Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol &symbol,
- ScopeBlockIdMap &scopeBlockIdMap,
- bool keepExternalInScope) {
+std::string Fortran::lower::mangle::mangleName(
+ const Fortran::semantics::Symbol &symbol, ScopeBlockIdMap &scopeBlockIdMap,
+ bool keepExternalInScope, bool underscoring) {
// Resolve module and host associations before mangling.
const auto &ultimateSymbol = symbol.GetUltimate();
@@ -167,11 +166,12 @@ Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol &symbol,
symbolName);
},
[&](const Fortran::semantics::CommonBlockDetails &) {
- return fir::NameUniquer::doCommonBlock(symbolName);
+ return Fortran::semantics::GetCommonBlockObjectName(ultimateSymbol,
+ underscoring);
},
[&](const Fortran::semantics::ProcBindingDetails &procBinding) {
return mangleName(procBinding.symbol(), scopeBlockIdMap,
- keepExternalInScope);
+ keepExternalInScope, underscoring);
},
[&](const Fortran::semantics::DerivedTypeDetails &) -> std::string {
// Derived type mangling must use mangleName(DerivedTypeSpec) so
@@ -186,13 +186,14 @@ Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol &symbol,
std::string
Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol &symbol,
- bool keepExternalInScope) {
+ bool keepExternalInScope,
+ bool underscoring) {
assert((symbol.owner().kind() !=
Fortran::semantics::Scope::Kind::BlockConstruct ||
symbol.has<Fortran::semantics::SubprogramDetails>()) &&
"block object mangling must specify a scopeBlockIdMap");
ScopeBlockIdMap scopeBlockIdMap;
- return mangleName(symbol, scopeBlockIdMap, keepExternalInScope);
+ return mangleName(symbol, scopeBlockIdMap, keepExternalInScope, underscoring);
}
std::string Fortran::lower::mangle::mangleName(
diff --git a/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp b/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
index 67756766fb355bd..64791d673dacd36 100644
--- a/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "flang/Common/Fortran.h"
#include "flang/Optimizer/Dialect/FIRDialect.h"
#include "flang/Optimizer/Dialect/FIROps.h"
#include "flang/Optimizer/Support/InternalNames.h"
@@ -36,7 +37,7 @@ mangleExternalName(const std::pair<fir::NameUniquer::NameKind,
bool appendUnderscore) {
if (result.first == fir::NameUniquer::NameKind::COMMON &&
result.second.name.empty())
- return "__BLNK__";
+ return Fortran::common::blankCommonObjectName;
if (appendUnderscore)
return result.second.name + "_";
diff --git a/flang/lib/Semantics/semantics.cpp b/flang/lib/Semantics/semantics.cpp
index 1121be48200c23f..7176deba27068b6 100644
--- a/flang/lib/Semantics/semantics.cpp
+++ b/flang/lib/Semantics/semantics.cpp
@@ -212,7 +212,14 @@ class CommonBlockMap {
void MapCommonBlockAndCheckConflicts(
SemanticsContext &context, const Symbol &common) {
const Symbol *isInitialized{CommonBlockIsInitialized(common)};
- auto [it, firstAppearance] = commonBlocks_.insert({common.name(),
+ // Merge common according to the name they will have in the object files.
+ // This allows merging BIND(C) and non BIND(C) common block instead of
+ // later crashing. This "merge" matches what ifort/gfortran/nvfortran are
+ // doing and what a linker would do if the definition were in distinct
+ // files.
+ std::string commonName{
+ GetCommonBlockObjectName(common, context.underscoring())};
+ auto [it, firstAppearance] = commonBlocks_.insert({commonName,
isInitialized ? CommonBlockInfo{common, common}
: CommonBlockInfo{common, std::nullopt}});
if (!firstAppearance) {
@@ -291,7 +298,8 @@ class CommonBlockMap {
}
return nullptr;
}
- std::map<SourceName, CommonBlockInfo> commonBlocks_;
+
+ std::map<std::string, CommonBlockInfo> commonBlocks_;
};
SemanticsContext::SemanticsContext(
diff --git a/flang/lib/Semantics/tools.cpp b/flang/lib/Semantics/tools.cpp
index 7c523971e8e2479..54047f9c8d0a37b 100644
--- a/flang/lib/Semantics/tools.cpp
+++ b/flang/lib/Semantics/tools.cpp
@@ -1655,4 +1655,15 @@ std::string GetModuleOrSubmoduleName(const Symbol &symbol) {
return result;
}
+std::string GetCommonBlockObjectName(const Symbol &common, bool underscoring) {
+ if (const std::string * bind{common.GetBindName()}) {
+ return *bind;
+ }
+ if (common.name().empty()) {
+ return Fortran::common::blankCommonObjectName;
+ }
+ return underscoring ? common.name().ToString() + "_"s
+ : common.name().ToString();
+}
+
} // namespace Fortran::semantics
diff --git a/flang/test/Lower/HLFIR/common-block-bindc-conflicts.f90 b/flang/test/Lower/HLFIR/common-block-bindc-conflicts.f90
new file mode 100644
index 000000000000000..07259539d851d51
--- /dev/null
+++ b/flang/test/Lower/HLFIR/common-block-bindc-conflicts.f90
@@ -0,0 +1,47 @@
+! Test the mixing BIND(C) and non BIND(C) common blocks.
+
+! RUN: %flang_fc1 -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=UNDERSCORING
+! RUN: %flang_fc1 -emit-llvm -fno-underscoring %s -o - 2>&1 | FileCheck %s --check-prefix=NO-UNDERSCORING
+
+! Scenario 1: Fortran symbols collide, but not the object file names, emit
diff erent
+! globals for each common
+subroutine bindc_common_with_same_fortran_name()
+ real :: x
+ common /com1/ x
+ bind(c, name="not_com1") :: /com1/
+ print *, x
+end subroutine
+
+subroutine bindc_common_with_same_fortran_name_2()
+ real :: x(2), y(2)
+ common /com1/ x
+ print *, x
+end subroutine
+
+! Scenario 2: object file names of common block may collide (depending on
+! underscoring option). Merge common block into a single global symbol.
+subroutine bindc_common_colliding_with_normal_common()
+ real :: x, y
+ common /com3/ x
+ common /com4/ y
+ bind(c, name="some_common_") :: /com3/
+ bind(c, name="__BLNK__") :: /com4/
+ print *, x, y
+end subroutine
+subroutine bindc_common_colliding_with_normal_common_2()
+ real :: x(2), y(2)
+ common /some_common/ x
+ common // y
+ print *, x, y
+end subroutine
+
+! UNDERSCORING: @__BLNK__ = common global [8 x i8] zeroinitializer
+! UNDERSCORING: @com1_ = common global [8 x i8] zeroinitializer
+! UNDERSCORING: @not_com1 = common global [4 x i8] zeroinitializer
+! UNDERSCORING: @some_common_ = common global [8 x i8] zeroinitializer
+
+! NO-UNDERSCORING: @__BLNK__ = common global [8 x i8] zeroinitializer
+! NO-UNDERSCORING: @com1 = common global [8 x i8] zeroinitializer
+! NO-UNDERSCORING: @not_com1 = common global [4 x i8] zeroinitializer
+! NO-UNDERSCORING: @some_common = common global [8 x i8] zeroinitializer
+! NO-UNDERSCORING: @some_common_ = common global [4 x i8] zeroinitializer
diff --git a/flang/test/Lower/OpenMP/copyin.f90 b/flang/test/Lower/OpenMP/copyin.f90
index 5c76a4f15b73d17..ddfa0ea0914628f 100644
--- a/flang/test/Lower/OpenMP/copyin.f90
+++ b/flang/test/Lower/OpenMP/copyin.f90
@@ -207,7 +207,7 @@ subroutine combined_parallel_sections()
!CHECK: func.func @_QPcommon_1() {
-!CHECK: %[[val_0:.*]] = fir.address_of(@_QCc) : !fir.ref<!fir.array<4xi8>>
+!CHECK: %[[val_0:.*]] = fir.address_of(@c_) : !fir.ref<!fir.array<4xi8>>
!CHECK: %[[val_1:.*]] = omp.threadprivate %[[val_0]] : !fir.ref<!fir.array<4xi8>> -> !fir.ref<!fir.array<4xi8>>
!CHECK: %[[val_2:.*]] = fir.convert %[[val_1]] : (!fir.ref<!fir.array<4xi8>>) -> !fir.ref<!fir.array<?xi8>>
!CHECK: %[[val_c0:.*]] = arith.constant 0 : index
@@ -258,7 +258,7 @@ subroutine common_1()
!CHECK: func.func @_QPcommon_2() {
!CHECK: %[[val_0:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFcommon_2Ei"}
-!CHECK: %[[val_1:.*]] = fir.address_of(@_QCd) : !fir.ref<!fir.array<8xi8>>
+!CHECK: %[[val_1:.*]] = fir.address_of(@d_) : !fir.ref<!fir.array<8xi8>>
!CHECK: %[[val_2:.*]] = omp.threadprivate %[[val_1]] : !fir.ref<!fir.array<8xi8>> -> !fir.ref<!fir.array<8xi8>>
!CHECK: %[[val_3:.*]] = fir.convert %[[val_2]] : (!fir.ref<!fir.array<8xi8>>) -> !fir.ref<!fir.array<?xi8>>
!CHECK: %[[val_c0:.*]] = arith.constant 0 : index
diff --git a/flang/test/Lower/OpenMP/declare-target-data.f90 b/flang/test/Lower/OpenMP/declare-target-data.f90
index 2897c9762923e6e..e57d928f5497a17 100644
--- a/flang/test/Lower/OpenMP/declare-target-data.f90
+++ b/flang/test/Lower/OpenMP/declare-target-data.f90
@@ -52,19 +52,19 @@ module test_0
end module test_0
PROGRAM commons
- !CHECK-DAG: fir.global @_QCnumbers {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>} : tuple<f32, f32> {
+ !CHECK-DAG: fir.global @numbers_ {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>} : tuple<f32, f32> {
REAL :: one = 1
REAL :: two = 2
COMMON /numbers/ one, two
!$omp declare target(/numbers/)
- !CHECK-DAG: fir.global @_QCnumbers_link {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (link)>} : tuple<f32, f32> {
+ !CHECK-DAG: fir.global @numbers_link_ {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (link)>} : tuple<f32, f32> {
REAL :: one_link = 1
REAL :: two_link = 2
COMMON /numbers_link/ one_link, two_link
!$omp declare target link(/numbers_link/)
- !CHECK-DAG: fir.global @_QCnumbers_to {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>} : tuple<f32, f32> {
+ !CHECK-DAG: fir.global @numbers_to_ {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>} : tuple<f32, f32> {
REAL :: one_to = 1
REAL :: two_to = 2
COMMON /numbers_to/ one_to, two_to
diff --git a/flang/test/Lower/OpenMP/firstprivate-commonblock.f90 b/flang/test/Lower/OpenMP/firstprivate-commonblock.f90
index 9b1759555c6bb5c..a230c8ab64c30ea 100644
--- a/flang/test/Lower/OpenMP/firstprivate-commonblock.f90
+++ b/flang/test/Lower/OpenMP/firstprivate-commonblock.f90
@@ -1,7 +1,7 @@
! RUN: %flang_fc1 -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
!CHECK: func.func @_QPfirstprivate_common() {
-!CHECK: %[[val_0:.*]] = fir.address_of(@_QCc) : !fir.ref<!fir.array<8xi8>>
+!CHECK: %[[val_0:.*]] = fir.address_of(@c_) : !fir.ref<!fir.array<8xi8>>
!CHECK: %[[val_1:.*]] = fir.convert %[[val_0]] : (!fir.ref<!fir.array<8xi8>>) -> !fir.ref<!fir.array<?xi8>>
!CHECK: %[[val_c0:.*]] = arith.constant 0 : index
!CHECK: %[[val_2:.*]] = fir.coordinate_of %[[val_1]], %[[val_c0]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>
diff --git a/flang/test/Lower/OpenMP/lastprivate-commonblock.f90 b/flang/test/Lower/OpenMP/lastprivate-commonblock.f90
index 73175cbd45623fb..06f3e1ca82234ee 100644
--- a/flang/test/Lower/OpenMP/lastprivate-commonblock.f90
+++ b/flang/test/Lower/OpenMP/lastprivate-commonblock.f90
@@ -3,7 +3,7 @@
!CHECK: func.func @_QPlastprivate_common() {
!CHECK: %[[val_0:.*]] = fir.alloca i32 {adapt.valuebyref, pinned}
!CHECK: %[[val_1:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFlastprivate_commonEi"}
-!CHECK: %[[val_2:.*]] = fir.address_of(@_QCc) : !fir.ref<!fir.array<8xi8>>
+!CHECK: %[[val_2:.*]] = fir.address_of(@c_) : !fir.ref<!fir.array<8xi8>>
!CHECK: %[[val_3:.*]] = fir.convert %[[val_2]] : (!fir.ref<!fir.array<8xi8>>) -> !fir.ref<!fir.array<?xi8>>
!CHECK: %[[val_c0:.*]] = arith.constant 0 : index
!CHECK: %[[val_4:.*]] = fir.coordinate_of %[[val_3]], %[[val_c0]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>
diff --git a/flang/test/Lower/OpenMP/private-commonblock.f90 b/flang/test/Lower/OpenMP/private-commonblock.f90
index 644453a691318c6..767458e3effbf07 100644
--- a/flang/test/Lower/OpenMP/private-commonblock.f90
+++ b/flang/test/Lower/OpenMP/private-commonblock.f90
@@ -15,7 +15,7 @@ subroutine private_common
!$omp end parallel
end subroutine
-!CHECK: %[[val_0:.*]] = fir.address_of(@_QCblk) : !fir.ref<!fir.array<74xi8>>
+!CHECK: %[[val_0:.*]] = fir.address_of(@blk_) : !fir.ref<!fir.array<74xi8>>
!CHECK: %[[val_1:.*]] = fir.convert %0 : (!fir.ref<!fir.array<74xi8>>) -> !fir.ref<!fir.array<?xi8>>
!CHECK: %[[val_c0:.*]] = arith.constant 0 : index
!CHECK: %[[val_2:.*]] = fir.coordinate_of %[[val_1]], %[[val_c0]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>
@@ -72,7 +72,7 @@ subroutine private_clause_commonblock()
end subroutine
!CHECK: func.func @_QPprivate_clause_commonblock_pointer() {
-!CHECK: %[[val_0:.*]] = fir.address_of(@_QCblk) : !fir.ref<!fir.array<74xi8>>
+!CHECK: %[[val_0:.*]] = fir.address_of(@blk_) : !fir.ref<!fir.array<74xi8>>
!CHECK: %[[val_1:.*]] = fir.convert %[[val_0]] : (!fir.ref<!fir.array<74xi8>>) -> !fir.ref<!fir.array<?xi8>>
!CHECK: %[[val_c24:.*]] = arith.constant 24 : index
!CHECK: %[[val_2:.*]] = fir.coordinate_of %[[val_1]], %[[val_c24]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>
diff --git a/flang/test/Lower/OpenMP/threadprivate-common-block-hlfir.f90 b/flang/test/Lower/OpenMP/threadprivate-common-block-hlfir.f90
index 29e3e277dc89602..e9cad51534d01a8 100644
--- a/flang/test/Lower/OpenMP/threadprivate-common-block-hlfir.f90
+++ b/flang/test/Lower/OpenMP/threadprivate-common-block-hlfir.f90
@@ -5,7 +5,7 @@
!RUN: bbc -hlfir -emit-hlfir -fopenmp %s -o - | FileCheck %s
-!CHECK: %[[CBLK_ADDR:.*]] = fir.address_of(@_QCblk) : !fir.ref<!fir.array<4xi8>>
+!CHECK: %[[CBLK_ADDR:.*]] = fir.address_of(@blk_) : !fir.ref<!fir.array<4xi8>>
!CHECK: {{.*}} = omp.threadprivate %[[CBLK_ADDR]] : !fir.ref<!fir.array<4xi8>> -> !fir.ref<!fir.array<4xi8>>
!CHECK: omp.parallel {
!CHECK: %[[TP_PARALLEL:.*]] = omp.threadprivate %[[CBLK_ADDR]] : !fir.ref<!fir.array<4xi8>> -> !fir.ref<!fir.array<4xi8>>
diff --git a/flang/test/Lower/OpenMP/threadprivate-commonblock.f90 b/flang/test/Lower/OpenMP/threadprivate-commonblock.f90
index 5cecb372e630bef..0a1252d881605da 100644
--- a/flang/test/Lower/OpenMP/threadprivate-commonblock.f90
+++ b/flang/test/Lower/OpenMP/threadprivate-commonblock.f90
@@ -12,11 +12,11 @@ module test
!$omp threadprivate(/blk/)
-!CHECK: fir.global common @_QCblk(dense<0> : vector<103xi8>) : !fir.array<103xi8>
+!CHECK: fir.global common @blk_(dense<0> : vector<103xi8>) : !fir.array<103xi8>
contains
subroutine sub()
-!CHECK: [[ADDR0:%.*]] = fir.address_of(@_QCblk) : !fir.ref<!fir.array<103xi8>>
+!CHECK: [[ADDR0:%.*]] = fir.address_of(@blk_) : !fir.ref<!fir.array<103xi8>>
!CHECK: [[NEWADDR0:%.*]] = omp.threadprivate [[ADDR0]] : !fir.ref<!fir.array<103xi8>> -> !fir.ref<!fir.array<103xi8>>
!CHECK-DAG: [[ADDR1:%.*]] = fir.convert [[NEWADDR0]] : (!fir.ref<!fir.array<103xi8>>) -> !fir.ref<!fir.array<?xi8>>
!CHECK-DAG: [[C0:%.*]] = arith.constant 0 : index
diff --git a/flang/test/Lower/OpenMP/threadprivate-use-association.f90 b/flang/test/Lower/OpenMP/threadprivate-use-association.f90
index 2a4649259d36f18..71d454bb39ce1d1 100644
--- a/flang/test/Lower/OpenMP/threadprivate-use-association.f90
+++ b/flang/test/Lower/OpenMP/threadprivate-use-association.f90
@@ -3,7 +3,7 @@
!RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s
-!CHECK-DAG: fir.global common @_QCblk(dense<0> : vector<24xi8>) : !fir.array<24xi8>
+!CHECK-DAG: fir.global common @blk_(dense<0> : vector<24xi8>) : !fir.array<24xi8>
!CHECK-DAG: fir.global @_QMtestEy : f32 {
module test
@@ -16,7 +16,7 @@ module test
contains
subroutine sub()
! CHECK-LABEL: @_QMtestPsub
-!CHECK-DAG: [[ADDR0:%.*]] = fir.address_of(@_QCblk) : !fir.ref<!fir.array<24xi8>>
+!CHECK-DAG: [[ADDR0:%.*]] = fir.address_of(@blk_) : !fir.ref<!fir.array<24xi8>>
!CHECK-DAG: [[NEWADDR0:%.*]] = omp.threadprivate [[ADDR0]] : !fir.ref<!fir.array<24xi8>> -> !fir.ref<!fir.array<24xi8>>
!CHECK-DAG: [[ADDR1:%.*]] = fir.address_of(@_QMtestEy) : !fir.ref<f32>
!CHECK-DAG: [[NEWADDR1:%.*]] = omp.threadprivate [[ADDR1]] : !fir.ref<f32> -> !fir.ref<f32>
@@ -49,9 +49,9 @@ program main
call sub()
! CHECK-LABEL: @_QQmain()
-!CHECK-DAG: [[ADDR0:%.*]] = fir.address_of(@_QCblk) : !fir.ref<!fir.array<24xi8>>
+!CHECK-DAG: [[ADDR0:%.*]] = fir.address_of(@blk_) : !fir.ref<!fir.array<24xi8>>
!CHECK-DAG: [[NEWADDR0:%.*]] = omp.threadprivate [[ADDR0]] : !fir.ref<!fir.array<24xi8>> -> !fir.ref<!fir.array<24xi8>>
-!CHECK-DAG: [[ADDR1:%.*]] = fir.address_of(@_QCblk) : !fir.ref<!fir.array<24xi8>>
+!CHECK-DAG: [[ADDR1:%.*]] = fir.address_of(@blk_) : !fir.ref<!fir.array<24xi8>>
!CHECK-DAG: [[NEWADDR1:%.*]] = omp.threadprivate [[ADDR1]] : !fir.ref<!fir.array<24xi8>> -> !fir.ref<!fir.array<24xi8>>
!CHECK-DAG: [[ADDR2:%.*]] = fir.address_of(@_QMtestEy) : !fir.ref<f32>
!CHECK-DAG: [[NEWADDR2:%.*]] = omp.threadprivate [[ADDR2]] : !fir.ref<f32> -> !fir.ref<f32>
diff --git a/flang/test/Lower/array.f90 b/flang/test/Lower/array.f90
index 852f5605892800f..e6e12862858385d 100644
--- a/flang/test/Lower/array.f90
+++ b/flang/test/Lower/array.f90
@@ -1,6 +1,6 @@
! RUN: bbc -o - %s | FileCheck %s
-! CHECK-LABEL: fir.global @_QCblock
+! CHECK-LABEL: fir.global @block_
! CHECK-DAG: %[[VAL_1:.*]] = arith.constant 1.000000e+00 : f32
! CHECK-DAG: %[[VAL_2:.*]] = arith.constant 2.400000e+00 : f32
! CHECK-DAG: %[[VAL_3:.*]] = arith.constant 0.000000e+00 : f32
diff --git a/flang/test/Lower/common-block-2.f90 b/flang/test/Lower/common-block-2.f90
index 80bb7411bb4f8c2..31916f4be9fcb2e 100644
--- a/flang/test/Lower/common-block-2.f90
+++ b/flang/test/Lower/common-block-2.f90
@@ -5,12 +5,12 @@
! - A blank common that is initialized
! - A common block that is initialized outside of a BLOCK DATA.
-! CHECK-LABEL: fir.global @_QC : tuple<i32, !fir.array<8xi8>> {
+! CHECK-LABEL: fir.global @__BLNK__ : tuple<i32, !fir.array<8xi8>> {
! CHECK: %[[undef:.*]] = fir.undefined tuple<i32, !fir.array<8xi8>>
! CHECK: %[[init:.*]] = fir.insert_value %[[undef]], %c42{{.*}}, [0 : index] : (tuple<i32, !fir.array<8xi8>>, i32) -> tuple<i32, !fir.array<8xi8>>
! CHECK: fir.has_value %[[init]] : tuple<i32, !fir.array<8xi8>>
-! CHECK-LABEL: fir.global @_QCa : tuple<i32, !fir.array<8xi8>> {
+! CHECK-LABEL: fir.global @a_ : tuple<i32, !fir.array<8xi8>> {
! CHECK: %[[undef:.*]] = fir.undefined tuple<i32, !fir.array<8xi8>>
! CHECK: %[[init:.*]] = fir.insert_value %[[undef]], %c42{{.*}}, [0 : index] : (tuple<i32, !fir.array<8xi8>>, i32) -> tuple<i32, !fir.array<8xi8>>
! CHECK: fir.has_value %[[init]] : tuple<i32, !fir.array<8xi8>>
diff --git a/flang/test/Lower/common-block.f90 b/flang/test/Lower/common-block.f90
index a09181bfd78f0d2..bd3fab507c0ef41 100644
--- a/flang/test/Lower/common-block.f90
+++ b/flang/test/Lower/common-block.f90
@@ -1,18 +1,18 @@
! RUN: bbc %s -o - | tco | FileCheck %s
! RUN: %flang -emit-llvm -S -mmlir -disable-external-name-interop %s -o - | FileCheck %s
-! CHECK: @_QC = common global [8 x i8] zeroinitializer
-! CHECK: @_QCrien = common global [1 x i8] zeroinitializer
-! CHECK: @_QCwith_empty_equiv = common global [8 x i8] zeroinitializer
-! CHECK: @_QCx = global { float, float } { float 1.0{{.*}}, float 2.0{{.*}} }
-! CHECK: @_QCy = common global [12 x i8] zeroinitializer
-! CHECK: @_QCz = global { i32, [4 x i8], float } { i32 42, [4 x i8] undef, float 3.000000e+00 }
+! CHECK: @__BLNK__ = common global [8 x i8] zeroinitializer
+! CHECK: @rien_ = common global [1 x i8] zeroinitializer
+! CHECK: @with_empty_equiv_ = common global [8 x i8] zeroinitializer
+! CHECK: @x_ = global { float, float } { float 1.0{{.*}}, float 2.0{{.*}} }
+! CHECK: @y_ = common global [12 x i8] zeroinitializer
+! CHECK: @z_ = global { i32, [4 x i8], float } { i32 42, [4 x i8] undef, float 3.000000e+00 }
! CHECK-LABEL: _QPs0
subroutine s0
common // a0, b0
- ! CHECK: call void @_QPs(ptr @_QC, ptr getelementptr (i8, ptr @_QC, i64 4))
+ ! CHECK: call void @_QPs(ptr @__BLNK__, ptr getelementptr (i8, ptr @__BLNK__, i64 4))
call s(a0, b0)
end subroutine s0
@@ -21,7 +21,7 @@ subroutine s1
common /x/ a1, b1
data a1 /1.0/, b1 /2.0/
- ! CHECK: call void @_QPs(ptr @_QCx, ptr getelementptr (i8, ptr @_QCx, i64 4))
+ ! CHECK: call void @_QPs(ptr @x_, ptr getelementptr (i8, ptr @x_, i64 4))
call s(a1, b1)
end subroutine s1
@@ -29,7 +29,7 @@ end subroutine s1
subroutine s2
common /y/ a2, b2, c2
- ! CHECK: call void @_QPs(ptr @_QCy, ptr getelementptr (i8, ptr @_QCy, i64 4))
+ ! CHECK: call void @_QPs(ptr @y_, ptr getelementptr (i8, ptr @y_, i64 4))
call s(a2, b2)
end subroutine s2
@@ -54,9 +54,9 @@ module mod_with_common
! CHECK-LABEL: _QPs4
subroutine s4
use mod_with_common
- ! CHECK: load i32, ptr @_QCc_in_mod
+ ! CHECK: load i32, ptr @c_in_mod_
print *, i
- ! CHECK: load i32, ptr getelementptr (i8, ptr @_QCc_in_mod, i64 4)
+ ! CHECK: load i32, ptr getelementptr (i8, ptr @c_in_mod_, i64 4)
print *, j
end subroutine s4
diff --git a/flang/test/Lower/equivalence-2.f90 b/flang/test/Lower/equivalence-2.f90
index e53f265c630457e..36a7c10ba2e936c 100644
--- a/flang/test/Lower/equivalence-2.f90
+++ b/flang/test/Lower/equivalence-2.f90
@@ -111,7 +111,7 @@ subroutine eq_and_comm_same_offset
equivalence(arr3,arr4)
! CHECK: %[[arr4Store:.*]] = fir.alloca !fir.array<70756xi8> {uniq_name = "_QFeq_and_comm_same_offsetEarr3"}
- ! CHECK: %[[mcbAddr:.*]] = fir.address_of(@_QCmy_common_block) : !fir.ref<!fir.array<1064xi8>>
+ ! CHECK: %[[mcbAddr:.*]] = fir.address_of(@my_common_block_) : !fir.ref<!fir.array<1064xi8>>
! CHECK: %[[mcbCast:.*]] = fir.convert %[[mcbAddr]] : (!fir.ref<!fir.array<1064xi8>>) -> !fir.ref<!fir.array<?xi8>>
! CHECK: %[[c0:.*]] = arith.constant 0 : index
! CHECK: %[[mcbCoor:.*]] = fir.coordinate_of %[[mcbCast]], %[[c0]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>
diff --git a/flang/test/Lower/explicit-interface-results-2.f90 b/flang/test/Lower/explicit-interface-results-2.f90
index f77eb7157c237e7..64af605cf23a9e4 100644
--- a/flang/test/Lower/explicit-interface-results-2.f90
+++ b/flang/test/Lower/explicit-interface-results-2.f90
@@ -140,7 +140,7 @@ subroutine host7()
common /mycom/ n_common
call takes_array(return_array())
! CHECK: %[[VAL_0:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_2:.*]] = fir.address_of(@_QCmycom) : !fir.ref<!fir.array<4xi8>>
+! CHECK: %[[VAL_2:.*]] = fir.address_of(@mycom_) : !fir.ref<!fir.array<4xi8>>
! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]] : (!fir.ref<!fir.array<4xi8>>) -> !fir.ref<!fir.array<?xi8>>
! CHECK: %[[VAL_4:.*]] = fir.coordinate_of %[[VAL_3]], %[[VAL_0]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>
! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (!fir.ref<i8>) -> !fir.ref<i32>
@@ -162,7 +162,7 @@ subroutine host8()
implicit none
call takes_array(return_array())
! CHECK: %[[VAL_0:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_1:.*]] = fir.address_of(@_QCmycom) : !fir.ref<!fir.array<4xi8>>
+! CHECK: %[[VAL_1:.*]] = fir.address_of(@mycom_) : !fir.ref<!fir.array<4xi8>>
! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]] : (!fir.ref<!fir.array<4xi8>>) -> !fir.ref<!fir.array<?xi8>>
! CHECK: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_2]], %[[VAL_0]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>
! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.ref<i8>) -> !fir.ref<i32>
@@ -190,7 +190,7 @@ subroutine host9()
! CHECK-LABEL: func @_QFhost9Pinternal_proc_a
subroutine internal_proc_a()
! CHECK: %[[VAL_0:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_1:.*]] = fir.address_of(@_QCmycom) : !fir.ref<!fir.array<4xi8>>
+! CHECK: %[[VAL_1:.*]] = fir.address_of(@mycom_) : !fir.ref<!fir.array<4xi8>>
! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]] : (!fir.ref<!fir.array<4xi8>>) -> !fir.ref<!fir.array<?xi8>>
! CHECK: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_2]], %[[VAL_0]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>
! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.ref<i8>) -> !fir.ref<i32>
@@ -217,7 +217,7 @@ subroutine host10()
subroutine internal_proc_a()
call takes_array(return_array())
! CHECK: %[[VAL_0:.*]] = arith.constant 0 : index
-! CHECK: %[[VAL_1:.*]] = fir.address_of(@_QCmycom) : !fir.ref<!fir.array<4xi8>>
+! CHECK: %[[VAL_1:.*]] = fir.address_of(@mycom_) : !fir.ref<!fir.array<4xi8>>
! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]] : (!fir.ref<!fir.array<4xi8>>) -> !fir.ref<!fir.array<?xi8>>
! CHECK: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_2]], %[[VAL_0]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>
! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.ref<i8>) -> !fir.ref<i32>
diff --git a/flang/test/Lower/host-associated-globals.f90 b/flang/test/Lower/host-associated-globals.f90
index 1f23b15fe3af4bc..018eb7aee3bc8c9 100644
--- a/flang/test/Lower/host-associated-globals.f90
+++ b/flang/test/Lower/host-associated-globals.f90
@@ -38,7 +38,7 @@ subroutine bar()
end subroutine
end subroutine
! CHECK-LABEL: func.func @_QFtest_commonPbar() attributes {fir.internal_proc} {
-! CHECK: %[[VAL_0:.*]] = fir.address_of(@_QCx) : !fir.ref<!fir.array<12xi8>>
+! CHECK: %[[VAL_0:.*]] = fir.address_of(@x_) : !fir.ref<!fir.array<12xi8>>
! CHECK: %[[VAL_1:.*]] = fir.convert %[[VAL_0]] : (!fir.ref<!fir.array<12xi8>>) -> !fir.ref<!fir.array<?xi8>>
! CHECK: %[[VAL_2:.*]] = arith.constant 4 : index
! CHECK: %[[VAL_3:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_2]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>
diff --git a/flang/test/Lower/module_definition.f90 b/flang/test/Lower/module_definition.f90
index f79bb4cf03f3e16..fd3b89db7d20c9a 100644
--- a/flang/test/Lower/module_definition.f90
+++ b/flang/test/Lower/module_definition.f90
@@ -12,15 +12,15 @@ module modCommonNoInit1
real :: x_named1
common /named1/ x_named1
end module
-! CHECK-LABEL: fir.global common @_QC(dense<0> : vector<4xi8>) : !fir.array<4xi8>
-! CHECK-LABEL: fir.global common @_QCnamed1(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+! CHECK-LABEL: fir.global common @__BLNK__(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+! CHECK-LABEL: fir.global common @named1_(dense<0> : vector<4xi8>) : !fir.array<4xi8>
! Module defines variable in common block with initialization
module modCommonInit1
integer :: i_named2 = 42
common /named2/ i_named2
end module
-! CHECK-LABEL: fir.global @_QCnamed2 : tuple<i32> {
+! CHECK-LABEL: fir.global @named2_ : tuple<i32> {
! CHECK: %[[init:.*]] = fir.insert_value %{{.*}}, %c42{{.*}}, [0 : index] : (tuple<i32>, i32) -> tuple<i32>
! CHECK: fir.has_value %[[init]] : tuple<i32>
diff --git a/flang/test/Lower/module_use.f90 b/flang/test/Lower/module_use.f90
index c7f23c20ada9cfe..21458bb488430f8 100644
--- a/flang/test/Lower/module_use.f90
+++ b/flang/test/Lower/module_use.f90
@@ -5,9 +5,9 @@
! The modules are defined in module_definition.f90
! The first runs ensures the module file is generated.
-! CHECK: fir.global common @_QC(dense<0> : vector<4xi8>) : !fir.array<4xi8>
-! CHECK-NEXT: fir.global common @_QCnamed1(dense<0> : vector<4xi8>) : !fir.array<4xi8>
-! CHECK-NEXT: fir.global common @_QCnamed2(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+! CHECK: fir.global common @__BLNK__(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+! CHECK-NEXT: fir.global common @named1_(dense<0> : vector<4xi8>) : !fir.array<4xi8>
+! CHECK-NEXT: fir.global common @named2_(dense<0> : vector<4xi8>) : !fir.array<4xi8>
! CHECK-LABEL: func @_QPm1use()
real function m1use()
@@ -32,9 +32,9 @@ real function m1use()
real function modCommon1Use()
use modCommonInit1
use modCommonNoInit1
- ! CHECK-DAG: fir.address_of(@_QCnamed2) : !fir.ref<!fir.array<4xi8>>
- ! CHECK-DAG: fir.address_of(@_QC) : !fir.ref<!fir.array<4xi8>>
- ! CHECK-DAG: fir.address_of(@_QCnamed1) : !fir.ref<!fir.array<4xi8>>
+ ! CHECK-DAG: fir.address_of(@named2_) : !fir.ref<!fir.array<4xi8>>
+ ! CHECK-DAG: fir.address_of(@__BLNK__) : !fir.ref<!fir.array<4xi8>>
+ ! CHECK-DAG: fir.address_of(@named1_) : !fir.ref<!fir.array<4xi8>>
modCommon1Use = x_blank + x_named1 + i_named2
end function
diff --git a/flang/test/Lower/module_use_in_same_file.f90 b/flang/test/Lower/module_use_in_same_file.f90
index ea4ca3d0f7388c4..9e51bee14fd7a61 100644
--- a/flang/test/Lower/module_use_in_same_file.f90
+++ b/flang/test/Lower/module_use_in_same_file.f90
@@ -79,26 +79,26 @@ module modCommon2
contains
! CHECK-LABEL: func @_QMmodcommon2Pfoo()
real function foo()
- ! CHECK-DAG: fir.address_of(@_QCnamed2) : !fir.ref<tuple<i32>>
- ! CHECK-DAG: fir.address_of(@_QC) : !fir.ref<!fir.array<4xi8>>
- ! CHECK-DAG: fir.address_of(@_QCnamed1) : !fir.ref<!fir.array<40xi8>>
+ ! CHECK-DAG: fir.address_of(@named2_) : !fir.ref<tuple<i32>>
+ ! CHECK-DAG: fir.address_of(@__BLNK__) : !fir.ref<!fir.array<4xi8>>
+ ! CHECK-DAG: fir.address_of(@named1_) : !fir.ref<!fir.array<40xi8>>
foo = x_blank + x_named1(5) + i_named2
end function
end module
! CHECK-LABEL: func @_QPmodcommon2use()
real function modCommon2use()
use modCommon2
- ! CHECK-DAG: fir.address_of(@_QCnamed2) : !fir.ref<tuple<i32>>
- ! CHECK-DAG: fir.address_of(@_QC) : !fir.ref<!fir.array<4xi8>>
- ! CHECK-DAG: fir.address_of(@_QCnamed1) : !fir.ref<!fir.array<40xi8>>
+ ! CHECK-DAG: fir.address_of(@named2_) : !fir.ref<tuple<i32>>
+ ! CHECK-DAG: fir.address_of(@__BLNK__) : !fir.ref<!fir.array<4xi8>>
+ ! CHECK-DAG: fir.address_of(@named1_) : !fir.ref<!fir.array<40xi8>>
modCommon2use = x_blank + x_named1(5) + i_named2
end function
! CHECK-LABEL: func @_QPmodcommon2use_rename()
real function modCommon2use_rename()
use modCommon2, only : renamed0 => x_blank, renamed1 => x_named1, renamed2 => i_named2
- ! CHECK-DAG: fir.address_of(@_QCnamed2) : !fir.ref<tuple<i32>>
- ! CHECK-DAG: fir.address_of(@_QC) : !fir.ref<!fir.array<4xi8>>
- ! CHECK-DAG: fir.address_of(@_QCnamed1) : !fir.ref<!fir.array<40xi8>>
+ ! CHECK-DAG: fir.address_of(@named2_) : !fir.ref<tuple<i32>>
+ ! CHECK-DAG: fir.address_of(@__BLNK__) : !fir.ref<!fir.array<4xi8>>
+ ! CHECK-DAG: fir.address_of(@named1_) : !fir.ref<!fir.array<40xi8>>
modCommon2use_rename = renamed0 + renamed1(5) + renamed2
end function
diff --git a/flang/test/Lower/namelist-common-block.f90 b/flang/test/Lower/namelist-common-block.f90
index 39deb7b51059cc5..f47d4c9bd87ea39 100644
--- a/flang/test/Lower/namelist-common-block.f90
+++ b/flang/test/Lower/namelist-common-block.f90
@@ -18,7 +18,7 @@ subroutine print_t()
end
! CHECK-LABEL: fir.global linkonce @_QFNt.list constant : !fir.array<2xtuple<!fir.ref<i8>, !fir.ref<!fir.box<none>>>> {
-! CHECK: %[[CB_ADDR:.*]] = fir.address_of(@_QCc) : !fir.ref<!fir.array<56xi8>>
+! CHECK: %[[CB_ADDR:.*]] = fir.address_of(@c_) : !fir.ref<!fir.array<56xi8>>
! CHECK: %[[CB_CAST:.*]] = fir.convert %[[CB_ADDR]] : (!fir.ref<!fir.array<56xi8>>) -> !fir.ref<!fir.array<?xi8>>
! CHECK: %[[OFFSET:.*]] = arith.constant 8 : index
! CHECK: %[[COORD:.*]] = fir.coordinate_of %[[CB_CAST]], %[[OFFSET]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>
diff --git a/flang/test/Lower/pointer-assignments.f90 b/flang/test/Lower/pointer-assignments.f90
index 767a5121cffa429..24154d83e992c86 100644
--- a/flang/test/Lower/pointer-assignments.f90
+++ b/flang/test/Lower/pointer-assignments.f90
@@ -364,7 +364,7 @@ subroutine issue1180(x)
integer, target :: x
integer, pointer :: p
common /some_common/ p
- ! CHECK: %[[VAL_1:.*]] = fir.address_of(@_QCsome_common) : !fir.ref<!fir.array<24xi8>>
+ ! CHECK: %[[VAL_1:.*]] = fir.address_of(@some_common_) : !fir.ref<!fir.array<24xi8>>
! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]] : (!fir.ref<!fir.array<24xi8>>) -> !fir.ref<!fir.array<?xi8>>
! CHECK: %[[VAL_3:.*]] = arith.constant 0 : index
! CHECK: %[[VAL_4:.*]] = fir.coordinate_of %[[VAL_2]], %[[VAL_3]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>
diff --git a/flang/test/Lower/pointer-initial-target-2.f90 b/flang/test/Lower/pointer-initial-target-2.f90
index 2889d58d385c270..69e9f23126708fb 100644
--- a/flang/test/Lower/pointer-initial-target-2.f90
+++ b/flang/test/Lower/pointer-initial-target-2.f90
@@ -11,7 +11,7 @@
real, save, target :: b
common /a/ p
data p /b/
-! CHECK-LABEL: fir.global @_QCa : tuple<!fir.box<!fir.ptr<f32>>>
+! CHECK-LABEL: fir.global @a_ : tuple<!fir.box<!fir.ptr<f32>>>
! CHECK: %[[undef:.*]] = fir.undefined tuple<!fir.box<!fir.ptr<f32>>>
! CHECK: %[[b:.*]] = fir.address_of(@_QEb) : !fir.ref<f32>
! CHECK: %[[box:.*]] = fir.embox %[[b]] : (!fir.ref<f32>) -> !fir.box<f32>
@@ -29,10 +29,10 @@ block data tied
real, pointer :: p2 => x1
common /c1/ x1, p1
common /c2/ x2, p2
-! CHECK-LABEL: fir.global @_QCc1 : tuple<f32, !fir.array<4xi8>, !fir.box<!fir.ptr<f32>>>
- ! CHECK: fir.address_of(@_QCc2) : !fir.ref<tuple<f32, !fir.array<4xi8>, !fir.box<!fir.ptr<f32>>>>
-! CHECK-LABEL: fir.global @_QCc2 : tuple<f32, !fir.array<4xi8>, !fir.box<!fir.ptr<f32>>>
- ! CHECK: fir.address_of(@_QCc1) : !fir.ref<tuple<f32, !fir.array<4xi8>, !fir.box<!fir.ptr<f32>>>>
+! CHECK-LABEL: fir.global @c1_ : tuple<f32, !fir.array<4xi8>, !fir.box<!fir.ptr<f32>>>
+ ! CHECK: fir.address_of(@c2_) : !fir.ref<tuple<f32, !fir.array<4xi8>, !fir.box<!fir.ptr<f32>>>>
+! CHECK-LABEL: fir.global @c2_ : tuple<f32, !fir.array<4xi8>, !fir.box<!fir.ptr<f32>>>
+ ! CHECK: fir.address_of(@c1_) : !fir.ref<tuple<f32, !fir.array<4xi8>, !fir.box<!fir.ptr<f32>>>>
end block data
! Test pointer in a common with initial target in the same common.
@@ -40,9 +40,9 @@ block data bdsnake
integer, target :: b = 42
integer, pointer :: p => b
common /snake/ p, b
-! CHECK-LABEL: fir.global @_QCsnake : tuple<!fir.box<!fir.ptr<i32>>, i32>
+! CHECK-LABEL: fir.global @snake_ : tuple<!fir.box<!fir.ptr<i32>>, i32>
! CHECK: %[[tuple0:.*]] = fir.undefined tuple<!fir.box<!fir.ptr<i32>>, i32>
- ! CHECK: %[[snakeAddr:.*]] = fir.address_of(@_QCsnake) : !fir.ref<tuple<!fir.box<!fir.ptr<i32>>, i32>>
+ ! CHECK: %[[snakeAddr:.*]] = fir.address_of(@snake_) : !fir.ref<tuple<!fir.box<!fir.ptr<i32>>, i32>>
! CHECK: %[[byteView:.*]] = fir.convert %[[snakeAddr:.*]] : (!fir.ref<tuple<!fir.box<!fir.ptr<i32>>, i32>>) -> !fir.ref<!fir.array<?xi8>>
! CHECK: %[[coor:.*]] = fir.coordinate_of %[[byteView]], %c24{{.*}} : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>
! CHECK: %[[bAddr:.*]] = fir.convert %[[coor]] : (!fir.ref<i8>) -> !fir.ref<i32>
@@ -72,7 +72,7 @@ module some_mod_2
save :: /com/
real, pointer :: p(:) => y
! CHECK-LABEL: fir.global @_QMsome_mod_2Ep : !fir.box<!fir.ptr<!fir.array<?xf32>>> {
- ! CHECK: %[[c:.*]] = fir.address_of(@_QCcom) : !fir.ref<!fir.array<1200xi8>>
+ ! CHECK: %[[c:.*]] = fir.address_of(@com_) : !fir.ref<!fir.array<1200xi8>>
! CHECK: %[[com:.*]] = fir.convert %[[c]] : (!fir.ref<!fir.array<1200xi8>>) -> !fir.ref<!fir.array<?xi8>>
! CHECK: %[[yRaw:.*]] = fir.coordinate_of %[[com]], %c400{{.*}} : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>
! CHECK: %[[y:.*]] = fir.convert %[[yRaw]] : (!fir.ref<i8>) -> !fir.ref<!fir.array<200xf32>>
More information about the flang-commits
mailing list