aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-reduce/llvm-reduce.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-05-23[llvm-reduce] Remove unused includes (NFC) (#141322)Kazu Hirata1-2/+0
These are identified by misc-include-cleaner. I've filtered out those that break builds. Also, I'm staying away from llvm-config.h, config.h, and Compiler.h, which likely cause platform- or compiler-specific build failures.
2025-04-10llvm-reduce: Link to command guide in help like bugpoint does (#134810)Matt Arsenault1-1/+5
2025-04-09[DebugInfo][RemoveDIs] Eliminate another debug-info variation flag (#133917)Jeremy Morse1-3/+0
The "preserve input debug-info format" flag allowed some tooling to opt into not seeing the new debug records yet, and to not autoupgrade. This was good at the time, but un-necessary now that we'll be ditching intrinsics shortly. It also hides errors now: verify-uselistorder was hardcoding this flag to on, and as a result it hasn't seen debug records before. Thus, we missed a uselistorder variation: constant-expressions such as GEPs can be contained within debug records and completely isolated from the value hierachy, see the metadata-use-uselistorder.ll test. These Values didn't get ordered, but were legitimate uses of constants like "i64 0", and we now run into difficulty handling that. The patch to AsmWriter seeks Values to order even through debug-info now. Finally there are a few intrinsics-tests relying on this flag that we can just delete, such as one in llvm-reduce and another few in the LocalTest unit tests. For the fast-isel test, it was added in https://reviews.llvm.org/D67703 explicitly for checking the size of blocks without debug-info and in 1525abb9c94 the codepath it tests moved towards being sunsetted. It'll be totally redundant once RemoveDIs is on permanently. Note that there's now no explicit test for the textual-IR autoupgrade path. I submit that we can rely on the thousands of .ll files where we've only been bothered to update the outputs, not the inputs, to debug records.
2025-04-02llvm-reduce: Change exit code for uninteresting inputs (#134021)Matt Arsenault1-1/+1
This makes it easier to reduce llvm-reduce with llvm-reduce to filter cases where the input reduced too much. Not sure if it's possible to test the exit code in lit.
2024-04-22[RemoveDIs] Preserve debug info format in llvm-reduce (#89220)Stephen Tozer1-13/+2
As the goal of LLVM reduce is to simplify the input file, it should not modify the debug info format - doing so by default would make it impossible to reduce an error that only occurs in the old format, for example (as briefly discussed at https://github.com/llvm/llvm-project/pull/86275). This patch uses the new "preserve debug info format" flag in llvm-reduce to prevent the input from being subtly transformed by llvm-reduce itself; this has no effect on any tools used for the interestingness check (i.e. if `opt` is invoked, it will still convert the reduced input to the new format by default), but simply ensures that the reduced file is strictly reduced rather than modified.
2024-02-08[NFC][RemoveDIs] Remove conditional compilation for RemoveDIs (#81149)Jeremy Morse1-6/+2
A colleague observes that switching the default value of LLVM_EXPERIMENTAL_DEBUGINFO_ITERATORS to "On" hasn't flipped the value in their CMakeCache.txt. This probably means that everyone with an existing build tree is going to not have support built in, meaning everyone in LLVM would need to clean+rebuild their worktree when we flip the switch on... which doesn't sound good. So instead, just delete the flag and everything it does, making everyone build and run ~400 lit tests in RemoveDIs mode. None of the buildbots have had trouble with this, so it Should Be Fine (TM). (Sending for review as this is changing various comments, and touches several different areas -- I don't want to get too punchy).
2024-01-23[llvm-reduce][DebugInfo] Support reducing non-instruction debug-info (#78995)Jeremy Morse1-0/+18
LLVM will shortly be able to represent variable locations without encoding information into intrinsics -- they'll be stored as DPValue objects instead. We'll still need to be able to llvm-reduce these variable location assignments just like we can with intrinsics today, thus, here's an llvm-reduce pass that enumerates and reduces the DPValue objects. The test for this is paradoxically written with dbg.value intrinsics: this is because we're changing all the core parts of LLVM to support this first, with the textual IR format coming last. Until that arrives, testing the llvm-reduce'ing of DPValues needs the added test using intrinsics. We should be able to drop the variable assignment using %alsoloaded using this method. As with the other llvm-reduce tests, I've got one set of check lines for making the reduction happen as desired, and the other set to check the final output.
2023-12-11[llvm] Use StringRef::{starts,ends}_with (NFC) (#74956)Kazu Hirata1-1/+1
This patch replaces uses of StringRef::{starts,ends}with with StringRef::{starts,ends}_with for consistency with std::{string,string_view}::{starts,ends}_with in C++20. I'm planning to deprecate and eventually remove StringRef::{starts,ends}with.
2023-12-03[llvm] Stop including vector (NFC)Kazu Hirata1-1/+0
Identified with clangd.
2023-01-20llvm-reduce: Reorganize some function locationsMatt Arsenault1-21/+1
Move things that are naturally methods of ReducerWorkItem to be methods of ReducerWorkItem in the same source file.
2023-01-19llvm-reduce: Trim includes and avoid using namespace in a headerMatt Arsenault1-0/+2
2023-01-17llvm-reduce: Add missing constsMatt Arsenault1-1/+1
2023-01-11Revert "llvm-reduce: Try to kill parallel workitems once we have a result."Matt Arsenault1-3/+2
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-11llvm-reduce: Try to kill parallel workitems once we have a result.Matt Arsenault1-2/+3
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-03llvm-reduce: Remove leftover commentMatt Arsenault1-1/+0
2023-01-03llvm-reduce: Refine missing argument behaviorMatt Arsenault1-8/+27
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.
2022-12-20llvm-reduce: Disable crash reports, symbolization and core dumpsMatt Arsenault1-1/+31
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-11-29llvm-reduce: Add some missing constsMatt Arsenault1-1/+1
2022-10-31llvm-reduce: Write bitcode temporary files for bitcode inputsMatt Arsenault1-1/+2
Most tools accept .ll or .bc inputs interchangably, but some don't. Default to writing temporary files that match the input. This will also aid reducing deserialization bugs.
2022-10-31llvm-reduce: Drop guessing output format based on file extensionMatt Arsenault1-6/+3
2022-10-31llvm-reduce: Support emitting bitcode for final resultMatt Arsenault1-50/+33
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-28llvm-reduce: Stop checking workitem is interesting before each passMatt Arsenault1-0/+11
Each delta pass run should have guaranteed the output is still interesting, so it should be pointless to recheck this each iteration. I have many issues that take multiple minutes to reproduce, so this ends up being a huge waste of time. Also, remove broken line counting. This never worked, since getLines was failing to open the temporary file which was just deleted.
2022-10-18[llvm-reduce] Unify pass loggingArthur Eubanks1-1/+1
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
2022-08-15[NFC][llvm-reduce] Use new pass manager for printing ThinLTO bitcodeArthur Eubanks1-14/+16
2022-06-30[llvm-reduce] Add support for LTO bitcode filesMatthew Voss1-11/+40
Adds support for reading and writing LTO bitcode files. - Emit a summary if the original bitcode file had a summary - Use split LTO units if the original bitcode file used them. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D127168
2022-06-21in the absense of the -max-pass-iterations command line options, makeJohn Regehr1-2/+2
llvm-reduce run its full pass sequence up to 5 times, instead of just once Differential Revision: https://reviews.llvm.org/D128284
2022-06-04Remove unneeded cl::ZeroOrMore for cl::list optionsFangrui Song1-1/+1
2022-06-03[tools] Forward declare classes & remove includesClemens Wasser1-0/+2
Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D120208
2022-04-27llvm-reduce: Support multiple MachineFunctionsMatt Arsenault1-4/+4
The current testcase I'm trying to reduce only reproduces with IPRA enabled and requires handling multiple functions. The only real difference vs. the IR is the extra indirect to look for the underlying MachineFunction, so treat the ReduceWorkItem as the module instead of the function. The ugliest piece of this is really the ugliness of MachineModuleInfo. It not only tracks actual module state, but has a number of transient fields used for isel and/or the asm printer. These shouldn't do any harm for the use here, though they should be separated out.
2022-04-27llvm-reduce: Try to parse triple/datalayout from moduleMatt Arsenault1-33/+15
This saves needing to specify -mtriple on nearly every use for MIR reduction.
2022-02-02[llvm-reduce] Display all relevant options in -helpMarkus Lavin1-13/+13
Previously the options category given to cl::HideUnrelatedOptions was local to llvm-reduce.cpp and as a result only options declared in that file were visible in the -help options listing. This was a bit unfortunate since there were several useful options declared in other files. This patch addresses that. Differential Revision: https://reviews.llvm.org/D118682
2022-01-21[llvm] Cleanup header dependencies in ADT and Supportserge-sans-paille1-0/+1
The cleanup was manual, but assisted by "include-what-you-use". It consists in 1. Removing unused forward declaration. No impact expected. 2. Removing unused headers in .cpp files. No impact expected. 3. Removing unused headers in .h files. This removes implicit dependencies and is generally considered a good thing, but this may break downstream builds. I've updated llvm, clang, lld, lldb and mlir deps, and included a list of the modification in the second part of the commit. 4. Replacing header inclusion by forward declaration. This has the same impact as 3. Notable changes: - llvm/Support/TargetParser.h no longer includes llvm/Support/AArch64TargetParser.h nor llvm/Support/ARMTargetParser.h - llvm/Support/TypeSize.h no longer includes llvm/Support/WithColor.h - llvm/Support/YAMLTraits.h no longer includes llvm/Support/Regex.h - llvm/ADT/SmallVector.h no longer includes llvm/Support/MemAlloc.h nor llvm/Support/ErrorHandling.h You may need to add some of these headers in your compilation units, if needs be. As an hint to the impact of the cleanup, running clang++ -E -Iinclude -I../llvm/include ../llvm/lib/Support/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l before: 8000919 lines after: 7917500 lines Reduced dependencies also helps incremental rebuilds and is more ccache friendly, something not shown by the above metric :-) Discourse thread on the topic: https://llvm.discourse.group/t/include-what-you-use-include-cleanup/5831
2022-01-10allow llvm-reduce, if asked, to run its set of passes more than once, taking ↵John Regehr1-1/+7
longer to finish but also potentially resulting in a smaller reduced file.
2021-11-02Recommit "[llvm-reduce] Add MIR support"Markus Lavin1-25/+61
(Second try. Need to link against CodeGen and MC libs.) The llvm-reduce tool has been extended to operate on MIR (import, clone and export). Current limitation is that only a single machine function is supported. A single reducer pass that operates on machine instructions (while on SSA-form) has been added. Additional MIR specific reducer passes can be added later as needed. Differential Revision: https://reviews.llvm.org/D110527
2021-11-02Revert "[llvm-reduce] Add MIR support"Markus Lavin1-61/+25
This reverts commit bc2773cb1bdfacfda773eb492e7b0cc65a78cda6. Broke the clang-ppc64le-linux-multistage build. Reverting while I investigate.
2021-11-02[llvm-reduce] Add MIR supportMarkus Lavin1-25/+61
The llvm-reduce tool has been extended to operate on MIR (import, clone and export). Current limitation is that only a single machine function is supported. A single reducer pass that operates on machine instructions (while on SSA-form) has been added. Additional MIR specific reducer passes can be added later as needed. Differential Revision: https://reviews.llvm.org/D110527
2021-10-10[NFC][llvm-reduce] Cleanup typesArthur Eubanks1-13/+8
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
2021-07-22[llvm][tools] Hide remaining unrelated llvm- tool optionsTimm Bäder1-0/+1
Differential Revision: https://reviews.llvm.org/D106430
2021-05-25[llvm-reduce] Exit when input module is malformedLangston Barrett1-0/+4
The parseInputFile function returns an empty unique_ptr to signal an error, like when the input file doesn't exist, or is malformed. In this case, the tool should exit immediately rather than segfault by dereferencing the unique_ptr later. Reviewed By: aeubanks Differential Revision: https://reviews.llvm.org/D102891
2021-04-30[llvm-reduce] Add flag to only run specific passesArthur Eubanks1-0/+11
Reviewed By: fhahn, hans Differential Revision: https://reviews.llvm.org/D101278
2021-04-01[llvm-reduce] Add header guards and fix clang-tidy warningsSamuel1-3/+3
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
2020-08-22[llvm-reduce] make llvm-reduce save the best reduction it has when it crashesTyker1-15/+18
This helps with both debugging llvm-reduce and sometimes getting usefull result even if llvm-reduce crashes Reviewed By: lebedev.ri Differential Revision: https://reviews.llvm.org/D85996
2020-07-22[NFC][Reduce] Group llvm-reduce options into a group, uncluttering --helpRoman Lebedev1-7/+16
2019-12-05llvm-reduce: Add a space to an option's --helpGeorge Burgess IV1-1/+1
Otherwise, we get "filewith".
2019-09-12PR43278: llvm-reduce: Use temporary file names (and ToolOutputFile) rather ↵David Blaikie1-4/+9
than unique ones - to ensure they're cleaned up This modifies the tool somewhat to only create files when about to run the "interestingness" test, and delete them immediately after - this means some more files will be created sometimes (when "double checking" work - which should probably be fixed/avoided anyway). This now creates temporary files, rather than only unique ones, and also uses ToolOutputFile (without ever calling "keep") to ensure the files are deleted as soon as the interestingness test is run. llvm-svn: 371696
2019-09-10llvm-reduce: Simplify testing using -implicit-check-notDavid Blaikie1-2/+0
Also fix llvm-reduce to use the specified output file name directly, without appending '.ll' to the name. llvm-svn: 371555
2019-08-15[Bugpoint redesign] Output option can now print to STDOUTDiego Trevino Ferrer1-10/+15
Summary: This also changes all the outs() statements to errs() so the output and progress streams don't get mixed. This has been added because D64176 had flaky tests, which I believe were because the reduced file was being catted into `FileCheck`, instead of being pass from STDOUT directly. Reviewers: chandlerc, dblaikie, xbolva00 Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66314 llvm-svn: 369060
2019-08-08Added Delta IR Reduction ToolDiego Trevino Ferrer1-0/+106
Summary: Tool parses input IR file, and runs the delta debugging algorithm to reduce the functions inside the input file. Reviewers: alexshap, chandlerc Subscribers: mgorny, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63672 > llvm-svn: 368071 llvm-svn: 368358
2019-08-07Revert Added Delta IR Reduction ToolDiego Trevino Ferrer1-105/+0
This reverts r368071 (git commit a2584978f5bb41973d65a145b0d9459b81e3ac6d) llvm-svn: 368217
2019-08-07Added Delta IR Reduction ToolDiego Trevino Ferrer1-0/+105
Summary: Tool parses input IR file, and runs the delta debugging algorithm to reduce the functions inside the input file. Reviewers: alexshap, chandlerc Subscribers: mgorny, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63672 > llvm-svn: 368071 llvm-svn: 368214