[clang] [CIR] Flatten loop ops with a cleanup region (PR #210472)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 20 11:47:35 PDT 2026
================
@@ -518,6 +518,164 @@ class CIRLoopOpInterfaceFlattening
exit);
}
+ // Return the cleanup-kind attribute or a null attribute if the loop has no
+ // cleanups.
+ static cir::CleanupKindAttr getLoopCleanupKind(cir::LoopOpInterface op) {
----------------
andykaylor wrote:
> Ah, right, it takes expression there.... what about with a statement expression?
>
> ```
> do { }
> while(({S s{}; (bool)s;} ));
> ```
>
> See here: https://godbolt.org/z/4eraGfxW6
>
> That seems to match what I was talking about?
I think that's basically the same as the temporary case. I don't think we could force it into the condition-cleanup pattern even if we wanted to. That will become more apparent in my next PR when you see how I place the codegen for the variable cleanup. In order to handle the weird case we talked about before where a while condition contains a statement expression which itself contains a while loop, I had to strictly limit the cleanup capture in the condition to the condition variable itself. In the case of a do..while loop all we get from the AST is the condition expression. We don't want all cleanups in that expression going to the loop cleanup region, so we can't capture any of them.
https://github.com/llvm/llvm-project/pull/210472
More information about the cfe-commits
mailing list