summaryrefslogtreecommitdiff
path: root/llvm/tools/bugpoint/bugpoint.cpp
AgeCommit message (Collapse)Author
2025-10-13[NFC][LLVM] Code cleanup in bugpoint (#162909)Rahul Joshi
- Move file local variables and functions out of anonymous namespace and mark them static. - Change a few function names to conform to LLVM coding standard (camelCase). - Add end of namespace comments for anonymous namespaces.
2025-07-23Slightly improve the getenv("bar") linking problemLuke Drummond
There's been a variation of the following in the code since 2005: if (unoptimizable_true) return; use_this_symbol_to_force_linking(); // unreachable but never removed Way back in 00d5508496c it was the win32 call `GetCurrentProcess` but switched to `getenv("bar")` fairly soon after in 63e504ff43. While that pulled in fewer dependencies and made the code portable, it's a bit of a weird construct. The environment variable used for the `getenv` call is "bar", which is particularly weird to see fly past when you run `ltrace` on a binary linked against LLVM. In this patch I don't try to replace this construct wholesale - it's still required for architectural reasons I'm not able to tackle right now, but I did try and make it slightly less weird and opaque: - It gives the construct a name - The environment variable hints where this comes from and that its value is ignored Combined, this should be a bit of improvement for the next person who wonders what LLVM is up to when they trace their process or see smatterings of `getenv("bar")` dotted around the source.
2023-03-13[PassManagerBuilder] Remove PassManagerBuilderArthur Eubanks
PassManagerBuilder is dead, long live PassBuilder! bugpoint's -O# are now useless (and probably have been for a while given the number of passes we've removed from PassManagerBuilder). Perhaps they'll be revived if bugpoint ever works with the new PM. Reviewed By: nikic, MaskRay Differential Revision: https://reviews.llvm.org/D145835
2023-02-09[Inliner] Remove legacy simple inlinerArthur Eubanks
It's part of the optimization pipeline, of which the legacy pass manager version is deprecated.
2022-11-15[AggressiveInstCombine] Remove legacy PM passArthur Eubanks
As part of legacy PM optimization pipeline removal. This shouldn't be used in codegen pipelines so it should be ok to remove. Reviewed By: asbirlea Differential Revision: https://reviews.llvm.org/D137116
2022-10-25[Instrumentation] Remove legacy passesArthur Eubanks
Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D136615
2022-10-21[ObjCARC] Remove legacy PM versions of optimization passesArthur Eubanks
This doesn't touch objc-arc-contract because that's in the codegen pipeline. However, this does move its corresponding initialize function into initializeCodegen(). Reviewed By: asbirlea Differential Revision: https://reviews.llvm.org/D135041
2022-07-07Remove unnecessary includes of ManagedStatic.hNicolai Hähnle
Differential Revision: https://reviews.llvm.org/D129115
2022-06-04Remove unneeded cl::ZeroOrMore for cl::list optionsFangrui Song
2022-04-18[LegacyPM] Remove ThinLTO/LTO pipelinesArthur Eubanks
Using the legacy PM for the optimization pipeline was deprecated in 13.0.0. Following recent changes to remove non-core features of the legacy PM/optimization pipeline, remove the (Thin)LTO pipelines. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D123882
2021-11-02Revert "[NFC] Remove LinkAll*.h"Arthur Eubanks
This reverts commit fe364e5dc78c58a915986d9a44cfd65f919a00c2. Causes breakages, e.g. https://lab.llvm.org/buildbot/#/builders/188/builds/5266
2021-11-02[NFC] Remove LinkAll*.hArthur Eubanks
These were added to prevent functions from being removed by WPO. But that doesn't make sense, correct WPO will not remove functions we actually use. I noticed these because compiling cc1_main.cpp was pulling in random LLVM pass headers. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D112971
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2020-01-02Generalize the pass registration mechanism used by Polly to any third-party toolserge_sans_paille
There's quite a lot of references to Polly in the LLVM CMake codebase. However the registration pattern used by Polly could be useful to other external projects: thanks to that mechanism it would be possible to develop LLVM extension without touching the LLVM code base. This patch has two effects: 1. Remove all code specific to Polly in the llvm/clang codebase, replaicing it with a generic mechanism 2. Provide a generic mechanism to register compiler extensions. A compiler extension is similar to a pass plugin, with the notable difference that the compiler extension can be configured to be built dynamically (like plugins) or statically (like regular passes). As a result, people willing to add extra passes to clang/opt can do it using a separate code repo, but still have their pass be linked in clang/opt as built-in passes. Differential Revision: https://reviews.llvm.org/D61446
2019-11-13Sink all InitializePasses.h includesReid Kleckner
This file lists every pass in LLVM, and is included by Pass.h, which is very popular. Every time we add, remove, or rename a pass in LLVM, it caused lots of recompilation. I found this fact by looking at this table, which is sorted by the number of times a file was changed over the last 100,000 git commits multiplied by the number of object files that depend on it in the current checkout: recompiles touches affected_files header 342380 95 3604 llvm/include/llvm/ADT/STLExtras.h 314730 234 1345 llvm/include/llvm/InitializePasses.h 307036 118 2602 llvm/include/llvm/ADT/APInt.h 213049 59 3611 llvm/include/llvm/Support/MathExtras.h 170422 47 3626 llvm/include/llvm/Support/Compiler.h 162225 45 3605 llvm/include/llvm/ADT/Optional.h 158319 63 2513 llvm/include/llvm/ADT/Triple.h 140322 39 3598 llvm/include/llvm/ADT/StringRef.h 137647 59 2333 llvm/include/llvm/Support/Error.h 131619 73 1803 llvm/include/llvm/Support/FileSystem.h Before this change, touching InitializePasses.h would cause 1345 files to recompile. After this change, touching it only causes 550 compiles in an incremental rebuild. Reviewers: bkramer, asbirlea, bollu, jdoerfert Differential Revision: https://reviews.llvm.org/D70211
2019-09-17[bugpoint] Add support for -Oz and properly enable -Os.Florian Hahn
This patch adds -Oz as option and also properly enables support for -Os. Currently, the existing check for -Os is dead, because the enclosing if only checks of O1, O2 and O3. There is still a difference between the -Oz pipeline compared to opt, but I have not been able to track that down yet. Reviewers: bogner, sebpop, efriedma Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D67593 llvm-svn: 372079
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-04-30IWYU for llvm-config.h in llvm, additions.Nico Weber
See r331124 for how I made a list of files missing the include. I then ran this Python script: for f in open('filelist.txt'): f = f.strip() fl = open(f).readlines() found = False for i in xrange(len(fl)): p = '#include "llvm/' if not fl[i].startswith(p): continue if fl[i][len(p):] > 'Config': fl.insert(i, '#include "llvm/Config/llvm-config.h"\n') found = True break if not found: print 'not found', f else: open(f, 'w').write(''.join(fl)) and then looked through everything with `svn diff | diffstat -l | xargs -n 1000 gvim -p` and tried to fix include ordering and whatnot. No intended behavior change. llvm-svn: 331184
2018-04-24[AggressiveInstCombine] Add library initializer routine for ↵Craig Topper
AggressiveInstCombine library. Use it in bugpoint and llvm-opt-fuzzer to match regular InstCombine. This should make aggressive instcombine usable with these tools. llvm-svn: 330663
2018-04-13Define InitLLVM to do common initialization all at once.Rui Ueyama
We have a few functions that virtually all command wants to run on process startup/shutdown. This patch adds InitLLVM class to do that all at once, so that we don't need to copy-n-paste boilerplate code to each llvm command's main() function. Differential Revision: https://reviews.llvm.org/D45602 llvm-svn: 330046
2017-09-01Fix check-llvm on kernel 4.9+ with asan or msanVitaly Buka
Summary: Before https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?h=v4.9.46&id=84638335900f1995495838fe1bd4870c43ec1f67 test worked because memory allocated with mmap was not counted against RLIMIT_DATA. Reviewers: eugenis Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D37366 llvm-svn: 312303
2017-06-26[bugpoint] Do not initialize disassembler passesTobias Grosser
We added the initilization of disassembler passes in r306208 with the goal to bring bugpoint in line with 'opt'. However, 'opt' does itself not initialize dissassembler passes. As our goal was consistency, we drop the initialization of dissassembler passes again from bugpoint. Thanks to Chandler for pointing this out! llvm-svn: 306275
2017-06-24Ensure backends available in 'opt' are also available in 'bugpoint'Tobias Grosser
This patch links LLVM back-ends into bugpoint the same way they are already available in 'opt' and 'clang'. This resolves an inconsistency that allowed the use of LLVM backends in loadable modules that run in 'opt', but that would prevent the debugging of these modules with bugpoint due to unavailable / unresolved symbols. For e.g. In D31859, Polly requires the NVPTX back-end. Reviewers: hfinkel, bogner, chandlerc, grosser, Meinersbur Subscribers: bollu, mgorny, grosser, Meinersbur Tags: #polly Contributed by: Singapuram Sanjay Differential Revision: https://reviews.llvm.org/D32003 llvm-svn: 306208
2017-03-21Do not inline hot callsites for samplepgo in thinlto compile phase.Dehao Chen
Summary: Because SamplePGO passes will be invoked twice in ThinLTO build: once at compile phase, the other at backend. We want to make sure the IR at the 2nd phase matches the hot part in profile, thus we do not want to inline hot callsites in the first phase. Reviewers: tejohnson, eraman Reviewed By: tejohnson Subscribers: mehdi_amini, llvm-commits, Prazek Differential Revision: https://reviews.llvm.org/D31201 llvm-svn: 298428
2016-09-06bugpoint: Return Errors instead of passing around stringsJustin Bogner
This replaces the threading of `std::string &Error` through all of these APIs with checked Error returns instead. There are very few places here that actually emit any errors right now, but threading the APIs through will allow us to replace a bunch of exit(1)'s that are scattered through this code with proper error handling. This is more or less NFC, but does move around where a couple of error messages are printed out. llvm-svn: 280720
2016-09-06Revert "bugpoint: Stop threading errors through APIs that never fail"Justin Bogner
This isn't the right thing to do - it turns out a number of the APIs that "never fail" just exit(1) if something bad happens. We can and should thread Error through this instead. That diff will make more sense with this reverted. Sorry for the noise. This reverts r280690 llvm-svn: 280691
2016-09-06bugpoint: Stop threading errors through APIs that never failJustin Bogner
This simplifies ListReducer and most of its subclasses by removing the std::string &Error that was threaded through all of them but almost never used. If we end up needing error handling in more places here we can reinstate it using llvm::Error instead of these unwieldy strings. The 2 cases (out of 12) that actually can hit the error cases are a little bit awkward now, but those will clean up as I refactor this API further. llvm-svn: 280690
2016-09-02bugpoint: clang-format all of bugpoint. NFCJustin Bogner
I'm going to clean up the APIs here a bit and touch many many lines anyway. llvm-svn: 280450
2016-08-17[PM] Port the always inliner to the new pass manager in a much moreChandler Carruth
minimal and boring form than the old pass manager's version. This pass does the very minimal amount of work necessary to inline functions declared as always-inline. It doesn't support a wide array of things that the legacy pass manager did support, but is alse ... about 20 lines of code. So it has that going for it. Notably things this doesn't support: - Array alloca merging - To support the above, bottom-up inlining with careful history tracking and call graph updates - DCE of the functions that become dead after this inlining. - Inlining through call instructions with the always_inline attribute. Instead, it focuses on inlining functions with that attribute. The first I've omitted because I'm hoping to just turn it off for the primary pass manager. If that doesn't pan out, I can add it here but it will be reasonably expensive to do so. The second should really be handled by running global-dce after the inliner. I don't want to re-implement the non-trivial logic necessary to do comdat-correct DCE of functions. This means the -O0 pipeline will have to be at least 'always-inline,global-dce', but that seems reasonable to me. If others are seriously worried about this I'd like to hear about it and understand why. Again, this is all solveable by factoring that logic into a utility and calling it here, but I'd like to wait to do that until there is a clear reason why the existing pass-based factoring won't work. The final point is a serious one. I can fairly easily add support for this, but it seems both costly and a confusing construct for the use case of the always inliner running at -O0. This attribute can of course still impact the normal inliner easily (although I find that a questionable re-use of the same attribute). I've started a discussion to sort out what semantics we want here and based on that can figure out if it makes sense ta have this complexity at O0 or not. One other advantage of this design is that it should be quite a bit faster due to checking for whether the function is a viable candidate for inlining exactly once per function instead of doing it for each call site. Anyways, hopefully a reasonable starting point for this pass. Differential Revision: https://reviews.llvm.org/D23299 llvm-svn: 278896
2016-07-31[bugpoint] Add a -Os optionDavid Majnemer
llvm-svn: 277295
2016-06-09Search for llvm-symbolizer binary in the same directory as argv[0], beforeRichard Smith
looking for it along $PATH. This allows installs of LLVM tools outside of $PATH to find the symbolizer and produce pretty backtraces if they crash. llvm-svn: 272232
2016-04-14Remove every uses of getGlobalContext() in LLVM (but the C API)Mehdi Amini
At the same time, fixes InstructionsTest::CastInst unittest: yes you can leave the IR in an invalid state and exit when you don't destroy the context (like the global one), no longer now. This is the first part of http://reviews.llvm.org/D19094 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266379
2015-10-15[bugpoint] llvm-gcc doesn't exist anymore ...Davide Italiano
... so this comment is stale. Remove it. Range-loopify while here. llvm-svn: 250354
2015-08-18[PM/AA] Remove the last relics of the separate IPA library from LLVM,Chandler Carruth
folding the code into the main Analysis library. There already wasn't much of a distinction between Analysis and IPA. A number of the passes in Analysis are actually IPA passes, and there doesn't seem to be any advantage to separating them. Moreover, it makes it hard to have interactions between analyses that are both local and interprocedural. In trying to make the Alias Analysis infrastructure work with the new pass manager, it becomes particularly awkward to navigate this split. I've tried to find all the places where we referenced this, but I may have missed some. I have also adjusted the C API to continue to be equivalently functional after this change. Differential Revision: http://reviews.llvm.org/D12075 llvm-svn: 245318
2015-05-05[bugpoint] Increase default memory limit to 400MB to fix bugpoint tests.Daniel Sanders
I tracked down the bug to an unchecked malloc in SmallVectorBase::grow_pod(). This malloc is returning NULL on my machine when running under bugpoint but not when -enable-valgrind is given. llvm-svn: 236504
2015-04-15uselistorder: Remove the global bitsDuncan P. N. Exon Smith
Remove all the global bits to do with preserving use-list order by moving the `cl::opt`s to the individual tools that want them. There's a minor functionality change to `libLTO`, in that you can't send in `-preserve-bc-uselistorder=false`, but making that bit settable (if it's worth doing) should be through explicit LTO API. As a drive-by fix, I removed some includes of `UseListOrder.h` that were made unnecessary by recent commits. llvm-svn: 234973
2015-04-14IR: Set -preserve-bc-uselistorder=false by defaultDuncan P. N. Exon Smith
But keep it on by default in `llvm-as`, `opt`, `bugpoint`, `llvm-link`, `llvm-extract`, and `LTOCodeGenerator`. Part of PR5680. llvm-svn: 234921
2015-02-13[PM] Remove the old 'PassManager.h' header file at the top level ofChandler Carruth
LLVM's include tree and the use of using declarations to hide the 'legacy' namespace for the old pass manager. This undoes the primary modules-hostile change I made to keep out-of-tree targets building. I sent an email inquiring about whether this would be reasonable to do at this phase and people seemed fine with it, so making it a reality. This should allow us to start bootstrapping with modules to a certain extent along with making it easier to mix and match headers in general. The updates to any code for users of LLVM are very mechanical. Switch from including "llvm/PassManager.h" to "llvm/IR/LegacyPassManager.h". Qualify the types which now produce compile errors with "legacy::". The most common ones are "PassManager", "PassManagerBase", and "FunctionPassManager". llvm-svn: 229094
2014-10-16Delete -std-compile-opts.Rafael Espindola
These days -std-compile-opts was just a silly alias for -O3. llvm-svn: 219951
2014-08-21Handle inlining in populateLTOPassManager like in populateModulePassManager.Rafael Espindola
No functionality change. llvm-svn: 216178
2014-08-21Move DisableGVNLoadPRE from populateLTOPassManager to PassManagerBuilder.Rafael Espindola
llvm-svn: 216174
2014-08-05Don't internalize all but main by default.Rafael Espindola
This is mostly a cleanup, but it changes a fairly old behavior. Every "real" LTO user was already disabling the silly internalize pass and creating the internalize pass itself. The difference with this patch is for "opt -std-link-opts" and the C api. Now to get a usable behavior out of opt one doesn't need the funny looking command line: opt -internalize -disable-internalize -internalize-public-api-list=foo,bar -std-link-opts llvm-svn: 214919
2014-04-25[C++] Use 'nullptr'. Tools edition.Craig Topper
llvm-svn: 207176
2014-03-14static link polly into toolsSebastian Pop
llvm-svn: 203886
2014-03-08[C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper
class. llvm-svn: 203345
2014-03-04[Modules] Move the PassNameParser to the IR library as it deals in theChandler Carruth
PassInfo structures of the legacy pass manager. Also give it the Legacy prefix as it is not a particularly widely used header. llvm-svn: 202839
2014-02-19Fix typoTobias Grosser
Found by: Duncan P. N. Exon Smith <dexonsmith@apple.com> llvm-svn: 201726
2014-01-27Do not reference llvm-gcc from bugpointTobias Grosser
Reiterating: llvm-gcc is dead since a long time. llvm-svn: 200220
2014-01-15Whitespace.NAKAMURA Takumi
llvm-svn: 199305
2013-10-25[bugpoint] Increase the default memory limit for subprocesses to 300MB.Daniel Sanders
Summary: Currently shared library builds (BUILD_SHARED_LIBS=ON in cmake) fail three bugpoint tests (BugPoint/remove_arguments_test.ll, BugPoint/crash-narrowfunctiontest.ll, and BugPoint/metadata.ll). If I run the bugpoint commands that llvm-lit runs with without -silence-passes I see errors such as this: opt: error while loading shared libraries: libLLVMSystemZInfo.so: failed to map segment from shared object: Cannot allocate memory It seems that the increased size of the binaries in a shared library build is causing the subprocess to exceed the 100MB memory limit. This patch therefore increases the default limit to a level at which these tests pass. Reviewers: dsanders Reviewed By: dsanders CC: llvm-commits, rafael Differential Revision: http://llvm-reviews.chandlerc.com/D2013 llvm-svn: 193420