Skip to content

Commit 6ffea74

Browse files
authored
[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.
1 parent d4d0b5e commit 6ffea74

32 files changed

+167
-79
lines changed

flang/include/flang/Common/Fortran.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,7 @@ std::string AsFortran(IgnoreTKRSet);
109109
bool AreCompatibleCUDADataAttrs(
110110
std::optional<CUDADataAttr>, std::optional<CUDADataAttr>, IgnoreTKRSet);
111111

112+
static constexpr char blankCommonObjectName[] = "__BLNK__";
113+
112114
} // namespace Fortran::common
113115
#endif // FORTRAN_COMMON_FORTRAN_H_

flang/include/flang/Lower/LoweringOptions.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,8 @@ ENUM_LOWERINGOPT(LowerToHighLevelFIR, unsigned, 1, 0)
3434
/// If true, reverse PowerPC native vector element order.
3535
ENUM_LOWERINGOPT(NoPPCNativeVecElemOrder, unsigned, 1, 0)
3636

37+
/// If true, assume external names will be suffixed with an underscore. On by default.
38+
ENUM_LOWERINGOPT(Underscoring, unsigned, 1, 1)
39+
3740
#undef LOWERINGOPT
3841
#undef ENUM_LOWERINGOPT

flang/include/flang/Lower/Mangler.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ using ScopeBlockIdMap =
4343
/// a symbol where all the Fortran context is needed. Otherwise, external
4444
/// symbols are mangled outside of any scope.
4545
std::string mangleName(const semantics::Symbol &, ScopeBlockIdMap &,
46-
bool keepExternalInScope = false);
46+
bool keepExternalInScope = false,
47+
bool underscoring = true);
4748
std::string mangleName(const semantics::Symbol &,
48-
bool keepExternalInScope = false);
49+
bool keepExternalInScope = false,
50+
bool underscoring = true);
4951

5052
/// Convert a derived type instance to an internal name.
5153
std::string mangleName(const semantics::DerivedTypeSpec &, ScopeBlockIdMap &);

flang/include/flang/Semantics/semantics.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class SemanticsContext {
9393
}
9494
const std::string &moduleDirectory() const { return moduleDirectory_; }
9595
const std::string &moduleFileSuffix() const { return moduleFileSuffix_; }
96+
bool underscoring() const { return underscoring_; }
9697
bool warningsAreErrors() const { return warningsAreErrors_; }
9798
bool debugModuleWriter() const { return debugModuleWriter_; }
9899
const evaluate::IntrinsicProcTable &intrinsics() const { return intrinsics_; }
@@ -130,6 +131,10 @@ class SemanticsContext {
130131
moduleFileSuffix_ = x;
131132
return *this;
132133
}
134+
SemanticsContext &set_underscoring(bool x) {
135+
underscoring_ = x;
136+
return *this;
137+
}
133138
SemanticsContext &set_warnOnNonstandardUsage(bool x) {
134139
warnOnNonstandardUsage_ = x;
135140
return *this;
@@ -262,6 +267,7 @@ class SemanticsContext {
262267
std::vector<std::string> intrinsicModuleDirectories_;
263268
std::string moduleDirectory_{"."s};
264269
std::string moduleFileSuffix_{".mod"};
270+
bool underscoring_{true};
265271
bool warnOnNonstandardUsage_{false};
266272
bool warningsAreErrors_{false};
267273
bool debugModuleWriter_{false};

flang/include/flang/Semantics/tools.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,5 +683,8 @@ std::optional<R> GetConstExpr(
683683
// Returns "m" for a module, "m:sm" for a submodule.
684684
std::string GetModuleOrSubmoduleName(const Symbol &);
685685

686+
// Return the assembly name emitted for a common block.
687+
std::string GetCommonBlockObjectName(const Symbol &, bool underscoring);
688+
686689
} // namespace Fortran::semantics
687690
#endif // FORTRAN_SEMANTICS_TOOLS_H_

flang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,8 @@ void CompilerInvocation::setSemanticsOpts(
12371237
.set_searchDirectories(fortranOptions.searchDirectories)
12381238
.set_intrinsicModuleDirectories(fortranOptions.intrinsicModuleDirectories)
12391239
.set_warningsAreErrors(getWarnAsErr())
1240-
.set_moduleFileSuffix(getModuleFileSuffix());
1240+
.set_moduleFileSuffix(getModuleFileSuffix())
1241+
.set_underscoring(getCodeGenOpts().Underscoring);
12411242

12421243
llvm::Triple targetTriple{llvm::Triple(this->targetOpts.triple)};
12431244
// FIXME: Handle real(3) ?
@@ -1262,6 +1263,7 @@ void CompilerInvocation::setLoweringOptions() {
12621263

12631264
// Lower TRANSPOSE as a runtime call under -O0.
12641265
loweringOpts.setOptimizeTranspose(codegenOpts.OptimizationLevel > 0);
1266+
loweringOpts.setUnderscoring(codegenOpts.Underscoring);
12651267

12661268
const LangOptions &langOptions = getLangOpts();
12671269
Fortran::common::MathOptionsBase &mathOpts = loweringOpts.getMathOptions();

flang/lib/Lower/Bridge.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,9 @@ class FirConverter : public Fortran::lower::AbstractConverter {
836836
}
837837
std::string
838838
mangleName(const Fortran::semantics::Symbol &symbol) override final {
839-
return Fortran::lower::mangle::mangleName(symbol, scopeBlockIdMap);
839+
return Fortran::lower::mangle::mangleName(
840+
symbol, scopeBlockIdMap, /*keepExternalInScope=*/false,
841+
getLoweringOptions().getUnderscoring());
840842
}
841843
std::string mangleName(
842844
const Fortran::semantics::DerivedTypeSpec &derivedType) override final {

flang/lib/Lower/Mangler.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,9 @@ Fortran::lower::mangle::mangleName(std::string &name,
8383
}
8484

8585
// Mangle the name of \p symbol to make it globally unique.
86-
std::string
87-
Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol &symbol,
88-
ScopeBlockIdMap &scopeBlockIdMap,
89-
bool keepExternalInScope) {
86+
std::string Fortran::lower::mangle::mangleName(
87+
const Fortran::semantics::Symbol &symbol, ScopeBlockIdMap &scopeBlockIdMap,
88+
bool keepExternalInScope, bool underscoring) {
9089
// Resolve module and host associations before mangling.
9190
const auto &ultimateSymbol = symbol.GetUltimate();
9291

@@ -167,11 +166,12 @@ Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol &symbol,
167166
symbolName);
168167
},
169168
[&](const Fortran::semantics::CommonBlockDetails &) {
170-
return fir::NameUniquer::doCommonBlock(symbolName);
169+
return Fortran::semantics::GetCommonBlockObjectName(ultimateSymbol,
170+
underscoring);
171171
},
172172
[&](const Fortran::semantics::ProcBindingDetails &procBinding) {
173173
return mangleName(procBinding.symbol(), scopeBlockIdMap,
174-
keepExternalInScope);
174+
keepExternalInScope, underscoring);
175175
},
176176
[&](const Fortran::semantics::DerivedTypeDetails &) -> std::string {
177177
// Derived type mangling must use mangleName(DerivedTypeSpec) so
@@ -186,13 +186,14 @@ Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol &symbol,
186186

187187
std::string
188188
Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol &symbol,
189-
bool keepExternalInScope) {
189+
bool keepExternalInScope,
190+
bool underscoring) {
190191
assert((symbol.owner().kind() !=
191192
Fortran::semantics::Scope::Kind::BlockConstruct ||
192193
symbol.has<Fortran::semantics::SubprogramDetails>()) &&
193194
"block object mangling must specify a scopeBlockIdMap");
194195
ScopeBlockIdMap scopeBlockIdMap;
195-
return mangleName(symbol, scopeBlockIdMap, keepExternalInScope);
196+
return mangleName(symbol, scopeBlockIdMap, keepExternalInScope, underscoring);
196197
}
197198

198199
std::string Fortran::lower::mangle::mangleName(

flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#include "flang/Common/Fortran.h"
910
#include "flang/Optimizer/Dialect/FIRDialect.h"
1011
#include "flang/Optimizer/Dialect/FIROps.h"
1112
#include "flang/Optimizer/Support/InternalNames.h"
@@ -36,7 +37,7 @@ mangleExternalName(const std::pair<fir::NameUniquer::NameKind,
3637
bool appendUnderscore) {
3738
if (result.first == fir::NameUniquer::NameKind::COMMON &&
3839
result.second.name.empty())
39-
return "__BLNK__";
40+
return Fortran::common::blankCommonObjectName;
4041

4142
if (appendUnderscore)
4243
return result.second.name + "_";

flang/lib/Semantics/semantics.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,14 @@ class CommonBlockMap {
212212
void MapCommonBlockAndCheckConflicts(
213213
SemanticsContext &context, const Symbol &common) {
214214
const Symbol *isInitialized{CommonBlockIsInitialized(common)};
215-
auto [it, firstAppearance] = commonBlocks_.insert({common.name(),
215+
// Merge common according to the name they will have in the object files.
216+
// This allows merging BIND(C) and non BIND(C) common block instead of
217+
// later crashing. This "merge" matches what ifort/gfortran/nvfortran are
218+
// doing and what a linker would do if the definition were in distinct
219+
// files.
220+
std::string commonName{
221+
GetCommonBlockObjectName(common, context.underscoring())};
222+
auto [it, firstAppearance] = commonBlocks_.insert({commonName,
216223
isInitialized ? CommonBlockInfo{common, common}
217224
: CommonBlockInfo{common, std::nullopt}});
218225
if (!firstAppearance) {
@@ -291,7 +298,8 @@ class CommonBlockMap {
291298
}
292299
return nullptr;
293300
}
294-
std::map<SourceName, CommonBlockInfo> commonBlocks_;
301+
302+
std::map<std::string, CommonBlockInfo> commonBlocks_;
295303
};
296304

297305
SemanticsContext::SemanticsContext(

flang/lib/Semantics/tools.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,4 +1655,15 @@ std::string GetModuleOrSubmoduleName(const Symbol &symbol) {
16551655
return result;
16561656
}
16571657

1658+
std::string GetCommonBlockObjectName(const Symbol &common, bool underscoring) {
1659+
if (const std::string * bind{common.GetBindName()}) {
1660+
return *bind;
1661+
}
1662+
if (common.name().empty()) {
1663+
return Fortran::common::blankCommonObjectName;
1664+
}
1665+
return underscoring ? common.name().ToString() + "_"s
1666+
: common.name().ToString();
1667+
}
1668+
16581669
} // namespace Fortran::semantics
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
! Test the mixing BIND(C) and non BIND(C) common blocks.
2+
3+
! RUN: %flang_fc1 -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=UNDERSCORING
4+
! RUN: %flang_fc1 -emit-llvm -fno-underscoring %s -o - 2>&1 | FileCheck %s --check-prefix=NO-UNDERSCORING
5+
6+
! Scenario 1: Fortran symbols collide, but not the object file names, emit different
7+
! globals for each common
8+
subroutine bindc_common_with_same_fortran_name()
9+
real :: x
10+
common /com1/ x
11+
bind(c, name="not_com1") :: /com1/
12+
print *, x
13+
end subroutine
14+
15+
subroutine bindc_common_with_same_fortran_name_2()
16+
real :: x(2), y(2)
17+
common /com1/ x
18+
print *, x
19+
end subroutine
20+
21+
! Scenario 2: object file names of common block may collide (depending on
22+
! underscoring option). Merge common block into a single global symbol.
23+
subroutine bindc_common_colliding_with_normal_common()
24+
real :: x, y
25+
common /com3/ x
26+
common /com4/ y
27+
bind(c, name="some_common_") :: /com3/
28+
bind(c, name="__BLNK__") :: /com4/
29+
print *, x, y
30+
end subroutine
31+
subroutine bindc_common_colliding_with_normal_common_2()
32+
real :: x(2), y(2)
33+
common /some_common/ x
34+
common // y
35+
print *, x, y
36+
end subroutine
37+
38+
! UNDERSCORING: @__BLNK__ = common global [8 x i8] zeroinitializer
39+
! UNDERSCORING: @com1_ = common global [8 x i8] zeroinitializer
40+
! UNDERSCORING: @not_com1 = common global [4 x i8] zeroinitializer
41+
! UNDERSCORING: @some_common_ = common global [8 x i8] zeroinitializer
42+
43+
! NO-UNDERSCORING: @__BLNK__ = common global [8 x i8] zeroinitializer
44+
! NO-UNDERSCORING: @com1 = common global [8 x i8] zeroinitializer
45+
! NO-UNDERSCORING: @not_com1 = common global [4 x i8] zeroinitializer
46+
! NO-UNDERSCORING: @some_common = common global [8 x i8] zeroinitializer
47+
! NO-UNDERSCORING: @some_common_ = common global [4 x i8] zeroinitializer

flang/test/Lower/OpenMP/copyin.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ subroutine combined_parallel_sections()
207207

208208

209209
!CHECK: func.func @_QPcommon_1() {
210-
!CHECK: %[[val_0:.*]] = fir.address_of(@_QCc) : !fir.ref<!fir.array<4xi8>>
210+
!CHECK: %[[val_0:.*]] = fir.address_of(@c_) : !fir.ref<!fir.array<4xi8>>
211211
!CHECK: %[[val_1:.*]] = omp.threadprivate %[[val_0]] : !fir.ref<!fir.array<4xi8>> -> !fir.ref<!fir.array<4xi8>>
212212
!CHECK: %[[val_2:.*]] = fir.convert %[[val_1]] : (!fir.ref<!fir.array<4xi8>>) -> !fir.ref<!fir.array<?xi8>>
213213
!CHECK: %[[val_c0:.*]] = arith.constant 0 : index
@@ -258,7 +258,7 @@ subroutine common_1()
258258

259259
!CHECK: func.func @_QPcommon_2() {
260260
!CHECK: %[[val_0:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFcommon_2Ei"}
261-
!CHECK: %[[val_1:.*]] = fir.address_of(@_QCd) : !fir.ref<!fir.array<8xi8>>
261+
!CHECK: %[[val_1:.*]] = fir.address_of(@d_) : !fir.ref<!fir.array<8xi8>>
262262
!CHECK: %[[val_2:.*]] = omp.threadprivate %[[val_1]] : !fir.ref<!fir.array<8xi8>> -> !fir.ref<!fir.array<8xi8>>
263263
!CHECK: %[[val_3:.*]] = fir.convert %[[val_2]] : (!fir.ref<!fir.array<8xi8>>) -> !fir.ref<!fir.array<?xi8>>
264264
!CHECK: %[[val_c0:.*]] = arith.constant 0 : index

flang/test/Lower/OpenMP/declare-target-data.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@ module test_0
5252
end module test_0
5353

5454
PROGRAM commons
55-
!CHECK-DAG: fir.global @_QCnumbers {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>} : tuple<f32, f32> {
55+
!CHECK-DAG: fir.global @numbers_ {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>} : tuple<f32, f32> {
5656
REAL :: one = 1
5757
REAL :: two = 2
5858
COMMON /numbers/ one, two
5959
!$omp declare target(/numbers/)
6060

61-
!CHECK-DAG: fir.global @_QCnumbers_link {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (link)>} : tuple<f32, f32> {
61+
!CHECK-DAG: fir.global @numbers_link_ {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (link)>} : tuple<f32, f32> {
6262
REAL :: one_link = 1
6363
REAL :: two_link = 2
6464
COMMON /numbers_link/ one_link, two_link
6565
!$omp declare target link(/numbers_link/)
6666

67-
!CHECK-DAG: fir.global @_QCnumbers_to {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>} : tuple<f32, f32> {
67+
!CHECK-DAG: fir.global @numbers_to_ {omp.declare_target = #omp.declaretarget<device_type = (any), capture_clause = (to)>} : tuple<f32, f32> {
6868
REAL :: one_to = 1
6969
REAL :: two_to = 2
7070
COMMON /numbers_to/ one_to, two_to

flang/test/Lower/OpenMP/firstprivate-commonblock.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
! RUN: %flang_fc1 -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
22

33
!CHECK: func.func @_QPfirstprivate_common() {
4-
!CHECK: %[[val_0:.*]] = fir.address_of(@_QCc) : !fir.ref<!fir.array<8xi8>>
4+
!CHECK: %[[val_0:.*]] = fir.address_of(@c_) : !fir.ref<!fir.array<8xi8>>
55
!CHECK: %[[val_1:.*]] = fir.convert %[[val_0]] : (!fir.ref<!fir.array<8xi8>>) -> !fir.ref<!fir.array<?xi8>>
66
!CHECK: %[[val_c0:.*]] = arith.constant 0 : index
77
!CHECK: %[[val_2:.*]] = fir.coordinate_of %[[val_1]], %[[val_c0]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>

flang/test/Lower/OpenMP/lastprivate-commonblock.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
!CHECK: func.func @_QPlastprivate_common() {
44
!CHECK: %[[val_0:.*]] = fir.alloca i32 {adapt.valuebyref, pinned}
55
!CHECK: %[[val_1:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFlastprivate_commonEi"}
6-
!CHECK: %[[val_2:.*]] = fir.address_of(@_QCc) : !fir.ref<!fir.array<8xi8>>
6+
!CHECK: %[[val_2:.*]] = fir.address_of(@c_) : !fir.ref<!fir.array<8xi8>>
77
!CHECK: %[[val_3:.*]] = fir.convert %[[val_2]] : (!fir.ref<!fir.array<8xi8>>) -> !fir.ref<!fir.array<?xi8>>
88
!CHECK: %[[val_c0:.*]] = arith.constant 0 : index
99
!CHECK: %[[val_4:.*]] = fir.coordinate_of %[[val_3]], %[[val_c0]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>

flang/test/Lower/OpenMP/private-commonblock.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ subroutine private_common
1515
!$omp end parallel
1616
end subroutine
1717

18-
!CHECK: %[[val_0:.*]] = fir.address_of(@_QCblk) : !fir.ref<!fir.array<74xi8>>
18+
!CHECK: %[[val_0:.*]] = fir.address_of(@blk_) : !fir.ref<!fir.array<74xi8>>
1919
!CHECK: %[[val_1:.*]] = fir.convert %0 : (!fir.ref<!fir.array<74xi8>>) -> !fir.ref<!fir.array<?xi8>>
2020
!CHECK: %[[val_c0:.*]] = arith.constant 0 : index
2121
!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()
7272
end subroutine
7373

7474
!CHECK: func.func @_QPprivate_clause_commonblock_pointer() {
75-
!CHECK: %[[val_0:.*]] = fir.address_of(@_QCblk) : !fir.ref<!fir.array<74xi8>>
75+
!CHECK: %[[val_0:.*]] = fir.address_of(@blk_) : !fir.ref<!fir.array<74xi8>>
7676
!CHECK: %[[val_1:.*]] = fir.convert %[[val_0]] : (!fir.ref<!fir.array<74xi8>>) -> !fir.ref<!fir.array<?xi8>>
7777
!CHECK: %[[val_c24:.*]] = arith.constant 24 : index
7878
!CHECK: %[[val_2:.*]] = fir.coordinate_of %[[val_1]], %[[val_c24]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>

flang/test/Lower/OpenMP/threadprivate-common-block-hlfir.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
!RUN: bbc -hlfir -emit-hlfir -fopenmp %s -o - | FileCheck %s
66

77

8-
!CHECK: %[[CBLK_ADDR:.*]] = fir.address_of(@_QCblk) : !fir.ref<!fir.array<4xi8>>
8+
!CHECK: %[[CBLK_ADDR:.*]] = fir.address_of(@blk_) : !fir.ref<!fir.array<4xi8>>
99
!CHECK: {{.*}} = omp.threadprivate %[[CBLK_ADDR]] : !fir.ref<!fir.array<4xi8>> -> !fir.ref<!fir.array<4xi8>>
1010
!CHECK: omp.parallel {
1111
!CHECK: %[[TP_PARALLEL:.*]] = omp.threadprivate %[[CBLK_ADDR]] : !fir.ref<!fir.array<4xi8>> -> !fir.ref<!fir.array<4xi8>>

flang/test/Lower/OpenMP/threadprivate-commonblock.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ module test
1212

1313
!$omp threadprivate(/blk/)
1414

15-
!CHECK: fir.global common @_QCblk(dense<0> : vector<103xi8>) : !fir.array<103xi8>
15+
!CHECK: fir.global common @blk_(dense<0> : vector<103xi8>) : !fir.array<103xi8>
1616

1717
contains
1818
subroutine sub()
19-
!CHECK: [[ADDR0:%.*]] = fir.address_of(@_QCblk) : !fir.ref<!fir.array<103xi8>>
19+
!CHECK: [[ADDR0:%.*]] = fir.address_of(@blk_) : !fir.ref<!fir.array<103xi8>>
2020
!CHECK: [[NEWADDR0:%.*]] = omp.threadprivate [[ADDR0]] : !fir.ref<!fir.array<103xi8>> -> !fir.ref<!fir.array<103xi8>>
2121
!CHECK-DAG: [[ADDR1:%.*]] = fir.convert [[NEWADDR0]] : (!fir.ref<!fir.array<103xi8>>) -> !fir.ref<!fir.array<?xi8>>
2222
!CHECK-DAG: [[C0:%.*]] = arith.constant 0 : index

flang/test/Lower/OpenMP/threadprivate-use-association.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
!RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s
55

6-
!CHECK-DAG: fir.global common @_QCblk(dense<0> : vector<24xi8>) : !fir.array<24xi8>
6+
!CHECK-DAG: fir.global common @blk_(dense<0> : vector<24xi8>) : !fir.array<24xi8>
77
!CHECK-DAG: fir.global @_QMtestEy : f32 {
88

99
module test
@@ -16,7 +16,7 @@ module test
1616
contains
1717
subroutine sub()
1818
! CHECK-LABEL: @_QMtestPsub
19-
!CHECK-DAG: [[ADDR0:%.*]] = fir.address_of(@_QCblk) : !fir.ref<!fir.array<24xi8>>
19+
!CHECK-DAG: [[ADDR0:%.*]] = fir.address_of(@blk_) : !fir.ref<!fir.array<24xi8>>
2020
!CHECK-DAG: [[NEWADDR0:%.*]] = omp.threadprivate [[ADDR0]] : !fir.ref<!fir.array<24xi8>> -> !fir.ref<!fir.array<24xi8>>
2121
!CHECK-DAG: [[ADDR1:%.*]] = fir.address_of(@_QMtestEy) : !fir.ref<f32>
2222
!CHECK-DAG: [[NEWADDR1:%.*]] = omp.threadprivate [[ADDR1]] : !fir.ref<f32> -> !fir.ref<f32>
@@ -49,9 +49,9 @@ program main
4949
call sub()
5050

5151
! CHECK-LABEL: @_QQmain()
52-
!CHECK-DAG: [[ADDR0:%.*]] = fir.address_of(@_QCblk) : !fir.ref<!fir.array<24xi8>>
52+
!CHECK-DAG: [[ADDR0:%.*]] = fir.address_of(@blk_) : !fir.ref<!fir.array<24xi8>>
5353
!CHECK-DAG: [[NEWADDR0:%.*]] = omp.threadprivate [[ADDR0]] : !fir.ref<!fir.array<24xi8>> -> !fir.ref<!fir.array<24xi8>>
54-
!CHECK-DAG: [[ADDR1:%.*]] = fir.address_of(@_QCblk) : !fir.ref<!fir.array<24xi8>>
54+
!CHECK-DAG: [[ADDR1:%.*]] = fir.address_of(@blk_) : !fir.ref<!fir.array<24xi8>>
5555
!CHECK-DAG: [[NEWADDR1:%.*]] = omp.threadprivate [[ADDR1]] : !fir.ref<!fir.array<24xi8>> -> !fir.ref<!fir.array<24xi8>>
5656
!CHECK-DAG: [[ADDR2:%.*]] = fir.address_of(@_QMtestEy) : !fir.ref<f32>
5757
!CHECK-DAG: [[NEWADDR2:%.*]] = omp.threadprivate [[ADDR2]] : !fir.ref<f32> -> !fir.ref<f32>

flang/test/Lower/array.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
! RUN: bbc -o - %s | FileCheck %s
22

3-
! CHECK-LABEL: fir.global @_QCblock
3+
! CHECK-LABEL: fir.global @block_
44
! CHECK-DAG: %[[VAL_1:.*]] = arith.constant 1.000000e+00 : f32
55
! CHECK-DAG: %[[VAL_2:.*]] = arith.constant 2.400000e+00 : f32
66
! CHECK-DAG: %[[VAL_3:.*]] = arith.constant 0.000000e+00 : f32

0 commit comments

Comments
 (0)