summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCDwarf.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [DebugInfo] Generate fixups as emitting DWARF .debug_line.Hsiangkai Wang2018-08-011-0/+51
| | | | | | | | | | | | | | | | It is necessary to generate fixups in .debug_line as relaxation is enabled due to the address delta may be changed after relaxation. DWARF will record the mappings of lines and addresses in .debug_line section. It will encode the information using special opcodes, standard opcodes and extended opcodes in Line Number Program. I use DW_LNS_fixed_advance_pc to encode fixed length address delta and DW_LNE_set_address to encode absolute address to make it possible to generate fixups in .debug_line section. Differential Revision: https://reviews.llvm.org/D46850 llvm-svn: 338477
* Remove trailing spaceFangrui Song2018-07-301-1/+1
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338293
* Use debug-prefix-map for AT_NAMEJonas Devlieghere2018-07-111-8/+1
| | | | | | | | | | | | | | | | | | AT_NAME was being emitted before the directory paths were remapped. This ensures that all paths are remapped before anything is emitted. An additional test case has been added. Note that this only works if the replacement string is an absolute path. If not, then AT_decl_file believes the new path is a relative path, and joins that path with the compilation directory. I do not know of a good way to resolve this. Patch by: Siddhartha Bagaria (starsid) Differential revision: https://reviews.llvm.org/D49169 llvm-svn: 336793
* Support -fdebug-prefix-map in llvm-mc. This is useful to omit thePaul Robinson2018-07-101-4/+12
| | | | | | | | | | | debug compilation dir when compiling assembly files with -g. Part of PR38050. Patch by Siddhartha Bagaria! Differential Revision: https://reviews.llvm.org/D48988 llvm-svn: 336680
* [DWARF] Don't keep a ref to possibly stack allocated data.Paul Robinson2018-06-201-2/+2
| | | | llvm-svn: 335146
* [DWARFv5] Tolerate files not all having an MD5 checksum.Paul Robinson2018-06-141-14/+10
| | | | | | | | | | | | | | | | | | In some cases, for example when compiling a preprocessed file, the front-end is not able to provide an MD5 checksum for all files. When that happens, omit the MD5 checksums from the final DWARF, because DWARF doesn't have a way to indicate that some but not all files have a checksum. When assembling a .s file, and some but not all .file directives provide an MD5 checksum, issue a warning and don't emit MD5 into the DWARF. Fixes PR37623. Differential Revision: https://reviews.llvm.org/D48135 llvm-svn: 334710
* [DWARFv5] llvm-mc -dwarf-version does not imply -g.Paul Robinson2018-06-121-7/+14
| | | | | | | | | | | | | Don't provide the assembler source as the "root file" unless the user asked to have debug info for the assembler source (with -g). If the source doesn't provide an explicit ".file 0" then (a) use the compilation directory as directory #0, and (b) use the file #1 info for file #0 also. Differential Revision: https://reviews.llvm.org/D48055 llvm-svn: 334512
* Support: Simplify endian stream interface. NFCI.Peter Collingbourne2018-05-181-8/+4
| | | | | | | | | | | | Provide some free functions to reduce verbosity of endian-writing a single value, and replace the endianness template parameter with a field. Part of PR37466. Differential Revision: https://reviews.llvm.org/D47032 llvm-svn: 332757
* Reapply "[DWARFv5] Emit file 0 to the line table."Paul Robinson2018-03-291-27/+34
| | | | | | | | | | | | | | | | | DWARF v5 specifies that the root file (also given in the DW_AT_name attribute of the compilation unit DIE) should be emitted explicitly to the line table's list of files. This makes the line table more independent of the .debug_info section. We emit the new syntax only for DWARF v5 and later. Fixes the bug found by asan. Also XFAIL the new test for Darwin, which is stuck on DWARF v2, and fix up other tests so they stop failing on Windows. Last but not least, don't break "clang -g" of an assembler file that has .file directives in it. Differential Revision: https://reviews.llvm.org/D44054 llvm-svn: 328805
* Revert "Reapply "[DWARFv5] Emit file 0 to the line table.""Alexander Potapenko2018-03-281-34/+27
| | | | | | | | | | | | | | | This reverts commit r328676. Commit r328676 broke the -no-integrated-as flag necessary to build Linux kernel with Clang: $ cat t.c void foo() {} $ clang -no-integrated-as -c t.c -g /tmp/t-dcdec5.s: Assembler messages: /tmp/t-dcdec5.s:8: Error: file number less than one clang-7.0: error: assembler command failed with exit code 1 (use -v to see invocation) llvm-svn: 328699
* Reapply "[DWARFv5] Emit file 0 to the line table."Paul Robinson2018-03-271-27/+34
| | | | | | | | | | | | | | | | DWARF v5 specifies that the root file (also given in the DW_AT_name attribute of the compilation unit DIE) should be emitted explicitly to the line table's list of files. This makes the line table more independent of the .debug_info section. Fixes the bug found by asan. Also XFAIL the new test for Darwin, which is stuck on DWARF v2, and fix up other tests so they stop failing on Windows. Last but not least, don't break "clang -g" of an assembler file that has .file directives in it. Differential Revision: https://reviews.llvm.org/D44054 llvm-svn: 328676
* [DWARF] Suppress split line tables more carefully.Paul Robinson2018-03-271-2/+5
| | | | | | | | | | | | | | | | If a given split type unit does not have source locations, don't have it refer to the split line table. If no split type unit refers to the split line table, don't emit the line table at all. This will save a little space on rare occasions, but also refactors things a bit to improve which class is responsible for what. Responding to review comments on r326395. Differential Revision: https://reviews.llvm.org/D44220 llvm-svn: 328670
* Revert "Reapply "[DWARFv5] Emit file 0 to the line table.""Alexander Kornienko2018-03-071-34/+27
| | | | | | | | | | | | | | | | This reverts commit r326839. r326839 breaks assembly file parsing: $ cat q.c void g() {} $ clang -S q.c -g $ clang -g -c q.s q.s:9:2: error: file number already allocated .file 1 "/tmp/test" "q.c" ^ llvm-svn: 326902
* Reapply "[DWARFv5] Emit file 0 to the line table."Paul Robinson2018-03-061-27/+34
| | | | | | | | Fixes the bug found by asan. Also XFAIL the new test for Darwin, which is stuck on DWARF v2, and fix up other tests so they stop failing on Windows. llvm-svn: 326839
* Revert "[DWARFv5] Emit file 0 to the line table."Paul Robinson2018-03-061-34/+27
| | | | | | | | | Caused an asan failure. This reverts commit d54883f081186cdcce74e6f98cfc0438579ec019. aka r326758 llvm-svn: 326762
* [DWARFv5] Emit file 0 to the line table.Paul Robinson2018-03-061-27/+34
| | | | | | | | | | | DWARF v5 specifies that the root file (also given in the DW_AT_name attribute of the compilation unit DIE) should be emitted explicitly to the line table's list of files. This makes the line table more independent of the .debug_info section. Differential Revision: https://reviews.llvm.org/D44054 llvm-svn: 326758
* [DebugInfo] Support DWARF v5 source code embedding extensionScott Linder2018-02-231-10/+41
| | | | | | | | | | | | | | | | | | | In DWARF v5 the Line Number Program Header is extensible, allowing values with new content types. In this extension a content type is added, DW_LNCT_LLVM_source, which contains the embedded source code of the file. Add new optional attribute for !DIFile IR metadata called source which contains source text. Use this to output the source to the DWARF line table of code objects. Analogously extend METADATA_FILE in Bitcode and .file directive in ASM to support optional source. Teach llvm-dwarfdump and llvm-objdump about the new values. Update the output format of llvm-dwarfdump to make room for the new attribute on file_names entries, and support embedded sources for the -source option in llvm-objdump. Differential Revision: https://reviews.llvm.org/D42765 llvm-svn: 325970
* [DWARFv5] Turn an assert into a diagnostic. Hand-coded assembler filesPaul Robinson2018-02-221-12/+18
| | | | | | | | should not trigger assertions. Differential Revision: https://reviews.llvm.org/D43152 llvm-svn: 325831
* [DWARFv5] Emit .debug_line_str (in a non-DWO file).Paul Robinson2018-02-061-22/+109
| | | | | | | | This should enable the linker to do string-pooling of path names. Differential Revision: https://reviews.llvm.org/D42707 llvm-svn: 324393
* Turn two static functions into methods, to simplify calling them.Paul Robinson2018-01-301-14/+6
| | | | llvm-svn: 323821
* [DWARFv5] MC support for MD5 file checksumsPaul Robinson2018-01-091-7/+26
| | | | | | | Extend .file directive syntax to allow specifying an MD5 checksum for the source file. Emit the checksums in DWARF v5 line tables. llvm-svn: 322134
* [MC] Allow .file directives to be out-of-orderPaul Robinson2017-12-141-1/+2
| | | | llvm-svn: 320727
* [MC/Dwarf] Use the older DWARF linetables format on Darwin.Davide Italiano2017-12-071-0/+3
| | | | | | | | | | dsymutil doesn't yet understand the new format and the change, among others, breaks a large fraction of the debugger tests on mac OS. rdar://problem/35856354 llvm-svn: 319995
* [DWARFv5] Emit v5 line table header.Paul Robinson2017-12-051-32/+84
| | | | | | Differential Revision: https://reviews.llvm.org/D40741 llvm-svn: 319827
* Re-submit r289925 (Update .debug_line section version to match DWARF version)Paul Robinson2017-12-041-2/+12
| | | | | | | | | | | | | | | Set the .debug_line version to match the requested DWARF version, except with a maximum of v4 because we don't support v5 yet. Previously Chromium had issues with this patch; see PR31407. Chromium tool issues have been addressed, so hopefully this will go through this time. Patch by Katya Romanova! Differential Revision: https://reviews.llvm.org/D38002 llvm-svn: 319699
* [MC] Handle unknown literal register numbers in .cfi_* directivesJake Ehrlich2017-12-011-6/+6
| | | | | | | | | | | | | | | | | r230670 introduced a step to map EH register numbers to standard DWARF register numbers. This failed to consider the case when a user .cfi_* directive uses an integer literal rather than a register name, to specify a DWARF register number that has no corresponding LLVM register number (e.g. a special register that the compiler and assembler have no name for). Fixes PR34028. Patch by Roland McGrath Differential Revision: https://reviews.llvm.org/D36493 llvm-svn: 319586
* MC: simplify internal function call parameterSaleem Abdulrasool2017-07-291-30/+26
| | | | | | | | | | Rather than passing along most of the parameters, pass a reference to the MCDWARFrameInfo instead. This makes it easier to pass additional information about the frame to the checks. We need to keep the extra constructor for the Key around to allow the construction of the null and tombstone keys. NFC. llvm-svn: 309493
* MC: account for the return column in the CIE keySaleem Abdulrasool2017-07-291-8/+11
| | | | | | | | If the return column is different, we cannot coalesce the CIE across the FDEs. Add that to the key calculation. This ensures that we emit a separate CIE. llvm-svn: 309492
* MC: add support for cfi_return_columnSaleem Abdulrasool2017-07-281-10/+12
| | | | | | | | | This adds support for the CFI pseudo-op return_column. This specifies the frame table column which contains the return address. Addresses PR33953! llvm-svn: 309360
* Move Object format code to lib/BinaryFormat.Zachary Turner2017-06-071-1/+1
| | | | | | | | | | | | This creates a new library called BinaryFormat that has all of the headers from llvm/Support containing structure and layout definitions for various types of binary formats like dwarf, coff, elf, etc as well as the code for identifying a file from its magic. Differential Revision: https://reviews.llvm.org/D33843 llvm-svn: 304864
* Sort the remaining #include lines in include/... and lib/....Chandler Carruth2017-06-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | I did this a long time ago with a janky python script, but now clang-format has built-in support for this. I fed clang-format every line with a #include and let it re-sort things according to the precise LLVM rules for include ordering baked into clang-format these days. I've reverted a number of files where the results of sorting includes isn't healthy. Either places where we have legacy code relying on particular include ordering (where possible, I'll fix these separately) or where we have particular formatting around #include lines that I didn't want to disturb in this patch. This patch is *entirely* mechanical. If you get merge conflicts or anything, just ignore the changes in this patch and run clang-format over your #include lines in the files. Sorry for any noise here, but it is important to keep these things stable. I was seeing an increasing number of patches with irrelevant re-ordering of #include lines because clang-format was used. This patch at least isolates that churn, makes it easy to skip when resolving conflicts, and gets us to a clean baseline (again). llvm-svn: 304787
* Distinguish between code pointer size and DataLayout::getPointerSize() in ↵Konstantin Zhuravlyov2017-04-171-10/+11
| | | | | | DWARF info generation llvm-svn: 300463
* [DWARFv5] llvm-mc support for new unit header.Paul Robinson2017-02-281-5/+9
| | | | | | | | | This is for running the assembler with -g (to emit DWARF describing the assembler source). Differential Revision: http://reviews.llvm.org/D30475 llvm-svn: 296541
* [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other ↵Eugene Zelenko2017-02-141-13/+33
| | | | | | | | minor fixes (NFC). Same changes in files affected by reduced MC headers dependencies. llvm-svn: 295009
* Speculatively revert r289925, see PR31407Nico Weber2016-12-161-7/+2
| | | | llvm-svn: 289944
* Update .debug_line section version information to match DWARF version.Ekaterina Romanova2016-12-161-2/+7
| | | | | | | | | | | | One more attempt to re-commit the patch r285355, which I had to revert in r285362, because some tests were failing (the reason is because the size of the line_table varied depending on the full file name). In the past the compiler always emitted .debug_line version 2, though some opcodes from DWARF 3 (e.g. DW_LNS_set_prologue_end, DW_LNS_set_epilogue_begin or DW_LNS_set_isa) and from DWARF 4 could be emitted by the compiler. This patch changes version information of .debug_line to exactly match the DWARF version. For .debug_line version 4, a new field maximum_operations_per_instruction is emitted. Differential Revision: https://reviews.llvm.org/D16697 llvm-svn: 289925
* Reverting back r285355: "Update .debug_line section version information to ↵Ekaterina Romanova2016-10-271-7/+2
| | | | | | match DWARF version", while I'm investigating a test failure. llvm-svn: 285362
* Update .debug_line section version information to match DWARF version.Ekaterina Romanova2016-10-271-2/+7
| | | | | | | | | | In the past the compiler always emitted .debug_line version 2, though some opcodes from DWARF 3 (e.g. DW_LNS_set_prologue_end, DW_LNS_set_epilogue_begin or DW_LNS_set_isa) and from DWARF 4 could be emitted by the compiler. This patch changes version information of .debug_line to exactly match the DWARF version. For .debug_line version 4, a new field maximum_operations_per_instruction is emitted. Differential Revision: https://reviews.llvm.org/D16697 llvm-svn: 285355
* Tidy the calls to getCurrentSection().first -> getCurrentSectionOnly to helpEric Christopher2016-10-141-1/+1
| | | | | | readability a bit. llvm-svn: 284202
* Invoke add-discriminator at -g0 -fsample-profileDehao Chen2016-10-071-1/+2
| | | | | | | | | | | | Summary: -fsample-profile needs discriminator, which will not be added if built with -g0. This patch makes sure the discriminator is added for sample-profile at -g0. A followup patch will be send out to update clang tests. Reviewers: davidxl, dblaikie, echristo, dnovillo Subscribers: mehdi_amini, probinson, llvm-commits Differential Revision: https://reviews.llvm.org/D25132 llvm-svn: 283565
* Apply clang-tidy's modernize-loop-convert to lib/MC.Benjamin Kramer2016-06-261-24/+19
| | | | | | Only minor manual fixes. No functionality change intended. llvm-svn: 273814
* Prune some includes from headers and sink some inline functionsReid Kleckner2016-06-221-0/+1
| | | | | | | | MCSymbol.h shouldn't pull in MCAssembler.h, just MCFragment.h. MCLinkerOptimizationHint.h shouldn't need MCMachObjectWriter.h. The rest is fixing the fallout. llvm-svn: 273507
* [MC] Rename EmitFill to emitFillPetr Hosek2016-06-011-1/+1
| | | | | | | | This is to match the overloaded variants as well as the new style. Differential Revision: http://reviews.llvm.org/D20690 llvm-svn: 271359
* Read discriminators correctly from object file.Dehao Chen2016-04-281-4/+1
| | | | | | | | | | | | | | | Summary: This is the follow-up patch for http://reviews.llvm.org/D19436 * Update the discriminator reading algorithm to match the assignment algorithm. * Add test to cover the new algorithm. Reviewers: dnovillo, echristo, dblaikie Subscribers: danielcdh, dblaikie, echristo, llvm-commits, joker.eph Differential Revision: http://reviews.llvm.org/D19522 llvm-svn: 267945
* Update discriminator assignment algorithm in clang assembler.Dehao Chen2016-04-221-1/+6
| | | | | | | | | | | | Summary: The clang assembler assumes that the discriminator remains the same when there is source line change. The correct behavior is that when there is line change, discriminator will automatically reset to 0. Reviewers: dnovillo, davidxl, echristo Subscribers: echristo, llvm-commits Differential Revision: http://reviews.llvm.org/D19436 llvm-svn: 267226
* Don't crash when compiling inline assembler containing .file directives.Adrian Prantl2016-03-091-3/+3
| | | | | | | | | | Removing the assertion is safe to do because any module level inline assembly is always emitted first via AsmPrinter::doInitialization(). http://reviews.llvm.org/D16101 rdar://22690666 llvm-svn: 263033
* [MCDwarf] Fix encoding of line tables with weird custom parametersFrederic Riss2016-01-311-2/+5
| | | | | | | | | | | | | | | | With poorly chosen custom parameters, the line table encoding logic would sometimes end up generating a special opcode bigger than 255, which is wrong. The set of default parameters that LLVM uses isn't subject to this bug. When carefully chosing the line table parameters, it's impossible to fall into the corner case that this patch fixes. The standard however doesn't require that these parameters be carefully chosen. And even if it did, we shouldn't generate broken encoding. Add a unittest for this specific encoding bug, and while at it, create some unit tests for the encoding logic using different sets of parameters. llvm-svn: 259334
* Rename MCLineEntry to MCDwarfLineEntryDavid Majnemer2016-01-211-5/+5
| | | | | | | MCLineEntry gives the impression that it is generic MC machinery. However, it is specific to DWARF. llvm-svn: 258381
* Clang-format my previous change (r256313)Paul Robinson2016-01-041-5/+5
| | | | llvm-svn: 256764
* Accept dwarf version 5 for CIE versions.Eric Christopher2015-12-281-0/+1
| | | | llvm-svn: 256527
OpenPOWER on IntegriCloud