summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCCodeView.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [codeview] Revert inline line table change of r362264Reid Kleckner2019-05-311-0/+1
| | | | | | | | | | | | Testing with debuggers shows that our previous behavior was correct. The reason I thought MSVC did things differently is that MSVC prefers to use the 0xB combined code offset and code length update opcode when inline sites are discontiguous. Keep the test changes, and update the llvm-pdbutil inline line table dumper to account for this new interpretation of the opcodes. llvm-svn: 362277
* [codeview] Fix inline line table accuracy for discontiguous segmentsReid Kleckner2019-05-311-1/+0
| | | | | | | | | | | | | | | | After improving the inline line table dumper in llvm-pdbutil and looking at MSVC's inline line tables, it is clear that setting the length of the inlined code region does not update the code offset. This means that the delta to the beginning of a new discontiguous inlined code region should be calculated relative to the last code offset, excluding the length. Implementing this is a one line fix for MC: simply don't update LastLabel. While I'm updating these test cases, switch them to use llvm-objdump -d and llvm-pdbutil. This allows us to show offsets of each instruction and correlate the line table offsets to the actual code. llvm-svn: 362264
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-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
* [codeview] Flush labels before S_DEFRANGE* fragmentsReid Kleckner2018-12-171-2/+2
| | | | | | | | | | | | | This was a pre-existing bug that could be triggered with assembly like this: .p2align 2 .LtmpN: .cv_def_range "..." I noticed this when attempting to change clang to emit aligned symbol records. llvm-svn: 349403
* [codeview] Clean up machinery for deferring .cv_loc emissionReid Kleckner2018-08-281-43/+24
| | | | | | | | | | | Now that we create the label at the point of the directive, we don't need to set the "current CV location", and then later when we emit the next instruction, create a label for it and emit it. DWARF still defers the labels used in .debug_loc until the next instruction or value, for reasons unknown. llvm-svn: 340883
* Support: Simplify endian stream interface. NFCI.Peter Collingbourne2018-05-181-1/+1
| | | | | | | | | | | | 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
* [codeview] Ignore .cv_loc directives at the end of a functionReid Kleckner2018-04-251-0/+13
| | | | | | | | | | If no data or instructions are emitted after a location directive, we should clear the cv_loc when we change sections, or it will be emitted at the beginning of the next section. This violates our invariant that all .cv_loc directives belong to the same section. Add clearer assertions for this. llvm-svn: 330884
* [CodeView] Add line numbers for inlined call sitesReid Kleckner2018-01-181-3/+27
| | | | | | | | We did this for inline call site line tables, but we hadn't done it for regular function line tables yet. This patch copies that logic from encodeInlineLineTable. llvm-svn: 322905
* [CodeView] Sink complex inline functions to .cpp file, NFCReid Kleckner2018-01-181-0/+45
| | | | | | I'm cleaning up this code before I attempt to fix a line table bug. llvm-svn: 322904
* MC: Remove redundant `SetUsed` arguments in MCSymbol methodsSam Clegg2018-01-121-1/+1
| | | | | | | | | | | We can probably take this a step further since the only user of the isUsed flag is AsmParser it should probably be doing this explicitly. For now this is a step in the right direction though. Differential Revision: https://reviews.llvm.org/D41971 llvm-svn: 322386
* Remove redundant includes from lib/MC.Michael Zolotukhin2017-12-131-1/+0
| | | | llvm-svn: 320624
* Re-land "Fix Bug 30978 by emitting cv file checksums."Reid Kleckner2017-09-191-29/+92
| | | | | | | This reverts r313431 and brings back r313374 with a fix to write checksums as binary data and not ASCII hex strings. llvm-svn: 313657
* Revert "Fix Bug 30978 by emitting cv file checksums."Eric Beckmann2017-09-161-90/+29
| | | | | | | | | | | This reverts commit 6389e7aa724ea7671d096f4770f016c3d86b0d54. There is a bug in this implementation where the string value of the checksum is outputted, instead of the actual hex bytes. Therefore the checksum is incorrect, and this prevent pdbs from being loaded by visual studio. Revert this until the checksum is emitted correctly. llvm-svn: 313431
* Fix Bug 30978 by emitting cv file checksums.Eric Beckmann2017-09-151-29/+90
| | | | | | | | | | | | Summary: The checksums had already been placed in the IR, this patch allows MCCodeView to actually write it out to an MCStreamer. Subscribers: llvm-commits, hiraditya Differential Revision: https://reviews.llvm.org/D37157 llvm-svn: 313374
* 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
* [CodeView] Move CodeView YAML code to ObjectYAML.Zachary Turner2017-05-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | This is the beginning of an effort to move the codeview yaml reader / writer into ObjectYAML so that it can be shared. Currently the only consumer / producer of CodeView YAML is llvm-pdbdump, but CodeView can exist outside of PDB files, and indeed is put into object files and passed to the linker to produce PDB files. Furthermore, there are subtle differences in the types of records that show up in object file CodeView vs PDB file CodeView, but they are otherwise 99% the same. By having this code in ObjectYAML, we can have llvm-pdbdump reuse this code, while teaching obj2yaml and yaml2obj to use this syntax for dealing with object files that can contain CodeView. This patch only adds support for CodeView type information to ObjectYAML. Subsequent patches will add support for CodeView symbol information. llvm-svn: 304248
* [CodeView] Rename ModuleDebugFragment -> DebugSubsection.Zachary Turner2017-05-301-3/+3
| | | | | | | This is more concise, and matches the terminology used in other parts of the codebase more closely. llvm-svn: 304218
* [llvm-pdbdump] Abstract some of the YAML/Raw printing code.Zachary Turner2017-04-291-1/+1
| | | | | | | | | There is a lot of duplicate code for printing line info between YAML and the raw output printer. This introduces a base class that can be shared between the two, and makes some minor cleanups in the process. llvm-svn: 301728
* Rename some PDB classes.Zachary Turner2017-04-271-3/+3
| | | | | | | | | | | | | | | | | | | We have a lot of very similarly named classes related to dealing with module debug info. This patch has NFC, it just renames some classes to be more descriptive (albeit slightly more to type). The mapping from old to new class names is as follows: Old | New ModInfo | DbiModuleDescriptor ModuleSubstream | ModuleDebugFragment ModStream | ModuleDebugStream With the corresponding Builder classes renamed accordingly. Differential Revision: https://reviews.llvm.org/D32506 llvm-svn: 301555
* [CodeView] Fix off-by-one error in def range gap emissionReid Kleckner2017-01-241-6/+6
| | | | | | | | | Also fixes a much worse bug where we emitted the wrong gap size for the def range uncovered by the test for this issue. Fixes PR31726. llvm-svn: 292949
* Reapply "[CodeGen] Fix invalid DWARF info on Win64"Keno Fischer2017-01-021-1/+1
| | | | | | | This reapplies rL289013 (reverted in rL289014) with the fixes identified in D21731. Should hopefully pass the buildbots this time. llvm-svn: 290809
* Resubmit "[CodeView] Hook CodeViewRecordIO for reading/writing symbols."Zachary Turner2016-12-161-1/+3
| | | | | | | The original patch was broken due to some undefined behavior as well as warnings that were triggering -Werror. llvm-svn: 290000
* Revert "[CodeView] Hook CodeViewRecordIO for reading/writing symbols."Zachary Turner2016-12-161-3/+1
| | | | | | | This reverts commit r289978, which is failing due to some rebase/merge issues. llvm-svn: 289981
* [CodeView] Hook CodeViewRecordIO for reading/writing symbols.Zachary Turner2016-12-161-1/+3
| | | | | | | | | This is the 3rd of 3 patches to get reading and writing of CodeView symbol and type records to use a single codepath. Differential Revision: https://reviews.llvm.org/D26427 llvm-svn: 289978
* Revert "[CodeGen] Fix invalid DWARF info on Win64"Keno Fischer2016-12-081-1/+1
| | | | | | Appears to break on build bots. Reverting pending investigation. llvm-svn: 289014
* [CodeGen] Fix invalid DWARF info on Win64Keno Fischer2016-12-081-1/+1
| | | | | | | | | | | | | | | The relocations for `DIEEntry::EmitValue` were wrong for Win64 (emitting FK_Data_4 instead of FK_SecRel_4). This corrects that oversight so that the DWARF data is correct in Win64 COFF files. Fixes PR15393. Patch by Jameson Nash <jameson@juliacomputing.com> based on a patch by David Majnemer. Differential Revision: https://reviews.llvm.org/D21731 llvm-svn: 289013
* [codeview] Truncate records to maximum record size near 64KBReid Kleckner2016-10-051-0/+7
| | | | | | | | | | | | If we don't truncate, LLVM asserts when the label difference doesn't fit in a 16 bit field. This patch truncates two kinds of data: trailing null terminated names in symbol records, and inline line tables. The inline line table test that I have is too large (many MB), so I'm not checking it in. Hopefully fixes PR28264. llvm-svn: 283403
* [codeview] Optimize the size of defranges with gapsReid Kleckner2016-09-151-5/+43
| | | | | | | | | For small, discontiguous local variable regions, CodeView can use a single defrange record with a gap, rather than having two defrange records. I expect that this optimization will only have a minor impact on debug info size. llvm-svn: 281664
* [codeview] Add new directives to record inlined call site line infoReid Kleckner2016-09-071-46/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously we were trying to represent this with the "contains" list of the .cv_inline_linetable directive, which was not enough information. Now we directly represent the chain of inlined call sites, so we know what location to emit when we encounter a .cv_loc directive of an inner inlined call site while emitting the line table of an outer function or inlined call site. Fixes PR29146. Also fixes PR29147, where we would crash when .cv_loc directives crossed sections. Now we write down the section of the first .cv_loc directive, and emit an error if any other .cv_loc directive for that function is in a different section. Also fixes issues with discontiguous inlined source locations, like in this example: volatile int unlikely_cond = 0; extern void __declspec(noreturn) abort(); __forceinline void f() { if (!unlikely_cond) abort(); } int main() { unlikely_cond = 0; f(); unlikely_cond = 0; } Previously our tables gave bad location information for the 'abort' call, and the debugger wouldn't snow the inlined stack frame for 'f'. It is important to emit good line tables for this code pattern, because it comes up whenever an asan bug occurs in an inlined function. The __asan_report* stubs are generally placed after the normal function epilogue, leading to discontiguous regions of inlined code. Reviewers: majnemer, amccarth Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D24014 llvm-svn: 280822
* [MC] Move .cv_loc management logic out of MCContextReid Kleckner2016-08-261-4/+5
| | | | | | | | | | | MCContext already has many tasks, and separating CodeView out from it is probably a good idea. The .cv_loc tracking was modelled on the DWARF tracking which lived directly in MCContext. Removes the inclusion of MCCodeView.h from MCContext.h, so now there are only 10 build actions while I hack on CodeView support instead of 265. llvm-svn: 279847
* [codeview] Shrink inlined call site line info tablesReid Kleckner2016-07-141-5/+11
| | | | | | | | | | | For a fully inlined call chain like a -> b -> c -> d, we were emitting line info for 'd' 3 separate times: once for d's actual InlineSite line table, and twice for 'b' and 'c'. This is particularly inefficient when all these functions are in different headers, because now we need to encode the file change. Windbg was coping with our suboptimal output, so this should not be noticeable from the debugger. llvm-svn: 275502
* 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
* [codeview] Avoid emitting an empty file checksum tableReid Kleckner2016-06-081-0/+5
| | | | | | | | | | Again, the Microsoft linker does not like empty substreams. We still emit an empty string table if CodeView is enabled, but that doesn't cause problems because it always contains at least one null byte. llvm-svn: 272183
* [codeview] Some cleanup of Symbol Records.Zachary Turner2016-05-171-7/+13
| | | | | | | | | | | | | | * Reworks the CVSymbolTypes.def to work similarly to TypeRecords.def. * Moves some enums from SymbolRecords.h to CodeView.h to maintain consistency with how we do type records. * Generalize a few simple things like the record prefix * Define the leaf enum and the kind enum similar to how we do with tyep records. Differential Revision: http://reviews.llvm.org/D20342 Reviewed By: amccarth, rnk llvm-svn: 269867
* [codeview] Fix emission of file changes in inline line tablesReid Kleckner2016-02-191-1/+4
| | | | | | These are supposed to be file checksum table offsets, not file ids. llvm-svn: 261379
* [MC] Add support for encoding CodeView variable definition rangesDavid Majnemer2016-02-051-0/+63
| | | | | | | | | | | | | | | | | | | CodeView, like most other debug formats, represents the live range of a variable so that debuggers might print them out. They use a variety of records to represent how a particular variable might be available (in a register, in a frame pointer, etc.) along with a set of ranges where this debug information is relevant. However, the format only allows us to use ranges which are limited to a maximum of 0xF000 in size. This means that we need to split our debug information into chunks of 0xF000. Because the layout of code is not known until *very* late, we must use a new fragment to record the information we need until we can know *exactly* what the range is. llvm-svn: 259868
* [codeview] Don't attempt a cross-section label diffReid Kleckner2016-02-041-5/+11
| | | | | | | | This only comes up when we're trying to find the next .cv_loc label. Fixes PR26467 llvm-svn: 259733
* [codeview] Correctly handle inlining functions post-dominated by unreachableDavid Majnemer2016-02-021-3/+16
| | | | | | | | | | | | | | CodeView requires us to accurately describe the extent of the inlined code. We did this by grabbing the next debug location in source order and using *that* to denote where we stopped inlining. However, this is not sufficient or correct in instances where there is no next debug location or the next debug location belongs to the start of another function. To get this correct, use the end symbol of the function to denote the last possible place the inlining could have stopped at. llvm-svn: 259548
* [codeview] Wire up the .cv_inline_linetable directiveReid Kleckner2016-02-021-25/+96
| | | | | | | | This directive emits the binary annotations that describe line and code deltas in inlined call sites. Single-stepping through inlined frames in windbg now works. llvm-svn: 259535
* [CodeView] Implement .cv_inline_linetableDavid Majnemer2016-01-291-3/+71
| | | | | | | | | | | This support is _very_ rudimentary, just enough to get some basic data into the CodeView debug section. Left to do is: - Use the combined opcodes to save space. - Do something about code offsets. llvm-svn: 259230
* Fix some -Wstring-conversion warningsDavid Blaikie2016-01-291-6/+6
| | | | | | | I don't seem to see these locally, maybe just need to update my compiler, or we haven't turned them on for LLVM's build and we should... llvm-svn: 259146
* Reland "[CodeView] Use assembler directives for line tables"Reid Kleckner2016-01-291-0/+222
| | | | | | | | This reverts commit r259126 and relands r259117. This time with updated library dependencies. llvm-svn: 259130
* Revert "[CodeView] Use assembler directives for line tables"Reid Kleckner2016-01-291-222/+0
| | | | | | | | | This reverts commit r259117. The LineInfo constructor is defined in the codeview library and we have to link against it now. Doing that isn't trivial, so reverting for now. llvm-svn: 259126
* Silence gcc warning about ternary and enumerationsReid Kleckner2016-01-281-1/+1
| | | | llvm-svn: 259123
* [CodeView] Use assembler directives for line tablesReid Kleckner2016-01-281-0/+222
Adds a new family of .cv_* directives to LLVM's variant of GAS syntax: - .cv_file: Similar to DWARF .file directives - .cv_loc: Similar to the DWARF .loc directive, but starts with a function id. CodeView line tables are emitted by function instead of by compilation unit, so we needed an extra field to communicate this. Rather than overloading the .loc direction further, we decided it was better to have our own directive. - .cv_stringtable: Emits the codeview string table at the current position. Currently this just contains the filenames as null-terminated strings. - .cv_filechecksums: Emits the file checksum table for all files used with .cv_file so far. There is currently no support for emitting actual checksums, just filenames. This moves the line table emission code down into the assembler. This is in preparation for implementing the inlined call site line table format. The inline line table format encoding algorithm requires knowing the absolute code offsets, so it must run after the assembler has laid out the code. David Majnemer collaborated on this patch. llvm-svn: 259117
OpenPOWER on IntegriCloud