[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 19:17:09 PDT 2023


rahmanl added inline comments.


================
Comment at: llvm/lib/CodeGen/GCEmptyBasicBlocks.cpp:58
+    // predecessors. Although this shouldn't happen in valid code.
+    if (NextMBB == E && !Preds.empty())
+      continue;
----------------
rahmanl wrote:
> tmsriram wrote:
> > If it is the last block it must have predecessors or you couldn't get to it, so !Preds.empty() is redundant.
> I found one case of a function with a single empty basic block which prompted me to add this check.
To be more precise, if I do remove the single empty basic block in that function, the compilation later breaks (during CFI-insertion) because the function becomes empty. I will take a look to see if I can mitigate the breakage. 


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