diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 18:31:57 +0900 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 18:33:27 +0900 |
commit | df025ebf872052c0761d44a3ef9b65e9675af8a8 (patch) | |
tree | 9b4e94583e2536546d6606270bcdf846c95e1ba2 /flang/lib/Lower/Allocatable.cpp | |
parent | 4428c9d0b1344179f85a72e183a44796976521e3 (diff) | |
parent | bdcf47e4bcb92889665825654bb80a8bbe30379e (diff) | |
download | llvm-users/chapuni/cov/single/loop.zip llvm-users/chapuni/cov/single/loop.tar.gz llvm-users/chapuni/cov/single/loop.tar.bz2 |
Merge branch 'users/chapuni/cov/single/base' into users/chapuni/cov/single/loopusers/chapuni/cov/single/loop
Conflicts:
clang/lib/CodeGen/CoverageMappingGen.cpp
Diffstat (limited to 'flang/lib/Lower/Allocatable.cpp')
-rw-r--r-- | flang/lib/Lower/Allocatable.cpp | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/flang/lib/Lower/Allocatable.cpp b/flang/lib/Lower/Allocatable.cpp index fb8380a..dc13554 100644 --- a/flang/lib/Lower/Allocatable.cpp +++ b/flang/lib/Lower/Allocatable.cpp @@ -22,12 +22,14 @@ #include "flang/Lower/PFTBuilder.h" #include "flang/Lower/Runtime.h" #include "flang/Lower/StatementContext.h" +#include "flang/Optimizer/Builder/CUFCommon.h" #include "flang/Optimizer/Builder/FIRBuilder.h" #include "flang/Optimizer/Builder/Runtime/RTBuilder.h" #include "flang/Optimizer/Builder/Todo.h" #include "flang/Optimizer/Dialect/CUF/CUFOps.h" #include "flang/Optimizer/Dialect/FIROps.h" #include "flang/Optimizer/Dialect/FIROpsSupport.h" +#include "flang/Optimizer/HLFIR/HLFIROps.h" #include "flang/Optimizer/Support/FatalError.h" #include "flang/Optimizer/Support/InternalNames.h" #include "flang/Parser/parse-tree.h" @@ -452,6 +454,19 @@ private: alloc.getSymbol()); } + void setPinnedToFalse() { + if (!pinnedExpr) + return; + Fortran::lower::StatementContext stmtCtx; + mlir::Value pinned = + fir::getBase(converter.genExprAddr(loc, *pinnedExpr, stmtCtx)); + mlir::Location loc = pinned.getLoc(); + mlir::Value falseValue = builder.createBool(loc, false); + mlir::Value falseConv = builder.createConvert( + loc, fir::unwrapRefType(pinned.getType()), falseValue); + builder.create<fir::StoreOp>(loc, falseConv, pinned); + } + void genSimpleAllocation(const Allocation &alloc, const fir::MutableBoxValue &box) { bool isCudaSymbol = Fortran::semantics::HasCUDAAttr(alloc.getSymbol()); @@ -467,6 +482,7 @@ private: // can be validated. genInlinedAllocation(alloc, box); postAllocationAction(alloc); + setPinnedToFalse(); return; } @@ -480,11 +496,13 @@ private: genSetDeferredLengthParameters(alloc, box); genAllocateObjectBounds(alloc, box); mlir::Value stat; - if (!isCudaSymbol) + if (!isCudaSymbol) { stat = genRuntimeAllocate(builder, loc, box, errorManager); - else + setPinnedToFalse(); + } else { stat = genCudaAllocate(builder, loc, box, errorManager, alloc.getSymbol()); + } fir::factory::syncMutableBoxFromIRBox(builder, loc, box); postAllocationAction(alloc); errorManager.assignStat(builder, loc, stat); @@ -614,13 +632,16 @@ private: genSetDeferredLengthParameters(alloc, box); genAllocateObjectBounds(alloc, box); mlir::Value stat; - if (Fortran::semantics::HasCUDAAttr(alloc.getSymbol())) + if (Fortran::semantics::HasCUDAAttr(alloc.getSymbol())) { stat = genCudaAllocate(builder, loc, box, errorManager, alloc.getSymbol()); - else if (isSource) - stat = genRuntimeAllocateSource(builder, loc, box, exv, errorManager); - else - stat = genRuntimeAllocate(builder, loc, box, errorManager); + } else { + if (isSource) + stat = genRuntimeAllocateSource(builder, loc, box, exv, errorManager); + else + stat = genRuntimeAllocate(builder, loc, box, errorManager); + setPinnedToFalse(); + } fir::factory::syncMutableBoxFromIRBox(builder, loc, box); postAllocationAction(alloc); errorManager.assignStat(builder, loc, stat); @@ -1093,11 +1114,13 @@ void Fortran::lower::associateMutableBox( fir::FirOpBuilder &builder = converter.getFirOpBuilder(); if (Fortran::evaluate::UnwrapExpr<Fortran::evaluate::NullPointer>(source)) { fir::factory::disassociateMutableBox(builder, loc, box); + cuf::genPointerSync(box.getAddr(), builder); return; } if (converter.getLoweringOptions().getLowerToHighLevelFIR()) { fir::ExtendedValue rhs = converter.genExprAddr(loc, source, stmtCtx); fir::factory::associateMutableBox(builder, loc, box, rhs, lbounds); + cuf::genPointerSync(box.getAddr(), builder); return; } // The right hand side is not be evaluated into a temp. Array sections can |