diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 17:50:40 +0900 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 17:50:40 +0900 |
commit | fea7da1b00cc97d742faede2df96c7d327950f49 (patch) | |
tree | 4de1d6b4ddc69f4f32daabb11ad5c71ab0cf895e /flang/lib/Lower/Bridge.cpp | |
parent | 9b99dde0d47102625d93c5d1cbbc04951025a6c9 (diff) | |
parent | 0aa930a41f2d1ebf1fa90ec42da8f96d15a4dcbb (diff) | |
download | llvm-users/chapuni/cov/single/nextcount.zip llvm-users/chapuni/cov/single/nextcount.tar.gz llvm-users/chapuni/cov/single/nextcount.tar.bz2 |
Merge branch 'users/chapuni/cov/single/nextcount-base' into users/chapuni/cov/single/nextcountusers/chapuni/cov/single/nextcount
Diffstat (limited to 'flang/lib/Lower/Bridge.cpp')
-rw-r--r-- | flang/lib/Lower/Bridge.cpp | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp index 17b794d1..37f51d7 100644 --- a/flang/lib/Lower/Bridge.cpp +++ b/flang/lib/Lower/Bridge.cpp @@ -34,6 +34,7 @@ #include "flang/Lower/StatementContext.h" #include "flang/Lower/Support/Utils.h" #include "flang/Optimizer/Builder/BoxValue.h" +#include "flang/Optimizer/Builder/CUFCommon.h" #include "flang/Optimizer/Builder/Character.h" #include "flang/Optimizer/Builder/FIRBuilder.h" #include "flang/Optimizer/Builder/Runtime/Assign.h" @@ -832,7 +833,11 @@ public: if_builder.end(); }, [&](const auto &) -> void { - if (skipDefaultInit) + // Always initialize allocatable component descriptor, even when the + // value is later copied from the host (e.g. firstprivate) because the + // assignment from the host to the copy will fail if the component + // descriptors are not initialized. + if (skipDefaultInit && !hlfir::mayHaveAllocatableComponent(hSymType)) return; // Initialize local/private derived types with default // initialization (Fortran 2023 section 11.1.7.5 and OpenMP 5.2 @@ -1028,7 +1033,7 @@ public: fir::FirOpBuilder &getFirOpBuilder() override final { return *builder; } - mlir::ModuleOp &getModuleOp() override final { return bridge.getModule(); } + mlir::ModuleOp getModuleOp() override final { return bridge.getModule(); } mlir::MLIRContext &getMLIRContext() override final { return bridge.getMLIRContext(); @@ -3952,6 +3957,7 @@ private: } else { fir::MutableBoxValue box = genExprMutableBox(loc, *expr); fir::factory::disassociateMutableBox(*builder, loc, box); + cuf::genPointerSync(box.getAddr(), *builder); } } } @@ -6137,10 +6143,7 @@ void Fortran::lower::LoweringBridge::lower( } void Fortran::lower::LoweringBridge::parseSourceFile(llvm::SourceMgr &srcMgr) { - mlir::OwningOpRef<mlir::ModuleOp> owningRef = - mlir::parseSourceFile<mlir::ModuleOp>(srcMgr, &context); - module.reset(new mlir::ModuleOp(owningRef.get().getOperation())); - owningRef.release(); + module = mlir::parseSourceFile<mlir::ModuleOp>(srcMgr, &context); } Fortran::lower::LoweringBridge::LoweringBridge( @@ -6207,19 +6210,18 @@ Fortran::lower::LoweringBridge::LoweringBridge( }; // Create the module and attach the attributes. - module = std::make_unique<mlir::ModuleOp>( + module = mlir::OwningOpRef<mlir::ModuleOp>( mlir::ModuleOp::create(getPathLocation())); - assert(module.get() && "module was not created"); - fir::setTargetTriple(*module.get(), triple); - fir::setKindMapping(*module.get(), kindMap); - fir::setTargetCPU(*module.get(), targetMachine.getTargetCPU()); - fir::setTuneCPU(*module.get(), targetOpts.cpuToTuneFor); - fir::setTargetFeatures(*module.get(), targetMachine.getTargetFeatureString()); - fir::support::setMLIRDataLayout(*module.get(), - targetMachine.createDataLayout()); - fir::setIdent(*module.get(), Fortran::common::getFlangFullVersion()); + assert(*module && "module was not created"); + fir::setTargetTriple(*module, triple); + fir::setKindMapping(*module, kindMap); + fir::setTargetCPU(*module, targetMachine.getTargetCPU()); + fir::setTuneCPU(*module, targetOpts.cpuToTuneFor); + fir::setTargetFeatures(*module, targetMachine.getTargetFeatureString()); + fir::support::setMLIRDataLayout(*module, targetMachine.createDataLayout()); + fir::setIdent(*module, Fortran::common::getFlangFullVersion()); if (cgOpts.RecordCommandLine) - fir::setCommandline(*module.get(), *cgOpts.RecordCommandLine); + fir::setCommandline(*module, *cgOpts.RecordCommandLine); } void Fortran::lower::genCleanUpInRegionIfAny( |