aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-lto2/llvm-lto2.cpp
AgeCommit message (Collapse)AuthorFilesLines
7 days[llvm-lto2] Replace std::atomic_init with brace initiation. NFC (#143274)scuzqy1-2/+1
In C++ 20, std::atomic_init is deprecated. This patch replaces call to std::atomic_init with brace initiation.
7 days[llvm-lto2] Added version command for llvm-lto2 (#148866)Faith Rivera1-0/+4
Previously, the only way to check version for llvm-lto2 was to add version as a subcommand: `llvm-lto2 run --version`. This adds version as a main command for llvm-lto2 for more intuitive access. You can now check version with the command `llvm-lto2 --version`.
2025-06-13llvm-lto2: Add print-guid subcommand.Peter Collingbourne1-1/+7
This is useful for debugging ThinLTO issues. Reviewers: teresajohnson Reviewed By: teresajohnson Pull Request: https://github.com/llvm/llvm-project/pull/143992
2025-05-23[DTLTO][LLVM] Integrated Distributed ThinLTO (DTLTO) (#127749)bd1976bris1-1/+35
This patch adds initial support for Integrated Distributed ThinLTO (DTLTO) in LLVM, which manages distribution internally during the traditional link step. This enables compatibility with any build system that supports in-process ThinLTO. In contrast, existing approaches to distributed ThinLTO, which split the thin-link (--thinlto-index-only), backend compilation, and final link into separate steps, require build system support, e.g. Bazel. This patch implements the core DTLTO mechanism, which enables delegation of ThinLTO backend jobs to an external process (the distributor). The distributor can then manage job distribution through systems like Incredibuild. A generic JSON interface is used to communicate with the distributor, allowing for the creation of new distributors (and thus integration with different distribution systems) without modifying LLVM. Please see llvm/docs/dtlto.rst for more details. RFC: https://discourse.llvm.org/t/rfc-integrated-distributed-thinlto/69641 Design Review: https://github.com/llvm/llvm-project/pull/126654
2025-04-22Modify the localCache API to require an explicit commit on CachedFile… ↵anjenner1-1/+3
(#136121) …Stream. CachedFileStream has previously performed the commit step in its destructor, but this means its only recourse for error handling is report_fatal_error. Modify this to add an explicit commit() method, and call this in the appropriate places with appropriate error handling for the location. Currently the destructor of CacheStream gives an assert failure in Debug builds if commit() was not called. This will help track down any remaining uses of the API that assume the old destructior behaviour. In Release builds we fall back to the previous behaviour and call report_fatal_error if the commit fails. This is version 2 of this PR, superseding reverted PR https://github.com/llvm/llvm-project/pull/115331 . I have incorporated a change to the testcase to make it more reliable on Windows, as well as two follow-up changes (https://github.com/llvm/llvm-project/commit/df79000896101acc9b8d7435e59f767b36c00ac8 and https://github.com/llvm/llvm-project/commit/b0baa1d8bd68a2ce2f7c5f2b62333e410e9122a1) that were also reverted when 115331 was reverted. --------- Co-authored-by: Augie Fackler <augie@google.com> Co-authored-by: Vitaly Buka <vitalybuka@google.com>
2025-04-09[DebugInfo][RemoveDIs] Eliminate another debug-info variation flag (#133917)Jeremy Morse1-7/+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-01[DebugInfo][RemoveDIs] Remove debug-intrinsic printing cmdline options (#131855)Jeremy Morse1-4/+0
During the transition from debug intrinsics to debug records, we used several different command line options to customise handling: the printing of debug records to bitcode and textual could be independent of how the debug-info was represented inside a module, whether the autoupgrader ran could be customised. This was all valuable during development, but now that totally removing debug intrinsics is coming up, this patch removes those options in favour of a single flag (experimental-debuginfo-iterators), which enables autoupgrade, in-memory debug records, and debug record printing to bitcode and textual IR. We need to do this ahead of removing the experimental-debuginfo-iterators flag, to reduce the amount of test-juggling that happens at that time. There are quite a number of weird test behaviours related to this -- some of which I simply delete in this commit. Things like print-non-instruction-debug-info.ll , the test suite now checks for debug records in all tests, and we don't want to check we can print as intrinsics. Or the update_test_checks tests -- these are duplicated with write-experimental-debuginfo=false to ensure file writing for intrinsics is correct, but that's something we're imminently going to delete. A short survey of curious test changes: * free-intrinsics.ll: we don't need to test that debug-info is a zero cost intrinsic, because we won't be using intrinsics in the future. * undef-dbg-val.ll: apparently we pinned this to non-RemoveDIs in-memory mode while we sorted something out; it works now either way. * salvage-cast-debug-info.ll: was testing intrinsics-in-memory get salvaged, isn't necessary now * localize-constexpr-debuginfo.ll: was producing "dead metadata" intrinsics for optimised-out variable values, dbg-records takes the (correct) representation of poison/undef as an operand. Looks like we didn't update this in the past to avoid spurious test differences. * Transforms/Scalarizer/dbginfo.ll: this test was explicitly testing that debug-info affected codegen, and we deferred updating the tests until now. This is just one of those silent gnochange issues that get fixed by RemoveDIs. Finally: I've added a bitcode test, dbg-intrinsics-autoupgrade.ll.bc, that checks we can autoupgrade debug intrinsics that are in bitcode into the new debug records.
2025-03-29[bugpoint] Avoid repeated hash lookups (NFC) (#133616)Kazu Hirata1-2/+1
2025-03-19[LTO][WPD] Suppress WPD on a class if the LTO unit doesn't have the ↵Mingming Liu1-0/+19
prevailing definition of this class (#131721) Before this patch, whole program devirtualization is suppressed on a class if any superclass is visible to regular object files, by recording the class GUID in `VisibleToRegularObjSymbols`. This patch suppresses whole program devirtualization on a class if the LTO unit doesn't have the prevailing definition of this class (e.g., the prevailing definition is in a shared library) Implementation summaries: 1. In llvm/lib/LTO/LTO.cpp, `IsVisibleToRegularObj` is updated to look at the global resolution's `IsPrevailing` bit for ThinLTO and regularLTO. 2. In llvm/tools/llvm-lto2/llvm-lto2.cpp, - three command line options are added so `llvm-lto2` can override `Conf.HasWholeProgramVisibility`, `Conf.ValidateAllVtablesHaveTypeInfos` and `Conf.AllVtablesHaveTypeInfos`. The test case is reduced from a small C++ program (main.cc, lib.cc/h pasted below in [1]). To reproduce the program failure without this patch, compile lib.cc into a shared library, and provide it to a ThinLTO build of main.cc (commands are pasted in [2]). [1] * lib.h ``` #include <cstdio> class Derived { public: void dispatch(); virtual void print(); virtual void sum(); }; void Derived::dispatch() { static_cast<Derived*>(this)->print(); static_cast<Derived*>(this)->sum(); } void Derived::sum() { printf("Derived::sum\n"); } __attribute__((noinline)) void* create(int i); __attribute__((noinline)) void* getPtr(int i); ``` * lib.cc ``` #include "lib.h" #include <cstdio> #include <iostream> class Derived2 : public Derived { public: void print() override { printf("DerivedSharedLib\n"); } void sum() override { printf("DerivedSharedLib::sum\n"); } }; void Derived::print() { printf("Derived\n"); } __attribute__((noinline)) void* create(int i) { if (i & 1) return new Derived2(); return new Derived(); } ``` * main.cc ``` cat main.cc #include "lib.h" class DerivedN : public Derived { public: }; __attribute__((noinline)) void* getPtr(int x) { return new DerivedN(); } int main() { Derived*b = static_cast<Derived*>(create(201)); b->dispatch(); delete b; Derived* a = static_cast<Derived*>(getPtr(202)); a->dispatch(); delete a; return 0; } ``` [2] ``` # compile lib.o in a shared library. $ ./bin/clang++ -O2 -fPIC -c lib.cc -o lib.o $ ./bin/clang++ -shared -o libdata.so lib.o # Provide the shared library in `-ldata` $ ./bin/clang++ -v -g -ldata --save-temps -fno-discard-value-names -Wl,-mllvm,-print-before=wholeprogramdevirt -Wl,-mllvm,-wholeprogramdevirt-check=trap -Rpass=wholeprogramdevirt -Wl,--lto-whole-program-visibility -Wl,--lto-validate-all-vtables-have-type-infos -mllvm -disable-icp=true -Wl,-mllvm,-disable-icp=false -flto=thin -fwhole-program-vtables -fno-split-lto-unit -fuse-ld=lld main.cc -L . -o main >/tmp/wholeprogramdevirt.ir 2>&1 # Run the program hits a segmentation fault with `-Wl,-mllvm,-wholeprogramdevirt-check=trap` $ LD_LIBRARY_PATH=. ./main DerivedSharedLib Trace/breakpoint trap (core dumped) ```
2025-03-14[RemoveDIs] Remove "try-debuginfo-iterators..." test flags (#130298)Jeremy Morse1-12/+0
These date back to when the non-intrinsic format of variable locations was still being tested and was behind a compile-time flag, so not all builds / bots would correctly run them. The solution at the time, to get at least some test coverage, was to have tests opt-in to non-intrinsic debug-info if it was built into LLVM. Nowadays, non-intrinsic format is the default and has been on for more than a year, there's no need for this flag to exist. (I've downgraded the flag from "try" to explicitly requesting non-intrinsic format in some places, so that we can deal with tests that are explicitly about non-intrinsic format in their own commit).
2025-03-08Revert "Modify the localCache API to require an explicit commit on ↵Douglas Yung1-3/+1
CachedFile… (#115331)" This reverts commit ce9e1d3c15ed6290f1cb07b482939976fa8115cd. The unittest added in this commit seems to be flaky causing random failure on buildbots: - https://lab.llvm.org/buildbot/#/builders/46/builds/13235 - https://lab.llvm.org/buildbot/#/builders/46/builds/13232 - https://lab.llvm.org/buildbot/#/builders/46/builds/13228 - https://lab.llvm.org/buildbot/#/builders/46/builds/13224 - https://lab.llvm.org/buildbot/#/builders/46/builds/13220 - https://lab.llvm.org/buildbot/#/builders/46/builds/13210 - https://lab.llvm.org/buildbot/#/builders/46/builds/13208 - https://lab.llvm.org/buildbot/#/builders/46/builds/13207 - https://lab.llvm.org/buildbot/#/builders/46/builds/13202 - https://lab.llvm.org/buildbot/#/builders/46/builds/13196 and - https://lab.llvm.org/buildbot/#/builders/180/builds/14266 - https://lab.llvm.org/buildbot/#/builders/180/builds/14254 - https://lab.llvm.org/buildbot/#/builders/180/builds/14250 - https://lab.llvm.org/buildbot/#/builders/180/builds/14245 - https://lab.llvm.org/buildbot/#/builders/180/builds/14244 - https://lab.llvm.org/buildbot/#/builders/180/builds/14226
2025-03-07Modify the localCache API to require an explicit commit on CachedFile… ↵anjenner1-1/+3
(#115331) …Stream. CachedFileStream has previously performed the commit step in its destructor, but this means its only recourse for error handling is report_fatal_error. Modify this to add an explicit commit() method, and call this in the appropriate places with appropriate error handling for the location. Currently the destructor of CacheStream gives an assert failure in Debug builds if commit() was not called. This will help track down any remaining uses of the API that assume the old destructior behaviour. In Release builds we fall back to the previous behaviour and call report_fatal_error if the commit fails.
2025-03-03[NFC]Make file-local cl::opt global variables static (#126486)chrisPyr1-1/+1
#125983
2024-10-07Make WriteIndexesThinBackend multi threaded (#109847)Nuri Amari1-1/+2
We've noticed that for large builds executing thin-link can take on the order of 10s of minutes. We are only using a single thread to write the sharded indices and import files for each input bitcode file. While we need to ensure the index file produced lists modules in a deterministic order, that doesn't prevent us from executing the rest of the work in parallel. In this change we use a thread pool to execute as much of the backend's work as possible in parallel. In local testing on a machine with 80 cores, this change makes a thin-link for ~100,000 input files run in ~2 minutes. Without this change it takes upwards of 10 minutes. --------- Co-authored-by: Nuri Amari <nuriamari@fb.com>
2024-04-26[llvm-lto2] Simplify SymbolResolutions loop and avoid expensive std::string ↵Fangrui Song1-4/+3
copy. NFC
2024-04-05[RemoveDIs] Add flag to preserve the debug info format of input IR (#87379)Stephen Tozer1-0/+5
This patch adds a new flag: `--preserve-input-debuginfo-format` This flag instructs the tool to not convert the debug info format (intrinsics/records) of input IR, but to instead determine the format of the input IR and overwrite the other format-determining flags so that we process and output the file in the same format that we received it in. This flag is turned off by llvm-link, llvm-lto, and llvm-lto2, and should be turned off by any other tool that expects to parse multiple IR modules and have their debug info formats match. The motivation for this flag is to allow tools to not convert the debug info format - verify-uselistorder and llvm-reduce, and any downstream tools that seek to test or mutate IR as-is, without applying extraneous modifications to the input. This is a necessary step to using debug records by default in all (other) LLVM tools.
2024-03-22[RemoveDIs] Load into new debug info format by default in llvm-lto and ↵Orlando Cazalet-Hyams1-0/+4
llvm-lto2 (#86271) Directly load all bitcode into the new debug info format in `llvm-lto` and `llvm-lto2`. This means that new-mode bitcode no longer round-trips back to old-mode after parsing, and that old-mode bitcode gets auto-upgraded to new-mode debug info (which is the current in-memory default in LLVM).
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-25Reapply 215b8f1e252, reverted in c3f7fb1421eJeremy Morse1-0/+18
Turns out I was using DbgMarker::getDbgValueRange rather than the helper utility in Instruction::getDbgValueRange, which checks for null-ness. Original commit message follows. [DebugInfo][RemoveDIs] Convert debug-info modes when loading bitcode (#78967) As part of eliminating debug-intrinsics in LLVM, we'll shortly be pushing the conversion from "old" dbg.value mode to "new" DPValue mode out from when the pass manager runs, to when modules are loaded. This patch adds that conversion process and some (temporary) options to llvm-lto{,2} to help test it. Specifically: now whenever we load a bitcode module, consider a flag of whether to "upgrade" it into the new debug-info mode, and if we're lazily materializing functions then do that lazily too. Doing this exposes an error in the IRLinker/materializer handling of DPValues, where we need to transfer the debug-info format flag correctly, and in ValueMapper we need to remap the Values that DPValues point at. I've added some test coverage in the modified tests; these will be exercised by our llvm-new-debug-iterators buildbot. This upgrading of debug-info won't be happening for the llvm18 release, instead we'll turn it on after the branch date, thenbe push the boundary of where "new" debug-info starts and ends down into the existing debug-info upgrade path over the course of the next release.
2024-01-25Revert "[DebugInfo][RemoveDIs] Convert debug-info modes when loading bitcode ↵Jeremy Morse1-18/+0
(#78967)" This reverts commit 215b8f1e252b4f30cf1b734faa370c0ac4b88659. Numerous builders exploded from this X_X, for example https://lab.llvm.org/buildbot/#/builders/46/builds/62657
2024-01-25[DebugInfo][RemoveDIs] Convert debug-info modes when loading bitcode (#78967)Jeremy Morse1-0/+18
As part of eliminating debug-intrinsics in LLVM, we'll shortly be pushing the conversion from "old" dbg.value mode to "new" DPValue mode out from when the pass manager runs, to when modules are loaded. This patch adds that conversion process and some (temporary) options to llvm-lto{,2} to help test it. Specifically: now whenever we load a bitcode module, consider a flag of whether to "upgrade" it into the new debug-info mode, and if we're lazily materializing functions then do that lazily too. Doing this exposes an error in the IRLinker/materializer handling of DPValues, where we need to transfer the debug-info format flag correctly, and in ValueMapper we need to remap the Values that DPValues point at. I've added some test coverage in the modified tests; these will be exercised by our llvm-new-debug-iterators buildbot. This upgrading of debug-info won't be happening for the llvm18 release, instead we'll turn it on after the branch date, thenbe push the boundary of where "new" debug-info starts and ends down into the existing debug-info upgrade path over the course of the next release.
2023-07-05[llvm] A Unified LTO Bitcode FrontendMatthew Voss1-1/+18
Here's a high level summary of the changes in this patch. For more information on rational, see the RFC. (https://discourse.llvm.org/t/rfc-a-unified-lto-bitcode-frontend/61774). - Add config parameter to LTO backend, specifying which LTO mode is desired when using unified LTO. - Add unified LTO flag to the summary index for efficiency. Unified LTO modules can be detected without parsing the module. - Make sure that the ModuleID is generated by incorporating more types of symbols. Differential Revision: https://reviews.llvm.org/D123803
2023-04-04[lld] Support separate native object file path in --thinlto-prefix-replaceIvan Tadeu Ferreira Antunes Filho1-5/+6
Currently, the --thinlto-prefix-replace="oldpath;newpath" option is used during distributed ThinLTO thin links to specify the mapping of the input bitcode object files' directory tree (oldpath) to the directory tree (newpath) used for both: 1) the output files of the thin link itself (the .thinlto.bc index files and the optional .imports files) 2) the specified object file paths written to the response file given in the --thinlto-index-only=${response} option, which is used by the final native link and must match the paths of the native object files that will be produced by ThinLTO backend compiles. This patch expands the --thinlto-prefix-replace option to allow a separate directory tree mapping to be specified for the object file paths written to the response file (number 2 above). This is important to support builds and build systems where the same output directory may not be written by multiple build actions (e.g. the thin link and the ThinLTO backend compiles). The new format is: --thinlto-prefix-replace="origpath;outpath[;objpath]" This replaces the origpath directory tree of the thin link input files with outpath when writing the thin link index and imports outputs (number 1 above). If objpath is specified it replaces origpath of the input files with objpath when writing the response file (number 2 above), otherwise it falls back to the old behavior of using outpath for this as well. Reviewed By: tejohnson, MaskRay Differential Revision: https://reviews.llvm.org/D144596
2023-01-25[LTO] Remove -lto-opaque-pointers flagNikita Popov1-5/+0
Always use the config default of OpaquePointers == true.
2023-01-23[NFC] Consolidate llvm::CodeGenOpt::Level handlingScott Linder1-14/+3
Add free functions llvm::CodeGenOpt::{getLevel,getID,parseLevel} to provide common implementations for functionality that has been duplicated in many places across the codebase. Differential Revision: https://reviews.llvm.org/D141968
2023-01-11[llvm-lto2] Remove unused include after D123126Fangrui Song1-1/+0
2022-12-04IR: HotnessThreshold llvm::Optional => std::optionalFangrui Song1-1/+1
2022-11-22Reland "[LTO][COFF] Use bitcode file names in lto native object file names."Zequan Wu1-3/+6
This reverts commit 34108082947c964ae9bbfcd9808f2fd31c0d672f with fixes.
2022-11-23Revert "Reland "[LTO][COFF] Use bitcode file names in lto native object file ↵Roman Lebedev1-6/+3
names."" Breaks build of LLVMgold here: ``` /repositories/llvm-project/llvm/tools/gold/gold-plugin.cpp:1108:19: error: no matching function for call to 'localCache' Cache = check(localCache("ThinLTO", "Thin", options::cache_dir, AddBuffer)); ^~~~~~~~~~ /repositories/llvm-project/llvm/include/llvm/Support/Caching.h:72:21: note: candidate function not viable: no known conversion from '(lambda at /repositories/llvm-project/llvm/tools/gold/gold-plugin.cpp:1102:20)' to 'llvm::AddBufferFn' (aka 'function<void (unsigned int, const llvm::Twine &, std::unique_ptr<MemoryBuffer>)>') for 4th argument Expected<FileCache> localCache( ^ /repositories/llvm-project/llvm/tools/gold/gold-plugin.cpp:1110:18: error: no viable conversion from '(lambda at /repositories/llvm-project/llvm/tools/gold/gold-plugin.cpp:1094:20)' to 'llvm::AddStreamFn' (aka 'function<Expected<std::unique_ptr<CachedFileStream>> (unsigned int, const llvm::Twine &)>') check(Lto->run(AddStream, Cache)); ^~~~~~~~~ /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_function.h:375:7: note: candidate constructor not viable: no known conversion from '(lambda at /repositories/llvm-project/llvm/tools/gold/gold-plugin.cpp:1094:20)' to 'std::nullptr_t' for 1st argument function(nullptr_t) noexcept ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_function.h:386:7: note: candidate constructor not viable: no known conversion from '(lambda at /repositories/llvm-project/llvm/tools/gold/gold-plugin.cpp:1094:20)' to 'const std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream>> (unsigned int, const llvm::Twine &)> &' for 1st argument function(const function& __x) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_function.h:404:7: note: candidate constructor not viable: no known conversion from '(lambda at /repositories/llvm-project/llvm/tools/gold/gold-plugin.cpp:1094:20)' to 'std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream>> (unsigned int, const llvm::Twine &)> &&' for 1st argument function(function&& __x) noexcept ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_function.h:435:2: note: candidate template ignored: requirement '_Callable<(lambda at /repositories/llvm-project/llvm/tools/gold/gold-plugin.cpp:1094:20) &, (lambda at /repositories/llvm-project/llvm/tools/gold/gold-plugin.cpp:1094:20), std::__invoke_result<(lambda at /repositories/llvm-project/llvm/tools/gold/gold-plugin.cpp:1094:20) &, unsigned int, const llvm::Twine &>>::value' was not satisfied [with _Functor = (lambda at /repositories/llvm-project/llvm/tools/gold/gold-plugin.cpp:1094:20) &] function(_Functor&& __f) ^ /repositories/llvm-project/llvm/include/llvm/LTO/LTO.h:278:25: note: passing argument to parameter 'AddStream' here Error run(AddStreamFn AddStream, FileCache Cache = nullptr); ^ ``` This reverts commit 387620aa8cea33174b6c1fb80c1af713fee732ac.
2022-11-22Reland "[LTO][COFF] Use bitcode file names in lto native object file names."Zequan Wu1-3/+6
This reverts commit eef5405f74ae208e3e2eb7daacecac923d7338f2.
2022-11-22Revert "[LTO][COFF] Use bitcode file names in lto native object file names."Zequan Wu1-6/+3
This reverts commit 531ed6d5aa65f41c6dfe2e74905d5c6c88fc95a7.
2022-11-22[LTO][COFF] Use bitcode file names in lto native object file names.Zequan Wu1-3/+6
Currently the lto native object files have names like main.exe.lto.1.obj. In PDB, those names are used as names for each compiland. Microsoft’s tool SizeBench uses those names to present to users the size of each object files. So, names like main.exe.lto.1.obj is not user friendly. This patch makes the lto native object file names more readable by using the bitcode file names as part of the file names. For example, if the input bitcode file has path like "path/to/foo.obj", its corresponding lto native object file path would be "path/to/main.exe.lto.foo.obj". Since the lto native object file name only bothers PDB, this patch only changes the lld-linker's behavior. Reviewed By: tejohnson, MaskRay, #lld-macho Differential Revision: https://reviews.llvm.org/D137217
2022-07-06[LTO][ELF] Add selective --save-temps= optionJin Xin Ng1-2/+28
Allows specific “temps” to be saved, instead of the current all-or-nothing nature of --save-temps. Multiple of these “temps” can be saved by specifying the argument multiple times. Differential Revision: https://reviews.llvm.org/D127778
2022-07-01[llvm-lto2] Remove unneeded cl::init(false). NFCFangrui Song1-6/+6
2022-06-29[ThinLTO][test] Add tests for emitting files in-processJin Xin Ng1-6/+20
Completes D127777 by adding llvm-side tests for emitting index and imports files from in-process ThinLTO Differential Revision: https://reviews.llvm.org/D128771
2022-06-20[llvm] Don't use Optional::getValue (NFC)Kazu Hirata1-2/+2
2022-06-05Remove unneeded cl::ZeroOrMore for cl::opt/cl::list optionsFangrui Song1-2/+1
2022-06-04Remove unneeded cl::ZeroOrMore for cl::opt optionsFangrui Song1-3/+4
Similar to 557efc9a8b68628c2c944678c6471dac30ed9e8e. This commit handles options where cl::ZeroOrMore is more than one line below cl::opt.
2022-06-01LTO: Decide upfront whether to use opaque/non-opaque pointer typesMatthias Braun1-0/+5
LTO code may end up mixing bitcode files from various sources varying in their use of opaque pointer types. The current strategy to decide between opaque / typed pointers upon the first bitcode file loaded does not work here, since we could be loading a non-opaque bitcode file first and would then be unable to load any files with opaque pointer types later. So for LTO this: - Adds an `lto::Config::OpaquePointer` option and enforces an upfront decision between the two modes. - Adds `-opaque-pointers`/`-no-opaque-pointers` options to the gold plugin; disabled by default. - `--opaque-pointers`/`--no-opaque-pointers` options with `-plugin-opt=-opaque-pointers`/`-plugin-opt=-no-opaque-pointers` aliases to lld; disabled by default. - Adds an `-lto-opaque-pointers` option to the `llvm-lto2` tool. - Changes the clang driver to pass `-plugin-opt=-opaque-pointers` to the linker in LTO modes when clang was configured with opaque pointers enabled by default. This fixes https://github.com/llvm/llvm-project/issues/55377 Differential Revision: https://reviews.llvm.org/D125847
2022-04-11[llvm-lto] Remove support for legacy pass managerNikita Popov1-6/+0
This removes support for the legacy pass manager in llvm-lto and llvm-lto2. In this case I've dropped the use-new-pm option entirely, as I don't think this is considered part of the public interface. This also makes -debug-pass-manager work with llvm-lto, because that was needed to migrate some tests to NewPM. Differential Revision: https://reviews.llvm.org/D123376
2022-04-06[cmake] Remove LLVM_ENABLE_NEW_PASS_MANAGER cmake optionNikita Popov1-1/+1
Or rather, error out if it is set to something other than ON. This removes the ability to enable the legacy pass manager by default, but does not remove the ability to explicitly enable it through various flags like -flegacy-pass-manager or -enable-new-pm=0. I checked, and our test suite definitely doesn't pass with LLVM_ENABLE_NEW_PASS_MANAGER=OFF anymore. Differential Revision: https://reviews.llvm.org/D123126
2021-12-21Reland - [CodeView] Emit S_OBJNAME recordAlexandre Ganea1-1/+1
Reland integrates build fixes & further review suggestions. Thanks to @zturner for the initial S_OBJNAME patch! Differential Revision: https://reviews.llvm.org/D43002
2021-12-21Revert [CodeView] Emit S_OBJNAME recordAlexandre Ganea1-1/+1
Also revert all subsequent fixes: - abd1cbf5e543f0f114d2742e109ead7d7ddbf9c4 [Clang] Disable debug-info-objname.cpp test on Unix until I sort out the issue. - 00ec441253048f5e30540ea26bb0a28c42a5fc18 [Clang] debug-info-objname.cpp test: explictly encode a x86 target when using %clang_cl to avoid falling back to a native CPU triple. - cd407f6e52b09cce2bef24c74b7f36fedc94991b [Clang] Fix build by restricting debug-info-objname.cpp test to x86.
2021-12-21[CodeView] Emit S_OBJNAME recordAlexandre Ganea1-1/+1
Thanks to @zturner for the initial patch! Differential Revision: https://reviews.llvm.org/D43002
2021-12-13[ThinLTO] Fix nondeterministic exit on error.Mircea Trofin1-9/+19
In the multi-threaded case, if a thread hits an error, we mimick LLVMContext's behavior of reporting the error and exit-ing. However, this doesn't cleanly join the other threads, so depending on how fast the process exits, other threads may report 'terminate called without an active exception'. To avoid this non-determinsim, and without introducing a more complicated design, we just report the error, but not exit early. We do track whether we hit errors and exit(1) after joining. Differential Revision: https://reviews.llvm.org/D115574
2021-11-04[Support] Improve Caching conformance with Support library behaviorNoah Shutty1-3/+3
This diff makes several amendments to the local file caching mechanism which was migrated from ThinLTO to Support in rGe678c51177102845c93529d457b020f969125373 in response to follow-up discussion on that commit. Patch By: noajshu Differential Revision: https://reviews.llvm.org/D113080
2021-10-18[Support][ThinLTO] Move ThinLTO caching to LLVM Support libraryNoah Shutty1-5/+5
We would like to move ThinLTO’s battle-tested file caching mechanism to the LLVM Support library so that we can use it elsewhere in LLVM. Patch By: noajshu Differential Revision: https://reviews.llvm.org/D111371
2021-10-18Revert "[Support][ThinLTO] Move ThinLTO caching to LLVM Support library"Petr Hosek1-5/+5
This reverts commit 92b8cc52bbc8194f2cd6a5f742b874969421afca since it broke the gold plugin.
2021-10-18[Support][ThinLTO] Move ThinLTO caching to LLVM Support libraryNoah Shutty1-5/+5
We would like to move ThinLTO’s battle-tested file caching mechanism to the LLVM Support library so that we can use it elsewhere in LLVM. Patch By: noajshu Differential Revision: https://reviews.llvm.org/D111371
2021-09-29Revert "[LTO][Legacy] Add -debug-pass-manager option to enable pass run/skip ↵Wael Yehia1-4/+4
trace." This reverts commit a60405cf035dc114e7ee090139bed2577f4ea7ef.