[PATCH] D104849: [SimplifyCFG] Tail-merging all blocks with `resume` terminator
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 24 10:17:04 PDT 2021
lebedev.ri marked an inline comment as done.
lebedev.ri added inline comments.
================
Comment at: llvm/test/Transforms/SimplifyCFG/tail-merge-resume.ll:28
+; CHECK: common.resume:
+; CHECK-NEXT: [[COMMON_RESUME_OP:%.*]] = phi { i8*, i32 } [ [[LP2:%.*]], [[LPAD2]] ], [ [[LP]], [[RESUME0]] ], [ [[LP]], [[RESUME1]] ]
+; CHECK-NEXT: resume { i8*, i32 } [[COMMON_RESUME_OP]]
----------------
rnk wrote:
> I thought PHIs of structs were considered non-canonical, but it looks like LLVM creates them in this C++ example:
> ```
> $ cat t.cpp
> struct Cleanup {
> ~Cleanup();
> };
> void maythrow();
> void resumeFromPhi() {
> Cleanup a;
> maythrow();
> Cleanup b;
> maythrow();
> }
>
> $ clang -S t.cpp -o - -emit-llvm -O2 | grep phi
> %.pn = phi { i8*, i32 } [ %3, %lpad1 ], [ %2, %lpad ]
> ```
>
> We should be OK then.
They are canonical, and in fact i had to invent `InstCombinerImpl::foldAggregateConstructionIntoAggregateReuse()`
(and i still need to finish it) so that `SimplifyCFGOpt::simplifyCommonResume()` would actually work...
So yes, such PHI's are absolutely fine.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104849/new/
https://reviews.llvm.org/D104849
More information about the llvm-commits
mailing list