summaryrefslogtreecommitdiff
path: root/flang/lib/Optimizer/Transforms/StackArrays.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2024-10-11 21:39:06 -0700
committerAmir Ayupov <aaupov@fb.com>2024-10-11 21:39:06 -0700
commit436701d88c1384d3f72c44dd152cd55e47ef2de3 (patch)
treec9825a370f1ba14e5fff19cea1279a0e7a7e9b54 /flang/lib/Optimizer/Transforms/StackArrays.cpp
parentefa1900174cb940f3750ce9e8cb6f06e69b4f3f0 (diff)
parentdd326b122506421aba2368053103767f4c56e2ba (diff)
[𝘀𝗽𝗿] changes introduced through rebaseusers/aaupov/spr/main.boltnfc-speedup-batwritemaps
Created using spr 1.3.4 [skip ci]
Diffstat (limited to 'flang/lib/Optimizer/Transforms/StackArrays.cpp')
-rw-r--r--flang/lib/Optimizer/Transforms/StackArrays.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/flang/lib/Optimizer/Transforms/StackArrays.cpp b/flang/lib/Optimizer/Transforms/StackArrays.cpp
index d9e7bd684d46..0c474f463f09 100644
--- a/flang/lib/Optimizer/Transforms/StackArrays.cpp
+++ b/flang/lib/Optimizer/Transforms/StackArrays.cpp
@@ -375,7 +375,7 @@ mlir::LogicalResult AllocationAnalysis::visitOperation(
}
} else if (mlir::isa<fir::ResultOp>(op)) {
mlir::Operation *parent = op->getParentOp();
- LatticePoint *parentLattice = getLattice(parent);
+ LatticePoint *parentLattice = getLattice(getProgramPointAfter(parent));
assert(parentLattice);
mlir::ChangeResult parentChanged = parentLattice->join(*after);
propagateIfChanged(parentLattice, parentChanged);
@@ -396,28 +396,29 @@ void AllocationAnalysis::setToEntryState(LatticePoint *lattice) {
/// Mostly a copy of AbstractDenseLattice::processOperation - the difference
/// being that call operations are passed through to the transfer function
mlir::LogicalResult AllocationAnalysis::processOperation(mlir::Operation *op) {
+ mlir::ProgramPoint *point = getProgramPointAfter(op);
// If the containing block is not executable, bail out.
- if (!getOrCreateFor<mlir::dataflow::Executable>(op, op->getBlock())->isLive())
+ if (op->getBlock() != nullptr &&
+ !getOrCreateFor<mlir::dataflow::Executable>(
+ point, getProgramPointBefore(op->getBlock()))
+ ->isLive())
return mlir::success();
// Get the dense lattice to update
- mlir::dataflow::AbstractDenseLattice *after = getLattice(op);
+ mlir::dataflow::AbstractDenseLattice *after = getLattice(point);
// If this op implements region control-flow, then control-flow dictates its
// transfer function.
if (auto branch = mlir::dyn_cast<mlir::RegionBranchOpInterface>(op)) {
- visitRegionBranchOperation(op, branch, after);
+ visitRegionBranchOperation(point, branch, after);
return mlir::success();
}
// pass call operations through to the transfer function
// Get the dense state before the execution of the op.
- const mlir::dataflow::AbstractDenseLattice *before;
- if (mlir::Operation *prev = op->getPrevNode())
- before = getLatticeFor(op, prev);
- else
- before = getLatticeFor(op, op->getBlock());
+ const mlir::dataflow::AbstractDenseLattice *before =
+ getLatticeFor(point, getProgramPointBefore(op));
/// Invoke the operation transfer function
return visitOperationImpl(op, *before, after);
@@ -452,9 +453,10 @@ StackArraysAnalysisWrapper::analyseFunction(mlir::Operation *func) {
return mlir::failure();
}
- LatticePoint point{func};
+ LatticePoint point{solver.getProgramPointAfter(func)};
auto joinOperationLattice = [&](mlir::Operation *op) {
- const LatticePoint *lattice = solver.lookupState<LatticePoint>(op);
+ const LatticePoint *lattice =
+ solver.lookupState<LatticePoint>(solver.getProgramPointAfter(op));
// there will be no lattice for an unreachable block
if (lattice)
(void)point.join(*lattice);