summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCContext.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert "Centralize the information about which object format we are using."Rafael Espindola2015-08-141-6/+4
| | | | | | | | | | | | | | | | | | | | | This reverts commit r245047. It was failing on the darwin bots. The problem was that when running ./bin/llc -march=msp430 llc gets to if (TheTriple.getTriple().empty()) TheTriple.setTriple(sys::getDefaultTargetTriple()); Which means that we go with an arch of msp430 but a triple of x86_64-apple-darwin14.4.0 which fails badly. That code has to be updated to select a triple based on the value of march, but that is not a trivial fix. llvm-svn: 245062
* Centralize the information about which object format we are using.Rafael Espindola2015-08-141-4/+6
| | | | | | | | | | | Other than some places that were handling unknown as ELF, this should have no change. The test updates are because we were detecting arm-coff or x86_64-win64-coff as ELF targets before. It is not clear if the enum should live on the Triple. At least now it lives in a single location and should be easier to move somewhere else. llvm-svn: 245047
* Revert r240302 ("Bring r240130 back.").Daniel Jasper2015-06-231-13/+15
| | | | | | | | | | | | | This causes errors like: ld: error: blah.o: requires dynamic R_X86_64_PC32 reloc against '' which may overflow at runtime; recompile with -fPIC blah.cc:function f(): error: undefined reference to '' blah.o:g(): error: undefined reference to '' I have not yet come up with an appropriate reproduction. llvm-svn: 240394
* Bring r240130 back.Rafael Espindola2015-06-221-15/+13
| | | | | | | | | | | | | | | | | | | | | | Now that pr23900 is fixed, we can bring it back with no changes. Original message: Make all temporary symbols unnamed. What this does is make all symbols that would otherwise start with a .L (or L on MachO) unnamed. Some of these symbols still show up in the symbol table, but we can just make them unnamed. In order to make sure we produce identical results when going thought assembly, all .L (not just the compiler produced ones), are now unnamed. Running llc on llvm-as.opt.bc, the peak memory usage goes from 208.24MB to 205.57MB. llvm-svn: 240302
* Revert 240130, it caused crashes (repro in PR23900).Nico Weber2015-06-191-13/+15
| | | | llvm-svn: 240193
* Make all temporary symbols unnamed.Rafael Espindola2015-06-191-15/+13
| | | | | | | | | | | | | | | | What this does is make all symbols that would otherwise start with a .L (or L on MachO) unnamed. Some of these symbols still show up in the symbol table, but we can just make them unnamed. In order to make sure we produce identical results when going thought assembly, all .L (not just the compiler produced ones), are now unnamed. Running llc on llvm-as.opt.bc, the peak memory usage goes from 208.24MB to 205.57MB. llvm-svn: 240130
* Use named temporaries for directional labels.Rafael Espindola2015-06-171-9/+10
| | | | | | | | | | Directional labels can show up in symbol tables (and we have a llvm-mc test for that). Given that, we need to make sure they are named. With that out of the way, use setUseNamesOnTempLabels in llvm-mc so that it too benefits from the memory saving. llvm-svn: 239914
* Allocate space for MCSymbol::Name only if required.Pete Cooper2015-06-091-5/+6
| | | | | | | | | | | | | | Similarly to User which allocates a number of Use's prior to the this pointer, allocate space for the Name* for MCSymbol only when we need a name. Given that an MCSymbol is 48-bytes on 64-bit systems, this saves a decent % of space. Given the verify_uselistorder test case with debug info and llc, 50k symbols have names out of 700k so this optimises for the common case of temporary unnamed symbols. Reviewed by David Blaikie. llvm-svn: 239423
* Add MCSymbolMachO which will be used to hide the MCSymbolMachO flags.Pete Cooper2015-06-081-1/+2
| | | | | | Reviewed by Rafael Espíndola. llvm-svn: 239315
* Add MCSymbolCOFF class and use it to get and set the COFF type field.Pete Cooper2015-06-081-3/+11
| | | | | | Reviewed by Rafael Espíndola. llvm-svn: 239312
* Change MCSymbol IsELF to an enum to support future MCSymbolCOFF and ↵Pete Cooper2015-06-081-1/+1
| | | | | | | | MCSymbolMachO. Reviewed by Rafael Espíndola. llvm-svn: 239311
* Clarify when we can avoid creating names for temp symbols.Rafael Espindola2015-06-021-9/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some temporary symbols are created by MC itself. These symbols are never used for lookup and are never included in the object symbol table, so we can avoid creating a name for them. Other temporaries are created by CodeGen or by the user by explicitly asking for a name starting with .L (or L on MachO). These temporaries behave like regular symbols, we just try to avoid including them in the object symbol table, but sometimes they end up there: const char *foo() { return "abc" + 3; } will have a relocation pointing to a .L symbol. It just so happens that almost all MC created temporary has the AlwaysAddSuffix option and CodeGen/user created ones don't. One interesting future optimization would be to use unnamed symbols for all temporaries, but that would require use an st_name of 0 or having the object writer create the names if a symbol does end up in the symbol table. No testcase since this just avoid creating a few extra names for MC created temporaries. llvm-svn: 238887
* Pass a MCSymbolELF to a few ELF only functions. NFC.Rafael Espindola2015-06-021-5/+5
| | | | llvm-svn: 238868
* Create a MCSymbolELF.Rafael Espindola2015-06-021-9/+16
| | | | | | | | | 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
* [MC] Simplify code. No functionality change intended.Benjamin Kramer2015-05-311-7/+2
| | | | llvm-svn: 238676
* Move MCSection destruction to MCContext::reset.Rafael Espindola2015-05-261-8/+8
| | | | | | | | Fixes the leaks when running llc. Also found by an asan bot. llvm-svn: 238167
* Call the destructors of the MCSections.Rafael Espindola2015-05-261-0/+8
| | | | | | | | | They now contain the fragments. If we don't call the destructors the fragments leak. Found by an asan bot. llvm-svn: 238161
* MC: Shave a pointer off of MCSymbol::NameDuncan P. N. Exon Smith2015-05-221-4/+3
| | | | | | | | | | | | | Shave a pointer off of `MCSymbolName` by storing `StringMapEntry<bool>*` instead of `StringRef`. This brings `sizeof(MCSymbol)` down to 64 on 64-bit platforms, a nice round number. My profile showed memory dropping from 914 MB down to 908 MB, roughly 0.7%. Other than memory usage, no functionality change here. (I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`; see r236629 for details.) llvm-svn: 238005
* Move alignment from MCSectionData to MCSection.Rafael Espindola2015-05-211-35/+35
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Avoid unnecessary section switching. NFC.Rafael Espindola2015-05-211-2/+1
| | | | llvm-svn: 237913
* Remove yet another method of creating begin and end symbol for sections.Rafael Espindola2015-05-211-19/+9
| | | | | | I missed this one when first unifying how we handle begin and end symbols. llvm-svn: 237912
* [WinEH] Store pointers to the LSDA in the exception registration objectReid Kleckner2015-05-201-0/+5
| | | | | | | We aren't yet emitting the LSDA yet, so this will still fail to assemble. llvm-svn: 237852
* MC: clang-format MCContext. NFC.Jim Grosbach2015-05-181-8/+9
| | | | llvm-svn: 237595
* MC: Clean up method names in MCContext.Jim Grosbach2015-05-181-15/+15
| | | | | | | The naming was a mish-mash of old and new style. Update to be consistent with the new. NFC. llvm-svn: 237594
* MC: Skip names of temporary symbols in object streamerDuncan P. N. Exon Smith2015-05-061-0/+3
| | | | | | | | | | | | | | Don't create names for temporary symbols when using an object streamer. The names never make it to the output anyway. From the starting point of r236629, my heap profile says this drops peak memory usage from 1100 MB to 1058 MB for CodeGen of `verify-uselistorder`, a savings of almost 4% on peak memory, and removes `StringMap<bool, BumpPtrAllocator...>` from the profile entirely. (I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`; see r236629 for details.) llvm-svn: 236642
* Remove the GroupMapTy DenseMap. NFC.Rafael Espindola2015-04-281-2/+2
| | | | | | Instead use the Group symbol of MCSectionELF. llvm-svn: 236033
* Revert accidentally committed "MC: Allow targets to stop symbol name quoting"Matt Arsenault2015-04-231-4/+2
| | | | llvm-svn: 235672
* MC: Allow targets to stop symbol name quotingMatt Arsenault2015-04-231-2/+4
| | | | | | | | | Currently symbol names are printed in quotes if it contains something outside of the arbitrary set of characters that isAcceptableChar tests for. On somem targets, it is never OK to print a symbol name in quotes so allow targets to opt out of this behavior. llvm-svn: 235670
* Store the sh_link of ARM_EXIDX directly in MCSectionELF.Rafael Espindola2015-04-061-4/+15
| | | | | | This avoids some pretty horrible and broken name based section handling. llvm-svn: 234142
* Simplify mapping from relocation sections to relocated sections.Rafael Espindola2015-04-061-5/+7
| | | | | | | | Just store the section in MCSectionELF. This avoids multiple hash lookups. This will also be used by ARM_EXIDX. llvm-svn: 234139
* Don't mix overload and default values.Rafael Espindola2015-04-041-14/+0
| | | | | | It makes it hard to see which one is being called. llvm-svn: 234100
* Implement unique sections with an unique ID.Rafael Espindola2015-04-041-11/+13
| | | | | | | | | | | This allows the compiler/assembly programmer to switch back to a section. This in turn fixes the bootstrap failure on powerpc (tested on gcc110) without changing the ppc codegen at all. I will try to cleanup the various getELFSection overloads in a followup patch. Just using a default argument now would lead to ambiguities. llvm-svn: 234099
* [WinEH] Generate .xdata for catch handlersDavid Majnemer2015-03-311-0/+5
| | | | | | | | | | | | | | This lets us catch exceptions in simple cases. N.B. Things that do not work include (but are not limited to): - Throwing from within a catch handler. - Catching an object with a named catch parameter. - 'CatchHigh' is fictitious, we aren't sure of its purpose. - We aren't entirely efficient with regards to the number of EH states that we generate. - IP-to-State tables are sensitive to the order of emission. llvm-svn: 233767
* Save a std::string.Rafael Espindola2015-03-301-9/+12
| | | | | | The group names are always symbol names, so we can use a StringRef. llvm-svn: 233545
* Special case the creation of relocation sections.Rafael Espindola2015-03-301-0/+12
| | | | | | | | | | | These sections are never looked up and we know when have to create them. Use that to save adding them to the regular map and avoid a symbol->string->symbol conversion for the group symbol. This also makes the implementation independent of the details of how unique sections are implemented. llvm-svn: 233539
* Add two small structs for readability in place of std::pair and std::tuple. NFC.Rafael Espindola2015-03-271-10/+9
| | | | llvm-svn: 233422
* Centralize the handling of unique ids for temporary labels.Rafael Espindola2015-03-171-32/+31
| | | | | | | | | | | | | | | | Before this patch code wanting to create temporary labels for a given entity (function, cu, exception range, etc) had to keep its own counter to have stable symbol names. createTempSymbol would still add a suffix to make sure a new symbol was always returned, but it kept a single counter. Because of that, if we were to use just createTempSymbol("cu_begin"), the label could change from cu_begin42 to cu_begin43 because some other code started using temporary labels. Simplify this by just keeping one counter per prefix and removing the various specialized counters. llvm-svn: 232535
* Remove LookupSymbol(StringRef) and optimize LookupSymbol(Twine).Yaron Keren2015-03-171-7/+3
| | | | | | | | Same as MakeArgString in r232465, keep only LookupSymbol(Twine) while making sure it handles the StringRef like cases efficiently using twine::toStringRef. llvm-svn: 232517
* Teach Twine to support SmallString.Yaron Keren2015-03-171-9/+6
| | | | | | | | Enable removing .str() member calls for these frequent cases. http://reviews.llvm.org/D6372 llvm-svn: 232465
* Create symbols marking the start of a section earlier.Rafael Espindola2015-03-101-25/+40
| | | | | | | | | This lets us pass the symbol to the constructor and avoid the mutable field. This also opens the way for outputting the symbol only when needed, instead of outputting them at the start of the file. llvm-svn: 231859
* clang-format code that is about to change.Rafael Espindola2015-03-101-8/+10
| | | | llvm-svn: 231848
* Replace llvm.frameallocate with llvm.frameescapeReid Kleckner2015-03-051-3/+4
| | | | | | | | | | Turns out it's pretty straightforward and simplifies the implementation. Reviewers: andrew.w.kaylor Differential Revision: http://reviews.llvm.org/D8051 llvm-svn: 231386
* Remove MCStreamer.h include from MCContext.h and explictly include it where ↵Pete Cooper2015-03-041-0/+1
| | | | | | necessary. NFC llvm-svn: 231193
* Centralize handling of the eh_begin and eh_end labels.Rafael Espindola2015-02-271-0/+6
| | | | | | | | | | This removes a bit of duplicated code and more importantly, remembers the labels so that they don't need to be looked up by name. This in turn allows for any name to be used and avoids a crash if the name we wanted was already taken. llvm-svn: 230772
* Add r228980 back.Rafael Espindola2015-02-171-6/+14
| | | | | | | | | | Add support for having multiple sections with the same name and comdat. Using this in combination with -ffunction-sections allows LLVM to output a .o file with mulitple sections named .text. This saves space by avoiding long unique names of the form .text.<C++ mangled name>. llvm-svn: 229541
* Revert a series of commits starting at r228886 which is triggering someChandler Carruth2015-02-131-14/+6
| | | | | | | | | | | | | | | | regressions for LLDB on Linux. Rafael indicated on lldb-dev that we should just go ahead and revert these but that he wasn't at a computer. The patches backed out are as follows: r228980: Add support for having multiple sections with the name and ... r228889: Invert the section relocation map. r228888: Use the existing SymbolTableIndex intsead of doing a lookup. r228886: Create the Section -> Rel Section map when it is first needed. These patches look pretty nice to me, so hoping its not too hard to get them re-instated. =D llvm-svn: 229080
* Add support for having multiple sections with the same name and comdat.Rafael Espindola2015-02-121-6/+14
| | | | | | | | Using this in combination with -ffunction-sections allows LLVM to output a .o file with mulitple sections named .text. This saves space by avoiding long unique names of the form .text.<C++ mangled name>. llvm-svn: 228980
* Compute the ELF SectionKind from the flags.Rafael Espindola2015-01-291-12/+13
| | | | | | | | | | | | Any code creating an MCSectionELF knows ELF and already provides the flags. SectionKind is an abstraction used by common code that uses a plain MCSection. Use the flags to compute the SectionKind. This removes a lot of guessing and boilerplate from the MCSectionELF construction. llvm-svn: 227476
* Add the llvm.frameallocate and llvm.recoverframeallocation intrinsicsReid Kleckner2015-01-131-0/+5
| | | | | | | | | | | | | | | | | | | | | These intrinsics allow multiple functions to share a single stack allocation from one function's call frame. The function with the allocation may only perform one allocation, and it must be in the entry block. Functions accessing the allocation call llvm.recoverframeallocation with the function whose frame they are accessing and a frame pointer from an active call frame of that function. These intrinsics are very difficult to inline correctly, so the intention is that they be introduced rarely, or at least very late during EH preparation. Reviewers: echristo, andrew.w.kaylor Differential Revision: http://reviews.llvm.org/D6493 llvm-svn: 225746
* Remove StringMap::GetOrCreateValue in favor of StringMap::insertDavid Blaikie2014-11-191-21/+14
| | | | | | | | | | | | | | Having two ways to do this doesn't seem terribly helpful and consistently using the insert version (which we already has) seems like it'll make the code easier to understand to anyone working with standard data structures. (I also updated many references to the Entry's key and value to use first() and second instead of getKey{Data,Length,} and get/setValue - for similar consistency) Also removes the GetOrCreateValue functions so there's less surface area to StringMap to fix/improve/change/accommodate move semantics, etc. llvm-svn: 222319
OpenPOWER on IntegriCloud