[PATCH] D107534: Add a pass to garbage-collect empty basic blocks after code generation.
Rahman Lavaee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 15 21:34:14 PDT 2023
rahmanl added inline comments.
================
Comment at: llvm/lib/CodeGen/GCEmptyBasicBlocks.cpp:53
+ if (HasAnyRealCode)
+ continue;
+
----------------
wenlei wrote:
> rahmanl wrote:
> > wenlei wrote:
> > > tmsriram wrote:
> > > > If the block has no real instructions but debug instructions, is it correct to nuke it?
> > > For debuggbility, probably not. Relatedly the current implementation also keep the block if it contains pseudo-probe, which is what we want.
> > I am guessing debug-info instructions in a basic block with zero binary size is never used. Any ideas @dblaikie ?
> >
> > @wenlei My initial idea was to GC all empty blocks before inserting pseudo probes. Now I realize pseudo probes may be inserted anytime. But I still think we can remove empty blocks with pseudo probes at this point of CodeGen. WDYT?
> pseudo-probes are inserted very early - similar to where IRPGO probes are inserted. If a block has pseudo-probe in it, we should not remove that block, because the purpose of pseudo-probe is to preserve control flow (branches) so profile can be mapped to unoptimized IR more accurately.
Thanks for the explanation. I got a bit confused looking at where PseudoProbeInserter is added in TargetPassConfig.cpp, which is only for callsites.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D107534/new/
https://reviews.llvm.org/D107534
More information about the llvm-commits
mailing list