Skip to content

Commit 8d161cb

Browse files
committed
Fix remaining build failures with GCC 8.3
When compiling for GCC 8.x (< 8.4), SFINAE is disabled for iterator_range constructor causing ambiguous resolution to construct an OperandRange from a MutableOperatorRange, even in the presence of a static_cast<OperatorRange>. This adds an explicit conversion method to lift the ambiguity. Tested with a full MLIR build with GCC 8.3.
1 parent 1d2eced commit 8d161cb

File tree

6 files changed

+14
-7
lines changed

6 files changed

+14
-7
lines changed

mlir/include/mlir/IR/ValueRange.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ class MutableOperandRange {
155155
/// Returns if the current range is empty.
156156
bool empty() const { return size() == 0; }
157157

158+
/// Explicit conversion to an OperandRange.
159+
OperandRange getAsOperandRange() const;
160+
158161
/// Allow implicit conversion to an OperandRange.
159162
operator OperandRange() const;
160163

mlir/lib/Dialect/Bufferization/Transforms/OwnershipBasedBufferDeallocation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,13 +956,13 @@ BufferDeallocation::handleInterface(RegionBranchTerminatorOpInterface op) {
956956

957957
SmallVector<Value> updatedOwnerships;
958958
auto result = deallocation_impl::insertDeallocOpForReturnLike(
959-
state, op, OperandRange(operands), updatedOwnerships);
959+
state, op, operands.getAsOperandRange(), updatedOwnerships);
960960
if (failed(result) || !*result)
961961
return result;
962962

963963
// Add an additional operand for every MemRef for the ownership indicator.
964964
if (!funcWithoutDynamicOwnership) {
965-
SmallVector<Value> newOperands{OperandRange(operands)};
965+
SmallVector<Value> newOperands{operands.getAsOperandRange()};
966966
newOperands.append(updatedOwnerships.begin(), updatedOwnerships.end());
967967
operands.assign(newOperands);
968968
}

mlir/lib/Dialect/ControlFlow/Transforms/BufferDeallocationOpInterfaceImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ struct CondBranchOpInterface
8484
DenseMap<Value, Value> &mapping) -> DeallocOp {
8585
SmallVector<Value> toRetain;
8686
state.getMemrefsToRetain(condBr->getBlock(), target,
87-
OperandRange(destOperands), toRetain);
87+
destOperands.getAsOperandRange(), toRetain);
8888
SmallVector<Value> adaptedConditions(
8989
llvm::map_range(conditions, conditionModifier));
9090
auto deallocOp = builder.create<bufferization::DeallocOp>(

mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static LinalgOp fuse(OpBuilder &b, LinalgOp producer,
149149
SmallVector<Type, 4> resultTypes;
150150
resultTypes.reserve(producer->getNumResults());
151151
int64_t firstInitOperandIdx =
152-
static_cast<OperandRange>(producerDpsInits).getBeginOperandIndex();
152+
producerDpsInits.getAsOperandRange().getBeginOperandIndex();
153153
for (int64_t i = 0, e = producer->getNumResults(); i < e; ++i) {
154154
resultTypes.push_back(clonedShapes[firstInitOperandIdx + i].getType());
155155
}

mlir/lib/IR/OperationSupport.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,9 +497,14 @@ void MutableOperandRange::clear() {
497497
}
498498
}
499499

500+
/// Explicit conversion to an OperandRange.
501+
OperandRange MutableOperandRange::getAsOperandRange() const {
502+
return owner->getOperands().slice(start, length);
503+
}
504+
500505
/// Allow implicit conversion to an OperandRange.
501506
MutableOperandRange::operator OperandRange() const {
502-
return owner->getOperands().slice(start, length);
507+
return getAsOperandRange();
503508
}
504509

505510
MutableOperandRange::operator MutableArrayRef<OpOperand>() const {

mlir/lib/Transforms/Utils/CFGToSCF.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,8 +1183,7 @@ static FailureOr<SmallVector<Block *>> transformToStructuredCFBranches(
11831183
auto builder = OpBuilder::atBlockTerminator(user->getBlock());
11841184
LogicalResult result = interface.createStructuredBranchRegionTerminatorOp(
11851185
user->getLoc(), builder, structuredCondOp, user,
1186-
static_cast<OperandRange>(
1187-
getMutableSuccessorOperands(user->getBlock(), 0)));
1186+
getMutableSuccessorOperands(user->getBlock(), 0).getAsOperandRange());
11881187
if (failed(result))
11891188
return failure();
11901189
user->erase();

0 commit comments

Comments
 (0)