clangir
clangir copied to clipboard
Cleanup `cir.scope`s with a single `cir.yield` operation
This is fine, the cir.scope
is created to represent the overall scope where the if codegen actually happens within (it's where init statements will place their alloca, etc). Poking at the IfStmt some layers above for this optimization isn't worth it IMO - the cleanup pass should be stripping the cir.scope
here anwyays, but let me track that as a separate issue.
Originally posted by @bcardosolopes in https://github.com/llvm/clangir/pull/436#discussion_r1480861603
Hi I'd like to take this issue
Hi, @bcardosolopes I'm trying to understand exactly where I should add this cleanup pass. Is there any documentation or resources I can consult outside of the clangir website?
@hardshah @bcardosolopes the issue's description is a bit misleading. This cleanup has already been implemented in MergeCleanupsPass
:
https://github.com/llvm/clangir/blob/3d839823fab13334f493f7c71c14b30051134e89/clang/lib/CIR/Dialect/Transforms/MergeCleanups.cpp#L57-L69
The reason why it is not being applied in the empty scope that originated the issue is because of an implicit cir.yield
operation that is not accounted for in the rewrite pattern's match clause.
@hardshah you can tackle this by fixing the rewrite pattern linked above.
Okay thanks for clarifying !