Similar to what we already do for ret terminators.
As noted by @rnk, clang seems to already generate a single ret/resume,
so this isn't likely to cause widespread changes.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/test/Transforms/SimplifyCFG/tail-merge-resume.ll | ||
---|---|---|
33 | 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. | |
91–97 | I think it's worth adding an extra block where the resume has a phi operand. That is the dominant pattern coming from clang, so it's important to show that simplifycfg can take a standalone resume block and merge it in. |
llvm/test/Transforms/SimplifyCFG/tail-merge-resume.ll | ||
---|---|---|
33 | They are canonical, and in fact i had to invent InstCombinerImpl::foldAggregateConstructionIntoAggregateReuse() |
lgtm, thanks
llvm/test/Transforms/SimplifyCFG/tail-merge-resume.ll | ||
---|---|---|
91–97 | Phabricator is being weird, and this isn't highlighted as a diff, but I see that you added the semicommon block as suggested. |
I thought PHIs of structs were considered non-canonical, but it looks like LLVM creates them in this C++ example:
We should be OK then.