summaryrefslogtreecommitdiff
path: root/lib/MC/MCContext.cpp
Commit message (Collapse)AuthorAge
* MC: Fix associative sections on COFFDavid Majnemer2014-06-27
| | | | | | | | | COFF sections in MC were represented by a tuple of section-name and COMDAT-name. This is not sufficient to represent a .text section associated with another .text section; we need a way to distinguish between the key section and the one marked associative. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211913 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Introduce a string_ostream string builder facilty"Alp Toker2014-06-26
| | | | | | Temporarily back out commits r211749, r211752 and r211754. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211814 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce a string_ostream string builder faciltyAlp Toker2014-06-26
| | | | | | | | | | | | | | | | | | | | string_ostream is a safe and efficient string builder that combines opaque stack storage with a built-in ostream interface. small_string_ostream<bytes> additionally permits an explicit stack storage size other than the default 128 bytes to be provided. Beyond that, storage is transferred to the heap. This convenient class can be used in most places an std::string+raw_string_ostream pair or SmallString<>+raw_svector_ostream pair would previously have been used, in order to guarantee consistent access without byte truncation. The patch also converts much of LLVM to use the new facility. These changes include several probable bug fixes for truncated output, a programming error that's no longer possible with the new interface. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211749 91177308-0d34-0410-b5e6-96231b3b80d8
* Emit DWARF info for all code section in an assembly fileOliver Stannard2014-06-19
| | | | | | | | | | Currently, when using llvm as an assembler, DWARF debug information is only generated for the .text section. This patch modifies this so that DWARF info is emitted for all executable sections. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211273 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove 'using std::errro_code' from lib.Rafael Espindola2014-06-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210871 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't use 'using std::error_code' in include/llvm.Rafael Espindola2014-06-12
| | | | | | This should make sure that most new uses use the std prefix. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210835 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a few issues with comdat handling on COFF.Rafael Espindola2014-06-06
| | | | | | | | | | | | | | | | | | | | | * Section association cannot use just the section name as many sections can have the same name. With this patch, the comdat symbol in an assoc section is interpreted to mean a symbol in the associated section and the mapping is discovered from it. * Comdat symbols were not being set correctly. Instead we were getting whatever was output first for that section. A consequence is that associative sections now must use .section to set the association. Using .linkonce would not work since it is not possible to change a sections comdat symbol (it is used to decide if we should create a new section or reuse an existing one). This includes r210298, which was reverted because it was asserting on an associated section having the same comdat as the associated section. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210367 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix uninitialized variable introduced in r207739.David Blaikie2014-05-01
| | | | | | | | | | This was initialized by llvm-mc (calling setDwarfVersion) but other clients (such as clang, llc, etc) aren't necessarily initializing this so we were getting garbage DWARF version values in the output. Initialize it to a reasonable default (the same default used in llvm-mc, though this is higher than it was (2) previously). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207788 91177308-0d34-0410-b5e6-96231b3b80d8
* Change the prototype for MCContext::FatalError() so it can be calledKevin Enderby2014-04-22
| | | | | | | | | | | from places like MCCodeEmitter() in the MC backend when the MCContext is const. I was going to use this in my change for r206669 but Jim convinced me to use an assert there. But this still is a good tweak. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206923 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
* 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
* 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
* 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
* 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
* 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
* MC: don't create a backtrace for diagnostics.Jim Grosbach2014-03-14
| | | | | | | | | | | For better or worse, this is currently the normal error reporting path when dealing with backend errors from inline assembly. It's not just internal compiler issues that come through here, so we shouldn't be creating a backtrace on this path. rdar://16329947 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203979 91177308-0d34-0410-b5e6-96231b3b80d8
* MCContext: Remove redundant assignmentDavid Blaikie2014-03-14
| | | | | | | The member variable is not initialized in the ctor so it's already empty. No need to empty it again. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203963 91177308-0d34-0410-b5e6-96231b3b80d8
* MCDwarf: Rename MCDwarfFileTable to MCDwarfLineTableDavid Blaikie2014-03-13
| | | | | | | This type now represents all the data for the DWARF line table: directory names, file names, and the line table proper. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203858 91177308-0d34-0410-b5e6-96231b3b80d8
* MCDwarf: Sink file/directory creation down into MCDwarfFileTable form MCContextDavid Blaikie2014-03-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203836 91177308-0d34-0410-b5e6-96231b3b80d8
* MCDwarf: Oh, and move the directory string over to std::string as wellDavid Blaikie2014-03-13
| | | | | | (see r203831 for similar stuff) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203833 91177308-0d34-0410-b5e6-96231b3b80d8
* MCDwarf: Simplify MCDwarfFile to just use std::string instead of cunning use ↵David Blaikie2014-03-13
| | | | | | | | | | | | | of MCContext's allocator. There aren't /that/ many files, and we are already using various maps and other standard containers that don't use MCContext's allocator to store these values, so this doesn't seem to be critical and simplifies the design (I'll be moving construction out of MCContext shortly so it'd be annoying to have to pass the allocator around to allocate these things... and we'll have non-MCContext users (debug_line.dwo) shortly) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203831 91177308-0d34-0410-b5e6-96231b3b80d8
* MCDwarf: Simply MCDwarfFile since it really is just a StringRef and unsigned.David Blaikie2014-03-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203827 91177308-0d34-0410-b5e6-96231b3b80d8
* Use printable names to implement directional labels.Rafael Espindola2014-03-13
| | | | | | | | | | | | | | This changes the implementation of local directional labels to use a dedicated map. With that it can then just use CreateTempSymbol, which is what the rest of MC uses. CreateTempSymbol doesn't do a great job at making sure the names are unique (or being efficient when the names are not needed), but that should probably be fixed in a followup patch. This fixes pr18928. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203826 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove stale commentDavid Blaikie2014-03-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203823 91177308-0d34-0410-b5e6-96231b3b80d8
* MCDwarf: Refactor line table handling into a single data structureDavid Blaikie2014-03-13
| | | | | | | | | | | | | | | | | This replaces several "compile unit ID -> thing" mappings in favor of one mapping from CUID to the whole line table structure (files, directories, and lines). This is another step along the way to refactoring out reusable components of line table handling for use when generating debug_line.dwo for fission type units. Also, might be a good basis to fold some of this handling down into MCStreamers to avoid the special case of "One line table when doing asm printing, line table per CU otherwise" by building it into the different MCStreamer implementations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203821 91177308-0d34-0410-b5e6-96231b3b80d8
* MCDwarf: Invert the Section+CU->LineEntries mapping so the CU is the primary ↵David Blaikie2014-03-12
| | | | | | | | | | | | | | | | | | | | | | | | dimension This makes the mapping consistent with other CU->X mappings in the MCContext, helping pave the way to refactor all these values into a single data structure per CU and thus a single map. I haven't renamed the data structure as that would make the patch churn even higher (the MCLineSection name no longer makes sense, as this structure now contains lines for multiple sections covered by a single CU, rather than lines for a single section in multiple CUs) and further refactorings will follow that may remove this type entirely. For convenience, I also gave the MCLineSection value semantics so we didn't have to do the lazy construction, manual delete, etc. (& for those playing at home, refactoring the line printing into a single data structure will eventually alow that data structure to be reused to own the debug_line.dwo line table used for type unit file name resolution) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203726 91177308-0d34-0410-b5e6-96231b3b80d8
* Correct typo ("a entry" -> "an entry")David Blaikie2014-03-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203678 91177308-0d34-0410-b5e6-96231b3b80d8
* Re-sort all of the includes with ./utils/sort_includes.py so thatChandler Carruth2014-01-07
| | | | | | | | | | subsequent changes are easier to review. About to fix some layering issues, and wanted to separate out the necessary churn. Also comment and sink the include of "Windows.h" in three .inc files to match the usage in Memory.inc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198685 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a crash that occurs when PWD is invalid.Andrew Trick2013-12-10
| | | | | | | | | | | | | | | | | | | | MCJIT needs to be able to run in hostile environments, even when PWD is invalid. There's no need to crash MCJIT in this case. The obvious fix is to simply leave MCContext's CompilationDir empty when PWD can't be determined. This way, MCJIT clients, and other clients that link with LLVM don’t need a valid working directory. If we do want to guarantee valid CompilationDir, that should be done only for clients of getCompilationDir(). This is as simple as checking for an empty string. The only current use of getCompilationDir is EmitGenDwarfInfo, which won’t conceivably run with an invalid working dir. However, in the purely hypothetically and untestable case that this happens, the AT_comp_dir will be omitted from the compilation_unit DIE. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196874 91177308-0d34-0410-b5e6-96231b3b80d8
* whitespaceAndrew Trick2013-12-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196873 91177308-0d34-0410-b5e6-96231b3b80d8
* Correct word hyphenationsAlp Toker2013-12-05
| | | | | | | This patch tries to avoid unrelated changes other than fixing a few hyphen-related ambiguities and contractions in nearby lines. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196471 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid buffer copies when a Twine already is a StringRef.David Blaikie2013-12-03
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196301 91177308-0d34-0410-b5e6-96231b3b80d8
* Support multiple COFF sections with the same name but different COMDAT.Rafael Espindola2013-11-19
| | | | | | | | | | | | | | | | | | This is the first step to fix pr17918. It extends the .section directive a bit, inspired by what the ELF one looks like. The problem with using linkonce is that given .section foo .linkonce.... .section foo .linkonce we would already have switched sections when getting to .linkonce. The cleanest solution seems to be to add the comdat information in the .section itself. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195148 91177308-0d34-0410-b5e6-96231b3b80d8
* MC: Support multiple sections with the same name in the same comdat groupDavid Blaikie2013-10-22
| | | | | | Code review by Eric Christopher and Rafael Espindola. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193209 91177308-0d34-0410-b5e6-96231b3b80d8
* MC: Implement COFF .linkonce directiveNico Rieck2013-07-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185753 91177308-0d34-0410-b5e6-96231b3b80d8
* Use pointers to the MCAsmInfo and MCRegInfo.Bill Wendling2013-06-18
| | | | | | | | | | Someone may want to do something crazy, like replace these objects if they change or something. No functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184175 91177308-0d34-0410-b5e6-96231b3b80d8
* Silence warning in Release builds.Benjamin Kramer2013-06-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184059 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace use of PathV1.h in MCContext.cpp.Rafael Espindola2013-06-14
| | | | | | GetCurrentDirectory is now unused. Remove it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184003 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't use PathV1.h in Signals.h.Rafael Espindola2013-06-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183947 91177308-0d34-0410-b5e6-96231b3b80d8
* Debug Info: use SmallVector instead of std::vector in MCDwarfDirsCUMap and ↵Manman Ren2013-03-12
| | | | | | MCDwarfFilesCUMap git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176893 91177308-0d34-0410-b5e6-96231b3b80d8
* Debug Info: store the files and directories for each compile unit.Manman Ren2013-03-07
| | | | | | | | | | | | | | | We now emit a line table for each compile unit. To reduce the prologue size of each line table, the files and directories used by each compile unit are stored in std::map<unsigned, std::vector< > > instead of std::vector< >. The prologue for a lto'ed image can be as big as 93K. Duplicating 93K for each compile unit causes a huge increase of debug info. With this patch, each prologue will only emit the files required by the compile unit. rdar://problem/13342023 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176605 91177308-0d34-0410-b5e6-96231b3b80d8
* clear new map and initialize new variablePedro Artigas2013-02-20
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175578 91177308-0d34-0410-b5e6-96231b3b80d8
* Dwarf: support for LTO where a single object file can have multiple line tablesManman Ren2013-02-05
| | | | | | | | | | We generate one line table for each compilation unit in the object file. Reviewed by Eric and Kevin. rdar://problem/13067005 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174445 91177308-0d34-0410-b5e6-96231b3b80d8
* Formatting.Eric Christopher2012-12-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170394 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for passing -main-file-name all the way through toEric Christopher2012-12-18
| | | | | | | | the assembler. Part of PR14624 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170390 91177308-0d34-0410-b5e6-96231b3b80d8
* Prepare LLVM to fix PR14625, exposing a hook in MCContext to manage theChandler Carruth2012-12-17
| | | | | | | | | | compilation directory. This defaults to the current working directory, just as it always has, but now an assembler can choose to override it with a custom directory. I've taught llvm-mc about this option and added a test case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170371 91177308-0d34-0410-b5e6-96231b3b80d8
* Make the MCStreamer have a reset method and call that after finalization of ↵Pedro Artigas2012-12-12
| | | | | | | | | | the asm printer, also changed MCContext to a single reset only method for simplicity as requested on the list git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170041 91177308-0d34-0410-b5e6-96231b3b80d8
* fixed valgrind issues of prior commit, this change applies r169456 changes ↵Pedro Artigas2012-12-06
| | | | | | | | | | | | | | | back to the tree with fixes. on darwin no valgrind issues exist in the tests that used to fail. original change description: change MCContext to work on the doInitialization/doFinalization model reviewed by Evan Cheng <evan.cheng@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169553 91177308-0d34-0410-b5e6-96231b3b80d8