aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-dwp/llvm-dwp.cpp
AgeCommit message (Collapse)AuthorFilesLines
2 days[llvm][support] Move `make_absolute` from `sys::fs` to `sys::path` (#161459)Jan Svoboda1-1/+1
The `llvm::sys::fs::make_absolute(const Twine &, SmallVectorImpl<char> &)` functions doesn't perform any FS access - it only modifies the second parameter via path/string operations. This function should live in the `llvm::sys::path` namespace for consistency and for making it easier to spot function calls that perform IO.
2025-09-08MC: Add Triple overloads for more MC constructors (#157321)Matt Arsenault1-3/+4
Avoids more Triple->string->Triple round trip. This is a continuation of f137c3d592e96330e450a8fd63ef7e8877fc1908
2024-12-11Rework the `Option` library to reduce dynamic relocations (#119198)Chandler Carruth1-6/+8
Apologies for the large change, I looked for ways to break this up and all of the ones I saw added real complexity. This change focuses on the option's prefixed names and the array of prefixes. These are present in every option and the dominant source of dynamic relocations for PIE or PIC users of LLVM and Clang tooling. In some cases, 100s or 1000s of them for the Clang driver which has a huge number of options. This PR addresses this by building a string table and a prefixes table that can be referenced with indices rather than pointers that require dynamic relocations. This removes almost 7k dynmaic relocations from the `clang` binary, roughly 8% of the remaining dynmaic relocations outside of vtables. For busy-boxing use cases where many different option tables are linked into the same binary, the savings add up a bit more. The string table is a straightforward mechanism, but the prefixes required some subtlety. They are encoded in a Pascal-string fashion with a size followed by a sequence of offsets. This works relatively well for the small realistic prefixes arrays in use. Lots of code has to change in order to land this though: both all the option library code has to be updated to use the string table and prefixes table, and all the users of the options library have to be updated to correctly instantiate the objects. Some follow-up patches in the works to provide an abstraction for this style of code, and to start using the same technique for some of the other strings here now that the infrastructure is in place.
2024-07-20[MC] Remove unused bool arguments from createMCObjectStreamer callersFangrui Song1-3/+2
2024-06-27Give a warning when no dwo files are provided (#94336)Jinjie Huang1-1/+4
In some scenarios based on the split-dwarf build process, the dwo file is not generated as expected(That is to say, no dwo file path is stored in the binary). When the llvm-dwp tool is called to generate the .dwp file, it will exit without any warning. So, the plan is to prompt a warning to tell the user that the dwo file was not actually generated. <img width="699" alt="image" src="https://github.com/llvm/llvm-project/assets/150100070/5e5742f6-daad-450f-87e9-cb25449c3c7a">
2024-06-13[llvm-dwp] Remove incorrect std::move()Nikita Popov1-1/+1
DWOName is still used afterwards. The only reason this works out right now is that SmallString does not actually have a constructor that can take advantage of the move.
2024-01-11[llvm-driver] Fix usage of `InitLLVM` on Windows (#76306)Alexandre Ganea1-3/+0
Previously, some tools such as `clang` or `lld` which require strict order for certain command-line options, such as `clang -cc1` or `lld -flavor`, would not longer work on Windows, when these tools were linked as part of `llvm-driver`. This was caused by `InitLLVM` which was part of the `*_main()` function of these tools, which in turn calls `windows::GetCommandLineArguments`. That function completly replaces argc/argv by new UTF-8 contents, so any ajustements to argc/argv made by `llvm-driver` prior to calling these tools was reset. `InitLLVM` is now called by the `llvm-driver`. Any tool that participates in (or is part of) the `llvm-driver` doesn't call `InitLLVM` anymore.
2023-12-18[DWP] Fix default for continue-on-cu-index-overflow (#75540)Alexander Yermolovich1-6/+14
This is follow up for https://github.com/llvm/llvm-project/pull/71902. The default option --continue-on-cu-index-overflow returned an error --continue-on-cu-index-overflow: missing argument. Changed it so that it is the same behavior as other flags like -gsplit-dwarf. Where --continue-on-cu-index-overflow will default to continue, and user can set mode with --continue-on-cu-index-overflow=\<value>.
2023-12-01Support soft failure on DWP section overflow, producing a truncated but ↵Jinjie Huang1-3/+12
valid DWP(#71902) When 'ContinueOnCuIndexOverflow' enables without this modification, the forcibly generated '.dwp' won't be recognized by Debugger(gdb 10.1) correctly. <img width="657" alt="image" src="https://github.com/llvm/llvm-project/assets/150100070/31732775-2548-453a-a47a-fa04c6d05fe9"> it looks like there's a problem with processing the dwarf header, which makes debugging completely impossible. (unless the consumer walks the debug_info section to rebuild that column (if that's the only section that overflowed - if it's another section, there's no recovery)) **About patch:** When llvm-dwp enables option '--continue-on-cu-index-overflow=soft-stop' and recognizes the overflow problem , it will stop packing and generate the '.dwp' file at once, discarding any DWO files that would not fit within the 32 bit/4GB limits of the format. <img width="625" alt="image" src="https://github.com/llvm/llvm-project/assets/150100070/77d6be24-262b-4f4c-afc0-9a6c49e133c7">
2023-08-15Reapply "[Option] Add "Visibility" field and clone the OptTable APIs to use it"Justin Bogner1-0/+1
This reverts commit 4e3b89483a6922d3f48670bb1c50a37f342918c6, with fixes for places I'd missed updating in lld and lldb. I've also renamed OptionVisibility::Default to "DefaultVis" to avoid ambiguity since the undecorated name has to be available anywhere Options.inc is included. Original message follows: This splits OptTable's "Flags" field into "Flags" and "Visibility", updates the places where we instantiate Option tables, and adds variants of the OptTable APIs that use Visibility mask instead of Include/Exclude flags. We need to do this to clean up a bunch of complexity in the clang driver's option handling - there's a whole slew of flags like CoreOption, NoDriverOption, and FlangOnlyOption there today to try to handle all of the permutations of flags that the various drivers need, but it really doesn't scale well, as can be seen by things like the somewhat recently introduced CLDXCOption. Instead, we'll provide an additive model for visibility that's separate from the other flags. For things like "HelpHidden", which is used as a "subtractive" modifier for option visibility, we leave that in "Flags" and handle it as a special case. Note that we don't actually update the users of the Include/Exclude APIs here or change the flags that exist in clang at all - that will come in a follow up that refactors clang's Options.td to use the increased flexibility this change allows. Differential Revision: https://reviews.llvm.org/D157149
2023-08-14Revert "[Option] Add "Visibility" field and clone the OptTable APIs to use it"Justin Bogner1-1/+0
this is failing on bots, reverting to investigate. This reverts commit a16104e6da6f36f3d72dbf53d10ba56495a0d65a.
2023-08-14[Option] Add "Visibility" field and clone the OptTable APIs to use itJustin Bogner1-0/+1
This splits OptTable's "Flags" field into "Flags" and "Visibility", updates the places where we instantiate Option tables, and adds variants of the OptTable APIs that use Visibility mask instead of Include/Exclude flags. We need to do this to clean up a bunch of complexity in the clang driver's option handling - there's a whole slew of flags like CoreOption, NoDriverOption, and FlangOnlyOption there today to try to handle all of the permutations of flags that the various drivers need, but it really doesn't scale well, as can be seen by things like the somewhat recently introduced CLDXCOption. Instead, we'll provide an additive model for visibility that's separate from the other flags. For things like "HelpHidden", which is used as a "subtractive" modifier for option visibility, we leave that in "Flags" and handle it as a special case. Note that we don't actually update the users of the Include/Exclude APIs here or change the flags that exist in clang at all - that will come in a follow up that refactors clang's Options.td to use the increased flexibility this change allows. Differential Revision: https://reviews.llvm.org/D157149
2023-08-04[llvm] Extract common `OptTable` bits into macrosJan Svoboda1-10/+2
All command-line tools using `llvm::opt` create an enum of option IDs and a table of `OptTable::Info` object. Most of the tools use the same ID (`OPT_##ID`), kind (`Option::KIND##Class`), group ID (`OPT_##GROUP`) and alias ID (`OPT_##ALIAS`). This patch extracts that common code into canonical macros. This results in fewer changes when tweaking the `OPTION` macros emitted by the TableGen backend. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D157028
2023-08-01[dwp][libtool-darwin][sancov] Enable llvm-driverAndrés Villegas1-1/+2
Enable llvm-driver for: llvm-dwp llvm-libtoo-darwin sancov Differential Revision: https://reviews.llvm.org/D156758
2023-07-12[NFC][llvm-dwp] Switch from llvm::cl to OptTableAndrés Villegas1-20/+68
Switch the parse of command line options from llvm::cl to OptTable. The motivation for this change is to continue adding llvm based tools to the llvm driver multicall. For more information about the proposal and motivation, please see https://discourse.llvm.org/t/rfc-llvm-busybox-proposal/58494 Reviewed By: abrachet Differential Revision: https://reviews.llvm.org/D154642
2023-06-01[DWP] add overflow check for llvm-dwp tools if offset overflowzhuna1-1/+7
Now, if the offset overflow happens, we just silently ignore it. We will generate a bad dwp file, which will crash the gdb or make it undefined behavior, and hard to address the root cause. So, we need to produce some messages if overflow happens. Reviewed By: ayermolo, dblaikie, steven.zhang Differential Revision: https://reviews.llvm.org/D144565
2022-11-26[llvm-dwp] Use std::optional in llvm-dwp.cpp (NFC)Kazu Hirata1-1/+2
This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-21Don't use Optional::getPointer (NFC)Kazu Hirata1-1/+1
Since std::optional does not offer getPointer(), this patch replaces X.getPointer() with &*X to make the migration from llvm::Optional to std::optional easier. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716 Differential Revision: https://reviews.llvm.org/D138466
2022-09-14[llvm-dwp] Report the filename if it cannot be foundZhang Qing Shan1-2/+14
For now, we report nothing if the execution/dwo file is missing, which is confusing. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D133549
2022-09-13Revert "[llvm-dwp] Report the filename if it cannot be found"Nico Weber1-14/+2
This reverts commit 35028d417bb32bc05294e77c9ddcf50f24f277eb. Breaks tests on Windows, see https://reviews.llvm.org/D133549#3785952
2022-09-13[llvm-dwp] Get the DWO file from relative path if the absolute path is not validZhang Qing Shan1-1/+4
Extend the llvm-dwp to support searching the DWOs that from relative path for the case that build from remote building system(different comp_dir). Reviewd By: dblaikie Differential Revision: https://reviews.llvm.org/D133480
2022-09-13[llvm-dwp] Report the filename if it cannot be foundZhang Qing Shan1-2/+14
For now, we report nothing if the execution/dwo file is missing, which is confusing. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D133549
2022-06-07[MC] De-capitalize MCStreamer functionsFangrui Song1-1/+1
Follow-up to c031378ce01b8485ba0ef486654bc9393c4ac024 . The class is mostly consistent now.
2022-06-05Remove unneeded cl::ZeroOrMore for cl::opt/cl::list optionsFangrui Song1-2/+3
2022-06-04Remove unneeded cl::ZeroOrMore for cl::list optionsFangrui Song1-3/+2
2022-02-16[NFC][MC] remove unused argument `MCRegisterInfo` in `MCCodeEmitter`Shao-Ce SUN1-1/+1
Reviewed By: skan Differential Revision: https://reviews.llvm.org/D119846
2022-02-16Revert "[NFC][MC] remove unused argument `MCRegisterInfo` in `MCCodeEmitter`"Shao-Ce SUN1-1/+1
This reverts commit fe25c06cc5bdc2ef9427309f8ec1434aad69dc7a.
2022-02-16[NFC][MC] remove unused argument `MCRegisterInfo` in `MCCodeEmitter`Shao-Ce SUN1-1/+1
For ten years, it seems that `MCRegisterInfo` is not used by any target. Reviewed By: skan Differential Revision: https://reviews.llvm.org/D119846
2022-02-10Cleanup LLVMObject headersserge-sans-paille1-0/+1
Most notably, llvm/Object/Binary.h no longer includes llvm/Support/MemoryBuffer.h llvm/Object/MachOUniversal*.h no longer include llvm/Object/Archive.h llvm/Object/TapiUniversal.h no longer includes llvm/Object/TapiFile.h llvm-project preprocessed size: before: 1068185081 after: 1068324320 Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D119457
2022-02-09Cleanup LLVMMC headersserge-sans-paille1-0/+2
There's a few relevant forward declarations in there that may require downstream adding explicit includes: llvm/MC/MCContext.h no longer includes llvm/BinaryFormat/ELF.h, llvm/MC/MCSubtargetInfo.h, llvm/MC/MCTargetOptions.h llvm/MC/MCObjectStreamer.h no longer include llvm/MC/MCAssembler.h llvm/MC/MCAssembler.h no longer includes llvm/MC/MCFixup.h, llvm/MC/MCFragment.h Counting preprocessed lines required to rebuild llvm-project on my setup: before: 1052436830 after: 1049293745 Which is significant and backs up the change in addition to the usual benefits of decreasing coupling between headers and compilation units. Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D119244
2021-10-08Move TargetRegistry.(h|cpp) from Support to MCReid Kleckner1-1/+1
This moves the registry higher in the LLVM library dependency stack. Every client of the target registry needs to link against MC anyway to actually use the target, so we might as well move this out of Support. This allows us to ensure that Support doesn't have includes from MC/*. Differential Revision: https://reviews.llvm.org/D111454
2021-07-22[DWP] Refactoring llvm-dwp in to a library part 2Alexander Yermolovich1-3/+3
This is follow up to https://reviews.llvm.org/D106198 where llvm-dwp was refactored in to multiple files. In this patch moving them in to lib/include directories. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D106493
2021-07-20[DWP] Refactoring llvm-dwp in to a library.Alexander Yermolovich1-850/+1
This is a step1, mechanical refactor, of moving the bulk of llvm-dwp functionality in to a library. This should allow other tools, like BOLT, to re-use some of the llvm-dwp functionality. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D106198
2021-07-20[llvm][tools] Hide more unrelated tool optionsTimm Bäder1-0/+1
Differential Revision: https://reviews.llvm.org/D106271
2021-06-02[llvm-dwp] Add support for rnglists and loclistsKim-Anh Tran1-0/+4
This patch updates llvm-dwp to include rnglists and loclists when parsing debug sections. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D101894
2021-06-02[llvm-dwp] Add support for DWARFv5 type units ↵Kim-Anh Tran1-36/+58
... This patch adds support for DWARFv5 type units: parsing from the .debug_info section, and writing index to the type unit index. Previously, the type units were part of the .debug_types section which is no longer used in DWARFv5. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D101818
2021-06-02[llvm-dwp] Adding support for v5 index writingKim-Anh Tran1-48/+78
This patch adds general support for DWARFv5 index writing. In particular, this means only allowing inputs with one version, either DWARFv5 or DWARFv4. This patch adds the .debug_macro section as an example, but the DWARFv5 type support and loc and rangelists are still missing (and upcoming). Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D102315
2021-06-02[llvm-dwp] Skip type unit debug info sectionsKim-Anh Tran1-55/+115
This patch makes llvm-dwp skip debug info sections that may not be encoding a compile unit. In DWARF5, debug info sections are also used for type units. As in preparation to support type units, make llvm-dwp aware of other uses of debug info sections but skip them for now. The patch first records all .debug_info sections, then goes through them one by one and records the cu debug info section for writing the index unit, and copies that section to the final dwp output info section. If it's not a compile unit, skip. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D102312
2021-05-23[MC] Refactor MCObjectFileInfo initialization and allow targets to create ↵Philipp Krones1-3/+4
MCObjectFileInfo This makes it possible for targets to define their own MCObjectFileInfo. This MCObjectFileInfo is then used to determine things like section alignment. This is a follow up to D101462 and prepares for the RISCV backend defining the text section alignment depending on the enabled extensions. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D101921
2021-05-05[MC] Untangle MCContext and MCObjectFileInfoPhilipp Krones1-4/+4
This untangles the MCContext and the MCObjectFileInfo. There is a circular dependency between MCContext and MCObjectFileInfo. Currently this dependency also exists during construction: You can't contruct a MOFI without a MCContext without constructing the MCContext with a dummy version of that MOFI first. This removes this dependency during construction. In a perfect world, MCObjectFileInfo wouldn't depend on MCContext at all, but only be stored in the MCContext, like other MC information. This is future work. This also shifts/adds more information to the MCContext making it more available to the different targets. Namely: - TargetTriple - ObjectFileType - SubtargetInfo Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D101462
2021-04-26[NFC] Fix "not used" warningVitaly Buka1-2/+1
2021-04-26Support DW_FORM_strx* in llvm-dwp.Ali Tamur1-40/+160
Currently llvm-dwp only handled DW_FORM_string and DW_FORM_GNU_str_index; with this patch it also starts to handle DW_FORM_strx[1-4]? Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D75485
2021-02-16[llvm-dwp] Join dwo paths correctly when DWOPath is absoluteSimonas Kazlauskas1-2/+2
When the `DWOPath` is absolute, we want to use `DWOPath` as is, without prepending any other components to the path. The `sys::path::append` does not join, but rather unconditionally appends the paths, so something like `sys::path::append("/tmp", "/tmp/banana")` will result in `/tmp/tmp/banana` rather than the desired `/tmp/banana`. This then causes `llvm-dwp` to fail in a following situation: ``` $ clang -gsplit-dwarf /tmp/banana/test.c -c -o /tmp/outdir/foo.o $ clang outdir/foo.o -o outdir/hm $ llvm-dwarfdump outdir/hm | grep -C2 foo.dwo DW_AT_comp_dir ("/tmp") DW_AT_GNU_pubnames (true) DW_AT_GNU_dwo_name ("/tmp/outdir/foo.dwo") DW_AT_GNU_dwo_id (0xde4d396f3bf0e257) DW_AT_low_pc (0x0000000000401100) $ strace -o trace llvm-dwp -e outdir/hm -o outdir/hm.dwp error: No such file or directory $ cat trace | grep foo.dwo openat(AT_FDCWD, "/tmp/tmp/outdir/foo.dwo", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) ``` Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D96678
2021-01-25[llvm-dwp] Automatically set the target triplePhilip Pfaffe1-17/+32
The llvm-dwp tool hard-codes the target triple to x86. Instead, deduce the target triple from the object files being read. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D93749
2020-09-26Internalize functions from various tools. NFCFangrui Song1-1/+2
And internalize some classes if I noticed them:)
2020-06-23llvm-dwp.cpp - fix implicit CommandLine.h dependency. NFC.Simon Pilgrim1-0/+1
llvm-dwp uses cl::opt + cl::list but don't include CommandLine.h.
2020-04-25[llvm-dwp] Refuse DWARFv5 input DWP files.Igor Kudrin1-0/+9
The library can parse DWARFv5 unit index sections of DWP files, but llvm-dwp is not ready to process them. Refuse such input files for now. Differential Revision: https://reviews.llvm.org/D77143
2020-04-06[llvm-dwp] Fix a possible out of bound access.Igor Kudrin1-0/+8
llvm-dwp did not check section identifiers read from input files. In the case of an unexpected identifier, the calculated index for Contributions[] pointed outside the array. This fix avoids the issue by skipping unsupported identifiers. Differential Revision: https://reviews.llvm.org/D76543
2020-04-06[DebugInfo] Support DWARFv5 index sections.Igor Kudrin1-3/+4
DWARFv5 defines index sections in package files in a slightly different way than the pre-standard GNU proposal, see Section 7.3.5 in the DWARF standard and https://gcc.gnu.org/wiki/DebugFissionDWP for GNU proposal. The main concern here is values for section identifiers, which are partially overlapped with changed meanings. The patch adds support for v5 index sections and resolves that difficulty by defining a set of identifiers for internal use which can represent and distinct values of both standards. Differential Revision: https://reviews.llvm.org/D75929
2020-04-06[DebugInfo] Rename section identifiers which are deprecated in DWARFv5. NFC.Igor Kudrin1-9/+10
This is a preparation for an upcoming patch which adds support for DWARFv5 unit index sections. The patch adds tag "_EXT_" to identifiers which reference sections that are deprecated in the DWARFv5 standard. See D75929 for the discussion. Differential Revision: https://reviews.llvm.org/D77141