161 Commits

Author SHA1 Message Date
Matt Arsenault
2aafb73f86 llvm-reduce: Actually change to the temporary directory in test
Hopefully fixes issue #61132
2023-04-08 07:07:29 -04:00
Matt Arsenault
546daf1a50 llvm-reduce: Try running test in temporary directory
Attempt to fix issue #61761
2023-04-07 19:25:39 -04:00
Kirill Stoimenov
011b4d4706 [HWASAN][LSAN] Disable tests which don't pass in HWASAN+LSAN mode
Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D145727
2023-03-10 00:51:55 +00:00
Matt Arsenault
2fdd55c4b0 llvm-reduce: Use explicit output file in a test
The default argument behavior test tries to make use
of the default reduced.ll, so other tests should not try to
write to the same file.

Maybe fixes issue #61132.
2023-03-05 16:49:59 -04:00
J. Ryan Stinnett
065e77b1b7 [DebugInfo] Remove dbg.addr from llvm-reduce
Part of `dbg.addr` removal
Discussed in https://discourse.llvm.org/t/what-is-the-status-of-dbg-addr/62898

Differential Revision: https://reviews.llvm.org/D144798
2023-03-02 09:29:43 +00:00
Anton Sidorenko
6820cb2dd5 [Test] Fix YAML mapping keys duplication. NFC.
YAML specification does not allow keys duplication an a mapping. However, YAML
parser in LLVM does not have any check on that and uses only the last key entry.
In this change duplicated keys are merged to satisfy the spec.

Differential Revision: https://reviews.llvm.org/D141848
2023-02-09 12:59:50 +03:00
Matt Arsenault
9a501ebee2 llvm-reduce: Add REQUIRES: default_triple to test
Allegedly fixes test failure if there are no targets built.
2023-01-27 22:17:26 -04:00
Matt Arsenault
d78b4c44ab llvm-reduce: Fix default handling of intermediate format
Bitcode inputs should produce bitcode intermediates by
default.
2023-01-20 23:21:13 -04:00
Matt Arsenault
bc3e492323 llvm-reduce: Reduce ifuncs
Reduce by calling the resolver function at the use site, and inserting
an indirect call. Try to delete if there are no uses left over.

We should also probably try to do something about constantexpr uses;
perhaps treat them like aliases.
2023-01-17 22:33:57 -05:00
Matt Arsenault
1ad4527801 Revert "llvm-reduce: Try to kill parallel workitems once we have a result."
This reverts commit 4f575620d51032cf98424c9defafe4dfc8d66f45.

I realized the test wasn't very good and when fixed, shows the
reduction doesn't work correctly. Revert the change and keep the fixed
version of the test.
2023-01-11 11:11:23 -05:00
Matt Arsenault
4f575620d5 llvm-reduce: Try to kill parallel workitems once we have a result.
The current reduction logic tries to reproduce what a serial reduction
would produce, and just takes the first one that is still
interesting. We still have to wait for all others to complete though,
which at that point is just a waste.

This helps speed things up with long running reducers, which I
frequently have. e.g. for the added sleep test on my system, it took
about 8 seconds before this change and about 4 after.

https://reviews.llvm.org/D138953
2023-01-11 08:58:22 -05:00
Matt Arsenault
ae6a5c1d08 llvm-reduce: Fix assertion on blockaddress during function reduction
Just avoid crashing for now, we should be able to replace the blockaddresses
themselves.

BlockAddress::handleOperandChangeImpl assumes it can cast to Function.
The verifier seems nonexistent and the langref isn't particularly explicit
on what's allowed as a blockaddress operand. As far as I can tell bugpoint
isn't doing anything to handle this.

Something low level is broken with BlockAddress handling,
demonstrated by reduce-functions-blockaddress-wrong-function.ll.
The BasicBlock destructor of the deleted function is triggering replacement
of blockaddresses for the kept function in some cases. I've only half debugged
this but it seems like blockaddress is handled too-specially compared to other
Constants. I have tentative patches to allow any constant to be a blockaddress
input, but having the verifier check if it's really a function/block.

https://reviews.llvm.org/D140909
2023-01-11 08:10:04 -05:00
Matt Arsenault
a50cec5bf9 llvm-reduce: Don't delete instructions in global variable reduction
For some reason the global variable reduction was trying to delete
use instructions. This broke the verifier if the user was a terminator,
since the block now no longer has one. It doesn't make sense for this
reduction to delete the users, so just stop doing that.
2023-01-05 10:26:02 -05:00
Nikita Popov
6236d77d2b [llvm-reduce] Remove typed pointer test (NFC)
There already is a test using opaque pointers instead.
2023-01-05 12:26:39 +01:00
Matt Arsenault
a455c91601 llvm-reduce: Add reduction for invokes
Main thing I was unsure about was to whether try to delete the now
dead landing blocks, or leave that for the unreachable block reduction.

Personality function is not reduced, but that should be a separate
reduction on the function.

Fixes #58815
2023-01-03 17:03:44 -05:00
Matt Arsenault
f4cb935ce8 llvm-reduce: Fix invalid reductions for exceptions, tokens and swifterror
Copies the same special cases that bugpoint uses. Technically the
token condition is stricter than what the verifier enforces.

Part 1 of #58815
2023-01-03 17:03:20 -05:00
Matt Arsenault
84e888e5e4 llvm-reduce: Speculative fix for windows build bot
I'm guessing grep wasn't matching the backtick in the message for some
reason.
2023-01-03 17:00:35 -05:00
Matt Arsenault
9c8b89f580 llvm-reduce: Refine missing argument behavior
We required the test and input arguments for --print-delta-passes
which is unhelpful. Also, start printing the help output if no
arguments were supplied.

It looks like there's more sophisticated ways to accomplish this with
the opt library, but it was less work to manually emit these errors.
2023-01-03 16:01:36 -05:00
Matt Arsenault
d5b7514c3d llvm-reduce: Don't remove strictfp
The verifier should fail if constrained intrinsics are used in
functions with strictfp, but that patch hasn't been pushed yet.

Ideally we would be able to analyze the function body to see if any
constrained intrinsics were used, but we seem to be missing a utility
function to check for any constrained ops.
2023-01-03 15:57:58 -05:00
Matt Arsenault
7cd0fd6f51 llvm-reduce: Avoid invalid attribute reduction on optnone functions
We have this ridiculous restriction that optnone requires noinline,
so the pair needs to be removed if we want to remove noinline.
2023-01-03 15:48:14 -05:00
Matt Arsenault
5f6bf752d9 llvm-reduce: Reduce individual operands of named metadata
The current reduction tries all or nothing elimination of named
metadata. I noticed in one case where one of the module flags was
necessary, but it left the rest. Reduce the individual operands of
named metadata nodes that are known to behave like lists. Be
conservative since some named metadata may have more specific verifier
requirements for the operands.
2023-01-03 11:48:00 -05:00
Matt Arsenault
e60b0d2a22 llvm-reduce: Reduce prologue data
Identical to the prefix data handling, and also had broken cloning.
2023-01-03 11:07:02 -05:00
Matt Arsenault
4afb10d572 llvm-reduce: Reduce prefix data
Also fixes broken cloning.
2023-01-03 11:03:43 -05:00
Matt Arsenault
47e44c0c2e llvm-reduce: Add reduction for function personalities
Fixes second piece of #58815
2023-01-03 11:02:34 -05:00
Matt Arsenault
cf99be5c7c llvm-reduce: Restrict set of run delta passes in invoke test
Also stop using cat
2023-01-03 10:13:17 -05:00
Matt Arsenault
3f3b71ae02 llvm-reduce: Try to fix error message test on windows
It seems the execute implementations have gone out of their way to
produce inconsistent error messages. The unix version explicitly
checks if the file exists before trying to execute. The windows
version checks if it's executable. I don't understand why they
wouldn't just try the execution and check the error code.
2023-01-03 09:58:29 -05:00
Matt Arsenault
40903bad46 llvm-reduce: Fix missing newline after error message
Fixes missing test coverage for the failed to execute case. However,
this test fails to verify the newline is printed. I can't figure out
how to get FileCheck to match the trailing newline.
2023-01-03 09:09:17 -05:00
Matt Arsenault
d8fb46ee55 llvm-reduce: Remove test dependence on registered targets
This reverts e4b126cc2d33033a5538d72a88f6aa153ac8b757 and
e57ab8fe91f06e71d3de2df07e6c7efd2f0c6078.

This previously depended on where the target happened to construct (or
not) the MachineFunctionInfo during the initial MIR construction. Now
that the MachineFunctionInfo is consistently constructed at
MachineFunction construction time, this should always work.
2022-12-21 10:50:21 -05:00
Matt Arsenault
b55b4150e9 Revert "llvm-reduce: Try to fix test on windows"
This reverts commit 3b0b0965c4eb603af5d97733775df315ba2241a1.

I hadn't noticed 638b25711540ff7897750ab07592b3d168e65aca
2022-12-20 21:28:58 -05:00
Matt Arsenault
3b0b0965c4 llvm-reduce: Try to fix test on windows
It seems to not like the environment variable set syntax.
2022-12-20 20:38:41 -05:00
Douglas Yung
638b257115 Fix test added in 95abdeb to set environment variables in a way that works on both Windows and linux.
This should fix the test failure on Windows bots such as https://lab.llvm.org/buildbot/#/builders/216/builds/14829.
2022-12-20 17:31:01 -08:00
Matt Arsenault
95abdeba61 llvm-reduce: Disable crash reports, symbolization and core dumps
These are going to waste a lot of time and produce clutter when we're
bulk introducing crashes. Add a flag to disable this behavior in case
this matters to a reproducer.
2022-12-20 19:01:26 -05:00
Matt Arsenault
aa9bdd50c2 llvm-reduce: Fix invalid reductions with llvm.used
Fixes issue 59413.
2022-12-14 15:06:22 -05:00
Roman Lebedev
73017515b6
[NFC] Port all tools tests to -passes= syntax 2022-12-09 01:04:46 +03:00
Roman Lebedev
b1a9584818
[opt] Disincentivize new tests from using old pass syntax
Over the past day or so, i've took a large swing at our tests,
and reduced the number of tests that were still using the old syntax
from ~1800 to just 200.

Left to handle: (as it is seen in this patch)
* Transforms/LSR
* Transforms/CGP
* Transforms/TypePromotion
* Transforms/HardwareLoops
* Analysis/*
* some misc.

I think this is the right point to start actively refusing
to honor the old syntax, except for the old tests,
to prevent the old syntax from creeping back in.

Thus, let's add temporary default-off flag,
and if it is not passed refuse to accept old syntax.
The tests that still need porting are annotated with this flag.

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D139647
2022-12-08 23:54:03 +03:00
Matt Arsenault
8e3e218a5f llvm-reduce: Fix producing invalid reductions on ifunc 2022-11-27 12:41:29 -05:00
Florian Hahn
5b6575d50e
[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
2022-11-18 15:19:50 +00:00
Matt Arsenault
4638ba7b45 llvm-reduce: Try to turn calls into something else
Try to turn calls that look like operators into known
intrinsics. Also try to turn calls that look like a load or
a store into a load or store.
2022-11-07 21:04:21 -08:00
Nikita Popov
304f1d59ca [IR] Switch everything to use memory attribute
This switches everything to use the memory attribute proposed in
https://discourse.llvm.org/t/rfc-unify-memory-effect-attributes/65579.
The old argmemonly, inaccessiblememonly and inaccessiblemem_or_argmemonly
attributes are dropped. The readnone, readonly and writeonly attributes
are restricted to parameters only.

The old attributes are auto-upgraded both in bitcode and IR.
The bitcode upgrade is a policy requirement that has to be retained
indefinitely. The IR upgrade is mainly there so it's not necessary
to update all tests using memory attributes in this patch, which
is already large enough. We could drop that part after migrating
tests, or retain it longer term, to make it easier to import IR
from older LLVM versions.

High-level Function/CallBase APIs like doesNotAccessMemory() or
setDoesNotAccessMemory() are mapped transparently to the memory
attribute. Code that directly manipulates attributes (e.g. via
AttributeList) on the other hand needs to switch to working with
the memory attribute instead.

Differential Revision: https://reviews.llvm.org/D135780
2022-11-04 10:21:38 +01:00
Matt Arsenault
e4b126cc2d llvm-reduce: Require x86 to run file ouput test
The MIR test somewhat depends on target support.
2022-11-02 10:48:52 -07:00
Matt Arsenault
e57ab8fe91 llvm-reduce: Add explicit triple to test
Some host targets are managing to get through MIR parsing
without constructing their MachineFunctionInfo.

Fixes at least SystemZ and SPARC (issue 58768)
2022-11-02 08:31:38 -07:00
Matt Arsenault
4e21bc0c40 llvm-reduce: Drop guessing output format based on file extension 2022-10-31 20:35:08 -07:00
Matt Arsenault
3c436ab0d4 llvm-reduce: Support emitting bitcode for final result
Previously, this unconditionally emitted text IR. I ran
into a bug that manifested in broken disassembly, so the
desired output was the bitcode format. If the input format
was binary bitcode, the requested output file ends in .bc,
or an explicit -output-bitcode option was used, emit bitcode.
2022-10-31 20:35:08 -07:00
Matt Arsenault
f02bc70c7d 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.
2022-10-28 17:07:26 -07:00
Matt Arsenault
45a91c1521 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).
2022-10-28 17:07:26 -07:00
Matt Arsenault
bc405e37ee 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.
2022-10-28 17:07:26 -07:00
Matt Arsenault
df60f0bbef llvm-reduce: Remove unnecessary arguments from test 2022-10-24 22:32:31 -07:00
Matt Arsenault
08d1c43c70 llvm-reduce: Add conditional reduction passes
Copy this technique from bugpoint. Before trying to blindly
delete blocks, try to fold branch conditions. This intuitively
makes more sense for a faster reduction, since you can find
dead paths in the function to prune out before trying to bisect
blocks in source order.

Seems to provide some speedup on my multi-hour reduction samples.

This does have the potential to produce testcases with unreachable
blocks. This is already a problem with the existing block
reduction pass. I'm struggling dealing with invalid reductions
in these cases, so in the future this should probably start
deleting those. However, I do sometimes try to reduce failures
in code that becomes unreachable, so I'm not totally sure
what to do here.
2022-10-23 15:39:39 -07:00
Matt Arsenault
3e6f7ab867 llvm-reduce: Fix opcode reduction leaving behind dead instructions
ce3c3cb2912425bb4367bfbe9a4c68a6d6f0a04a broke this by
speculatively making transforms before checking shouldKeep.
Originally I tried to roll back changes to the IR, but it's probably
best to not touch it before querying.
2022-10-23 15:37:03 -07:00
Matt Arsenault
827f01c275 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.
2022-10-23 15:16:55 -07:00