Skip to content

Commit 1f74f5f

Browse files
[flang] Fix flang build after #83132 (#83253)
This fix is a temporary workaround. `LowerHLFIRIntrinsics.cpp` should be using the greedy pattern rewriter or a manual IR traversal. All patterns in this file are rewrite patterns. The test failure was caused by `replaceAllUsesWith`, which is not supported by the dialect conversion; additional asserts were added recently to prevent incorrect API usage. These trigger now. Alternatively, turning the patterns into conversion patterns and specifying a type converter may work. Failing test case: `Fortran/gfortran/regression/gfortran-regression-compile-regression__inline_matmul_14_f90.test`
1 parent 27b297b commit 1f74f5f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,14 @@ class HlfirIntrinsicConversion : public mlir::OpRewritePattern<OP> {
176176
rewriter.eraseOp(use);
177177
}
178178
}
179-
rewriter.replaceAllUsesWith(op->getResults(), {base});
179+
// TODO: This entire pass should be a greedy pattern rewrite or a manual
180+
// IR traversal. A dialect conversion cannot be used here because
181+
// `replaceAllUsesWith` is not supported. Similarly, `replaceOp` is not
182+
// suitable because "op->getResult(0)" and "base" can have different types.
183+
// In such a case, the dialect conversion will attempt to convert the type,
184+
// but no type converter is specified in this pass. Also note that all
185+
// patterns in this pass are actually rewrite patterns.
186+
op->getResult(0).replaceAllUsesWith(base);
180187
rewriter.replaceOp(op, base);
181188
}
182189
};

0 commit comments

Comments
 (0)