aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCMachOStreamer.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-04-21MachO: enable .data_region directives everywhereTim Northover1-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
2016-03-15[MachO] Extend the alt_entry support for aliases added in r263521 toLang Hames1-4/+7
expressions of the form 'a = .' and 'a = Ltmp'. llvm-svn: 263528
2016-03-15[MachO] Add MachO alt-entry directive support.Lang Hames1-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
2016-02-02Fix Clang-tidy readability-redundant-control-flow warnings; other minor fixes.Eugene Zelenko1-1/+0
Differential revision: http://reviews.llvm.org/D16793 llvm-svn: 259539
2016-01-19Simplify MCFillFragment.Rafael Espindola1-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
2015-12-03MC: Make sure to clear *all* of MCMachOStreamer's stateJustin Bogner1-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
2015-10-28ARM: support .watchos_version_min and .tvos_version_min.Tim Northover1-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
2015-10-14Use range-based for loops. NFCCraig Topper1-9/+7
llvm-svn: 250266
2015-10-10MC: Remove implicit ilist iterator conversions, NFCDuncan P. N. Exon Smith1-1/+1
llvm-svn: 249922
2015-10-05Fix pr24486.Rafael Espindola1-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
2015-10-03Disallow assigning symbol a null section.Rafael Espindola1-2/+0
They are constructed without one and they can't go back, so this was effectively dead code. llvm-svn: 249220
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-05Force the MachO generated for Darwin to have VERSION_MIN load commandSteven Wu1-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
2015-06-08Remove includes of MCMachOSymbolFlags.h after it was deletedPete Cooper1-1/+0
llvm-svn: 239318
2015-06-08Move all flags logic to MCSymbolMachO.Pete Cooper1-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
2015-06-02Create a MCSymbolELF.Rafael Espindola1-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
2015-06-01The fragment implies the section, don't store both.Rafael Espindola1-2/+2
This reduces MCSymbol from 64 to 56 bytes on x86_64. llvm-svn: 238747
2015-05-29Remove getData.Rafael Espindola1-14/+9
This completes the mechanical part of merging MCSymbol and MCSymbolData. llvm-svn: 238617
2015-05-29Remove the MCSymbolData typedef.Rafael Espindola1-5/+5
The getData member function is next. llvm-svn: 238611
2015-05-29Rename getOrCreateSymbolData to registerSymbol and return void.Rafael Espindola1-7/+10
Another step in merging MCSymbol and MCSymbolData. llvm-svn: 238607
2015-05-29Move Flags from MCSymbolData to MCSymbol.Rafael Espindola1-13/+12
llvm-svn: 238598
2015-05-29Move common symbol related information from MCSectionData to MCSymbol.Rafael Espindola1-2/+3
llvm-svn: 238583
2015-05-28Remove a trivial forwarding function. NFC.Rafael Espindola1-1/+1
llvm-svn: 238506
2015-05-27Rename and move getCurrentSectionData.Rafael Espindola1-1/+1
I think this concludes the merge of MCSectionData and MCSection. llvm-svn: 238358
2015-05-27There is only one current section.Rafael Espindola1-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
2015-05-27Delete MCSectionData.Rafael Espindola1-2/+2
llvm-svn: 238331
2015-05-26Replace getOrCreateSectionData with registerSection.Rafael Espindola1-4/+3
There is now no SectionData to be created. llvm-svn: 238208
2015-05-26Have getCurrentSectionData return a MCSection.Rafael Espindola1-1/+1
I will fix the name shortly. llvm-svn: 238204
2015-05-26Remove most uses of MCSectionData from MCAssembler.Rafael Espindola1-1/+1
llvm-svn: 238172
2015-05-25Store a MCSection in MCFragment.Rafael Espindola1-2/+3
Part of the work to merge MCSectionData into MCSection. llvm-svn: 238160
2015-05-21Stop forwarding (get|set)Aligment from MCSectionData to MCSection.Rafael Espindola1-2/+2
llvm-svn: 237956
2015-05-21Move alignment from MCSectionData to MCSection.Rafael Espindola1-6/+6
This starts merging MCSection and MCSectionData. There are a few issues with the current split between MCSection and MCSectionData. * It optimizes the the not as important case. We want the production of .o files to be really fast, but the split puts the information used for .o emission in a separate data structure. * The ELF/COFF/MachO hierarchy is not represented in MCSectionData, leading to some ad-hoc ways to represent the various flags. * It makes it harder to remember where each item is. The attached patch starts merging the two by moving the alignment from MCSectionData to MCSection. Most of the patch is actually just dropping 'const', since MCSectionData is mutable, but MCSection was not. llvm-svn: 237936
2015-05-20MC: Remove most remaining uses of MCSymbolData::getSymbol(), NFCDuncan P. N. Exon Smith1-4/+4
Remove most remaining calls to `MCSymbolData::getSymbol()`, instead using the already available `MCSymbol` directly. llvm-svn: 237829
2015-05-18MC: Clean up method names in MCContext.Jim Grosbach1-3/+3
The naming was a mish-mash of old and new style. Update to be consistent with the new. NFC. llvm-svn: 237594
2015-05-16MC: Change MCFragment::Atom to an MCSymbol, NFCDuncan P. N. Exon Smith1-2/+2
Change `MCFragment::Atom` from an `MCSymbolData` to an `MCSymbol`, moving in the direction of removing the back-pointer. llvm-svn: 237497
2015-05-16MC: Change MCAssembler::Symbols to store MCSymbol, NFCDuncan P. N. Exon Smith1-3/+3
Instead of storing a list of the `MCSymbolData` in use, store the `MCSymbol`s. Churning in the direction of removing the back pointer from `MCSymbolData`. llvm-svn: 237496
2015-05-15MC: Update MCCodeEmitter naming. NFC.Jim Grosbach1-1/+1
s/EncodeInstruction/encodeInstruction/ llvm-svn: 237469
2015-04-14Use raw_pwrite_stream in the object writer/streamer.Rafael Espindola1-2/+2
The ELF object writer will take advantage of that in the next commit. llvm-svn: 234950
2015-03-20Don't declare all text sections at the start of the .sRafael Espindola1-6/+43
The code this patch removes was there to make sure the text sections went before the dwarf sections. That is necessary because MachO uses offsets relative to the start of the file, so adding a section can change relaxations. The dwarf sections were being printed at the start just to produce symbols pointing at the start of those sections. The underlying issue was fixed in r231898. The dwarf sections are now printed when they are about to be used, which is after we printed the text sections. To make sure we don't regress, the patch makes the MachO streamer assert if CodeGen puts anything unexpected after the DWARF sections. llvm-svn: 232842
2015-03-19Split the object streamer callback in one per file format.Rafael Espindola1-0/+1
There are two main advantages to doing this * Targets that only need to handle one of the formats specially don't have to worry about the others. For example, x86 now only registers a constructor for the COFF streamer. * Changes to the arguments passed to one format constructor will not impact the other formats. llvm-svn: 232699
2015-01-15Replace size method call of containers to empty method where appropriateAlexander Kornienko1-1/+1
This patch was generated by a clang tidy checker that is being open sourced. The documentation of that checker is the following: /// The emptiness of a container should be checked using the empty method /// instead of the size method. It is not guaranteed that size is a /// constant-time function, and it is generally more efficient and also shows /// clearer intent to use empty. Furthermore some containers may implement the /// empty method but not implement the size method. Using empty whenever /// possible makes it easier to switch to another container in the future. Patch by Gábor Horváth! llvm-svn: 226161
2014-09-17Add and update reset() and doInitialization() methods to MC* and passes.Yaron Keren1-0/+6
This enables reusing a PassManager instead of re-constructing it every time. llvm-svn: 217948
2014-09-03Add override to overriden virtual methods, remove virtual keywords.Benjamin Kramer1-2/+2
No functionality change. Changes made by clang-tidy + some manual cleanup. llvm-svn: 217028
2014-06-24Print a=b as an assignment.Rafael Espindola1-4/+0
In assembly the expression a=b is parsed as an assignment, so it should be printed as one. This remove a truly horrible hack for producing a label with "a=.". It would be used by codegen but would never be reached by the asm parser. Sorry I missed this when it was first committed. llvm-svn: 211639
2014-05-12Remove an always true argument.Rafael Espindola1-1/+1
llvm-svn: 208557
2014-04-29Centralize the handling of the thumb bit.Rafael Espindola1-4/+0
This patch centralizes the handling of the thumb bit around MCStreamer::isThumbFunc and makes isThumbFunc handle aliases. This fixes a corner case, but the main advantage is having just one way to check if a MCSymbol is thumb or not. This should still be refactored to be ARM only, but at least now it is just one predicate that has to be refactored instead of 3 (isThumbFunc, ELF_Other_ThumbFunc, and SF_ThumbFunc). llvm-svn: 207522
2014-04-18Add range access to MCAssembler's symbol collection.David Blaikie1-6/+5
llvm-svn: 206631
2014-04-13[C++11] More 'nullptr' conversion or in some cases just using a boolean ↵Craig Topper1-5/+5
check instead of comparing to nullptr. llvm-svn: 206129
2014-03-29MachO: Add linker-optimisation hint framework to MC.Tim Northover1-0/+5
Another part of the ARM64 backend (so tests will be following soon). This is currently used by the linker to relax adrp/ldr pairs into nops where possible, though could well be more broadly applicable. llvm-svn: 205084
2014-03-29MachO: allow each section to have a linker-private symbolTim Northover1-4/+33
The upcoming ARM64 backend doesn't have section-relative relocations, so we give each section its own symbol to provide this functionality. Of course, it doesn't need to appear in the final executable, so linker-private is the best kind for this purpose. llvm-svn: 205081