Skip to content

dialects: (scf) scf.WhileOp crashes with ValueError when regions contain multiple blocks #5644

@wulu007

Description

@wulu007

Description

The current implementation of WhileOp in the SCF dialect fails when its regions contain more than one block. This is because it accesses the entry block arguments using the .block property of the Region class, which raises a ValueError if the region contains multiple blocks.

In MLIR, scf.while regions are allowed to have multiple blocks (forming a Control Flow Graph). The initialization arguments and results should only be mapped to the entry block of the respective regions.

https://github.com/llvm/llvm-project/blob/47fb7cd732ffc666d2865e1a187db24f8e09ab25/mlir/lib/Dialect/SCF/IR/SCF.cpp#L3328

Expected Behavior

WhileOp should be able to print and verify correctly even if the before or after regions contain multiple blocks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions