aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCObjectStreamer.cpp
AgeCommit message (Collapse)AuthorFilesLines
2018-03-15Re-land r327620 "[CodeView] Initial support for emitting S_BLOCK32 symbols ↵Reid Kleckner1-0/+1
for lexical scopes" This is safe to land now that we don't copy FunctionInfo when rehashing the DenseMap. llvm-svn: 327670
2018-02-09Use assembler expressions to lay out the EH LSDA.Rafael Espindola1-5/+22
Rely on the assembler to finalize the layout of the DWARF/Itanium exception-handling LSDA. Rather than calculate the exact size of each thing in the LSDA, use assembler directives: To emit the offset to the TTBase label: .uleb128 .Lttbase0-.Lttbaseref0 .Lttbaseref0: To emit the size of the call site table: .uleb128 .Lcst_end0-.Lcst_begin0 .Lcst_begin0: ... call site table entries ... .Lcst_end0: To align the type info table: ... action table ... .balign 4 .long _ZTIi .long _ZTIl .Lttbase0: Using assembler directives simplifies the compiler and allows switching the encoding of offsets in the call site table from udata4 to uleb128 for a large code size savings. (This commit does not change the encoding.) The combination of the uleb128 followed by a balign creates an unfortunate dependency cycle that the assembler must sometimes resolve either by padding an LEB or by inserting zero padding before the type table. See PR35809 or GNU as bug 4029. Patch by Ryan Prichard! llvm-svn: 324749
2018-01-09Use a MCExpr for the size of MCFillFragment.Rafael Espindola1-12/+1
This allows the size to be found during ralaxation. This fixes pr35858. llvm-svn: 322131
2018-01-09Inline a emitFill variant that is only used once. NFC.Rafael Espindola1-1/+7
llvm-svn: 322111
2018-01-09Make one of the emitFill methods non virtual. NFC.Rafael Espindola1-7/+3
This is just preparatory work to fix PR35858. llvm-svn: 322108
2017-12-13Remove redundant includes from lib/MC.Michael Zolotukhin1-2/+0
llvm-svn: 320624
2017-10-24[MC] Adding code padding for performance stability - infrastructure. NFC.Omer Paparo Bivas1-0/+27
Infrastructure designed for padding code with nop instructions in key places such that preformance improvement will be achieved. The infrastructure is implemented such that the padding is done in the Assembler after the layout is done and all IPs and alignments are known. This patch by itself in a NFC. Future patches will make use of this infrastructure to implement required policies for code padding. Reviewers: aaboud zvi craig.topper gadi.haber Differential revision: https://reviews.llvm.org/D34393 Change-Id: I92110d0c0a757080a8405636914a93ef6f8ad00e llvm-svn: 316413
2017-10-11[MC] Have MCObjectStreamer take its MCAsmBackend argument via unique_ptr.Lang Hames1-6/+5
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-5/+5
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-10-10[MC] Thread unique_ptr<MCObjectWriter> through the create.*ObjectWriterLang Hames1-3/+2
functions. This makes the ownership of the resulting MCObjectWriter clear, and allows us to remove one instance of MCObjectStreamer's bizarre "holding ownership via someone else's reference" trick. llvm-svn: 315327
2017-10-10[MC] Suppress .Lcfi labels when emitting textual assemblyReid Kleckner1-0/+6
Summary: This suppresses the generation of .Lcfi labels in our textual assembler. It was annoying that this generated cascading .Lcfi labels: llc foo.ll -o - | llvm-mc | llvm-mc After three trips through MCAsmStreamer, we'd have three labels in the output when none are necessary. We should only bother creating the labels and frame data when making a real object file. This supercedes D38605, which moved the entire .seh_ implementation into MCObjectStreamer. This has the advantage that we do more checking when emitting textual assembly, as a minor efficiency cost. Outputting textual assembly is not performance critical, so this shouldn't matter. Reviewers: majnemer, MatzeB Subscribers: qcolombet, nemanjai, javed.absar, eraman, hiraditya, JDevlieghere, llvm-commits Differential Revision: https://reviews.llvm.org/D38638 llvm-svn: 315259
2017-10-09[MC] Use a unique_ptr<MCAssembler> for MCObjectStreamer's Assembler member.Lang Hames1-3/+2
Removes manual new/delete. llvm-svn: 315225
2017-09-19Re-land "Fix Bug 30978 by emitting cv file checksums."Reid Kleckner1-0/+3
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-3/+0
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-0/+3
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-05-15MCObjectStreamer : fail with a diagnostic when emitting an out of range value.Arnaud A. de Grandmaison1-0/+5
We were previously silently emitting bogus data in release mode, making it very hard to diagnose the error, or crashing with an assert in debug mode. A proper diagnostic is now always emitted when the value to be emitted is out of range. llvm-svn: 303041
2017-04-14This patch closes PR#32216: Better testing of schedule model instruction ↵Andrew V. Tischenko1-1/+1
latencies/throughputs. The details are here: https://reviews.llvm.org/D30941 llvm-svn: 300311
2017-04-03Reland r298901 with modifications (reverted in r298932)Weiming Zhao1-4/+14
Dont emit Mapping symbols for sections that contain only data. Summary: Dont emit mapping symbols for sections that contain only data. Reviewers: rengolin, weimingz, kparzysz, t.p.northover, peter.smith Reviewed By: t.p.northover Patched by Shankar Easwaran <shankare@codeaurora.org> Subscribers: alekseyshl, t.p.northover, llvm-commits Differential Revision: https://reviews.llvm.org/D30724 llvm-svn: 299392
2017-03-28Revert "Dont emit Mapping symbols for sections that contain only data."Weiming Zhao1-14/+4
It breaks some lld tests. This reverts commit 3a50eea6d9732ab40e9a7aebe6be777b53a8b35c. llvm-svn: 298932
2017-03-28Dont emit Mapping symbols for sections that contain only data.Weiming Zhao1-4/+14
Summary: Dont emit mapping symbols for sections that contain only data. Patched by Shankar Easwaran <shankare@codeaurora.org> Reviewers: rengolin, peter.smith, weimingz, kparzysz, t.p.northover Reviewed By: t.p.northover Subscribers: t.p.northover, llvm-commits Differential Revision: https://reviews.llvm.org/D30724 llvm-svn: 298901
2017-03-16Check that line table entries don't spill over between sections even if ↵David Blaikie1-0/+1
they're empty at the end of a section llvm-svn: 297922
2017-03-03MC: De-duplicate the object streamer implementations of EmitFileDirective ↵Peter Collingbourne1-0/+4
into MCObjectStreamer. NFCI. llvm-svn: 296912
2017-02-10Move some error handling down to MCStreamer.Rafael Espindola1-2/+2
This makes sure we get the same redefinition rules regardless of who is printing (asm parser, codegen) and to what (asm, obj). This fixes an unintentional regression in r293936. llvm-svn: 294752
2016-12-14[Assembler] Better error messages for .org directiveOliver Stannard1-2/+3
Currently, the error messages we emit for the .org directive when the expression is not absolute or is out of range do not include the line number of the directive, so it can be hard to track down the problem if a file contains many .org directives. This patch stores the source location in the MCOrgFragment, so that it can be used for diagnostics emitted during layout. Since layout is an iterative process, and the errors are detected during each iteration, it would have been possible for errors to be reported multiple times. To prevent this, I've made the assembler bail out after each iteration if any errors have been reported. This will still allow multiple unrelated errors to be reported in the common case where they are all detected in the first round of layout. Differential Revision: https://reviews.llvm.org/D27411 llvm-svn: 289643
2016-10-14Tidy the calls to getCurrentSection().first -> getCurrentSectionOnly to helpEric Christopher1-8/+6
readability a bit. llvm-svn: 284202
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