summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC
Commit message (Collapse)AuthorAgeFilesLines
* Simplify use of formatted_raw_ostream.Rafael Espindola2015-04-091-8/+10
| | | | | | | | | | | | | | | formatted_raw_ostream is a wrapper over another stream to add column and line number tracking. It is used only for asm printing. This patch moves the its creation down to where we know we are printing assembly. This has the following advantages: * Simpler lifetime management: std::unique_ptr * We don't compute column and line number of object files :-) llvm-svn: 234535
* Define a function with "... llvm::func...".Rafael Espindola2015-04-091-6/+5
| | | | | | | | | | | | Using this instead of namespace llvm { func... } Has the advantage that the build fails with a compiler error if it gets out of sync with the .h file. llvm-svn: 234515
* Nothing inherits from the asm streamer.Rafael Espindola2015-04-091-3/+1
| | | | | | Make that explicit and remove protected: llvm-svn: 234484
* Remove unused variable.Rafael Espindola2015-04-081-2/+0
| | | | llvm-svn: 234426
* Write the section header in the end.Rafael Espindola2015-04-081-27/+4
| | | | | | | | One could make the argument for writing it immediately after the ELF header, but writing it in the middle of the sections like we were doing just makes it harder for no reason. llvm-svn: 234400
* ELFObjectWriter.cpp: Prune obsolete \param since r234342. [-Wdocumentation]NAKAMURA Takumi2015-04-081-1/+0
| | | | llvm-svn: 234377
* Delete commented code. Don't repeat name in comment.Rafael Espindola2015-04-071-7/+1
| | | | llvm-svn: 234370
* Don't subtract the header size just to add it back.Rafael Espindola2015-04-071-5/+4
| | | | llvm-svn: 234362
* Remove dead code. NFC.Rafael Espindola2015-04-071-6/+0
| | | | llvm-svn: 234352
* Remove intermediate variables.Rafael Espindola2015-04-071-7/+1
| | | | | | | The name of these variables was completely out of date with the information stored in them. llvm-svn: 234345
* Remove unused argument.Rafael Espindola2015-04-071-9/+6
| | | | llvm-svn: 234342
* Use a comma after the unique keyword.Rafael Espindola2015-04-062-1/+4
| | | | | | | | H.J. Lu noted that all .section options are separated by a comma. This patch changes the syntax of unique to require one. llvm-svn: 234174
* Remove unnecessary uses of AliasedSymbol.Rafael Espindola2015-04-062-6/+5
| | | | | | | | | As pr19627 points out, every use of AliasedSymbol is likely a bug. The main use was to avoid the oddity of a variable showing up as undefined. That was fixed in r233995, which made these calls nops. llvm-svn: 234169
* Be consistent when deciding if a relocation is needed.Rafael Espindola2015-04-065-26/+23
| | | | | | | | | | | | | | Before when deciding if we needed a relocation in A-B, we wore only checking if A was weak. This fixes the asymmetry. The "InSet" argument should probably be renamed to "ForValue", since InSet is very MachO specific, but doing so in this patch would make it hard to read. This fixes PR22815. llvm-svn: 234165
* Store the sh_link of ARM_EXIDX directly in MCSectionELF.Rafael Espindola2015-04-062-17/+17
| | | | | | This avoids some pretty horrible and broken name based section handling. llvm-svn: 234142
* Simplify this function a bit. NFC.Rafael Espindola2015-04-061-20/+4
| | | | | | | | | The case values are not a tidy enum we can fully cover. They even ovelap over the various extension. Just use a default: llvm-svn: 234140
* Simplify mapping from relocation sections to relocated sections.Rafael Espindola2015-04-062-44/+28
| | | | | | | | 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-045-24/+25
| | | | | | | | | | | 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
* MC: For variable symbols, maintain MCSymbol::Section as a cache.Peter Collingbourne2015-04-033-28/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes PR19582. Previously, when an asm assignment (.set or =) was created, we would look up the section immediately in MCSymbol::setVariableValue. This caused symbols to receive the wrong section if the RHS of the assignment had not been seen yet. This had a knock-on effect in the object file emitters, causing them to emit extra symbols, or to give symbols the wrong visibility or the wrong section. For example, in the following asm: .data .Llocal: .text leaq .Llocal1(%rip), %rdi .Llocal1 = .Llocal2 .Llocal2 = .Llocal the first assignment would give .Llocal1 a null section, which would never get fixed up by the second assignment. This would cause the ELF object file emitter to consider .Llocal1 to be an undefined symbol and give it external linkage, even though .Llocal1 should not have been emitted at all in the object file. Or in the following asm: alias_to_local = Ltmp0 Ltmp0: the Mach-O object file emitter would give the alias_to_local symbol a n_type of N_SECT and a n_sect of 0. This is invalid under the Mach-O specification, which requires N_SECT symbols to receive a non-zero section number if the symbol is defined in a section in the object file. https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/MachORuntime/#//apple_ref/c/tag/nlist After this change we do not look up the section when the assignment is created, but instead look it up on demand and store it in Section, which is treated as a cache if the symbol is a variable symbol. This change also fixes a bug in MCExpr::FindAssociatedSection. Previously, if we saw a subtraction, we would return the first referenced section, even in cases where we should have been returning the absolute pseudo-section. Now we always return the absolute pseudo-section for expressions that subtract two section-derived expressions. This isn't always correct (e.g. if one of the sections ends up being laid out at an absolute address), but it's probably the best we can do without more context. This allows us to remove code in two places where we appear to have been working around this bug, in MachObjectWriter::markAbsoluteVariableSymbols and in X86AsmPrinter::EmitStartOfAsmFile. Re-applies r233595 (aka D8586), which was reverted in r233898. Differential Revision: http://reviews.llvm.org/D8798 llvm-svn: 233995
* Revert r233595, "MC: For variable symbols, maintain MCSymbol::Section as a ↵Peter Collingbourne2015-04-023-4/+28
| | | | | | cache." llvm-svn: 233898
* Don't print an error message when looking up the scheduling model if user ↵Craig Topper2015-04-021-3/+4
| | | | | | specified -mcpu=help. llvm-svn: 233884
* [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
* Make llc use getHostCPUFeatures when 'native' is specified for cpu.Craig Topper2015-03-311-2/+3
| | | | | | This is necessary for x86 where not all Sandybridge, Ivybrige, Haswell, and Broadwell CPUs support AVX. Currently we modify the CPU name back to Nehalem for this case, but that turns off additional features for these CPUs. llvm-svn: 233673
* Replace the MCSubtargetInfo parameter with a Triple when creatingEric Christopher2015-03-311-4/+3
| | | | | | | an MCInstPrinter. Update all callers and use where we wanted a Triple previously. llvm-svn: 233648
* Rename const char *Triple argument to TT to avoid shadowing llvm::Triple.Eric Christopher2015-03-301-21/+20
| | | | llvm-svn: 233615
* MC: For variable symbols, maintain MCSymbol::Section as a cache.Peter Collingbourne2015-03-303-28/+4
| | | | | | | | | | | This fixes the visibility of symbols in certain edge cases involving aliases with multiple levels of indirection. Fixes PR19582. Differential Revision: http://reviews.llvm.org/D8586 llvm-svn: 233595
* Remove more superfluous .str() and replace std::string concatenation with Twine.Yaron Keren2015-03-302-4/+2
| | | | | | Following r233392, http://llvm.org/viewvc/llvm-project?rev=233392&view=rev. llvm-svn: 233555
* 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-302-6/+15
| | | | | | | | | | | 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
* Convert feature strings to lowercase even if they have a '+'/'-' in front of ↵Craig Topper2015-03-281-1/+1
| | | | | | them. llvm-svn: 233475
* Update comment to match code behavior.Craig Topper2015-03-281-1/+1
| | | | llvm-svn: 233470
* Add two small structs for readability in place of std::pair and std::tuple. NFC.Rafael Espindola2015-03-271-10/+9
| | | | llvm-svn: 233422
* [MCInstPrinter] Enable MCInstPrinter to change its behavior based on theAkira Hatanaka2015-03-272-2/+2
| | | | | | | | | | | | | | | | | | | | per-function subtarget. Currently, code-gen passes the default or generic subtarget to the constructors of MCInstPrinter subclasses (see LLVMTargetMachine::addPassesToEmitFile), which enables some targets (AArch64, ARM, and X86) to change their instprinter's behavior based on the subtarget feature bits. Since the backend can now use different subtargets for each function, instprinter has to be changed to use the per-function subtarget rather than the default subtarget. This patch takes the first step towards enabling instprinter to change its behavior based on the per-function subtarget. It adds a bit "PassSubtarget" to AsmWriter which tells table-gen to pass a reference to MCSubtargetInfo to the various print methods table-gen auto-generates. I will follow up with changes to instprinters of AArch64, ARM, and X86. llvm-svn: 233411
* Close unique sections when switching away from them.Rafael Espindola2015-03-272-1/+7
| | | | | | | It is not possible to switch back to unique secitons, so close them automatically when switching away. llvm-svn: 233380
* Fix PR23025.Rafael Espindola2015-03-263-5/+22
| | | | | | | | | | | | | | | There is something in link.exe that requires a relocation to use a global symbol. Not doing so breaks the chrome build on windows. This patch sets isWeak for that to work. To compensate, we then need to look past those symbols when not creating relocations. This patch includes an ELF test that matches GNU as behaviour. I am still reducing the chrome build issue and will add a test once that is done. llvm-svn: 233318
* clang-format bits of code to make another patch readable.Rafael Espindola2015-03-252-23/+14
| | | | llvm-svn: 233203
* Fix fixup evaluation when deciding what to relocate with.Rafael Espindola2015-03-254-55/+43
| | | | | | | | | | | | | | The previous logic was to first try without relocations at all and failing that stop on the first defined symbol. That was inefficient and incorrect in the case part of the expression could be simplified and another part could not (see included test). We now stop the evaluation when we get to a variable whose value can change (i.e. is weak). llvm-svn: 233187
* Fix warning on non-assert build.Rafael Espindola2015-03-251-0/+2
| | | | llvm-svn: 233158
* Produce an error instead of asserting on invalid .sleb128/.uleb128.Rafael Espindola2015-03-252-10/+14
| | | | llvm-svn: 233155
* Don't be over eager in evaluating a subtraction with a weak symbol.Rafael Espindola2015-03-241-1/+9
| | | | | | | In a subtraction of the form A - B, if B is weak, there is no way to represent that on ELF since all relocations add the value of a symbol. llvm-svn: 233139
* Reset the CFA offset at the start of every FDE.Rafael Espindola2015-03-241-1/+7
| | | | | | This fixes PR21515. llvm-svn: 233120
* Revert "Use std::bitset for SubtargetFeatures"Michael Kuperstein2015-03-242-19/+13
| | | | | | | | This reverts commit r233055. It still causes buildbot failures (gcc running out of memory on several platforms, and a self-host failure on arm), although less than the previous time. llvm-svn: 233068
* Use std::bitset for SubtargetFeaturesMichael Kuperstein2015-03-242-13/+19
| | | | | | | | | | | | | Previously, subtarget features were a bitfield with the underlying type being uint64_t. Since several targets (X86 and ARM, in particular) have hit or were very close to hitting this bound, switching the features to use a bitset. No functional change. The first time this was committed (r229831), it caused several buildbot failures. At least some of the ARM ones were due to gcc/binutils issues, and should now be fixed. Differential Revision: http://reviews.llvm.org/D8542 llvm-svn: 233055
* Refactor how passes get a symbol at the end of a section.Rafael Espindola2015-03-233-15/+28
| | | | | | | | | | There is now a canonical symbol at the end of a section that different passes can request. This also allows us to assert that we don't switch back to a section whose end symbol has already been printed. llvm-svn: 233026
* Update variable name and reuse existing variable. NFC.Rafael Espindola2015-03-231-5/+5
| | | | llvm-svn: 233014
* Re-sort includes with sort-includes.py and insert raw_ostream.h where it's used.Benjamin Kramer2015-03-231-0/+1
| | | | llvm-svn: 232998
* Add missing ELFObjectWriter::reset() override, like other MC classes.Yaron Keren2015-03-231-0/+14
| | | | | | | | | | | | | See detailed discussion at http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140915/235418.html and r217907, r217948: http://llvm.org/viewvc/llvm-project?view=revision&revision=217907 http://llvm.org/viewvc/llvm-project?view=revision&revision=217948 llvm-svn: 232982
* Don't declare all text sections at the start of the .sRafael Espindola2015-03-202-7/+51
| | | | | | | | | | | | | | | | | The code this patch removes was there to make sure the text sections went before the dwarf sections. That is necessary because MachO uses offsets relative to the start of the file, so adding a section can change relaxations. The dwarf sections were being printed at the start just to produce symbols pointing at the start of those sections. The underlying issue was fixed in r231898. The dwarf sections are now printed when they are about to be used, which is after we printed the text sections. To make sure we don't regress, the patch makes the MachO streamer assert if CodeGen puts anything unexpected after the DWARF sections. llvm-svn: 232842
* Split the object streamer callback in one per file format.Rafael Espindola2015-03-193-13/+2
| | | | | | | | | | | | | There are two main advantages to doing this * Targets that only need to handle one of the formats specially don't have to worry about the others. For example, x86 now only registers a constructor for the COFF streamer. * Changes to the arguments passed to one format constructor will not impact the other formats. llvm-svn: 232699
OpenPOWER on IntegriCloud