summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCContext.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [ARM] Implement execute-only support in CodeGenPrakhar Bahuguna2016-12-151-1/+3
| | | | | | | | | | | | | | | | | | | | This implements execute-only support for ARM code generation, which prevents the compiler from generating data accesses to code sections. The following changes are involved: * Add the CodeGen option "-arm-execute-only" to the ARM code generator. * Add the clang flag "-mexecute-only" as well as the GCC-compatible alias "-mpure-code" to enable this option. * When enabled, literal pools are replaced with MOVW/MOVT instructions, with VMOV used in addition for floating-point literals. As the MOVT instruction is required, execute-only support is only available in Thumb mode for targets supporting ARMv8-M baseline or Thumb2. * Jump tables are placed in data sections when in execute-only mode. * The execute-only text section is assigned section ID 0, and is marked as unreadable with the SHF_ARM_PURECODE flag with symbol 'y'. This also overrides selection of ELF sections for globals. llvm-svn: 289784
* [llvm] Fix D26214: Move error handling out of MC and to the callers.Mandeep Singh Grang2016-12-061-14/+5
| | | | | | | | | | | | Summary: Related clang patch; https://reviews.llvm.org/D27360 Reviewers: t.p.northover, grosbach, compnerd, echristo Subscribers: compnerd, mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D27359 llvm-svn: 288763
* [MC] Generalize MCContext's SectionSymbols field.Dan Gohman2016-12-031-3/+3
| | | | | | | Change SectionSymbols so that it doesn't hard-code ELF types, so that it can be used for non-ELF targets. llvm-svn: 288607
* [llvm] Implement support for -defsym assembler optionMandeep Singh Grang2016-12-011-0/+16
| | | | | | | | | | | | | | | Summary: Changes to llvm-mc to move common logic to separate function. Related clang patch: https://reviews.llvm.org/D26213 Reviewers: rafael, t.p.northover, colinl, echristo, rengolin Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D26214 llvm-svn: 288396
* Tidy spelling and grammar.Eric Christopher2016-09-291-1/+1
| | | | llvm-svn: 282672
* [MC] Move .cv_loc management logic out of MCContextReid Kleckner2016-08-261-8/+0
| | | | | | | | | | | 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
* Add support for allowing us to create uniquely identified "COMDAT" or "ELFEric Christopher2016-07-011-7/+15
| | | | | | | | | | | | | Group" sections while lowering. In particular, for ELF sections this is useful for creating function-specific groups that get merged into the same named section. Also use const Twine& instead of StringRef for the getELF functions while we're here. Differential Revision: http://reviews.llvm.org/D21743 llvm-svn: 274336
* [MCContext] Don't use getenv inside class constructorIgor Laevsky2016-06-171-1/+9
| | | | | | Differential Revision: http://reviews.llvm.org/D21471 llvm-svn: 273005
* Revert r270569 (teach llvm-mc to generate compressed debug sections in zlibRichard Smith2016-05-251-0/+16
| | | | | | style). It appears that current ELF linkers are not ready for this. llvm-svn: 270638
* Recommit r270070 ([llvm-mc] - Teach llvm-mc to generate compressed debug ↵George Rimar2016-05-241-16/+0
| | | | | | | | | | | | | | | | | | | sections in zlib style.) Now, after landing r270560, r270557, r270320 it is a proper time. Original commit message: [llvm-mc] - Teach llvm-mc to generate compressed debug sections in zlib style. Before this patch llvm-mc generated zlib-gnu styled sections. That means no SHF_COMPRESSED flag was set, magic 'zlib' signature was used in combination with full size field. Sections were renamed to "*.z*". This patch reimplements the compression style to zlib one as zlib-gnu looks to be depricated everywhere. Differential revision: http://reviews.llvm.org/D20331 llvm-svn: 270569
* Temporarily revert r270070George Rimar2016-05-191-0/+16
| | | | | | | | | | | | | | | | | | | | | | It broke buildbot: http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/4817/steps/ninja%20check%201/logs/stdio Actually it is just because D20273 not yet commited, but these 2 were crossing with each other, and I`ll better find the way to land them separatelly soon. Initial commit message: [llvm-mc] - Teach llvm-mc to generate compressed debug sections in zlib style. Before this patch llvm-mc generated zlib-gnu styled sections. That means no SHF_COMPRESSED flag was set, magic 'zlib' signature was used in combination with full size field. Sections were renamed to "*.z*". This patch reimplements the compression style to zlib one as zlib-gnu looks to be depricated everywhere. Differential revision: http://reviews.llvm.org/D20331 llvm-svn: 270075
* [llvm-mc] - Teach llvm-mc to generate compressed debug sections in zlib style.George Rimar2016-05-191-16/+0
| | | | | | | | | | | | Before this patch llvm-mc generated zlib-gnu styled sections. That means no SHF_COMPRESSED flag was set, magic 'zlib' signature was used in combination with full size field. Sections were renamed to "*.z*". This patch reimplements the compression style to zlib one as zlib-gnu looks to be depricated everywhere. Differential revision: http://reviews.llvm.org/D20331 llvm-svn: 270070
* [MC] Create unique .pdata sections for every .text sectionReid Kleckner2016-05-021-12/+21
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This adds a unique ID to the COFF section uniquing map, similar to the one we have for ELF. The unique id is not currently exposed via the assembler because we don't have a use case for it yet. Users generally create .pdata with the .seh_* family of directives, and the assembler internally needs to produce .pdata and .xdata sections corresponding to the code section. The association between .text sections and the assembler-created .xdata and .pdata sections is maintained as an ID field of MCSectionCOFF. The CFI-related sections are created with the given unique ID, so if more code is added to the same text section, we can find and reuse the CFI sections that were already created. Reviewers: majnemer, rafael Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D19376 llvm-svn: 268331
* [NFC] Header cleanupMehdi Amini2016-04-181-3/+1
| | | | | | | | | | | | | | Removed some unused headers, replaced some headers with forward class declarations. Found using simple scripts like this one: clear && ack --cpp -l '#include "llvm/ADT/IndexedMap.h"' | xargs grep -L 'IndexedMap[<]' | xargs grep -n --color=auto 'IndexedMap' Patch by Eugene Kosov <claprix@yandex.ru> Differential Revision: http://reviews.llvm.org/D19219 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266595
* Handle section vs global name conflict.Evgeniy Stepanov2016-03-281-14/+7
| | | | | | | | | | | | | This is a fix for PR26941. When there is both a section and a global definition with the same name, the global wins. Section symbols are not added to the symbol table; section references are left undefined and fixed up in the object writer unless they've been satisfied by some other definition. llvm-svn: 264649
* MC: Don't access the filesystem in MCContext's constructorJustin Bogner2016-03-221-5/+0
| | | | | | | | | | | | | | MCContext shouldn't be accessing the filesystem - that's a gross layering violation and makes it awkward to use as a library or in a daemon where it may not even be allowed filesystem access. The CWD lookup here is normally redundant anyway, since the calling context either also looks up the CWD or sets this to something more specific. Here, we fix up the one caller that doesn't already set up a debug compilation dir and make it clear that the responsibility for such set up is in the users of MCContext. llvm-svn: 264109
* Reland "[CodeView] Use assembler directives for line tables"Reid Kleckner2016-01-291-0/+17
| | | | | | | | This reverts commit r259126 and relands r259117. This time with updated library dependencies. llvm-svn: 259130
* Revert "[CodeView] Use assembler directives for line tables"Reid Kleckner2016-01-291-17/+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
* [CodeView] Use assembler directives for line tablesReid Kleckner2016-01-281-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Use std::unique_ptr. NFC.Rafael Espindola2015-12-161-3/+0
| | | | llvm-svn: 255852
* [Assembler] Allow non-fatal errors after parsingOliver Stannard2015-11-171-5/+17
| | | | | | | | | | | | | | | | | This adds reportError to MCContext, which can be used as an alternative to reportFatalError when the assembler wants to try to continue processing the rest of the file after the error is reported, so that all of the errors ina file can be reported. It records the fact that an error was encountered, so we can avoid emitting an object file if any errors occurred. This patch doesn't add any uses of this function (a later patch will convert most uses of reportFatalError to use it), but there is a small functional change: we use the SourceManager to print the error message, even if we have a null SMLoc. This means that we get a SourceManager-style message, with the file and line information shown as <unknown>, rather than the "LLVM ERROR" style used by report_fatal_error. llvm-svn: 253327
* Reduce the size of MCRelaxableFragment.Akira Hatanaka2015-11-141-0/+5
| | | | | | | | | | | | | | | | | | | | | | MCRelaxableFragment previously kept a copy of MCSubtargetInfo and MCInst to enable re-encoding the MCInst later during relaxation. A copy of MCSubtargetInfo (instead of a reference or pointer) was needed because the feature bits could be modified by the parser. This commit replaces the MCSubtargetInfo copy in MCRelaxableFragment with a constant reference to MCSubtargetInfo. The copies of MCSubtargetInfo are kept in MCContext, and the target parsers are now responsible for asking MCContext to provide a copy whenever the feature bits of MCSubtargetInfo have to be toggled. With this patch, I saw a 4% reduction in peak memory usage when I compiled verify-uselistorder.lto.bc using llc. rdar://problem/21736951 Differential Revision: http://reviews.llvm.org/D14346 llvm-svn: 253127
* Clear SectionSymbols in MCContext::ResetKeno Fischer2015-10-091-0/+1
| | | | | | | | | | | | | This was just forgotten when SectionSymbols was introduced and could cause corruption if the MCContext was reused after Reset. Reviewers: rafael Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D13547 llvm-svn: 249854
* Use SpecificBumpPtrAllocator to simplify the MCSeciton destruction.Rafael Espindola2015-10-071-14/+11
| | | | llvm-svn: 249589
* Sink COFF.h MC include into .cpp filesReid Kleckner2015-09-031-0/+1
| | | | | | | | This prevents MC clients from getting COFF.h, which conflicts with winnt.h macros. Also a minor IWYU cleanup. Now the only public headers including COFF.h are in Object, and they actually need it. llvm-svn: 246784
* 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
OpenPOWER on IntegriCloud