Skip to content

Commit 9eef8ba

Browse files
committed
rebase
Created using spr 1.3.4
2 parents 41e282f + f1a2f6d commit 9eef8ba

File tree

36 files changed

+761
-363
lines changed

36 files changed

+761
-363
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ jobs:
205205
steps.docs-changed-subprojects.outputs.workflow_any_changed == 'true'
206206
run: |
207207
cmake -B flang-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;mlir;flang" -DLLVM_ENABLE_SPHINX=ON ./llvm
208-
TZ=UTC ninja -C flang-build docs-flang-html
208+
TZ=UTC ninja -C flang-build docs-flang-html docs-flang-man
209209
mkdir built-docs/flang
210210
cp -r flang-build/docs/* built-docs/flang/
211211
- name: Upload docs

flang/lib/Lower/OpenMP/PrivateReductionUtils.h renamed to flang/include/flang/Lower/Support/PrivateReductionUtils.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ namespace Fortran {
3535
namespace lower {
3636
class AbstractConverter;
3737

38-
namespace omp {
39-
40-
enum class DeclOperationKind { Private, FirstPrivate, Reduction };
38+
enum class DeclOperationKind {
39+
PrivateOrLocal,
40+
FirstPrivateOrLocalInit,
41+
Reduction
42+
};
4143
inline bool isPrivatization(DeclOperationKind kind) {
42-
return (kind == DeclOperationKind::FirstPrivate) ||
43-
(kind == DeclOperationKind::Private);
44+
return (kind == DeclOperationKind::FirstPrivateOrLocalInit) ||
45+
(kind == DeclOperationKind::PrivateOrLocal);
4446
}
4547
inline bool isReduction(DeclOperationKind kind) {
4648
return kind == DeclOperationKind::Reduction;
@@ -56,7 +58,7 @@ void populateByRefInitAndCleanupRegions(
5658
mlir::Value allocatedPrivVarArg, mlir::Value moldArg,
5759
mlir::Region &cleanupRegion, DeclOperationKind kind,
5860
const Fortran::semantics::Symbol *sym = nullptr,
59-
bool cannotHaveNonDefaultLowerBounds = false);
61+
bool cannotHaveNonDefaultLowerBounds = false, bool isDoConcurrent = false);
6062

6163
/// Generate a fir::ShapeShift op describing the provided boxed array.
6264
/// `cannotHaveNonDefaultLowerBounds` should be set if `box` is known to have
@@ -69,7 +71,6 @@ fir::ShapeShiftOp getShapeShift(fir::FirOpBuilder &builder, mlir::Location loc,
6971
bool cannotHaveNonDefaultLowerBounds = false,
7072
bool useDefaultLowerBounds = false);
7173

72-
} // namespace omp
7374
} // namespace lower
7475
} // namespace Fortran
7576

flang/include/flang/Lower/Support/Utils.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "mlir/Dialect/Arith/IR/Arith.h"
2121
#include "mlir/Dialect/Func/IR/FuncOps.h"
2222
#include "mlir/IR/BuiltinAttributes.h"
23+
#include "llvm/ADT/SmallSet.h"
2324
#include "llvm/ADT/StringRef.h"
2425

2526
namespace Fortran::lower {
@@ -98,8 +99,9 @@ bool isEqual(const Fortran::lower::ExplicitIterSpace::ArrayBases &x,
9899
template <typename OpType, typename OperandsStructType>
99100
void privatizeSymbol(
100101
lower::AbstractConverter &converter, fir::FirOpBuilder &firOpBuilder,
101-
lower::SymMap &symTable, std::function<void(OpType, mlir::Type)> initGen,
102+
lower::SymMap &symTable,
102103
llvm::SetVector<const semantics::Symbol *> &allPrivatizedSymbols,
104+
llvm::SmallSet<const semantics::Symbol *, 16> &mightHaveReadHostSym,
103105
const semantics::Symbol *symToPrivatize, OperandsStructType *clauseOps);
104106

105107
} // end namespace Fortran::lower

flang/lib/Lower/Bridge.cpp

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#include "flang/Lower/Bridge.h"
1414

15-
#include "OpenMP/DataSharingProcessor.h"
1615
#include "flang/Lower/Allocatable.h"
1716
#include "flang/Lower/CallInterface.h"
1817
#include "flang/Lower/Coarray.h"
@@ -2040,44 +2039,38 @@ class FirConverter : public Fortran::lower::AbstractConverter {
20402039
bool useDelayedPriv =
20412040
enableDelayedPrivatizationStaging && doConcurrentLoopOp;
20422041
llvm::SetVector<const Fortran::semantics::Symbol *> allPrivatizedSymbols;
2042+
llvm::SmallSet<const Fortran::semantics::Symbol *, 16> mightHaveReadHostSym;
20432043

2044-
for (const Fortran::semantics::Symbol *sym : info.localSymList) {
2044+
for (const Fortran::semantics::Symbol *symToPrivatize : info.localSymList) {
20452045
if (useDelayedPriv) {
20462046
Fortran::lower::privatizeSymbol<fir::LocalitySpecifierOp>(
2047-
*this, this->getFirOpBuilder(), localSymbols,
2048-
[this](fir::LocalitySpecifierOp result, mlir::Type argType) {
2049-
TODO(this->toLocation(),
2050-
"Localizers that need init regions are not supported yet.");
2051-
},
2052-
allPrivatizedSymbols, sym, &privateClauseOps);
2047+
*this, this->getFirOpBuilder(), localSymbols, allPrivatizedSymbols,
2048+
mightHaveReadHostSym, symToPrivatize, &privateClauseOps);
20532049
continue;
20542050
}
20552051

2056-
createHostAssociateVarClone(*sym, /*skipDefaultInit=*/false);
2052+
createHostAssociateVarClone(*symToPrivatize, /*skipDefaultInit=*/false);
20572053
}
20582054

2059-
for (const Fortran::semantics::Symbol *sym : info.localInitSymList) {
2055+
for (const Fortran::semantics::Symbol *symToPrivatize :
2056+
info.localInitSymList) {
20602057
if (useDelayedPriv) {
20612058
Fortran::lower::privatizeSymbol<fir::LocalitySpecifierOp>(
2062-
*this, this->getFirOpBuilder(), localSymbols,
2063-
[this](fir::LocalitySpecifierOp result, mlir::Type argType) {
2064-
TODO(this->toLocation(),
2065-
"Localizers that need init regions are not supported yet.");
2066-
},
2067-
allPrivatizedSymbols, sym, &privateClauseOps);
2059+
*this, this->getFirOpBuilder(), localSymbols, allPrivatizedSymbols,
2060+
mightHaveReadHostSym, symToPrivatize, &privateClauseOps);
20682061
continue;
20692062
}
20702063

2071-
createHostAssociateVarClone(*sym, /*skipDefaultInit=*/true);
2064+
createHostAssociateVarClone(*symToPrivatize, /*skipDefaultInit=*/true);
20722065
const auto *hostDetails =
2073-
sym->detailsIf<Fortran::semantics::HostAssocDetails>();
2066+
symToPrivatize->detailsIf<Fortran::semantics::HostAssocDetails>();
20742067
assert(hostDetails && "missing locality spec host symbol");
20752068
const Fortran::semantics::Symbol *hostSym = &hostDetails->symbol();
20762069
Fortran::evaluate::ExpressionAnalyzer ea{semanticsContext};
20772070
Fortran::evaluate::Assignment assign{
2078-
ea.Designate(Fortran::evaluate::DataRef{*sym}).value(),
2071+
ea.Designate(Fortran::evaluate::DataRef{*symToPrivatize}).value(),
20792072
ea.Designate(Fortran::evaluate::DataRef{*hostSym}).value()};
2080-
if (Fortran::semantics::IsPointer(*sym))
2073+
if (Fortran::semantics::IsPointer(*symToPrivatize))
20812074
assign.u = Fortran::evaluate::Assignment::BoundsSpec{};
20822075
genAssignment(assign);
20832076
}

flang/lib/Lower/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ add_flang_library(FortranLower
2828
OpenMP/DataSharingProcessor.cpp
2929
OpenMP/Decomposer.cpp
3030
OpenMP/OpenMP.cpp
31-
OpenMP/PrivateReductionUtils.cpp
3231
OpenMP/ReductionProcessor.cpp
3332
OpenMP/Utils.cpp
3433
PFTBuilder.cpp
3534
Runtime.cpp
35+
Support/PrivateReductionUtils.cpp
3636
Support/Utils.cpp
3737
SymbolMap.cpp
3838
VectorSubscripts.cpp

flang/lib/Lower/OpenMP/DataSharingProcessor.cpp

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212

1313
#include "DataSharingProcessor.h"
1414

15-
#include "PrivateReductionUtils.h"
1615
#include "Utils.h"
1716
#include "flang/Lower/ConvertVariable.h"
1817
#include "flang/Lower/PFTBuilder.h"
18+
#include "flang/Lower/Support/PrivateReductionUtils.h"
1919
#include "flang/Lower/Support/Utils.h"
2020
#include "flang/Lower/SymbolMap.h"
2121
#include "flang/Optimizer/Builder/BoxValue.h"
@@ -537,38 +537,10 @@ void DataSharingProcessor::privatizeSymbol(
537537
return;
538538
}
539539

540-
auto initGen = [&](mlir::omp::PrivateClauseOp result, mlir::Type argType) {
541-
lower::SymbolBox hsb = converter.lookupOneLevelUpSymbol(*symToPrivatize);
542-
assert(hsb && "Host symbol box not found");
543-
hlfir::Entity entity{hsb.getAddr()};
544-
bool cannotHaveNonDefaultLowerBounds =
545-
!entity.mayHaveNonDefaultLowerBounds();
546-
547-
mlir::Region &initRegion = result.getInitRegion();
548-
mlir::Location symLoc = hsb.getAddr().getLoc();
549-
mlir::Block *initBlock = firOpBuilder.createBlock(
550-
&initRegion, /*insertPt=*/{}, {argType, argType}, {symLoc, symLoc});
551-
552-
bool emitCopyRegion =
553-
symToPrivatize->test(semantics::Symbol::Flag::OmpFirstPrivate);
554-
555-
populateByRefInitAndCleanupRegions(
556-
converter, symLoc, argType, /*scalarInitValue=*/nullptr, initBlock,
557-
result.getInitPrivateArg(), result.getInitMoldArg(),
558-
result.getDeallocRegion(),
559-
emitCopyRegion ? omp::DeclOperationKind::FirstPrivate
560-
: omp::DeclOperationKind::Private,
561-
symToPrivatize, cannotHaveNonDefaultLowerBounds);
562-
// TODO: currently there are false positives from dead uses of the mold
563-
// arg
564-
if (result.initReadsFromMold())
565-
mightHaveReadHostSym.insert(symToPrivatize);
566-
};
567-
568540
Fortran::lower::privatizeSymbol<mlir::omp::PrivateClauseOp,
569541
mlir::omp::PrivateClauseOps>(
570-
converter, firOpBuilder, symTable, initGen, allPrivatizedSymbols,
571-
symToPrivatize, clauseOps);
542+
converter, firOpBuilder, symTable, allPrivatizedSymbols,
543+
mightHaveReadHostSym, symToPrivatize, clauseOps);
572544
}
573545
} // namespace omp
574546
} // namespace lower

flang/lib/Lower/OpenMP/ReductionProcessor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
#include "ReductionProcessor.h"
1414

15-
#include "PrivateReductionUtils.h"
1615
#include "flang/Lower/AbstractConverter.h"
1716
#include "flang/Lower/ConvertType.h"
17+
#include "flang/Lower/Support/PrivateReductionUtils.h"
1818
#include "flang/Lower/SymbolMap.h"
1919
#include "flang/Optimizer/Builder/Complex.h"
2020
#include "flang/Optimizer/Builder/HLFIRTools.h"

0 commit comments

Comments
 (0)