Skip to content

Commit 0b442bc

Browse files
authored
[flang][NFC] Added debug output to opt-bufferization pass. (#119936)
1 parent a9237b1 commit 0b442bc

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

flang/lib/Optimizer/HLFIR/Transforms/OptimizedBufferization.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,15 +463,19 @@ ElementalAssignBufferization::findMatch(hlfir::ElementalOp elemental) {
463463
match.array = match.assign.getLhs();
464464
mlir::Type arrayType = mlir::dyn_cast<fir::SequenceType>(
465465
fir::unwrapPassByRefType(match.array.getType()));
466-
if (!arrayType)
466+
if (!arrayType) {
467+
LLVM_DEBUG(llvm::dbgs() << "AssignOp's result is not an array\n");
467468
return std::nullopt;
469+
}
468470

469471
// require that the array elements are trivial
470472
// TODO: this is just to make the pass easier to think about. Not an inherent
471473
// limitation
472474
mlir::Type eleTy = hlfir::getFortranElementType(arrayType);
473-
if (!fir::isa_trivial(eleTy))
475+
if (!fir::isa_trivial(eleTy)) {
476+
LLVM_DEBUG(llvm::dbgs() << "AssignOp's data type is not trivial\n");
474477
return std::nullopt;
478+
}
475479

476480
// The array must have the same shape as the elemental.
477481
//
@@ -485,8 +489,10 @@ ElementalAssignBufferization::findMatch(hlfir::ElementalOp elemental) {
485489
// there is no reallocation of the lhs due to the assignment.
486490
// We can probably try generating multiple versions of the code
487491
// with checking for the shape match, length parameters match, etc.
488-
if (match.assign.getRealloc())
492+
if (match.assign.isAllocatableAssignment()) {
493+
LLVM_DEBUG(llvm::dbgs() << "AssignOp may involve (re)allocation of LHS\n");
489494
return std::nullopt;
495+
}
490496

491497
// the transformation wants to apply the elemental in a do-loop at the
492498
// hlfir.assign, check there are no effects which make this unsafe

0 commit comments

Comments
 (0)