Skip to content

Commit d99cf1b

Browse files
authored
[flang] lower assumed-rank inquiries - part 1 (#94475)
Lower assumed-rank inquiries, except SIZE/SHAPE/UBOUND/LBOUND. This is mainly about adding tests, and removing a couple TODOs in helpers.
1 parent e675d0d commit d99cf1b

File tree

3 files changed

+386
-7
lines changed

3 files changed

+386
-7
lines changed

flang/lib/Optimizer/Builder/IntrinsicCall.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4965,10 +4965,6 @@ fir::ExtendedValue
49654965
IntrinsicLibrary::genIsContiguous(mlir::Type resultType,
49664966
llvm::ArrayRef<fir::ExtendedValue> args) {
49674967
assert(args.size() == 1);
4968-
if (const auto *boxValue = args[0].getBoxOf<fir::BoxValue>())
4969-
if (boxValue->hasAssumedRank())
4970-
TODO(loc, "intrinsic: is_contiguous with assumed rank argument");
4971-
49724968
return builder.createConvert(
49734969
loc, resultType,
49744970
fir::runtime::genIsContiguous(builder, loc, fir::getBase(args[0])));

flang/lib/Optimizer/Builder/MutableBox.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ static bool readToBoxValue(const fir::MutableBoxValue &box,
394394
// Track value as fir.box
395395
if ((box.isDerived() && mayBePolymorphic) || box.isUnlimitedPolymorphic())
396396
return true;
397+
if (box.hasAssumedRank())
398+
return true;
397399
// Intrinsic allocatables are contiguous, no need to track the value by
398400
// fir.box.
399401
if (box.isAllocatable() || box.rank() == 0)
@@ -409,14 +411,12 @@ fir::factory::genMutableBoxRead(fir::FirOpBuilder &builder, mlir::Location loc,
409411
const fir::MutableBoxValue &box,
410412
bool mayBePolymorphic,
411413
bool preserveLowerBounds) {
412-
if (box.hasAssumedRank())
413-
TODO(loc, "assumed rank allocatables or pointers");
414414
llvm::SmallVector<mlir::Value> lbounds;
415415
llvm::SmallVector<mlir::Value> extents;
416416
llvm::SmallVector<mlir::Value> lengths;
417417
if (readToBoxValue(box, mayBePolymorphic)) {
418418
auto reader = MutablePropertyReader(builder, loc, box);
419-
if (preserveLowerBounds)
419+
if (preserveLowerBounds && !box.hasAssumedRank())
420420
reader.getLowerBounds(lbounds);
421421
return fir::BoxValue{reader.getIrBox(), lbounds,
422422
box.nonDeferredLenParams()};

0 commit comments

Comments
 (0)