summaryrefslogtreecommitdiff
path: root/llvm/tools/bugpoint/OptimizerDriver.cpp
AgeCommit message (Collapse)Author
2025-11-20Revert "[NFC][bugpoint] Namespace cleanup in `bugpoint`" (#168961)Rahul Joshi
Reverts llvm/llvm-project#168921 Causes build failures.
2025-11-20[NFC][bugpoint] Namespace cleanup in `bugpoint` (#168921)Rahul Joshi
Add declaration of command line options to BugDriver.h and remove extern declarations in individual .cpp files.
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-10-11Move the preserve-{bc,ll}-uselistorder options out of individual tools, make ↵Mingjie Xu
them global defaults for AsmWriter and BitcodeWriter (#160079) This patch moves the `preserve-bc-uselistorder` and `preserve-ll-uselistorder` options out of individual tools(opt, llvm-as, llvm-dis, llvm-link, llvm-extract) and make them global defaults for AsmWriter and BitcodeWriter. These options are useful when we use `-print-*` options to dump LLVM IR.
2025-03-29[bugpoint] Avoid repeated hash lookups (NFC) (#133616)Kazu Hirata
2025-03-03[NFC]Make file-local cl::opt global variables static (#126486)chrisPyr
#125983
2024-01-19[tools] Use SmallString::operator std::string (NFC)Kazu Hirata
2023-03-16[opt] Rename -enable-new-pm -> -bugpoint-enable-legacy-pmArthur Eubanks
-enable-new-pm is no longer necessary except for bugpoint. Make the name more clunky so it hopefully won't be used. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D146103
2022-12-01Support: Convert Program APIs to std::optionalMatt Arsenault
2022-06-05Remove unneeded cl::ZeroOrMore for cl::opt/cl::list optionsFangrui Song
2022-01-07[llvm] Use true/false instead of 1/0 (NFC)Kazu Hirata
Identified with modernize-use-bool-literals.
2021-09-02[clangd, llvm] Remove redundant calls to c_str() (NFC)Kazu Hirata
Identified with readability-redundant-string-cstr.
2020-09-15[Bugpoint][NewPM] Pin bugpoint to legacy PMArthur Eubanks
Bugpoint has lots of assumptions and hacks around the legacy PM, put off migrating it to NPM until later. Fixes tests under BugPoint under NPM. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D87655
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.
2019-09-30[bugpoint] Update runPasses to take ArrayRef instead of a pointer (NFC)Florian Hahn
This makes it slightly easier to pass extra arguments to runPasses and simplifies the code slightly. Reviewers: efriedma, bogner, dblaikie, diegotf, hiraditya Reviewed By: dblaikie, hiraditya Differential Revision: https://reviews.llvm.org/D68228 llvm-svn: 373265
2019-08-05Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFCFangrui Song
F_{None,Text,Append} are kept for compatibility since r334221. llvm-svn: 367800
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-12-10[bugpoint] Find 'opt', etc., in bugpoint directoryBrian Gesiak
Summary: When bugpoint attempts to find the other executables it needs to run, such as `opt` or `clang`, it tries searching the user's PATH. However, in many cases, the 'bugpoint' executable is part of an LLVM build, and the 'opt' executable it's looking for is in that same directory. Many LLVM tools handle this case by using the `Paths` parameter of `llvm::sys::findProgramByName`, passing the parent path of the currently running executable. Do this same thing for bugpoint. However, to preserve the current behavior exactly, first search the user's PATH, and then search for 'opt' in the directory containing 'bugpoint'. Test Plan: `check-llvm`. Many of the existing bugpoint tests no longer need to use the `--opt-command` option as a result of these changes. Reviewers: MatzeB, silvas, davide Reviewed By: MatzeB, davide Subscribers: davide, llvm-commits Differential Revision: https://reviews.llvm.org/D54884 llvm-svn: 348734
2018-06-12Refactor ExecuteAndWait to take StringRefs.Zachary Turner
This simplifies some code which had StringRefs to begin with, and makes other code more complicated which had const char* to begin with. In the end, I think this makes for a more idiomatic and platform agnostic API. Not all platforms launch process with null terminated c-string arrays for the environment pointer and argv, but the api was designed that way because it allowed easy pass-through for posix-based platforms. There's a little additional overhead now since on posix based platforms we'll be takign StringRefs which were constructed from null terminated strings and then copying them to null terminate them again, but from a readability and usability standpoint of the API user, I think this API signature is strictly better. llvm-svn: 334518
2018-05-14Rename DEBUG macro to LLVM_DEBUG.Nicola Zaghen
The DEBUG() macro is very generic so it might clash with other projects. The renaming was done as follows: - git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g' - git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM - Manual change to APInt - Manually chage DOCS as regex doesn't match it. In the transition period the DEBUG() macro is still present and aliased to the LLVM_DEBUG() one. Differential Revision: https://reviews.llvm.org/D43624 llvm-svn: 332240
2018-02-14Change the BugDriver to store the current module with std::unique_ptr.Rafael Espindola
While there, change a bunch of helper functions to take references to avoid adding calls to get(). This should conclude the bugpoint yak shaving. llvm-svn: 325177
2018-02-14Pass a reference to a module to the bitcode writer.Rafael Espindola
This simplifies most callers as they are already using references or std::unique_ptr. llvm-svn: 325155
2018-02-09[bugpoint] Report non-existent opt binaryVedant Kumar
Bugpoint will keep going even if the opt binary it's given doesn't exist. It should at least alert the user, so it's clear why reductions are failing. llvm-svn: 324713
2018-02-09[bugpoint] Delete a dead cl::opt (-child-output)Vedant Kumar
This option isn't used anywhere, as far as I can tell. llvm-svn: 324704
2017-12-13Remove redundant includes from tools.Michael Zolotukhin
llvm-svn: 320631
2017-11-22Remove unnecessary code.Rafael Espindola
There is already an RAII in place to discard the temporary. llvm-svn: 318868
2017-11-16Convert another use of createUniqueFile to TempFile::create.Rafael Espindola
This one requires a new small feature in TempFile: the ability to keep the temporary file with the temporary name. llvm-svn: 318458
2017-11-16Convert another use of createUniqueFile to TempFile::create.Rafael Espindola
llvm-svn: 318427
2017-11-16Convert a use of createUniqueFile to TempFile::create.Rafael Espindola
llvm-svn: 318361
2017-09-23[Support] Rename tool_output_file to ToolOutputFile, NFCReid Kleckner
This class isn't similar to anything from the STL, so it shouldn't use the STL naming conventions. llvm-svn: 314050
2017-09-13Convenience/safety fix for llvm::sys::Execute(And|No)WaitAlexander Kornienko
Summary: Change the type of the Redirects parameter of llvm::sys::ExecuteAndWait, ExecuteNoWait and other APIs that wrap them from `const StringRef **` to `ArrayRef<Optional<StringRef>>`, which is safer and simplifies the use of these APIs (no more local StringRef variables just to get a pointer to). Corresponding clang changes will be posted as a separate patch. Reviewers: bkramer Reviewed By: bkramer Subscribers: vsk, llvm-commits Differential Revision: https://reviews.llvm.org/D37563 llvm-svn: 313155
2017-06-09bugpoint: disabling symbolication of bugpoint-executed programsDavid Blaikie
Initial implementation - needs similar work/testing for other tools bugpoint invokes (llc, lli I think, maybe more). Alternatively (as suggested by chandlerc@) an environment variable could be used. This would allow the option to pass transparently through user scripts, pass to compilers if they happened to be LLVM-ish, etc. I worry a bit about using cl::opt in the crash handling code - LLVM might crash early, perhaps before the cl::opt is properly initialized? Or at least before arguments have been parsed? - should be OK since it defaults to "pretty", so if the crash is very early in opt parsing, etc, then crash reports will still be symbolized. I shyed away from doing this with an environment variable when I realized that would require copying the existing environment and appending the env variable of interest. But it seems there's no existing LLVM API for accessing the environment (even the Support tests for process launching have their own ifdefs for getting the environment). It could be added, but seemed like a higher bar/untested codepath to actually add environment variables. Most importantly, this reduces the runtime of test/BugPoint/metadata.ll in a split-dwarf Debug build from 1m34s to 6.5s by avoiding a lot of symbolication. (this wasn't a problem for non-split-dwarf builds only because the executable was too large to map into memory (due to bugpoint setting a 400MB memory (including address space - not sure why? Going to remove that) limit on the child process) so symbolication would fail fast & wouldn't spend all that time parsing DWARF, etc) Reviewers: chandlerc, dannyb Differential Revision: https://reviews.llvm.org/D33804 llvm-svn: 305056
2017-06-01Prefer static namespace-scoped variables over anon namespacing per style guideDavid Blaikie
Also for consistency with the immediately preceeding variable definition. llvm-svn: 304457
2016-11-11Split Bitcode/ReaderWriter.h into separate reader and writer headersTeresa Johnson
Summary: Split ReaderWriter.h which contains the APIs into both the BitReader and BitWriter libraries into BitcodeReader.h and BitcodeWriter.h. This is to address Chandler's concern about sharing the same API header between multiple libraries (BitReader and BitWriter). That concern is why we create a single bitcode library in our downstream build of clang, which led to r286297 being reverted as it added a dependency that created a cycle only when there is a single bitcode library (not two as in upstream). Reviewers: mehdi_amini Subscribers: dlj, mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D26502 llvm-svn: 286566
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-06-29[bugpoint] Simplify code by moving exception to only callerPhilip Reames
llvm-svn: 274083
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-15uselistorder: Pull the bit through WriteToBitcodFile()Duncan P. N. Exon Smith
Change the callers of `WriteToBitcodeFile()` to pass `true` or `shouldPreserveBitcodeUseListOrder()` explicitly. I left the callers that want to send `false` alone. I'll keep pushing the bit higher until hopefully I can delete the global `cl::opt` entirely. llvm-svn: 234957
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-11-07Fix style.Michael J. Spencer
llvm-svn: 221547
2014-11-04Use findProgramByName.Michael J. Spencer
llvm-svn: 221221
2014-08-26Return a std::unique_ptr from parseInputFile and propagate. NFC.Rafael Espindola
The memory management in BugPoint is fairly convoluted, so this just unwraps one layer by changing the return type of functions that always return owned Modules. llvm-svn: 216464
2014-08-25Modernize raw_fd_ostream's constructor a bit.Rafael Espindola
Take a StringRef instead of a "const char *". Take a "std::error_code &" instead of a "std::string &" for error. A create static method would be even better, but this patch is already a bit too big. llvm-svn: 216393
2014-06-13Remove 'using std::error_code' from tools.Rafael Espindola
llvm-svn: 210876
2014-06-12Don't use 'using std::error_code' in include/llvm.Rafael Espindola
This should make sure that most new uses use the std prefix. llvm-svn: 210835
2014-04-25[C++] Use 'nullptr'. Tools edition.Craig Topper
llvm-svn: 207176
2014-04-21[Modules] Make Support/Debug.h modular. This requires it to not changeChandler Carruth
behavior based on other files defining DEBUG_TYPE, which means it cannot define DEBUG_TYPE at all. This is actually better IMO as it forces folks to define relevant DEBUG_TYPEs for their files. However, it requires all files that currently use DEBUG(...) to define a DEBUG_TYPE if they don't already. I've updated all such files in LLVM and will do the same for other upstream projects. This still leaves one important change in how LLVM uses the DEBUG_TYPE macro going forward: we need to only define the macro *after* header files have been #include-ed. Previously, this wasn't possible because Debug.h required the macro to be pre-defined. This commit removes that. By defining DEBUG_TYPE after the includes two things are fixed: - Header files that need to provide a DEBUG_TYPE for some inline code can do so by defining the macro before their inline code and undef-ing it afterward so the macro does not escape. - We no longer have rampant ODR violations due to including headers with different DEBUG_TYPE definitions. This may be mostly an academic violation today, but with modules these types of violations are easy to check for and potentially very relevant. Where necessary to suppor headers with DEBUG_TYPE, I have moved the definitions below the includes in this commit. I plan to move the rest of the DEBUG_TYPE macros in LLVM in subsequent commits; this one is big enough. The comments in Debug.h, which were hilariously out of date already, have been updated to reflect the recommended practice going forward. llvm-svn: 206822
2014-02-24Replace the F_Binary flag with a F_Text one.Rafael Espindola
After this I will set the default back to F_None. The advantage is that before this patch forgetting to set F_Binary would corrupt a file on windows. Forgetting to set F_Text produces one that cannot be read in notepad, which is a better failure mode :-) llvm-svn: 202052
2014-01-13[cleanup] Move the Dominators.h and Verifier.h headers into the IRChandler Carruth
directory. These passes are already defined in the IR library, and it doesn't make any sense to have the headers in Analysis. Long term, I think there is going to be a much better way to divide these matters. The dominators code should be fully separated into the abstract graph algorithm and have that put in Support where it becomes obvious that evn Clang's CFGBlock's can use it. Then the verifier can manually construct dominance information from the Support-driven interface while the Analysis library can provide a pass which both caches, reconstructs, and supports a nice update API. But those are very long term, and so I don't want to leave the really confusing structure until that day arrives. llvm-svn: 199082
2013-08-05[bugpoint] Allow the user to specify the path to opt on the commandline.Michael Gottesman
llvm-svn: 187739