aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-dwp/llvm-dwp.cpp
AgeCommit message (Collapse)AuthorFilesLines
2020-04-06[llvm-dwp] Refactor handling of section identifiers. NFCI.Igor Kudrin1-13/+27
There is a number of places in llvm-dwp.cpp where a section identifier is translated into an index of an internal array of section contributions, and another place where the index is converted to an on-disk value. All these places use direct expressions like "<id> - DW_SECT_INFO" or "<index> + DW_SECT_INFO", exploiting the fact that DW_SECT_INFO is the minimum valid value of that kind. The patch adds distinct functions for that translation. The goal is to make the code more readable and to prepare it to support index sections of new versions, where the numeric scheme of section indexes is changed. Differential Revision: https://reviews.llvm.org/D76067
2020-04-03[DebugInfo] Rename getOffset() to getContribution(). NFC.Igor Kudrin1-3/+3
The old name was a bit misleading because the functions actually return contributions to the corresponding sections. Differential revision: https://reviews.llvm.org/D77302
2020-03-19[llvm-dwp] Start error messages with a lowercase letter.Igor Kudrin1-3/+3
We usually start error messages with lowercase letters and most of them in llvm-dwp follow that rule. This patch fixes a few messages that started with capital letters. Differential revision: https://reviews.llvm.org/D76277
2020-03-17Replace MCTargetOptionsCommandFlags.inc and CommandFlags.inc by runtime ↵serge-sans-paille1-2/+4
registration MCTargetOptionsCommandFlags.inc and CommandFlags.inc are headers which contain cl::opt with static storage. These headers are meant to be incuded by tools to make it easier to parametrize codegen/mc. However, these headers are also included in at least two libraries: lldCommon and handle-llvm. As a result, when creating DYLIB, clang-cpp holds a reference to the options, and lldCommon holds another reference. Linking the two in a single executable, as zig does[0], results in a double registration. This patch explores an other approach: the .inc files are moved to regular files, and the registration happens on-demand through static declaration of options in the constructor of a static object. [0] https://bugzilla.redhat.com/show_bug.cgi?id=1756977#c5 Differential Revision: https://reviews.llvm.org/D75579
2020-02-20[DebugInfo][NFCI]: Removed an exclamation mark from error message.Sourabh Singh Tomar1-1/+1
2020-02-19[DebugInfo]: Added support for DWARFv5 Info section header parsing in ↵Sourabh Singh Tomar1-4/+14
llvm-dwp utility. Summary: This patch teaches llvm-dwp to parse DWARFv5 info section header. Tested this using asm test case caontaining DWARFv5 info. Assemling it to DWO object, checking corresponding content using llvm-dwarfdump. Then finally, packaging it to DWP using llvm-dwp and again checking corresponding content using llvm-dwarfdump. Reviewers: dblaikie, aprantl, probinson. Reviewed By: dblaikie. Differential Revision: https://reviews.llvm.org/D74425
2020-02-14[MCStreamer] De-capitalize EmitValue EmitIntValue{,InHex}Fangrui Song1-9/+9
2020-02-14[MC] De-capitalize some MCStreamer::Emit* functionsFangrui Song1-3/+3
2020-02-10Revert "Remove redundant "std::move"s in return statements"Bill Wendling1-1/+1
The build failed with error: call to deleted constructor of 'llvm::Error' errors. This reverts commit 1c2241a7936bf85aa68aef94bd40c3ba77d8ddf2.
2020-02-10Remove redundant "std::move"s in return statementsBill Wendling1-1/+1
2019-10-23[Mips] Use appropriate private label prefix based on Mips ABIMirko Brkusanin1-2/+3
MipsMCAsmInfo was using '$' prefix for Mips32 and '.L' for Mips64 regardless of -target-abi option. By passing MCTargetOptions to MCAsmInfo we can find out Mips ABI and pick appropriate prefix. Tags: #llvm, #clang, #lldb Differential Revision: https://reviews.llvm.org/D66795
2019-08-14Recommit r368812 "[llvm/Object] - Convert SectionRef::getName() to return ↵George Rimar1-3/+4
Expected<>" Changes: no changes. A fix for the clang code will be landed right on top. Original commit message: SectionRef::getName() returns std::error_code now. Returning Expected<> instead has multiple benefits. For example, it forces user to check the error returned. Also Expected<> may keep a valuable string error message, what is more useful than having a error code. (Object\invalid.test was updated to show the new messages printed.) This patch makes a change for all users to switch to Expected<> version. Note: in a few places the error returned was ignored before my changes. In such places I left them ignored. My intention was to convert the interface used, and not to improve and/or the existent users in this patch. (Though I think this is good idea for a follow-ups to revisit such places and either remove consumeError calls or comment each of them to clarify why it is OK to have them). Differential revision: https://reviews.llvm.org/D66089 llvm-svn: 368826
2019-08-14Revert r368812 "[llvm/Object] - Convert SectionRef::getName() to return ↵George Rimar1-4/+3
Expected<>" It broke clang BB: http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/16455 llvm-svn: 368813
2019-08-14[llvm/Object] - Convert SectionRef::getName() to return Expected<>George Rimar1-3/+4
SectionRef::getName() returns std::error_code now. Returning Expected<> instead has multiple benefits. For example, it forces user to check the error returned. Also Expected<> may keep a valuable string error message, what is more useful than having a error code. (Object\invalid.test was updated to show the new messages printed.) This patch makes a change for all users to switch to Expected<> version. Note: in a few places the error returned was ignored before my changes. In such places I left them ignored. My intention was to convert the interface used, and not to improve and/or the existent users in this patch. (Though I think this is good idea for a follow-ups to revisit such places and either remove consumeError calls or comment each of them to clarify why it is OK to have them). Differential revision: https://reviews.llvm.org/D66089 llvm-svn: 368812
2019-08-06Switch LLVM to use 64-bit offsets (2/5)Igor Kudrin1-12/+12
This updates all libraries and tools in LLVM Core to use 64-bit offsets which directly or indirectly come to DataExtractor. Differential Revision: https://reviews.llvm.org/D65638 llvm-svn: 368014
2019-08-05Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFCFangrui Song1-1/+1
F_{None,Text,Append} are kept for compatibility since r334221. llvm-svn: 367800
2019-05-16Recommit [Object] Change object::SectionRef::getContents() to return ↵Fangrui Song1-3/+4
Expected<StringRef> r360876 didn't fix 2 call sites in clang. Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now. Follow-up of D61781. llvm-svn: 360892
2019-05-16Revert r360876 "[Object] Change object::SectionRef::getContents() to return ↵Hans Wennborg1-4/+3
Expected<StringRef>" It broke the Clang build, see llvm-commits thread. > Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now. > > Follow-up of D61781. llvm-svn: 360878
2019-05-16[Object] Change object::SectionRef::getContents() to return Expected<StringRef>Fangrui Song1-3/+4
Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now. Follow-up of D61781. llvm-svn: 360876
2019-02-12[llvm-dwp] Use color-formatted error reportingJordan Rupprecht1-2/+3
llvm-svn: 353876
2019-02-12[llvm-dwp] Avoid writing the output dwp file when there is an errorJordan Rupprecht1-6/+9
Summary: Use ToolOutputFile to clean up the output file unless dwp actually finishes successfully. Reviewers: dblaikie Reviewed By: dblaikie Subscribers: jdoerfert, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58130 llvm-svn: 353873
2019-02-12[llvm-dwp] Abort when dwo_id is unsetJordan Rupprecht1-3/+8
Summary: An empty dwo_id indicates a degenerate .dwo file that should not have been generated in the first place. Instead of discovering this error later when merging with another degenerate .dwo file, print an error immediately when noticing an unset dwo_id, including the filename of the offending file. Test case created by compiling a trivial file w/ `-fno-split-dwarf-inlining -gmlt -gsplit-dwarf -c` prior to r353771 Reviewers: dblaikie Reviewed By: dblaikie Subscribers: jdoerfert, aprantl, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58085 llvm-svn: 353846
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
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-09-06Reland rL341509: "[llvm-dwp] Use buffer_stream if output file is not ↵Fangrui Song1-1/+9
seekable (e.g. "-")" It caused ambiguity between llvm::cl::Optional and llvm::Optional, which has been fixed by dropping `using namespace cl;` in favor of explicit cl:: qualified names. llvm-svn: 341586
2018-09-06[llvm-dwp] Use cl:: instead of using namespace clFangrui Song1-13/+13
`using namespace cl` makes llvm::cl::Optional (in Support/CommandLine.h) visible which will cause ambiguity when unqualified `Optional` is looked up (can also refer to llvm::Optional). cl:: is used much more than `using namespace cl`, so let's not use the latter. Also append \n to the argument of cl::ParseCommandLineOptions llvm-svn: 341584
2018-09-06Revert rL341509 to fix massive failures on buildbotsMax Kazantsev1-9/+1
llvm-svn: 341515
2018-09-06[llvm-dwp] Use buffer_stream if output file is not seekable (e.g. "-")Fangrui Song1-1/+9
Reviewers: dblaikie, pcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D51707 llvm-svn: 341509
2018-05-18MC: Change the streamer ctors to take an object writer instead of a stream. ↵Peter Collingbourne1-3/+4
NFCI. The idea is that a client that wants split dwarf would create a specific kind of object writer that creates two files, and use it to create the streamer. Part of PR37466. Differential Revision: https://reviews.llvm.org/D47050 llvm-svn: 332749
2018-05-06[llvm-dwp] Define InitLLVM.Fangrui Song1-0/+2
llvm-svn: 331610
2018-04-11Rename *CommandFlags.def to *CommandFlags.incDavid Blaikie1-1/+1
These aren't the .def style files used in LLVM that require a macro defined before their inclusion - they're just basic non-modular includes to stamp out command line flag variables. llvm-svn: 329840
2018-03-14DWARF: Unify form size handling codePavel Labath1-1/+1
Summary: This patch replaces the two switches which are deducing the size of various forms with a single implementation. I have put the new implementation into BinaryFormat, to avoid introducing dependencies between the two independent libraries (DebugInfo and CodeGen) that need this functionality. Reviewers: aprantl, JDevlieghere, dblaikie Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D44418 llvm-svn: 327486
2018-01-03Thread MCSubtargetInfo through Target::createMCAsmBackendAlex Bradbury1-6/+6
Currently it's not possible to access MCSubtargetInfo from a TgtMCAsmBackend. D20830 threaded an MCSubtargetInfo reference through MCAsmBackend::relaxInstruction, but this isn't the only function that would benefit from access. This patch removes the Triple and CPUString arguments from createMCAsmBackend and replaces them with MCSubtargetInfo. This patch just changes the interface without making any intentional functional changes. Once in, several cleanups are possible: * Get rid of the awkward MCSubtargetInfo handling in ARMAsmBackend * Support 16-bit instructions when valid in MipsAsmBackend::writeNopData * Get rid of the CPU string parsing in X86AsmBackend and just use a SubtargetFeature for HasNopl * Emit 16-bit nops in RISCVAsmBackend::writeNopData if the compressed instruction set extension is enabled (see D41221) This change initially exposed PR35686, which has since been resolved in r321026. Differential Revision: https://reviews.llvm.org/D41349 llvm-svn: 321692
2017-12-13Remove redundant includes from tools.Michael Zolotukhin1-9/+0
llvm-svn: 320631
2017-11-27Rename MCTargetOptionsCommandFlags.h to .def as it is not a normal/modular ↵David Blaikie1-1/+1
header as much as it is for stamping out some global/static variables llvm-svn: 319086
2017-10-11[MC] Have MCObjectStreamer take its MCAsmBackend argument via unique_ptr.Lang Hames1-2/+4
MCObjectStreamer owns its MCCodeEmitter -- this fixes the types to reflect that, and allows us to remove the last instance of MCObjectStreamer's weird "holding ownership via someone else's reference" trick. llvm-svn: 315531
2017-10-11[MC] Have MCObjectStreamer take its MCAsmBackend argument via unique_ptr.Lang Hames1-2/+3
MCObjectStreamer owns its MCAsmBackend -- this fixes the types to reflect that, and allows us to remove another instance of MCObjectStreamer's weird "holding ownership via someone else's reference" trick. llvm-svn: 315410
2017-09-02[llvm-dwp] Implement -e optionAlexander Shaposhnikov1-3/+51
The binutils utility dwp has an option "-e" https://gcc.gnu.org/wiki/DebugFissionDWP to specify an executable/library to get the list of *.dwo files from it. This option is particularly useful when someone runs the tool manually outside of a build system. This diff adds an implementation of "-e" to llvm-dwp. Test plan: make check-all Differential revision: https://reviews.llvm.org/D37371 llvm-svn: 312409
2017-08-02Don't pass the code model to MCRafael Espindola1-1/+1
I was surprised to see the code model being passed to MC. After all, it assembles code, it doesn't create it. The one place it is used is in the expansion of .cfi directives to handle .eh_frame being more that 2gb away from the code. As far as I can tell, gnu assembler doesn't even have an option to enable this. Compiling a c file with gcc -mcmodel=large produces a regular looking .eh_frame. This is probably because in practice linker parse and recreate .eh_frames. In llvm this is used because the JIT can place the code and .eh_frame very far apart. Ideally we would fix the jit and delete this option. This is hard. Apart from confusion another problem with the current interface is that most callers pass CodeModel::Default, which is bad since MC has no way to map it to the target default if it actually needed to. This patch then replaces the argument with a boolean with a default value. The vast majority of users don't ever need to look at it. In fact, only CodeGen and llvm-mc use it and llvm-mc just to enable more testing. llvm-svn: 309884
2017-06-26[DWARF] NFC: Collect info used by DWARFFormValue into a helper.Paul Robinson1-2/+2
Some forms have sizes that depend on the DWARF version, DWARF format (32/64-bit), or the size of an address. Collect these into a struct to simplify passing them around. Require callers to provide one when they query a form's size. Differential Revision: http://reviews.llvm.org/D34570 llvm-svn: 306315
2017-05-18[lib/Object] - Minor API update for llvm::Decompressor.George Rimar1-1/+1
I revisited Decompressor API (issue with it was triggered during D32865 review) and found it is probably provides more then we really need. Issue was about next method's signature: Error decompress(SmallString<32> &Out); It is too strict. At first I wanted to change it to decompress(SmallVectorImpl<char> &Out), but then found it is still not flexible because sticks to SmallVector. During reviews was suggested to use templating to simplify code. Patch do that. Differential revision: https://reviews.llvm.org/D33200 llvm-svn: 303331
2017-01-13[llvm-dwp] - Reuse object::Decompressor classGeorge Rimar1-31/+24
One more place where Decompressor class can be reused. Differential revision: https://reviews.llvm.org/D28679 llvm-svn: 291906
2016-11-11Clean up DWARFFormValue by reducing duplicated code and removing ↵Greg Clayton1-2/+10
DWARFFormValue::getFixedFormSizes() In preparation for a follow on patch that improves DWARF parsing speed, clean up DWARFFormValue so that we have can get the fixed byte size of a form value given a DWARFUnit or given the version, address byte size and dwarf32/64. This patch cleans up code so that everyone is using one of the new DWARFFormValue functions: static Optional<uint8_t> DWARFFormValue::getFixedByteSize(dwarf::Form Form, const DWARFUnit *U = nullptr); static Optional<uint8_t> DWARFFormValue::getFixedByteSize(dwarf::Form Form, uint16_t Version, uint8_t AddrSize, bool Dwarf32); This patch changes DWARFFormValue::skipValue() to rely on the output of DWARFFormValue::getFixedByteSize(...) instead of duplicating the code in each function. This will reduce the number of changes we need to make to DWARF to fewer places in DWARFFormValue when we add support for new form. This patch also starts to support DWARF64 so that we can get correct byte sizes for forms that vary according the DWARF 32/64. To reduce the code duplication a new FormSizeHelper pure virtual class was created that can be created as a FormSizeHelperDWARFUnit when you have a DWARFUnit, or FormSizeHelperManual where you manually specify the DWARF version, address byte size and DWARF32/DWARF64. There is now a single implementation of a function that gets the fixed byte size (instead of two where one took a DWARFUnit and one took the DWARF version, address byte size and DWARFFormat enum) and one function to skip the form values. https://reviews.llvm.org/D26526 llvm-svn: 286597
2016-11-11Make the Error class constructor protectedMehdi Amini1-7/+7
This is forcing to use Error::success(), which is in a wide majority of cases a lot more readable. Differential Revision: https://reviews.llvm.org/D26481 llvm-svn: 286561
2016-10-27Switch all DWARF variables for tags, attributes and forms over to use the ↵Greg Clayton1-5/+5
llvm::dwarf enumerations instead of using raw uint16_t values. This allows easier debugging as users can see the values of the enumerations in the variables view that will show the enumeration string instead of just a number. https://reviews.llvm.org/D26013 llvm-svn: 285309
2016-07-25MC] Provide an MCTargetOptions to implementors of MCAsmBackendCtorTy, NFCJoel Jones1-1/+2
Some targets, notably AArch64 for ILP32, have different relocation encodings based upon the ABI. This is an enabling change, so a future patch can use the ABIName from MCTargetOptions to chose which relocations to use. Tested using check-llvm. The corresponding change to clang is in: http://reviews.llvm.org/D16538 Patch by: Joel Jones Differential Revision: https://reviews.llvm.org/D16213 llvm-svn: 276654
2016-05-25llvm-dwp: Ensure uncompressed sections are not relocated during processing ↵David Blaikie1-3/+4
of later inputs Richard Smith identified this in post commit review of r270466. The string sections in particular (in the future, possibly all sections - so I'm not going to bother pulling out just the string sections for the extra lifetime handling right now) need to remain valid during processing of all inputs so that elements of the DWPStringPool can be looked up repeatedly without having to make in-memory copies of string contents in the noncompressed case (more common in dwp+dwp merge steps where the memory is a bigger problem because the files are larger). Using the SmallVector (or any vector) a reallocation on push_back could cause any of the nested SmallStrings in small mode to move in memory and invalid pointers to their contents. Using a deque the SmallStrings will never move around since no elements are removed from the container. llvm-svn: 270797
2016-05-23llvm-dwp: Reduce indentationDavid Blaikie1-48/+47
llvm-svn: 270507
2016-05-23llvm-dwp: Split out processing of input sections to improve readabilityDavid Blaikie1-61/+84
llvm-svn: 270503
2016-05-23llvm-dwp: Pull out compression handling helperDavid Blaikie1-15/+22
llvm-svn: 270496
2016-05-23llvm-dwp: More error handling around invalid compressed sectionsDavid Blaikie1-7/+4
llvm-svn: 270466