diff options
| author | Matthias Springer <me@m-sp.org> | 2025-11-04 08:34:52 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-03 23:34:52 +0000 |
| commit | d4c41b7fa30be06b5250c0d5abc7a26a83420321 (patch) | |
| tree | e192e3468fce5a4d488653c6d2d995576f0b6497 /llvm/tools/llvm-diff/lib | |
| parent | 285b57b1a68e6738dac047f5f6461f231448b0f5 (diff) | |
| download | llvm-d4c41b7fa30be06b5250c0d5abc7a26a83420321.zip llvm-d4c41b7fa30be06b5250c0d5abc7a26a83420321.tar.gz llvm-d4c41b7fa30be06b5250c0d5abc7a26a83420321.tar.bz2 | |
[mlir][Transforms] Dialect Conversion: Convert entry block only (#165180)
When converting a function, convert only the entry block signature. The
remaining block signatures should be converted by the respective
branching ops. The `FuncToLLVM` / `ControlFlowToLLVM` patterns already
use that design.
```c++
struct BranchOpLowering : public ConvertOpToLLVMPattern<cf::BranchOp> {
LogicalResult
matchAndRewrite(cf::BranchOp op, OneToNOpAdaptor adaptor,
ConversionPatternRewriter &rewriter) const override {
// Convert successor block.
SmallVector<Value> flattenedAdaptor = flattenValues(adaptor.getOperands());
FailureOr<Block *> convertedBlock =
getConvertedBlock(rewriter, getTypeConverter(), op, op.getSuccessor(),
TypeRange(ValueRange(flattenedAdaptor)));
// ...
}
};
```
This is consistent with the fact that operations from unreachable blocks
are not put on the initial worklist.
With this change, parent ops are no longer recursively legalized when
inserting a block, simplifying the conversion driver a bit.
Note for LLVM integration: If you are seeing failures, make sure to:
- Drop `converter.isLegal(&op.getBody())` when checking the legality of
a function op. Only the entry block signature / function type should be
taken into account.
- If you need to convert all reachable blocks and are using `cf`
branching ops, add `populateCFStructuralTypeConversionsAndLegality`.
- If you need to convert all reachable blocks and are using custom
branching ops, implement and populate custom structural type conversion
patterns, similar to `populateCFStructuralTypeConversionsAndLegality`.
Diffstat (limited to 'llvm/tools/llvm-diff/lib')
0 files changed, 0 insertions, 0 deletions
