summaryrefslogtreecommitdiff
path: root/lib/MC
Commit message (Collapse)AuthorAge
* Revert r206565 (and r206566 which updated tests).Chandler Carruth2014-04-18
| | | | | | | | | | | | | | This commit was attributed to a different person from the person who posted the patch to the list, and the person who posted it the list claimed when they did that they were not the author, but that the author was yet a third person. I don't know what is going on here, but reverting until the attribution is clear and the author has explicitly contributed the patch. Also, the review hasn't really involved any of the MC maintainers and that seems questionable too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206576 91177308-0d34-0410-b5e6-96231b3b80d8
* Patch by Ray Donnelly.Yaron Keren2014-04-18
| | | | | | | | Emit WIN64 SEH registers by name instead of just number. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206565 91177308-0d34-0410-b5e6-96231b3b80d8
* MC: rework static_assert to be MSVC compatibleSaleem Abdulrasool2014-04-17
| | | | | | | | Visual Studio does not permit referencing a structure member as a static field for sizeof calculations. Resort to a pointer cast which is compatible across Visual Studio and other compilers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206445 91177308-0d34-0410-b5e6-96231b3b80d8
* AArch64/ARM64: port across stub handling for ELF C++ exceptions.Tim Northover2014-04-16
| | | | | | | | The most important part here is that we should actuall emit the stubs we refer to in the exception table, but as a side issue this uses more sensible & GCC compatible representations for some of the bits of information. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206380 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify a static_assert so VS2013 can build itTimur Iskhodzhanov2014-04-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206363 91177308-0d34-0410-b5e6-96231b3b80d8
* COFF: fix an off by one errorSaleem Abdulrasool2014-04-16
| | | | | | | | | | Adjust the tests to validate the number of auxiliary entries used to store the filename. Thanks to majnemer's sharp eye for catching the missing - 1 in the round up calculation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206359 91177308-0d34-0410-b5e6-96231b3b80d8
* COFF: add support for .file symbolsSaleem Abdulrasool2014-04-16
| | | | | | | | | | | | | Add support for emitting .file records. This is mostly a quality of implementation change (more complete support for COFF file emission) that was noticed while working on COFF file emission for Windows on ARM. A .file record is emitted as a symbol with storage class FILE (103) and the name ".file". A series of auxiliary format 4 records follow which contain the file name. The filename is stored as an ANSI string and is padded with NULL if the length is not a multiple of COFF::SymbolSize (18). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206355 91177308-0d34-0410-b5e6-96231b3b80d8
* Use unique_ptr for section/segment ownership in WinCOFFObjectWriterDavid Blaikie2014-04-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206245 91177308-0d34-0410-b5e6-96231b3b80d8
* Use unique_ptr to own MCFunctions within MCModule.David Blaikie2014-04-15
| | | | | | | | MCModule's ctor had to be moved out of line so the definition of MCFunction was available. (ctor requires the dtor of members (in case the ctor throws) which required access to the dtor of MCFunction) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206244 91177308-0d34-0410-b5e6-96231b3b80d8
* Use std::unique_ptr to manage MCBasicBlocks in MCFunction.David Blaikie2014-04-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206242 91177308-0d34-0410-b5e6-96231b3b80d8
* [MC] Require an MCContext when constructing an MCDisassembler.Lang Hames2014-04-15
| | | | | | | | | | | | | | | | | | This patch re-introduces the MCContext member that was removed from MCDisassembler in r206063, and requires that an MCContext be passed in at MCDisassembler construction time. (Previously the MCContext member had been initialized in an ad-hoc fashion after construction). The MCCContext member can be used by MCDisassembler sub-classes to construct constant or target-specific MCExprs. This patch updates disassemblers for in-tree targets, and provides the MCRegisterInfo instance that some disassemblers were using through the MCContext (previously those backends were constructing their own MCRegisterInfo instances). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206241 91177308-0d34-0410-b5e6-96231b3b80d8
* [MC] Emit an error if cfi_startproc is used before a symbol is defined.Quentin Colombet2014-04-15
| | | | | | | | | | Currently, we bind those directives with the last symbol, so if none has been defined, this would lead to a crash of the compiler. <rdar://problem/15939159> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206236 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove a variable from r206192 that is only used in an assert.Kaelyn Takata2014-04-14
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206195 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix up MCFixup::getAccessVariant to handle unary expressions.Kaelyn Takata2014-04-14
| | | | | | | | | | | | This allows correct relocations to be generated for a symbolic address that is being adjusted by a negative constant. Since r204294, such expressions have triggered undefined behavior when LLVM was built without assertions. Credit goes to Rafael for this patch; I'm submitting it on his behalf as he is on vacation this week. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206192 91177308-0d34-0410-b5e6-96231b3b80d8
* MC: check machine magic when applying offset adjustmentsSaleem Abdulrasool2014-04-13
| | | | | | | | | | | | | | | The values for the relocation type can (and do) overlap across various architectures. When performing an adjustment of the emitted relocation in the final object file, check that the file magic matches the target for which the relocation type is valid (e.g. a I386 relocation is only applied to an X86 object file, and an AMD64 relocation is only applied to an X86_64 object file). This was noticed while adding support for ARM WinCOFF object file emission. A test case for this is not really possible as the values for REL32 do not overlap on I386 and AMD64, which is why this was never noticed in practice. The ARM WinCOFF emission is not yet ready to merge into the tree. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206138 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] More 'nullptr' conversion or in some cases just using a boolean ↵Craig Topper2014-04-13
| | | | | | check instead of comparing to nullptr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206129 91177308-0d34-0410-b5e6-96231b3b80d8
* Retire llvm::array_endof in favor of non-member std::end.Benjamin Kramer2014-04-12
| | | | | | While there make array_lengthof constexpr if we have support for it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206112 91177308-0d34-0410-b5e6-96231b3b80d8
* Pull out a named variable for the cached section names to aid readability.David Blaikie2014-04-11
| | | | | | Based on a code review suggestion from Eric Christopher in r205990 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206080 91177308-0d34-0410-b5e6-96231b3b80d8
* Format fixes for r205990David Blaikie2014-04-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206078 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove redundant symbolization support from MCDisassembler interface.Lang Hames2014-04-11
| | | | | | | | | | | | | | | | | | | MCDisassembler has an MCSymbolizer member that is meant to take care of symbolizing during disassembly, but it also has several methods that enable the disassembler to do symbolization internally (i.e. without an attached symbolizer object). There is no need for this duplication, but ARM64 had been making use of it. This patch moves the ARM64 symbolization logic out of ARM64Disassembler and into an ARM64ExternalSymbolizer class, and removes the duplicated MCSymbolizer functionality from the MCDisassembler interface. Symbolization will now be done exclusively through MCSymbolizers. There should be no impact on disassembly for any platform, but this allows us to tidy up the MCDisassembler interface and simplify the process of (and invariants related to) disassembler setup. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206063 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't lose the thumb bit by using relocations with sections.Rafael Espindola2014-04-11
| | | | | | This fixes a regression from r205076. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206047 91177308-0d34-0410-b5e6-96231b3b80d8
* Use value types instead of 'new'd objects to store dwarf labels for asm filesDavid Blaikie2014-04-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206009 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove lazy-initialization of section caches in MCContextDavid Blaikie2014-04-10
| | | | | | | | This seems to have been a cargo-culted habit from the very first such cache which didn't have any specific justification (but might've been a layering constraint at the time). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206003 91177308-0d34-0410-b5e6-96231b3b80d8
* Reimplement debug info compression by compressing the whole section, rather ↵David Blaikie2014-04-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | than a fragment. To support compressing the debug_line section that contains multiple fragments (due, I believe, to variation in choices of line table encoding depending on the size of instruction ranges in the actual program code) we needed to support compressing multiple MCFragments in a single pass. This patch implements that behavior by mutating the post-relaxed and relocated section to be the compressed form of its former self, including renaming the section. This is a more flexible (and less invasive, to a degree) implementation that will allow for other features such as "use compression only if it's smaller than the uncompressed data". Compressing debug_frame would be a possible further extension to this work, but I've left it for now. The hurdle there is alignment sections - which might require going as far as to refactor MCAssembler.cpp:writeFragment to handle writing to a byte buffer or an MCObjectWriter (there's already a virtual call there, so it shouldn't add substantial compile-time cost) which could in turn involve refactoring MCAsmBackend::writeNopData to use that same abstraction... which involves touching all the backends. This would remove the limited handling of fragment writing seen in ELFObjectWriter.cpp:getUncompressedData which would be nice - but it's more invasive. I did discover that I (perhaps obviously) don't need to handle relocations when I rewrite the fragments - since the relocations have already been applied and computed (and stored into ELFObjectWriter::Relocations) by this stage (necessarily, because we need to have written any immediate values or assembly-time relocations into the data already before we compress it, which we have). The test case doesn't necessarily cover that in detail - I can add more test coverage if that's preferred. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205990 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert debug info compression support.David Blaikie2014-04-10
| | | | | | | | | | To support compression for debug_line and debug_frame a different approach is required. To simplify review, revert the old implementation and XFAIL the test case. New implementation to follow shortly. Reverts r205059 and r204958. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205989 91177308-0d34-0410-b5e6-96231b3b80d8
* YAMLIO: Allow scalars to dictate quotation rulesDavid Majnemer2014-04-10
| | | | | | | Introduce ScalarTraits::mustQuote which determines whether or not a StringRef needs quoting before it is acceptable to output. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205955 91177308-0d34-0410-b5e6-96231b3b80d8
* WinCOFF: Emit common symbols as specified in the COFF specDavid Majnemer2014-04-08
| | | | | | | | | | | | | | | | | | Summary: Local common symbols were properly inserted into the .bss section. However, putting external common symbols in the .bss section would give them a strong definition. Instead, encode them as undefined, external symbols who's symbol value is equivalent to their size. Reviewers: Bigcheese, rafael, rnk CC: llvm-commits Differential Revision: http://reviews.llvm.org/D3324 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205811 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify compression API by compressing into a SmallVector rather than a ↵David Blaikie2014-04-05
| | | | | | | | MemoryBuffer This is the other half of r205676. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205677 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement getRelocationAddress for MachO and ET_REL elf files.Rafael Espindola2014-04-03
| | | | | | With that, fix the symbolizer to work with any ELF file. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205588 91177308-0d34-0410-b5e6-96231b3b80d8
* Work around gold bug http://sourceware.org/PR16794.Rafael Espindola2014-04-02
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205416 91177308-0d34-0410-b5e6-96231b3b80d8
* [ARM64][CollectLOH] Add some comments to explain how the LOHsQuentin Colombet2014-04-02
| | | | | | | | framework works (for the compiler part), since the design document is not available. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205379 91177308-0d34-0410-b5e6-96231b3b80d8
* DebugInfo: Avoid creating unnecessary/empty line tables and remove the ↵David Blaikie2014-04-01
| | | | | | | | | | | | special case of '0' in DwarfCompileUnit::initStmtList by just always using a label difference This moves one case of raw text checking down into the MCStreamer interfaces in the form of a virtual function, even if we ultimately end up consolidating on the one-or-many line tables issue one day, this is nicer in the interim. This just generally streamlines a bunch of use cases into a common code path. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205287 91177308-0d34-0410-b5e6-96231b3b80d8
* DebugInfo: Emit relocation to debug_line section when emitting asm for asmDavid Blaikie2014-04-01
| | | | | | | | | | | | | | I don't think this is reachable by any frontend (why would you transform asm to asm+debug info?) but it helps tidy up some of this code, avoid the weird special case of "emit the first CU, store the label, then emit the rest" in MCDwarfLineTable::Emit by instead having the DWARF-for-assembly case use the same codepath as DwarfDebug.cpp, by registering the label of the debug_line section, thus causing it to be emitted. (with a special case in asm output to just emit the label since asm output uses the .loc directives, etc, rather than the debug_loc directly) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205286 91177308-0d34-0410-b5e6-96231b3b80d8
* [MC] Remove an unused (and broken) variant of the setupForSymbolicDisassemblyLang Hames2014-03-30
| | | | | | | method in MCDisassembler. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205123 91177308-0d34-0410-b5e6-96231b3b80d8
* Detemplatize LOHDirective.Benjamin Kramer2014-03-29
| | | | | | | | | | | The ARM64 backend uses it only as a container to keep an MCLOHType and Arguments around so give it its own little copy. The other functionality isn't used and we had a crazy method specialization hack in place to keep it working. Unfortunately that was incompatible with MSVC. Also range-ify a couple of loops while at it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205114 91177308-0d34-0410-b5e6-96231b3b80d8
* ARM64: initial backend importTim Northover2014-03-29
| | | | | | | | | | | | This adds a second implementation of the AArch64 architecture to LLVM, accessible in parallel via the "arm64" triple. The plan over the coming weeks & months is to merge the two into a single backend, during which time thorough code review should naturally occur. Everything will be easier with the target in-tree though, hence this commit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205090 91177308-0d34-0410-b5e6-96231b3b80d8
* MC-exceptions: add support for compact-unwind without .eh_frameTim Northover2014-03-29
| | | | | | | | | | | | ARM64 has compact-unwind information, but doesn't necessarily want to emit .eh_frame directives as well. This teaches MC about such a situation so that it will skip .eh_frame info when compact unwind has been successfully produced. For functions incompatible with compact unwind, the normal information is still written. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205087 91177308-0d34-0410-b5e6-96231b3b80d8
* MC: add a RefKind field to MCValueTim Northover2014-03-29
| | | | | | | | This is principally to allow neater mapping of fixups to relocations in ARM64 ELF. Without this, there isn't enough information available to GetRelocType, leading to many more fixup_arm64_... enumerators. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205085 91177308-0d34-0410-b5e6-96231b3b80d8
* MachO: Add linker-optimisation hint framework to MC.Tim Northover2014-03-29
| | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205084 91177308-0d34-0410-b5e6-96231b3b80d8
* MachO: actually set linker-private prefix at MC level.Tim Northover2014-03-29
| | | | | | This was accidentally omitted from r205081. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205083 91177308-0d34-0410-b5e6-96231b3b80d8
* MachO: allow each section to have a linker-private symbolTim Northover2014-03-29
| | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205081 91177308-0d34-0410-b5e6-96231b3b80d8
* Completely rewrite ELFObjectWriter::RecordRelocation.Rafael Espindola2014-03-29
| | | | | | | | | | | | | | | | | | | I started trying to fix a small issue, but this code has seen a small fix too many. The old code was fairly convoluted. Some of the issues it had: * It failed to check if a symbol difference was in the some section when converting a relocation to pcrel. * It failed to check if the relocation was already pcrel. * The pcrel value computation was wrong in some cases (relocation-pc.s) * It was missing quiet a few cases where it should not convert symbol relocations to section relocations, leaving the backends to patch it up. * It would not propagate the fact that it had changed a relocation to pcrel, requiring a quiet nasty work around in ARM. * It was missing comments. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205076 91177308-0d34-0410-b5e6-96231b3b80d8
* Debug Compression: Avoid compression debug_frame for nowDavid Blaikie2014-03-28
| | | | | | | | Turns out debug_frame does use multiple fragments, so it doesn't compress correctly with the current approach. Disable compressing it for now while I figure out what's the best solution for it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205059 91177308-0d34-0410-b5e6-96231b3b80d8
* Map ELf flags back to more specific section kinds.Rafael Espindola2014-03-28
| | | | | | With that, convert another llc -filetype=obj test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205031 91177308-0d34-0410-b5e6-96231b3b80d8
* Canonicalise Windows target triple spellingsSaleem Abdulrasool2014-03-27
| | | | | | | | | | | | | | | | | | | | | | | | | Construct a uniform Windows target triple nomenclature which is congruent to the Linux counterpart. The old triples are normalised to the new canonical form. This cleans up the long-standing issue of odd naming for various Windows environments. There are four different environments on Windows: MSVC: The MS ABI, MSVCRT environment as defined by Microsoft GNU: The MinGW32/MinGW32-W64 environment which uses MSVCRT and auxiliary libraries Itanium: The MSVCRT environment + libc++ built with Itanium ABI Cygnus: The Cygwin environment which uses custom libraries for everything The following spellings are now written as: i686-pc-win32 => i686-pc-windows-msvc i686-pc-mingw32 => i686-pc-windows-gnu i686-pc-cygwin => i686-pc-windows-cygnus This should be sufficiently flexible to allow us to target other windows environments in the future as necessary. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204977 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove another unused argument.Rafael Espindola2014-03-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204961 91177308-0d34-0410-b5e6-96231b3b80d8
* DebugInfo: Support for compressed debug info sectionsDavid Blaikie2014-03-27
| | | | | | | | | | | | | | | | | | | 1) When creating a .debug_* section and instead create a .zdebug_ section. 2) When creating a fragment in a .zdebug_* section, make it a compressed fragment. 3) When computing the size of a compressed section, compress the data and use the size of the compressed data. 4) Emit the compressed bytes. Also, check that only if a section has a compressed fragment, then that is the only fragment in the section. Assert-fail if the fragment's data is modified after it is compressed. Initial review on llvm-commits by Eric Christopher and Rafael Espindola. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204958 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove unused argument.Rafael Espindola2014-03-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204956 91177308-0d34-0410-b5e6-96231b3b80d8
* Move MCSymbolizer's constructor into header. It's trivial - there's no need forLang Hames2014-03-27
| | | | | | | it to be out-of-line. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204892 91177308-0d34-0410-b5e6-96231b3b80d8
* Update MCSymbolizer and its subclasses' constructors to reflect the fact thatLang Hames2014-03-27
| | | | | | | | they take ownership of the RelocationInfo they're constructed with. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204891 91177308-0d34-0410-b5e6-96231b3b80d8