summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCMachOStreamer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [AIX]Emit function descriptor csect in assemblyXiangling Liao2019-09-261-0/+1
| | | | | | | | | This patch emits the function descriptor csect for functions with definitions under both 32-bit/64-bit mode on AIX. Differential Revision: https://reviews.llvm.org/D66724 llvm-svn: 373009
* [MC] Teach the MachO object writer about N_FUNC_COLDVedant Kumar2019-01-251-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | N_FUNC_COLD is a new MachO symbol attribute. It's a hint to the linker to order a symbol towards the end of its section, to improve locality. Example: ``` void a1() {} __attribute__((cold)) void a2() {} void a3() {} int main() { a1(); a2(); a3(); return 0; } ``` A linker that supports N_FUNC_COLD will order _a2 to the end of the text section. From `nm -njU` output, we see: ``` _a1 _a3 _main _a2 ``` Differential Revision: https://reviews.llvm.org/D57190 llvm-svn: 352227
* 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
* [macho] save the SDK version stored in module metadata into the version min andAlex Lorenz2018-12-141-9/+11
| | | | | | | | | | | | | | | | | | | | | build version load commands in the object file This commit introduces a new metadata node called "SDK Version". It will be set by the frontend to mark the platform SDK (macOS/iOS/etc) version which was used during that particular compilation. This node is used when machine code is emitted, by either saving the SDK version into the appropriate macho load command (version min/build version), or by emitting the assembly for these load commands with the SDK version specified as well. The assembly for both load commands is extended by allowing it to contain the sdk_version X, Y [, Z] trailing directive to represent the SDK version respectively. rdar://45774000 Differential Revision: https://reviews.llvm.org/D55612 llvm-svn: 349119
* [MC] Error on a .zerofill directive in a non-virtual sectionFrancis Visoiu Mistrih2018-07-021-4/+14
| | | | | | | | | | | | | | | On darwin, all virtual sections have zerofill type, and having a .zerofill directive in a non-virtual section is not allowed. Instead of asserting, show a nicer error. In order to use the equivalent of .zerofill in a non-virtual section, the usage of .zero of .space is required. This patch replaces the assert with an error. Differential Revision: https://reviews.llvm.org/D48517 llvm-svn: 336127
* Revert "[MC] Factor MCObjectStreamer::addFragmentAtoms out of MachO streamer."Sam Clegg2018-06-141-1/+24
| | | | | | | | | This reverts rL331412. We didn't up using fragment atoms in the wasm object writer after all. Differential Revision: https://reviews.llvm.org/D48173 llvm-svn: 334734
* [MC] Pass MCSubtargetInfo to fixupNeedsRelaxation and applyFixupPeter Smith2018-06-061-0/+1
| | | | | | | | | | | | | | | | | | On targets like Arm some relaxations may only be performed when certain architectural features are available. As functions can be compiled with differing levels of architectural support we must make a judgement on whether we can relax based on the MCSubtargetInfo for the function. This change passes through the MCSubtargetInfo for the function to fixupNeedsRelaxation so that the decision on whether to relax can be made per function. In this patch, only the ARM backend makes use of this information. We must also pass the MCSubtargetInfo to applyFixup because some fixups skip error checking on the assumption that relaxation has occurred, to prevent code-generation errors applyFixup must see the same MCSubtargetInfo as fixupNeedsRelaxation. Differential Revision: https://reviews.llvm.org/D44928 llvm-svn: 334078
* MC: Change the streamer ctors to take an object writer instead of a stream. ↵Peter Collingbourne2018-05-181-4/+7
| | | | | | | | | | | | | | NFCI. The idea is that a client that wants split dwarf would create a specific kind of object writer that creates two files, and use it to create the streamer. Part of PR37466. Differential Revision: https://reviews.llvm.org/D47050 llvm-svn: 332749
* [MC] Factor MCObjectStreamer::addFragmentAtoms out of MachO streamer.Sam Clegg2018-05-021-24/+1
| | | | | | | | | This code previously existed only in MCMachOStreamer but is useful for WebAssembly too. See: D46335 Differential Revision: https://reviews.llvm.org/D46297 llvm-svn: 331412
* Don't create MCFillFragment directly.Rafael Espindola2018-01-091-19/+9
| | | | | | Instead use higher level APIs that take care of most bookkeeping. llvm-svn: 322123
* MC/AsmPrinter: Reduce code duplication.Matthias Braun2017-12-141-20/+2
| | | | | | | | | | Factor out duplicated code emitting mach-o version-min specifiers. This should be NFC but happens to fix a bug where the code in MCMachoStreamer didn't take the version skew between darwin and macos versions into account. llvm-svn: 320666
* MC: Add support for mach-o build_versionMatthias Braun2017-12-141-1/+9
| | | | | | | | LC_BUILD_VERSION is a new load command superseding the previously used LC_XXX_MIN_VERSION commands. This adds an assembler directive along with encoding/streaming support. llvm-svn: 320661
* [MC] Have MCObjectStreamer take its MCAsmBackend argument via unique_ptr.Lang Hames2017-10-111-5/+7
| | | | | | | | 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
* [MC] Have MCObjectStreamer take its MCAsmBackend argument via unique_ptr.Lang Hames2017-10-111-6/+9
| | | | | | | | 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
* Sort the remaining #include lines in include/... and lib/....Chandler Carruth2017-06-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Simplify/make more explicit (by making less explicit in some ways) some ↵David Blaikie2017-03-161-1/+1
| | | | | | function calls llvm-svn: 297921
* MC: De-duplicate the object streamer implementations of EmitFileDirective ↵Peter Collingbourne2017-03-031-7/+0
| | | | | | into MCObjectStreamer. NFCI. llvm-svn: 296912
* [MC] Factor out non-COFF handling of COFF-specific directives.Dan Gohman2017-02-271-16/+0
| | | | | | | | | Instead of requiring every non-COFF MCObjectStreamer to implement the COFF hooks just to do an llvm_unreachable to say that they're not supported, do the llvm_unreachable in the default implementation, as suggested by rnk in https://reviews.llvm.org/D26722. llvm-svn: 296403
* Move some error handling down to MCStreamer.Rafael Espindola2017-02-101-5/+3
| | | | | | | | | 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
* [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other ↵Eugene Zelenko2017-02-071-5/+18
| | | | | | minor fixes (NFC). llvm-svn: 294369
* MCMacho: Allow __thread_ptr section after dwarf sectionsMatthias Braun2017-02-011-1/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D29315 llvm-svn: 293730
* MachO: enable .data_region directives everywhereTim Northover2016-04-211-4/+0
| | | | | | | | | | We'd disabled them on x86 because back in the early days some host tools couldn't handle the new load commands. This no longer holds: anyone capable of deploying Clang should be able to deploy its copies of ar/ranlib/etc. rdar://25254790 llvm-svn: 267075
* [MachO] Extend the alt_entry support for aliases added in r263521 toLang Hames2016-03-151-4/+7
| | | | | | expressions of the form 'a = .' and 'a = Ltmp'. llvm-svn: 263528
* [MachO] Add MachO alt-entry directive support.Lang Hames2016-03-151-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for the MachO .alt_entry assembly directive, and uses it for global aliases with non-zero GEP offsets. The alt_entry flag indicates that a symbol should be layed out immediately after the preceding symbol. Conceptually it introduces an alternate entry point for a function or data structure. E.g.: safe_foo: // check preconditions for foo .alt_entry fast_foo fast_foo: // body of foo, can assume preconditions. The .alt_entry flag is also implicitly set on assembly aliases of the form: a = b + C where C is a non-zero constant, since these have the same effect as an alt_entry symbol: they introduce a label that cannot be moved relative to the preceding one. Setting the alt_entry flag on aliases of this form fixes http://llvm.org/PR25381. llvm-svn: 263521
* Fix Clang-tidy readability-redundant-control-flow warnings; other minor fixes.Eugene Zelenko2016-02-021-1/+0
| | | | | | Differential revision: http://reviews.llvm.org/D16793 llvm-svn: 259539
* Simplify MCFillFragment.Rafael Espindola2016-01-191-1/+1
| | | | | | | | | 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
* MC: Make sure to clear *all* of MCMachOStreamer's stateJustin Bogner2015-12-031-0/+1
| | | | | | | The CreatedADWARFSection flag was added in r232842, but isn't cleared properly when resetting the streamer's state. Fix that. llvm-svn: 254571
* ARM: support .watchos_version_min and .tvos_version_min.Tim Northover2015-10-281-4/+14
| | | | | | | | These MachO file directives are used by linkers and other tools to provide compatibility information, much like the existing .ios_version_min and .macosx_version_min. llvm-svn: 251569
* Use range-based for loops. NFCCraig Topper2015-10-141-9/+7
| | | | llvm-svn: 250266
* MC: Remove implicit ilist iterator conversions, NFCDuncan P. N. Exon Smith2015-10-101-1/+1
| | | | llvm-svn: 249922
* Fix pr24486.Rafael Espindola2015-10-051-5/+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
* Disallow assigning symbol a null section.Rafael Espindola2015-10-031-2/+0
| | | | | | | They are constructed without one and they can't go back, so this was effectively dead code. llvm-svn: 249220
* Remove and forbid raw_svector_ostream::flush() calls.Yaron Keren2015-08-131-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
* Force the MachO generated for Darwin to have VERSION_MIN load commandSteven Wu2015-08-051-0/+10
| | | | | | | | | On Darwin, it is required to stamp the object file with VERSION_MIN load command. This commit will provide a VERSRION_MIN load command to the MachO file that doesn't specify the version itself by inferring from Target Triple. llvm-svn: 244059
* Remove includes of MCMachOSymbolFlags.h after it was deletedPete Cooper2015-06-081-1/+0
| | | | llvm-svn: 239318
* Move all flags logic to MCSymbolMachO.Pete Cooper2015-06-081-15/+17
| | | | | | | | | | | Also delete the now unused MCMachOSymbolFlags.h header as the only enum in there was moved to MCSymbolMachO. Similarly to ELF and COFF, manipulating the flags is now done via helpers instead of spread throughout the codebase. Reviewed by Rafael Espíndola. llvm-svn: 239316
* Create a MCSymbolELF.Rafael Espindola2015-06-021-3/+0
| | | | | | | | | This create a MCSymbolELF class and moves SymbolSize since only ELF needs a size expression. This reduces the size of MCSymbol from 56 to 48 bytes. llvm-svn: 238801
* The fragment implies the section, don't store both.Rafael Espindola2015-06-011-2/+2
| | | | | | This reduces MCSymbol from 64 to 56 bytes on x86_64. llvm-svn: 238747
* Remove getData.Rafael Espindola2015-05-291-14/+9
| | | | | | This completes the mechanical part of merging MCSymbol and MCSymbolData. llvm-svn: 238617
* Remove the MCSymbolData typedef.Rafael Espindola2015-05-291-5/+5
| | | | | | The getData member function is next. llvm-svn: 238611
* Rename getOrCreateSymbolData to registerSymbol and return void.Rafael Espindola2015-05-291-7/+10
| | | | | | Another step in merging MCSymbol and MCSymbolData. llvm-svn: 238607
* Move Flags from MCSymbolData to MCSymbol.Rafael Espindola2015-05-291-13/+12
| | | | llvm-svn: 238598
* Move common symbol related information from MCSectionData to MCSymbol.Rafael Espindola2015-05-291-2/+3
| | | | llvm-svn: 238583
* Remove a trivial forwarding function. NFC.Rafael Espindola2015-05-281-1/+1
| | | | llvm-svn: 238506
* Rename and move getCurrentSectionData.Rafael Espindola2015-05-271-1/+1
| | | | | | I think this concludes the merge of MCSectionData and MCSection. llvm-svn: 238358
* There is only one current section.Rafael Espindola2015-05-271-2/+3
| | | | | | | | | | | | | | | | | 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
* Delete MCSectionData.Rafael Espindola2015-05-271-2/+2
| | | | llvm-svn: 238331
* Replace getOrCreateSectionData with registerSection.Rafael Espindola2015-05-261-4/+3
| | | | | | There is now no SectionData to be created. llvm-svn: 238208
* Have getCurrentSectionData return a MCSection.Rafael Espindola2015-05-261-1/+1
| | | | | | I will fix the name shortly. llvm-svn: 238204
* Remove most uses of MCSectionData from MCAssembler.Rafael Espindola2015-05-261-1/+1
| | | | llvm-svn: 238172
OpenPOWER on IntegriCloud