[flang-commits] [flang] [flang] de-duplicate AbstractResult pass (PR #88867)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Thu Apr 18 09:47:09 PDT 2024


tblah wrote:

> Regarding the ReturnOp issue you saw, is it related to the weird way the ReturnOp op pattern is inserted (only inserted when the top level op is a function)? Maybe the pattern could just always be registered (just unused if there is not ReturnOp).

I think it is the difference in scope. For a pass scheduled on a function, creating a pattern for every `ReturnOp` will only match return operations inside of that function. If the pass is invoked on a module, the pattern will match every `ReturnOp` in that module. The way the pass is currently written, it uses different legality checks for the return operation depending on the prototype of the function being processed by the pass, so running it at the module scope adds several conflicting operation legality checks for return operations and each tries to process every return operation in the module.

The pass could be fixed to work correctly at module scope, or to create its own internal nested pipeline running on each function. I preferred not to modify the pass too much in this commit so the changes didn't get confusing to review. Let me know if you would prefer I make sure `fir-opt --abstract-result` works before merging this.

Personally, I don't think the exact `fir-opt` invocation is too important, especially in this case where it has to change anyway (previously it would have been `fir-opt --abstract-result-on-func`).

https://github.com/llvm/llvm-project/pull/88867


More information about the flang-commits mailing list