[flang-commits] [PATCH] D130484: [flang] Runs FIR SimplifyRegionLitePass pass after calling the inliner

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Mon Jul 25 10:37:06 PDT 2022


jeanPerier added a comment.

In D130484#3676207 <https://reviews.llvm.org/D130484#3676207>, @awarzynski wrote:

>> In flang pipeline, the inliner calls createCanonicalizerPass with the region simplification disabled.
>
> Why not //enable// region simplification instead? Just curious.

The issue with the MLIR regions simplification is that it always does block merging, and block merging breaks some properties of high level FIR where some operand are expected to be compile time constants/parent operation are expected to be visible: see  https://reviews.llvm.org/D109579#3052374 for a better explanation.

In D130484#3676302 <https://reviews.llvm.org/D130484#3676302>, @kiranchandramohan wrote:

> Just a drive-through comment. Feel free to ignore it.
>
> We have a call to `simplifyregions` in the lowering code with a comment to move this to a pass. With this change can we remove that call in Bridge.cpp? Or alternatively call the simplify region pass early in the flow?
> https://github.com/llvm/llvm-project/blob/883b0d5b7f873a7d6f8c8ee13c7f6174a2a79a50/flang/lib/Lower/Bridge.cpp#L2830

Thanks for the suggestion, the call to simplify region is required to produce valid CFGs after lowering (because we allow ourselves to produce unreachable blocks in lowering to simplify things), so this call does not allow removing it since many passes are called in between (in fact some regions `createSimplifyRegionLitePass` is already added a few line above in `createDefaultFIROptimizerPassPipeline`), it needs to be called every type a pass may create dead code.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130484/new/

https://reviews.llvm.org/D130484



More information about the flang-commits mailing list