[PATCH] D131204: llvm-reduce: add a pass for cleaning up branches

John Regehr via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 4 14:31:42 PDT 2022


regehr created this revision.
regehr added reviewers: aeubanks, arsenm.
Herald added a subscriber: mgorny.
Herald added a project: All.
regehr requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

  I'm doing a lot of reductions starting with full-sized IR modules,
  trying to find minimal triggers for random issues detected by alive2.
  Even after llvm-reduce reaches a fixpoint, there's often some
  control-flow-related junk, often towards the end of the module, that
  isn't getting cleaned up by existing passes that we have.
  
  This patch adds three reduction passes. The first one tries to make
  every conditional branch into an unconditional branch to the original
  branch's true target. The second pass does the same thing, but uses the
  false target. The third pass targets unconditional branches. For a BB
  terminated by an unconditional branch, all instructions in the BB are
  sunk to the start of the successor block and all branches targeting
  the original block are pointed to the successor. Then we delete the
  block.
  
  On a collection of 53 IR files that I'm using to benchmark
  llvm-reduce, this patch changes the average final file size from 710
  bytes to 615 bytes, about a 15% improvement.


https://reviews.llvm.org/D131204

Files:
  llvm/test/tools/llvm-reduce/remove-cond-branches-false.ll
  llvm/test/tools/llvm-reduce/remove-cond-branches-true.ll
  llvm/test/tools/llvm-reduce/remove-uncond-branches.ll
  llvm/tools/llvm-reduce/CMakeLists.txt
  llvm/tools/llvm-reduce/DeltaManager.cpp
  llvm/tools/llvm-reduce/deltas/ReduceBranches.cpp
  llvm/tools/llvm-reduce/deltas/ReduceBranches.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131204.450130.patch
Type: text/x-patch
Size: 10241 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220804/e9a4e50a/attachment.bin>


More information about the llvm-commits mailing list