History log of /llvm-project/llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp (Results 1 – 25 of 33)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: llvmorg-21-init
# 6292a808 24-Jan-2025 Jeremy Morse <jeremy.morse@sony.com>

[NFC][DebugInfo] Use iterator-flavour getFirstNonPHI at many call-sites (#123737)

As part of the "RemoveDIs" project, BasicBlock::iterator now carries a
debug-info bit that's needed when getFirstNo

[NFC][DebugInfo] Use iterator-flavour getFirstNonPHI at many call-sites (#123737)

As part of the "RemoveDIs" project, BasicBlock::iterator now carries a
debug-info bit that's needed when getFirstNonPHI and similar feed into
instruction insertion positions. Call-sites where that's necessary were
updated a year ago; but to ensure some type safety however, we'd like to
have all calls to getFirstNonPHI use the iterator-returning version.

This patch changes a bunch of call-sites calling getFirstNonPHI to use
getFirstNonPHIIt, which returns an iterator. All these call sites are
where it's obviously safe to fetch the iterator then dereference it. A
follow-up patch will contain less-obviously-safe changes.

We'll eventually deprecate and remove the instruction-pointer
getFirstNonPHI, but not before adding concise documentation of what
considerations are needed (very few).

---------

Co-authored-by: Stephen Tozer <Melamoto@gmail.com>

show more ...


Revision tags: llvmorg-19.1.7, llvmorg-19.1.6, llvmorg-19.1.5, llvmorg-19.1.4, llvmorg-19.1.3, llvmorg-19.1.2
# 9839b8cf 10-Oct-2024 Matt Arsenault <Matthew.Arsenault@amd.com>

llvm-reduce: Fix assert on invokes with catchswitch (#111838)

This is the minimal change to avoid the assert. There's an API flaw in
invoke instructions where getLandingPad assumes all invoke unwin

llvm-reduce: Fix assert on invokes with catchswitch (#111838)

This is the minimal change to avoid the assert. There's an API flaw in
invoke instructions where getLandingPad assumes all invoke unwind
blocks have landingpads, when some have catchswitch instead.

Fixes #111817

show more ...


Revision tags: llvmorg-19.1.1, llvmorg-19.1.0, llvmorg-19.1.0-rc4, llvmorg-19.1.0-rc3, llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init, llvmorg-18.1.8, llvmorg-18.1.7, llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init, llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4, llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2, llvmorg-17.0.0-rc1, llvmorg-18-init, llvmorg-16.0.6, llvmorg-16.0.5, llvmorg-16.0.4, llvmorg-16.0.3, llvmorg-16.0.2, llvmorg-16.0.1, llvmorg-16.0.0, llvmorg-16.0.0-rc4, llvmorg-16.0.0-rc3, llvmorg-16.0.0-rc2, llvmorg-16.0.0-rc1, llvmorg-17-init
# 23cc36e4 16-Jan-2023 Matt Arsenault <Matthew.Arsenault@amd.com>

llvm-reduce: Use consistent ReductionFunc types

Some of these were relying on ReducerWorkItem's operator Module&.


Revision tags: llvmorg-15.0.7, llvmorg-15.0.6
# 5b6575d5 18-Nov-2022 Florian Hahn <flo@fhahn.com>

[llvm-reduce] Do not crash when accessing landingpads of invokes.

Unconditionally removing landing pads results in invalid IR,
if there is a different `invoke` that uses it. Update the code
to only

[llvm-reduce] Do not crash when accessing landingpads of invokes.

Unconditionally removing landing pads results in invalid IR,
if there is a different `invoke` that uses it. Update the code
to only remove the landing pad if the current invoke is the only
user. Also carefully avoid creating plain branches to bbs with
landing pads we couldn't remove.

Reviewed By: arsenm, aeubanks

Differential Revision: https://reviews.llvm.org/D138072

show more ...


Revision tags: llvmorg-15.0.5, llvmorg-15.0.4
# f02bc70c 20-Oct-2022 Matt Arsenault <Matthew.Arsenault@amd.com>

llvm-reduce: Fix producing invalid reductions with landingpads

It's not valid to simply branch to a landingpad block, so it
needs to be removed.

Also stop trying to scan forward to find a block tha

llvm-reduce: Fix producing invalid reductions with landingpads

It's not valid to simply branch to a landingpad block, so it
needs to be removed.

Also stop trying to scan forward to find a block that can be merged.
The predecessor merge rules are more complex than this. This also
would need to have considered landingpads. Just do the minimum
to delete the block, and let the simplify-cfg reduction handle
the branch chain cleanups.

show more ...


Revision tags: llvmorg-15.0.3, working, llvmorg-15.0.2
# 45a91c15 04-Oct-2022 Matt Arsenault <Matthew.Arsenault@amd.com>

llvm-reduce: Fix block reduction with unreachable blocks

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

This fixes issues in cases

llvm-reduce: Fix block reduction with unreachable blocks

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).

show more ...


# bc405e37 19-Oct-2022 Matt Arsenault <Matthew.Arsenault@amd.com>

llvm-reduce: Don't turn switches into returns

Re-use one of the existing successors as the new default.
This helps with a future patch to fix handling of unreachable
blocks.


# 827f01c2 18-Oct-2022 Matt Arsenault <Matthew.Arsenault@amd.com>

llvm-reduce: Remove okToRemove logic in block reduction

This was making decisions based on BBsToDelete, while being
used to determine BBsToDelete which doesn't really work.
Additionally, this is a l

llvm-reduce: Remove okToRemove logic in block reduction

This was making decisions based on BBsToDelete, while being
used to determine BBsToDelete which doesn't really work.
Additionally, this is a lot of logic just to avoid deleting
the entry block when we can just skip it.

show more ...


# 2592ccde 18-Oct-2022 Arthur Eubanks <aeubanks@google.com>

[llvm-reduce] Unify pass logging

We randomly use outs() or errs(), which makes test logs confusing.
We also randomly add/don't add a line afterward.

Reviewed By: arsenm

Differential Revision: http

[llvm-reduce] Unify pass logging

We randomly use outs() or errs(), which makes test logs confusing.
We also randomly add/don't add a line afterward.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D136130

show more ...


Revision tags: llvmorg-15.0.1, llvmorg-15.0.0, llvmorg-15.0.0-rc3
# df308cab 14-Aug-2022 John Regehr <regehr@cs.utah.edu>

fix some bad logic that was removing all successor phi nodes, not just
out of chunk ones. the non-default second argument to
removePredecessor() is necessary to avoid creating invalid IR on
examples

fix some bad logic that was removing all successor phi nodes, not just
out of chunk ones. the non-default second argument to
removePredecessor() is necessary to avoid creating invalid IR on
examples like the one in the provided test case

Differential Revision: https://reviews.llvm.org/D131843

show more ...


# 195087d8 09-Aug-2022 Arthur Eubanks <aeubanks@google.com>

[llvm-reduce] Try harder to not create invalid aliases

This was done by adding --abort-on-invalid-reduction to remove-function-bodies-used-in-globals.ll and fixing the fallout.

Aliases must have a

[llvm-reduce] Try harder to not create invalid aliases

This was done by adding --abort-on-invalid-reduction to remove-function-bodies-used-in-globals.ll and fixing the fallout.

Aliases must have a GlobalValue or ConstantExpr aliasee and the aliasee must be a definition if it's a GlobalValue.
Don't RAUW functions with null if there's an alias pointing to it, and similarly don't delete the body of a function.
Don't delete the entire body of a function when reducing blocks, preserve at least one block.

Also make debugging these sorts of things easier by dumping the module when --abort-on-invalid-reduction triggers.

Reviewed By: regehr

Differential Revision: https://reviews.llvm.org/D131505

show more ...


Revision tags: llvmorg-15.0.0-rc2
# 213c21fe 04-Aug-2022 John Regehr <regehr@cs.utah.edu>

earlier I fixed a bug where the BB removal pass sometimes created
invalid IR. the fix was incomplete, this one is better and is believed
to be complete

Differential Revision: https://reviews.llvm.or

earlier I fixed a bug where the BB removal pass sometimes created
invalid IR. the fix was incomplete, this one is better and is believed
to be complete

Differential Revision: https://reviews.llvm.org/D131132

show more ...


# 1116fa47 03-Aug-2022 John Regehr <regehr@cs.utah.edu>

avoid a bug where we remove a BB and then the next one becomes the
entry block and is illegal due to having more then one predecessor
block

Differential Revision: https://reviews.llvm.org/D131026


Revision tags: llvmorg-15.0.0-rc1, llvmorg-16-init, llvmorg-14.0.6
# 2962f9df 21-Jun-2022 John Regehr <regehr@cs.utah.edu>

stop llvm-reduce from introducing undefs

Differential Revision: https://reviews.llvm.org/D128317


Revision tags: llvmorg-14.0.5, llvmorg-14.0.4
# bb8e0232 24-May-2022 Markus Lavin <markus.lavin@ericsson.com>

llvm-reduce: improve basic-blocks removal pass

When the single branch target of a block has been removed try updating
it to target a block that is kept (by scanning forward in the sequence)
instead

llvm-reduce: improve basic-blocks removal pass

When the single branch target of a block has been removed try updating
it to target a block that is kept (by scanning forward in the sequence)
instead of replacing the branch with a return instruction. Doing so
reduces the risk of breaking loop structures meaning that when the loop
is 'interesting' these reductions should have more blocks eliminated.

Differential Revision: https://reviews.llvm.org/D125766

show more ...


Revision tags: llvmorg-14.0.3, llvmorg-14.0.2
# f7db8b7a 20-Apr-2022 Matt Arsenault <Matthew.Arsenault@amd.com>

llvm-reduce: Fix variable name typo


# 6f3f19a3 13-Apr-2022 Matt Arsenault <Matthew.Arsenault@amd.com>

llvm-reduce: Fix some copy-pasted comment errors


Revision tags: llvmorg-14.0.1, llvmorg-14.0.0, llvmorg-14.0.0-rc4, llvmorg-14.0.0-rc3, llvmorg-14.0.0-rc2
# a5bbc6ef 23-Feb-2022 Bill Wendling <isanbard@gmail.com>

[NFC] Remove unnecessary "#include"s from header files


Revision tags: llvmorg-14.0.0-rc1, llvmorg-15-init, llvmorg-13.0.1, llvmorg-13.0.1-rc3, llvmorg-13.0.1-rc2, llvmorg-13.0.1-rc1
# 4081df43 13-Nov-2021 Florian Hahn <flo@fhahn.com>

[llvm-reduce] Remove unnecessary loop.

After cd8aa234fdd2, there's no need to collect a vector of basic blocks
to keep first. Remove the first loop.


# 6f288bd7 12-Nov-2021 Arthur Eubanks <aeubanks@google.com>

[llvm-reduce] Count chunks by running a preliminary reduction

Having a separate counting method runs the risk of a mismatch between
the actual reduction method and the counting method.

Instead, cre

[llvm-reduce] Count chunks by running a preliminary reduction

Having a separate counting method runs the risk of a mismatch between
the actual reduction method and the counting method.

Instead, create an Oracle that always returns true for shouldKeep(), run
the reduction, and count how many times shouldKeep() was called. The
module should not be modified if shouldKeep() always returns true.

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D113537

show more ...


# cd8aa234 10-Nov-2021 Florian Hahn <flo@fhahn.com>

[llvm-reduce] Use DenseSet instead of std::set (NFC).

When reducing functions with very large basic blocks (~ almost 1 million
BBs), the majority of time is spent maintaining the order in the std::s

[llvm-reduce] Use DenseSet instead of std::set (NFC).

When reducing functions with very large basic blocks (~ almost 1 million
BBs), the majority of time is spent maintaining the order in the std::set
for the basic blocks to keep.

In those cases, DenseSet<> is much more efficient. Use it instead.

show more ...


# 16c3db8d 09-Nov-2021 Dwight Guth <dwight.guth@runtimeverification.com>

[llvm-reduce] Fix invalid reduction in basic-blocks delta pass

Previously, if the basic-blocks delta pass tried to remove a basic block
that was the last basic block in a function that did not have

[llvm-reduce] Fix invalid reduction in basic-blocks delta pass

Previously, if the basic-blocks delta pass tried to remove a basic block
that was the last basic block in a function that did not have external
or weak linkage, the resulting IR would become invalid. Since removing
the last basic block in a function is effectively identical to removing
the function body itself, we check explicitly for this case and if we
detect it, we run the same logic as in ReduceFunctionBodies.cpp

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D113486

show more ...


# 2f161736 29-Oct-2021 Dwight Guth <dwight.guth@runtimeverification.com>

[llvm-reduce] optimize extractFromModule functions

The extractBasicBlocksFromModule, extractInstrFromModule, and other
similar functions previously performed very poorly when the number of
such elem

[llvm-reduce] optimize extractFromModule functions

The extractBasicBlocksFromModule, extractInstrFromModule, and other
similar functions previously performed very poorly when the number of
such elements in the program to reduce was very high. Previously, we
were creating the set which caches elements to keep by looping through
all elements in the module and adding them to the set. However, since
std::set is an ordered set, this introduces a massive amount of
rebalancing if the order of elements in the program and the order of
their pointers in memory are not the same.

The solution is straightforward: first put all the elements to be kept
in a vector, then use the constructor for std::set which takes a pair of
iterators over a collection. This constructor is optimized to avoid
doing unnecessary work when initializing large sets.

Also in this change, we pass BBsToKeep set to functions
replaceBranchTerminator and removeUninterestingBBsFromSwitch as a const
reference rather than passing it by value. This ought to prevent the
need to copy the collection each time these functions are called, which
is expensive if the collection is large.

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D112757

show more ...


# 77bc3ba3 05-Oct-2021 Arthur Eubanks <aeubanks@google.com>

[NFC][llvm-reduce] Cleanup types

Use Module& wherever possible.
Since every reduction immediately turns Chunks into an Oracle, directly pass Oracle instead.

Reviewed By: hans

Differential Revision

[NFC][llvm-reduce] Cleanup types

Use Module& wherever possible.
Since every reduction immediately turns Chunks into an Oracle, directly pass Oracle instead.

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D111122

show more ...


Revision tags: llvmorg-13.0.0, llvmorg-13.0.0-rc4, llvmorg-13.0.0-rc3, llvmorg-13.0.0-rc2, llvmorg-13.0.0-rc1, llvmorg-14-init, llvmorg-12.0.1, llvmorg-12.0.1-rc4, llvmorg-12.0.1-rc3, llvmorg-12.0.1-rc2, llvmorg-12.0.1-rc1, llvmorg-12.0.0, llvmorg-12.0.0-rc5
# 56fa1b4f 02-Apr-2021 Samuel <swamulism@gmail.com>

[llvm-reduce] Add header guards and fix clang-tidy warnings

Add header guards and fix other clang-tidy warnings in .h files.
Also align misaligned header docs

Reviewed By: aeubanks

Differential Re

[llvm-reduce] Add header guards and fix clang-tidy warnings

Add header guards and fix other clang-tidy warnings in .h files.
Also align misaligned header docs

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D99634

show more ...


12