This is an archive of the discontinued LLVM Phabricator instance.

llvm-reduce: Fix block reduction with unreachable blocks
ClosedPublic

Authored by arsenm on Oct 21 2022, 9:03 AM.

Details

Summary

Previously this would produce many invalid reductions with
"Instruction does not dominate uses" verifier errors.

This fixes issues in cases where the incoming IR
has unreachable blocks, and the resulting reduction
introduced new reachable blocks.

Have basic-blocks skip functions that have unreachable
blocks, Introduce a separate reduction which only
deletes unreachable blocks. Cleanup any newly unreachable
blocks after trimming out the requested deletions.

Includes a variety of meta-reduced tests for llvm-reduce
itself with -abort-on-invalid-reduction that were failing
on different iterations of this patch.

Bugpoint's implementation is much simpler (but currently I don't
understand how it avoids disconnecting interesting blocks from the CFG).

Diff Detail

Event Timeline

arsenm created this revision.Oct 21 2022, 9:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 21 2022, 9:03 AM
arsenm requested review of this revision.Oct 21 2022, 9:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 21 2022, 9:03 AM
Herald added a subscriber: wdng. · View Herald Transcript
aeubanks accepted this revision.Oct 21 2022, 4:02 PM

nice!

llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp
137

remove parens

199

probably not super important, but keeping phis limits the instructions that the basic block pass messes with

This revision is now accepted and ready to land.Oct 21 2022, 4:02 PM
arsenm added inline comments.Oct 23 2022, 4:19 PM
llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp
199

Doesn't seem to do anything in the tests