aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCObjectStreamer.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-09-07[codeview] Add new directives to record inlined call site line infoReid Kleckner1-7/+5
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-0/+1
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-08-22[mips][ias] Support .dtprel[d]word and .tprel[d]word directivesSimon Atanasyan1-1/+41
Assembler directives .dtprelword, .dtpreldword, .tprelword, and .tpreldword generates relocations R_MIPS_TLS_DTPREL32, R_MIPS_TLS_DTPREL64, R_MIPS_TLS_TPREL32, and R_MIPS_TLS_TPREL64 respectively. The main motivation for this patch is to be able to write test cases for checking correctness of the LLD linker's behaviour. Differential Revision: https://reviews.llvm.org/D23669 llvm-svn: 279439
2016-07-11Fix branch relaxation in 16-bit mode.Nirav Dave1-2/+2
Thread through MCSubtargetInfo to relaxInstruction function allowing relaxation to generate jumps with 16-bit sized immediates in 16-bit mode. This fixes PR22097. Reviewers: dwmw2, tstellarAMD, craig.topper, jyknight Subscribers: jfb, arsenm, jyknight, llvm-commits, dsanders Differential Revision: http://reviews.llvm.org/D20830 llvm-svn: 275068
2016-06-01[MC] Rename EmitFill to emitFillPetr Hosek1-2/+2
This is to match the overloaded variants as well as the new style. Differential Revision: http://reviews.llvm.org/D20690 llvm-svn: 271359
2016-05-28[MC] Support symbolic expressions in assembly directivesPetr Hosek1-0/+38
This matches the behavior of GNU assembler which supports symbolic expressions in absolute expressions used in assembly directives. Differential Revision: http://reviews.llvm.org/D20752 llvm-svn: 271102
2016-05-27Revert "[MC] Support symbolic expressions in assembly directives"Petr Hosek1-38/+0
This reverts commit r271028, it causes the directive_fill.s to fail. llvm-svn: 271038
2016-05-27[MC] Support symbolic expressions in assembly directivesPetr Hosek1-0/+38
This matches the behavior of GNU assembler which supports symbolic expressions in absolute expressions used in assembly directives. Differential Revision: http://reviews.llvm.org/D20656 llvm-svn: 271028
2016-05-25Revert "[MC] Support symbolic expressions in assembly directives"Reid Kleckner1-38/+0
This reverts commit r270786, it causes the directive_fill.s to fail. llvm-svn: 270795
2016-05-25[MC] Support symbolic expressions in assembly directivesPetr Hosek1-0/+38
This matches the behavior of GNU assembler which supports symbolic expressions in absolute expressions used in assembly directives. Differential Revision: http://reviews.llvm.org/D20337 llvm-svn: 270786
2016-02-05[MC] Add support for encoding CodeView variable definition rangesDavid Majnemer1-0/+7
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-02[codeview] Correctly handle inlining functions post-dominated by unreachableDavid Majnemer1-3/+4
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-3/+4
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-0/+10
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-29Reland "[CodeView] Use assembler directives for line tables"Reid Kleckner1-0/+31
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-31/+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-28[CodeView] Use assembler directives for line tablesReid Kleckner1-0/+31
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
2016-01-21Rename MCLineEntry to MCDwarfLineEntryDavid Majnemer1-4/+4
MCLineEntry gives the impression that it is generic MC machinery. However, it is specific to DWARF. llvm-svn: 258381
2016-01-19[MC, COFF] Add .reloc support for WinCOFFDavid Majnemer1-2/+7
This adds rudimentary support for a few relocations that we will use for the CodeView debug format. llvm-svn: 258216
2016-01-19Simplify MCFillFragment.Rafael Espindola1-2/+2
The value size was always 1 or 0, so we don't need to store it. In a no asserts build this takes the testcase of pr26208 from 11 to 10 seconds. llvm-svn: 258141
2016-01-11Remove a bugs assert.Rafael Espindola1-2/+0
There is no reason the value being printed has to be positive. Fixes pr25802. llvm-svn: 257412
2015-11-12Implement .reloc (constant offset only) with support for R_MIPS_NONE and ↵Daniel Sanders1-0/+20
R_MIPS_32. Summary: Support for R_MIPS_NONE allows us to parse MIPS16's usage of .reloc. R_MIPS_32 was included to be able to better test the directive. Targets can add their relocations by overriding MCAsmBackend::getFixupKind(). Subscribers: grosbach, rafael, majnemer, dsanders, llvm-commits Differential Revision: http://reviews.llvm.org/D13659 llvm-svn: 252888
2015-11-05Fix pr24832.Rafael Espindola1-9/+1
It is pretty simple now that the yak is shaved. llvm-svn: 252105
2015-11-04Simplify now that emitValueToOffset always returns false.Rafael Espindola1-2/+1
llvm-svn: 252102
2015-11-04Simplify .org processing and make it a bit more powerful.Rafael Espindola1-17/+1
We now always create the fragment, which lets us handle things like .org after a .align. llvm-svn: 252101
2015-10-10MC: Remove implicit ilist iterator conversions, NFCDuncan P. N. Exon Smith1-1/+1
llvm-svn: 249922
2015-10-05Fix pr24486.Rafael Espindola1-2/+2
This extends the work done in r233995 so that now getFragment (in addition to getSection) also works for variable symbols. With that the existing logic to decide if a-b can be computed works even if a or b are variables. Given that, the expression evaluation can avoid expanding variables as aggressively and that in turn lets the relocation code see the original variable. In order for this to work with the asm streamer, there is now a dummy fragment per section. It is used to assign a section to a symbol when no other fragment exists. This patch is a joint work by Maxim Ostapenko andy myself. llvm-svn: 249303
2015-10-03Use early return. NFC.Rafael Espindola1-12/+12
llvm-svn: 249224
2015-09-20Cleanup places that passed SMLoc by const reference to pass it by value ↵Craig Topper1-1/+1
instead. NFC llvm-svn: 248135
2015-09-01[MC] Remove MCAssembler's copy of OSDavid Majnemer1-1/+1
We can just ask the ObjectWriter for it's stream instead of caching around our own reference to it. No functionality change is intended. llvm-svn: 246604
2015-08-13Remove and forbid raw_svector_ostream::flush() calls.Yaron Keren1-1/+0
After r244870 flush() will only compare two null pointers and return, doing nothing but wasting run time. The call is not required any more as the stream and its SmallString are always in sync. Thanks to David Blaikie for reviewing. llvm-svn: 244928
2015-08-07[MC/Dwarf] Allow to specify custom parameters for linetable emission.Frederic Riss1-6/+10
NFC patch for current users, but llvm-dsymutil will use the new functionality to adapt to the input linetable. Based on a patch by Adrian Prantl. llvm-svn: 244318
2015-06-27[MC] Ensure that pending labels are flushed when -mc-relax-all flag is usedPetr Hosek1-2/+9
Summary: The current implementation doesn't always flush all pending labels beforeemitting data which can result in an incorrectly placed labels in case when when instruction bundling is enabled and -mc-relax-all flag is being used. To address this issue, we always flush pending labels before emitting data. The change was tested by running PNaCl toolchain trybots with -mc-relax-all flag set. Fixes https://code.google.com/p/nativeclient/issues/detail?id=4063 Test Plan: Regression test attached Reviewers: mseaborn Subscribers: jfb, llvm-commits Differential Revision: http://reviews.llvm.org/D10325 llvm-svn: 240870
2015-06-11Generalize emitAbsoluteSymbolDiff.Rafael Espindola1-9/+6
This makes emitAbsoluteSymbolDiff always succeed and moves logic from the asm printer to it. The object one now also works on ELF. If two symbols are in the same fragment, we will never move them apart. llvm-svn: 239552
2015-06-01Rename HasData to IsRegistered.Rafael Espindola1-4/+0
There is no MCSectionData, so the old name is now meaningless. Also remove some asserts/checks that were there just because the information they used was in MCSectionData. llvm-svn: 238708
2015-06-01Remove trivial forwarding function.Rafael Espindola1-1/+1
llvm-svn: 238707
2015-05-30MC: Clean up MCExpr naming. NFC.Jim Grosbach1-13/+13
llvm-svn: 238634
2015-05-29Remove getData.Rafael Espindola1-9/+5
This completes the mechanical part of merging MCSymbol and MCSymbolData. llvm-svn: 238617
2015-05-29Remove the MCSymbolData typedef.Rafael Espindola1-2/+2
The getData member function is next. llvm-svn: 238611
2015-05-29Rename getOrCreateSymbolData to registerSymbol and return void.Rafael Espindola1-3/+4
Another step in merging MCSymbol and MCSymbolData. llvm-svn: 238607
2015-05-29Move common symbol related information from MCSectionData to MCSymbol.Rafael Espindola1-4/+4
llvm-svn: 238583
2015-05-29Store MCSymbols in PendingLabels.Rafael Espindola1-2/+3
llvm-svn: 238582
2015-05-28Remove a trivial forwarding function. NFC.Rafael Espindola1-2/+2
llvm-svn: 238506
2015-05-27Rename and move getCurrentSectionData.Rafael Espindola1-4/+4
I think this concludes the merge of MCSectionData and MCSection. llvm-svn: 238358
2015-05-27There is only one current section.Rafael Espindola1-6/+5
Both MCStreamer and MCObjectStreamer were maintaining a current section variable and they were slightly out of sync. I don't think this was observable, but was inefficient and error prone. Changing this requires a few cascading changes: * SwitchSection has to call ChangeSection earlier for ChangeSection to see the old section. * With that change, ChangeSection cannot call EmitLabel, since during ChangeSection we are still in the old section. * When the object streamer requires a begin label, just reused the existing generic support for begin labels instead of calling EmitLabel directly. llvm-svn: 238357
2015-05-27Delete MCSectionData.Rafael Espindola1-1/+1
llvm-svn: 238331
2015-05-27Move getSubsectionInsertionPoint to MCSection.Rafael Espindola1-2/+1
llvm-svn: 238320
2015-05-26Replace getOrCreateSectionData with registerSection.Rafael Espindola1-2/+1
There is now no SectionData to be created. llvm-svn: 238208
2015-05-26Have getCurrentSectionData return a MCSection.Rafael Espindola1-6/+8
I will fix the name shortly. llvm-svn: 238204
2015-05-25Store a MCSection in MCFragment.Rafael Espindola1-1/+1
Part of the work to merge MCSectionData into MCSection. llvm-svn: 238160