aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCCodeView.cpp
AgeCommit message (Collapse)AuthorFilesLines
2020-12-07[CodeView] Fix inline sites that are missing code offsets.Amy Huang1-4/+1
When an inline site has a starting code offset of 0, we sometimes don't emit the starting offset. Bug: https://bugs.llvm.org/show_bug.cgi?id=48377 Differential Revision: https://reviews.llvm.org/D92590
2020-04-20[MC][NFC] Use camelCase style for functions in MCObjectStreamerShengchen Kan1-1/+1
2020-02-29[MC] Add MCStreamer::emitInt{8,16,32,64}Fangrui Song1-13/+13
Similar to AsmPrinter::emitInt{8,16,32,64}.
2020-02-14[MCStreamer] De-capitalize EmitValue EmitIntValue{,InHex}Fangrui Song1-13/+13
2020-02-14[MC] De-capitalize another set of MCStreamer::Emit* functionsFangrui Song1-10/+10
Emit{ValueTo,Code}Alignment Emit{DTP,TP,GP}* EmitSymbolValue etc
2020-02-14[MC] De-capitalize some MCStreamer::Emit* functionsFangrui Song1-2/+2
2019-05-31[codeview] Revert inline line table change of r362264Reid Kleckner1-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
2019-05-31[codeview] Fix inline line table accuracy for discontiguous segmentsReid Kleckner1-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
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-12-17[codeview] Flush labels before S_DEFRANGE* fragmentsReid Kleckner1-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
2018-08-28[codeview] Clean up machinery for deferring .cv_loc emissionReid Kleckner1-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
2018-05-18Support: Simplify endian stream interface. NFCI.Peter Collingbourne1-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
2018-04-25[codeview] Ignore .cv_loc directives at the end of a functionReid Kleckner1-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
2018-01-18[CodeView] Add line numbers for inlined call sitesReid Kleckner1-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
2018-01-18[CodeView] Sink complex inline functions to .cpp file, NFCReid Kleckner1-0/+45
I'm cleaning up this code before I attempt to fix a line table bug. llvm-svn: 322904
2018-01-12MC: Remove redundant `SetUsed` arguments in MCSymbol methodsSam Clegg1-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
2017-12-13Remove redundant includes from lib/MC.Michael Zolotukhin1-1/+0
llvm-svn: 320624
2017-09-19Re-land "Fix Bug 30978 by emitting cv file checksums."Reid Kleckner1-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
2017-09-16Revert "Fix Bug 30978 by emitting cv file checksums."Eric Beckmann1-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
2017-09-15Fix Bug 30978 by emitting cv file checksums.Eric Beckmann1-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
2017-06-07Move Object format code to lib/BinaryFormat.Zachary Turner1-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
2017-05-30[CodeView] Move CodeView YAML code to ObjectYAML.Zachary Turner1-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
2017-05-30[CodeView] Rename ModuleDebugFragment -> DebugSubsection.Zachary Turner1-3/+3
This is more concise, and matches the terminology used in other parts of the codebase more closely. llvm-svn: 304218
2017-04-29[llvm-pdbdump] Abstract some of the YAML/Raw printing code.Zachary Turner1-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
2017-04-27Rename some PDB classes.Zachary Turner1-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
2017-01-24[CodeView] Fix off-by-one error in def range gap emissionReid Kleckner1-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
2017-01-02Reapply "[CodeGen] Fix invalid DWARF info on Win64"Keno Fischer1-1/+1
This reapplies rL289013 (reverted in rL289014) with the fixes identified in D21731. Should hopefully pass the buildbots this time. llvm-svn: 290809
2016-12-16Resubmit "[CodeView] Hook CodeViewRecordIO for reading/writing symbols."Zachary Turner1-1/+3
The original patch was broken due to some undefined behavior as well as warnings that were triggering -Werror. llvm-svn: 290000
2016-12-16Revert "[CodeView] Hook CodeViewRecordIO for reading/writing symbols."Zachary Turner1-3/+1
This reverts commit r289978, which is failing due to some rebase/merge issues. llvm-svn: 289981
2016-12-16[CodeView] Hook CodeViewRecordIO for reading/writing symbols.Zachary Turner1-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
2016-12-08Revert "[CodeGen] Fix invalid DWARF info on Win64"Keno Fischer1-1/+1
Appears to break on build bots. Reverting pending investigation. llvm-svn: 289014
2016-12-08[CodeGen] Fix invalid DWARF info on Win64Keno Fischer1-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
2016-10-05[codeview] Truncate records to maximum record size near 64KBReid Kleckner1-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
2016-09-15[codeview] Optimize the size of defranges with gapsReid Kleckner1-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
2016-09-07[codeview] Add new directives to record inlined call site line infoReid Kleckner1-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
2016-08-26[MC] Move .cv_loc management logic out of MCContextReid Kleckner1-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
2016-07-14[codeview] Shrink inlined call site line info tablesReid Kleckner1-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
2016-06-22Prune some includes from headers and sink some inline functionsReid Kleckner1-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
2016-06-08[codeview] Avoid emitting an empty file checksum tableReid Kleckner1-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
2016-05-17[codeview] Some cleanup of Symbol Records.Zachary Turner1-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
2016-02-19[codeview] Fix emission of file changes in inline line tablesReid Kleckner1-1/+4
These are supposed to be file checksum table offsets, not file ids. llvm-svn: 261379
2016-02-05[MC] Add support for encoding CodeView variable definition rangesDavid Majnemer1-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
2016-02-04[codeview] Don't attempt a cross-section label diffReid Kleckner1-5/+11
This only comes up when we're trying to find the next .cv_loc label. Fixes PR26467 llvm-svn: 259733
2016-02-02[codeview] Correctly handle inlining functions post-dominated by unreachableDavid Majnemer1-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
2016-02-02[codeview] Wire up the .cv_inline_linetable directiveReid Kleckner1-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
2016-01-29[CodeView] Implement .cv_inline_linetableDavid Majnemer1-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
2016-01-29Fix some -Wstring-conversion warningsDavid Blaikie1-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
2016-01-29Reland "[CodeView] Use assembler directives for line tables"Reid Kleckner1-0/+222
This reverts commit r259126 and relands r259117. This time with updated library dependencies. llvm-svn: 259130
2016-01-29Revert "[CodeView] Use assembler directives for line tables"Reid Kleckner1-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
2016-01-28Silence gcc warning about ternary and enumerationsReid Kleckner1-1/+1
llvm-svn: 259123