summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCAssembler.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert "Remove doesSectionRequireSymbols."Rafael Espindola2014-12-311-14/+2
| | | | | | | | This reverts commit r224985. I am investigating why it made an Apple bot unhappy. llvm-svn: 225044
* Remove doesSectionRequireSymbols.Rafael Espindola2014-12-301-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | In an assembly expression like bar: .long L0 + 1 the intended semantics is that bar will contain a pointer one byte past L0. In sections that are merged by content (strings, 4 byte constants, etc), a single position in the section doesn't give the linker enough information. For example, it would not be able to tell a relocation must point to the end of a string, since that would look just like the start of the next. The solution used in ELF to use relocation with symbols if there is a non-zero addend. In MachO before this patch we would just keep all symbols in some sections. This would miss some cases (only cstrings on x86_64 were implemented) and was inefficient since most relocations have an addend of 0 and can be represented without the symbol. This patch implements the non-zero addend logic for MachO too. llvm-svn: 224985
* Refactor duplicated code.Rafael Espindola2014-12-291-2/+3
| | | | | | No intended functionality change. llvm-svn: 224935
* [MC] Make bundle alignment mode setting idempotent and support nested bundlesDerek Schuff2014-10-151-1/+22
| | | | | | | | | | | | | | | | | | | | | | Summary: Currently an error is thrown if bundle alignment mode is set more than once per module (either via the API or the .bundle_align_mode directive). This change allows setting it multiple times as long as the alignment doesn't change. Also nested bundle_lock groups are currently not allowed. This change allows them, with the effect that the group stays open until all nests are exited, and if any of the bundle_lock directives has the align_to_end flag, the group becomes align_to_end. These changes make the bundle aligment simpler to use in the compiler, and also better match the corresponding support in GNU as. Reviewers: jvoung, eliben Differential Revision: http://reviews.llvm.org/D5801 llvm-svn: 219811
* Simplify handling of --noexecstack by using getNonexecutableStackSection.Rafael Espindola2014-10-151-4/+3
| | | | llvm-svn: 219799
* MC: Bit pack MCSymbolData.Benjamin Kramer2014-10-111-7/+6
| | | | | | | | | On x86_64 this brings it from 80 bytes to 64 bytes. Also make any member variables private and clean up uses to go through the existing accessors. NFC. llvm-svn: 219573
* Add and update reset() and doInitialization() methods to MC* and passes.Yaron Keren2014-09-171-0/+5
| | | | | | This enables reusing a PassManager instead of re-constructing it every time. llvm-svn: 217948
* Add a helper to MCExpr for when an expression is know to be absolute.Rafael Espindola2014-08-151-12/+3
| | | | llvm-svn: 215713
* If available, pass down the Fixup object to EvaluateAsRelocatable.Joerg Sonnenberger2014-08-101-6/+7
| | | | | | | At least on PowerPC, the interpretation of certain modifiers depends on the context they appear in. llvm-svn: 215310
* MC: make MCSymbolData::dump work on const objectsDavid Majnemer2014-07-051-1/+1
| | | | | | | This just lets us dump a const MCSymbolData object, no functionality changed. llvm-svn: 212365
* Avoid revocations when possible.Rafael Espindola2014-07-011-1/+16
| | | | | | | | This is a small targeted fix for pr20119. The code needs quiet a bit of refactoring and I added some FIXMEs about it, but I want to get the testcase passing first. llvm-svn: 212101
* Report error for non-zero data in .bssWeiming Zhao2014-06-221-2/+8
| | | | | | | | | | | | User may initialize a var with non-zero value and specify .bss section. E.g. : int a __attribute__((section(".bss"))) = 2; This patch converts an assertion to error report for better user experience. Differential Revision: http://reviews.llvm.org/D4199 llvm-svn: 211455
* Move getBaseSymbol somewhere the COFF writer can use.Rafael Espindola2014-05-011-0/+22
| | | | | | I will use it there in a second. llvm-svn: 207761
* Provide a version of getSymbolOffset that returns false on error.Rafael Espindola2014-04-301-14/+43
| | | | | | | This simplifies ELFObjectWriter::SymbolValue a bit more. This new version will also be used in the COFF writer to fix pr19147. llvm-svn: 207711
* Grammar fix.Rafael Espindola2014-04-301-1/+1
| | | | | | Thanks to Saleem Abdulrasool for noticing it. llvm-svn: 207643
* Simplify getSymbolOffset.Rafael Espindola2014-04-301-26/+28
| | | | | | | We can now use EvaluateAsValue to make it non recursive and remove some code duplication. llvm-svn: 207604
* Another missing include for MSVC.Benjamin Kramer2014-04-291-1/+1
| | | | llvm-svn: 207596
* Centralize the handling of the thumb bit.Rafael Espindola2014-04-291-0/+25
| | | | | | | | | | | | | 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
* [Modules] Fix potential ODR violations by sinking the DEBUG_TYPEChandler Carruth2014-04-221-1/+2
| | | | | | | definition below all the header #include lines. This updates most of the miscellaneous other lib/... directories. A few left though. llvm-svn: 206845
* [C++11] More 'nullptr' conversion or in some cases just using a boolean ↵Craig Topper2014-04-131-8/+8
| | | | | | check instead of comparing to nullptr. llvm-svn: 206129
* Revert debug info compression support.David Blaikie2014-04-101-47/+0
| | | | | | | | | | 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. llvm-svn: 205989
* Simplify compression API by compressing into a SmallVector rather than a ↵David Blaikie2014-04-051-10/+10
| | | | | | | | MemoryBuffer This is the other half of r205676. llvm-svn: 205677
* MachO: Add linker-optimisation hint framework to MC.Tim Northover2014-03-291-0/+1
| | | | | | | | 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
* Completely rewrite ELFObjectWriter::RecordRelocation.Rafael Espindola2014-03-291-8/+12
| | | | | | | | | | | | | | | | | | | 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. llvm-svn: 205076
* DebugInfo: Support for compressed debug info sectionsDavid Blaikie2014-03-271-0/+47
| | | | | | | | | | | | | | | | | | | 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. llvm-svn: 204958
* Darwin: Add assembler directives to create version-min load commands.Jim Grosbach2014-03-181-0/+1
| | | | | | | | | | | | Allow object files to be tagged with a version-min load command for iOS or MacOSX. Teach macho-dump to understand the version-min load commands for testcases. rdar://11337778 llvm-svn: 204190
* Try harder to evaluate expressions when printing assembly.Rafael Espindola2014-03-121-2/+2
| | | | | | | | | When printing assembly we don't have a Layout object, but we can still try to fold some constants. Testcase by Ulrich Weigand. llvm-svn: 203677
* Explictly pass MCSubtargetInfo to MCCodeEmitter::EncodeInstruction()David Woodhouse2014-01-281-1/+1
| | | | llvm-svn: 200348
* Fix indentation.Joerg Sonnenberger2014-01-131-11/+11
| | | | llvm-svn: 199118
* Move assert above first use of variable that we'd be asserting on.Eric Christopher2013-08-071-2/+2
| | | | llvm-svn: 187899
* Use MCFillFragment for zero-initialized data.Serge Pavlov2013-06-271-3/+4
| | | | | | | | It fixes PR16338 (ICE when compiling very large two-dimensional array). Differential Revision: http://llvm-reviews.chandlerc.com/D1043 llvm-svn: 185080
* [MC/DWARF] Support .debug_frame / .debug_line code alignment factorsUlrich Weigand2013-06-121-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | I've been comparing the object file output of LLVM's integrated assembler against the external assembler on PowerPC, and one area where differences still remain are in DWARF sections. In particular, the GNU assembler generates .debug_frame and .debug_line sections using a code alignment factor of 4, since all PowerPC instructions have size 4 and must be aligned to a multiple of 4. However, current MC code hard-codes a code alignment factor of 1. This patch changes this by adding a "minimum instruction alignment" data element to MCAsmInfo and using this as code alignment factor. This requires passing a MCContext into MCDwarfLineAddr::Encode and MCDwarfLineAddr::EncodeAdvanceLoc. Note that one caller, MCDwarfLineAddr::Write, didn't actually have that information available. However, it turns out that this routine is in fact never used in the whole code base, so the patch simply removes it. If it turns out to be needed again at a later time, it could be re-added with an updated interface. llvm-svn: 183834
* Add support for subsections to the ELF assembler. Fixes PR8717.Peter Collingbourne2013-04-171-1/+32
| | | | | | Differential Revision: http://llvm-reviews.chandlerc.com/D598 llvm-svn: 179725
* Remove unused method and default values.Rafael Espindola2013-04-091-2/+1
| | | | llvm-svn: 179124
* Fix unnecessary removal of const through cast machineryDavid Blaikie2013-02-111-7/+7
| | | | | | | | I have some uncommitted changes to the cast code that catch this sort of thing at compile-time but I still need to do some other cleanup before I can enable it. llvm-svn: 174853
* [MC] Bundle alignment: Invalidate relaxed fragmentsDerek Schuff2013-02-051-7/+8
| | | | | | | | | | | | | | | | Currently, when a fragment is relaxed, its size is modified, but its offset is not (it gets laid out as a side effect of checking whether it needs relaxation), then all subsequent fragments are invalidated because their offsets need to change. When bundling is enabled, relaxed fragments need to get laid out again, because the increase in size may push it over a bundle boundary. So instead of only invalidating subsequent fragments, also invalidate the fragment that gets relaxed, which causes it to get laid out again. This patch also fixes some trailing whitespace and fixes the bundling-related debug output of MCFragments. llvm-svn: 174401
* [MC] bundle alignment: prevent padding instructions from crossing bundle ↵Derek Schuff2013-01-311-4/+20
| | | | | | boundaries llvm-svn: 174067
* This patch reworks how llvm targets set Jack Carter2013-01-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | and update ELF header e_flags. Currently gathering information such as symbol, section and data is done by collecting it in an MCAssembler object. From MCAssembler and MCAsmLayout objects ELFObjectWriter::WriteObject() forms and streams out the ELF object file. This patch just adds a few members to the MCAssember class to store and access the e_flag settings. It allows for runtime additions to the e_flag by assembler directives. The standalone assembler can get to MCAssembler from getParser().getStreamer().getAssembler(). This patch is the generic infrastructure and will be followed by patches for ARM and Mips for their target specific use. Contributer: Jack Carter llvm-svn: 173882
* Optimize the memory usage of MC bundling, by creating a new type of fragmentEli Bendersky2013-01-151-2/+34
| | | | | | | | | | | | | | | | | into which we can emit single instructions without fixups (which is most instructions). This is an optimization required because MCDataFragment is prety large (240 bytes on x64), with no change in functionality. For large programs, this reduces memory usage overhead required for bundling by 40%. To make the code as palatable as possible, the MCEncodedFragment interface was further fragmented (no pun intended) and MCEncodedFragmentWithFixups is used as the interface to work against when the user expects fixups. MCDataFragment and MCRelaxableFragment implement this interface, while the new MCCompactEncodedInstFragment implements MCEncodeFragment. llvm-svn: 172572
* Simplify the code a bit: MCRelaxableFragment doesn't need a separate getInstSizeEli Bendersky2013-01-081-3/+2
| | | | | | | | | | method because getContents().size() already covers it. So computeFragmentSize can use the generic MCEncodedFragment interface when querying both Data and Relaxable fragments for contents sizes. No change in functionality llvm-svn: 171903
* Rename statistic for instruction fragments -> relaxableEli Bendersky2013-01-081-3/+3
| | | | llvm-svn: 171872
* Renamed MCInstFragment to MCRelaxableFragment and added some comments.Eli Bendersky2013-01-081-24/+24
| | | | | | No change in functionality. llvm-svn: 171822
* Add the align_to_end option to .bundle_lock in the MC implementation of alignedEli Bendersky2013-01-071-5/+29
| | | | | | | | | bundling. The document describing this feature and the implementation has also been updated: https://sites.google.com/a/chromium.org/dev/nativeclient/pnacl/aligned-bundling-support-in-llvm llvm-svn: 171797
* Fix an unitialized member variable that may have caused sporadic failuresEli Bendersky2012-12-201-1/+2
| | | | | | for code that wasn't even in bundling mode. llvm-svn: 170793
* Aligned bundling support. Following the discussion here:Eli Bendersky2012-12-201-7/+74
| | | | | | | | | | | http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-December/056754.html The proposal and implementation are fully documented here: https://sites.google.com/a/chromium.org/dev/nativeclient/pnacl/aligned-bundling-support-in-llvm Tests will follow shortly. llvm-svn: 170718
* Add more reset methods to make all objects that the backend may use for ↵Pedro Artigas2012-12-141-0/+5
| | | | | | outputting code have a reset, some are not used but were declared for completeness llvm-svn: 170227
* Make the MCStreamer have a reset method and call that after finalization of ↵Pedro Artigas2012-12-121-0/+13
| | | | | | | | the asm printer, also changed MCContext to a single reset only method for simplicity as requested on the list llvm-svn: 170041
* Make naming consistent, add comments and sanity assertsEli Bendersky2012-12-121-24/+27
| | | | llvm-svn: 170007
* Remove the RelaxAll overrule in MCAssembler::fixupNeedsRelaxation,Eli Bendersky2012-12-111-3/+2
| | | | | | | | | | | | because that method is only getting called for MCInstFragment. These fragments aren't even generated when RelaxAll is set, which is why the flag reference here is superfluous. Removing it simplifies the code with no harmful effects. An assertion is added higher up to make sure this path is never reached. llvm-svn: 169886
* Cleanup formatting, comments and naming.Eli Bendersky2012-12-101-21/+21
| | | | llvm-svn: 169762
OpenPOWER on IntegriCloud