Commit Graph

3032 Commits

Author SHA1 Message Date
Rafael Espindola
a287fe7fa0 Remove uses of MCSectionData from ELFObjectWriter. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238317 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-27 13:30:50 +00:00
Rafael Espindola
eac1f66427 Use operator<< instead of print in a few more places.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238315 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-27 13:05:42 +00:00
Rafael Espindola
baaf8b82c3 We always have an InstPrinter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238311 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-27 12:13:06 +00:00
Daniel Sanders
3a9cbffdcb Revert r238190 and r238197: [mips] Make TTypeEncoding indirect to allow .eh_frame to be read-only.
This broke the llvm-mips-linux builder and several of our out-of-tree builders.
Initial investigations show that the commit probably isn't the problem but
reverting anyway while I investigate.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238302 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-27 08:44:01 +00:00
Matthias Braun
299e50237a MCSymbol: Make print() robust against empty names
This shouldn't happen, but it's nice not to abort when printing broken machine
functions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238287 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-27 05:12:37 +00:00
Rafael Espindola
b14ebd6a1d Replace getOrCreateSectionData with registerSection.
There is now no SectionData to be created.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238208 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-26 15:07:25 +00:00
Rafael Espindola
7ff8c5c348 Have getCurrentSectionData return a MCSection.
I will fix the name shortly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238204 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-26 14:48:11 +00:00
Rafael Espindola
da68b18db5 Pass a MCSection to getCurrentSectionData.
A step towards merging MCSection and MCSectionData.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238203 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-26 14:42:52 +00:00
Michael Kuperstein
d714fcf5c8 Use std::bitset for SubtargetFeatures.
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 several times this was committed (e.g. r229831, r233055), it caused several buildbot failures.
Apparently the reason for most failures was both clang and gcc's inability to deal with large numbers (> 10K) of bitset constructor calls in tablegen-generated initializers of instruction info tables. 
This should now be fixed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238192 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-26 10:47:10 +00:00
Daniel Sanders
bda72d8098 [mips] Make TTypeEncoding indirect to allow .eh_frame to be read-only.
Summary:
Following on from r209907 which made personality encodings indirect, do the
same for TType encodings. This fixes the case where a try/catch block needs
to generate references to, for example, std::exception in the
.gcc_except_table.

This commit uses DW_EH_PE_sdata8 for N64 as far as is possible at the moment.
However, it is possible to end up with DW_EH_PE_sdata4 when a TargetMachine is
not available. There's no risk of issues with inconsistency here since the
tables are self describing but it does mean there is a small chance of the
PC-relative offset being out of range for particularly large programs.

Reviewers: petarj

Reviewed By: petarj

Subscribers: srhines, joerg, tberghammer, llvm-commits

Differential Revision: http://reviews.llvm.org/D9669


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238190 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-26 10:19:18 +00:00
Rafael Espindola
2224f64c6d Remove most uses of MCSectionData from MCAssembler.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238172 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-26 02:17:21 +00:00
Rafael Espindola
ea3533b4c6 Stop using MCSectionData in MCAsmLayout.h.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238170 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-26 02:00:36 +00:00
Rafael Espindola
eac71e23fd Move MCSection destruction to MCContext::reset.
Fixes the leaks when running llc.

Also found by an asan bot.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238167 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-26 01:52:19 +00:00
Rafael Espindola
1826cd69f3 Stop using MCSectionData in MCMachObjectWriter.h.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238165 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-26 01:15:30 +00:00
Rafael Espindola
504473e6ae Stop using MCSectionData in MCExpr.h.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238163 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-26 00:52:18 +00:00
Rafael Espindola
f363960679 Return a MCSection from MCFragment::getParent().
Another step in merging MCSectionData and MCSection.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238162 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-26 00:36:57 +00:00
Rafael Espindola
be38d7cb8c Call the destructors of the MCSections.
They now contain the fragments. If we don't call the destructors the
fragments leak.

Found by an asan bot.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238161 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-26 00:32:28 +00:00
Rafael Espindola
68e7d22de4 Store a MCSection in MCFragment.
Part of the work to merge MCSectionData into MCSection.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238160 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-25 23:48:22 +00:00
Rafael Espindola
e86bc46939 Turn MCSectionData into a field of MCSection.
This also changes MCAssembler to store a vector of MCSections instead of an
iplist of MCSectionData.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238159 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-25 23:14:17 +00:00
Rafael Espindola
5e435847b0 Move MCSectionData to MCSection.h.
Another step in merging MCSectionData and MCSection.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238158 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-25 22:57:48 +00:00
Rafael Espindola
ab78d67435 Make a few MCSectionELF& variables const. NFC.
This just reduces the noise from another patch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238156 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-25 21:56:55 +00:00
Rafael Espindola
0d46e8a420 Insert MCSectionData into the section list directly in getOrCreateSectionData.
Removing the logic from the constructor will make it easier to merge
MCSectionData and MCSection.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238155 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-25 20:39:23 +00:00
Rafael Espindola
712c27f870 Move HasInstructions to MCSection.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238150 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-25 18:34:26 +00:00
Rafael Espindola
68c5b83e12 Move bundle info from MCSectionData to MCSection.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238143 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-25 15:04:26 +00:00
Rafael Espindola
63b75630b4 Add a isBundleLocked helper to MCELFStreamer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238142 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-25 14:57:35 +00:00
Rafael Espindola
b3eb86c875 Move LayoutOrder to MCSection.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238141 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-25 14:25:28 +00:00
Rafael Espindola
8823110a85 Stop forwarding getOrdinal and setOrdinal.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238139 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-25 14:12:48 +00:00
Rafael Espindola
84ff6c4ce7 Move Ordinal from MCSectionData to MCSection. NFC.
Part of the work to merge MCSectionData and MCSection.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238137 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-25 14:00:56 +00:00
Rafael Espindola
7c4f3dcc5e Produce a single string table in a ELF .o
Normally an ELF .o has two string tables, one for symbols, one for section
names.

With the scheme of naming sections like ".text.foo" where foo is a symbol,
there is a big potential saving in using a single one.

Building llvm+clang+lld with master and with this patch the results were:

master:                          193,267,008 bytes
patch:                           186,107,952 bytes
master non unique section names: 183,260,192 bytes
patch non unique section names:  183,118,632 bytes

So using non usique saves 10,006,816 bytes, and the patch saves 7,159,056 while
still using distinct names for the sections.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238073 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-22 23:58:30 +00:00
Duncan P. N. Exon Smith
f5e0674d06 MC: Shave a pointer off of MCSymbol::Name
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.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238005 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-22 06:04:42 +00:00
Duncan P. N. Exon Smith
6c3a7cbe54 MC: Lift MCSymbolData::Index up to MCSymbol::Index, NFC
Lift `MCSymbolData::Index` up a level to `MCSymbol`, as preparation for
packing it into the bitfield in `MCSymbol`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238001 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-22 05:54:01 +00:00
Rafael Espindola
477acf64d0 Stop forwarding (get|set)Aligment from MCSectionData to MCSection.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237956 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-21 21:02:35 +00:00
Rafael Espindola
fabbc4985b Stop creating MCSectionData is the ELF writer.
Now is is just its use of MCSymbolData that requires it to take a non const
MCAssembler.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237951 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-21 20:43:13 +00:00
Rafael Espindola
3b294b5753 writeSymbolTable now only needs a MCContext.
It used to use an MCAssembler just to record the alignment of the sections.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237944 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-21 19:54:44 +00:00
Rafael Espindola
9a9984d0b5 Pass a const MCAssembler to writeSectionHeader.
It never creates sections, so it can use Asm.getSectionData instead of
Asm.getOrCreateSectionData.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237943 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-21 19:46:39 +00:00
Rafael Espindola
a127bd0585 Remove unused argument. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-21 19:42:35 +00:00
Rafael Espindola
ad7c1174c7 Fetch alignment directly out of MCSection. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237938 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-21 19:36:43 +00:00
Rafael Espindola
7521964d28 Move alignment from MCSectionData to MCSection.
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237936 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-21 19:20:38 +00:00
Rafael Espindola
921229e74e Fix warning on builds without asserts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237915 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-21 17:09:22 +00:00
Rafael Espindola
e0376b0782 Avoid unnecessary section switching. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237913 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-21 17:00:40 +00:00
Rafael Espindola
43356a1a45 Remove yet another method of creating begin and end symbol for sections.
I missed this one when first unifying how we handle begin and end symbols.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237912 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-21 16:52:32 +00:00
Rafael Espindola
f209e26fcc Use existing helper for adding a section. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237909 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-21 16:19:32 +00:00
Duncan P. N. Exon Smith
583dac827c AsmPrinter: Compute absolute label difference directly
Create a low-overhead path for `EmitLabelDifference()` that emits a
emits an absolute number when (1) the output is an object stream and (2)
the two symbols are in the same data fragment.

This drops memory usage on Mach-O from 975 MB down to 919 MB (5.8%).
The only call is when `!doesDwarfUseRelocationsAcrossSections()` --
i.e., on Mach-O -- since otherwise an absolute offset from the start of
the section needs a relocation.  (`EmitLabelDifference()` is cheaper on
ELF anyway, since it creates 1 fewer temp symbol, and it gets called far
less often.  It's not clear to me if this is even a bottleneck there.)

(I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`;
see r236629 for details.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237876 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-21 02:41:23 +00:00
Duncan P. N. Exon Smith
4652459f64 MC: Simplify MCSymbolData initialization and remove MCSymbol pointer
Finally remove the `MCSymbolData::Symbol` pointer.  It was still being
used to track whether `MCSymbolData` had been initialized, but this is
better tracked by the bitfield in `MCSymbol`.

The only caller of `MCSymbolData::initialize()` was `MCAssembler`, which
(other than `Symbol`) passed in all-0 values.  Replace all that
indirection with a default constructor.

The main point is a cleanup (and there's more cleanup to do), but there
are also some small memory savings.  I measured ~989 MB down to ~975 MB,
cutting a little over 1% off the top of `llc`.

(I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`;
see r236629 for details.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237873 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-21 01:33:03 +00:00
Duncan P. N. Exon Smith
aa87ff8440 MC: Remove last use of MCSymbolData::getSymbol(), NFC
Remove the last use of `MCSymbolData::getSymbol()`.  There's some
*really* hairy stuff going on in `MachObjectWriter::WriteNList()` that I
want to come back to.  In particular, it updates `Symbol` to point at
its aliasee (if any), but leaves `Data` behind, and it's not clear
whether everything makes sense there.

For now I've left the logic unchanged by adding `OrigSymbol` and moving
the FIXME from r237750 up a bit higher.  I've filed PR23598 to track
looking into this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237867 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-21 00:39:24 +00:00
Reid Kleckner
7681f6a1b0 [WinEH] Store pointers to the LSDA in the exception registration object
We aren't yet emitting the LSDA yet, so this will still fail to
assemble.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237852 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-20 23:08:04 +00:00
Duncan P. N. Exon Smith
cfa5342444 MC: Remove most remaining uses of MCSymbolData::getSymbol(), NFC
Remove most remaining calls to `MCSymbolData::getSymbol()`, instead
using the already available `MCSymbol` directly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237829 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-20 20:18:16 +00:00
Duncan P. N. Exon Smith
96273f6cbe MC: Stop using MCSymbolData::getSymbol() in WinCOFF, NFC
Move APIs over from `MCSymbolData` to `MCSymbol`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237826 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-20 19:34:08 +00:00
Pete Cooper
bed96c8d97 Use a SmallString buffer instead of a std::string for debug info path lookup. NFC.
This code appends the filename to the directory then looks that up in a StringMap.  We should be using the existing Twine::toStringRef method instead of Twine::str() as most times we'll succeed in the lookup.

Its possible that we should also consider allowing StringMap to lookup a key using a Twine in addition to a StringRef but that would complicate the code with little known benefit above and beyond this change.

This saves 170k temporary allocations when running llc on the verify_use_list_order bitcode with debug info for x86.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237823 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-20 19:12:14 +00:00
Duncan P. N. Exon Smith
80b2cb6d4d MC: Use MCSymbol in LocalCommon, NFC
Switch from MCSymbolData to MCSymbol in LocalCommon.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237816 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-20 18:25:40 +00:00
Duncan P. N. Exon Smith
91a675f972 MC: Add MCSymbolData back to MCAssembler dump
r237490 accidentally dropped MCSymbolData from the MCAssembler dump.
Add it back underneath the MCSymbol dump.  Remove the MCSymbol dump from
MCSymbolData, since this would cause an infinite co-recursion, and
besides, that back pointer is going away.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237807 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-20 16:34:36 +00:00
Duncan P. N. Exon Smith
20cf3f41e7 MC: Update MCAssembler to use MCSymbol, NFC
Use `MCSymbol` over `MCSymbolData` where both are needed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237803 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-20 16:02:11 +00:00
Duncan P. N. Exon Smith
c8d166a437 MC: Use MCSymbol in MachObjectWriter, NFC
Replace uses of `MCSymbolData` with `MCSymbol` where both are needed, so
we can remove the backpointer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237799 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-20 15:16:14 +00:00
Duncan P. N. Exon Smith
f5bdf04f09 MC: Use MCSymbol in MCObjectWriter::isWeak(), NFC
Continue to prefer `MCSymbol` when we need both.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237798 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-20 15:10:03 +00:00
Duncan P. N. Exon Smith
37e9aba0db MC: Use MCSymbol in most of ELFObjectWriter, NFC
Stop using MCSymbolData where we also need MCSymbol.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237770 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-20 04:39:01 +00:00
Duncan P. N. Exon Smith
891fd53a90 MC: Take MCSymbol in MachObjectWriter::getSymbolAddress(), NFC
Pass through an `MCSymbol` instead of an `MCSymbolData` so we can get
rid of the back pointer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237750 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-20 00:02:39 +00:00
Duncan P. N. Exon Smith
e1fce8692d MC: Use MCSymbol in MCAsmLayout::getSymbolOffset(), NFC
Continue to canonicalize on MCSymbol instead of MCSymbolData when both
are needed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237749 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-19 23:53:20 +00:00
Jim Grosbach
7b81f734ee MC: clang-format MCContext. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237595 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-18 18:43:23 +00:00
Jim Grosbach
19696daa21 MC: Clean up method names in MCContext.
The naming was a mish-mash of old and new style. Update to be consistent
with the new. NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237594 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-18 18:43:14 +00:00
Duncan P. N. Exon Smith
57e32d40b7 MC: Use MCSymbol in RelAndSymbol, NFC
Switch from `MCSymbolData` to `MCSymbol`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237502 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-16 01:14:19 +00:00
Duncan P. N. Exon Smith
9e6378de57 MC: Use MCSymbol in MCObject::IsSymbolRefDifferenceFullyResolvedImpl()
Transition one API from `MCSymbolData` to `MCSymbol`.  The function
needs both, and the backpointer from `MCSymbolData` to `MCSymbol` is
going away.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237498 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-16 01:01:55 +00:00
Duncan P. N. Exon Smith
5f7c1f8415 MC: Change MCFragment::Atom to an MCSymbol, NFC
Change `MCFragment::Atom` from an `MCSymbolData` to an `MCSymbol`,
moving in the direction of removing the back-pointer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237497 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-16 00:48:58 +00:00
Duncan P. N. Exon Smith
a5bb842d95 MC: Change MCAssembler::Symbols to store MCSymbol, NFC
Instead of storing a list of the `MCSymbolData` in use, store the
`MCSymbol`s.  Churning in the direction of removing the back pointer
from `MCSymbolData`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237496 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-16 00:35:24 +00:00
Duncan P. N. Exon Smith
c5f2ba0401 MC: Merge MCSymbol and MCSymbolData
Turn `MCSymbolData` into a field inside of `MCSymbol`.  Keep all the old
API alive for now, so that consumers can be updated in a later commit.
This means we still temporarily need the back pointer from
`MCSymbolData` to `MCSymbol`, but I'll remove it in a follow-up.

This optimizes for object emission over assembly emission.  By removing
the `DenseMap` in `MCAssembler`, llc memory usage drops from around 1040
MB to 1001 MB (3.8%).

(I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`;
see r236629 for details.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237490 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-16 00:03:06 +00:00
Duncan P. N. Exon Smith
eaf14f30c8 MC: Reduce MCAssembler::Symbols API exposure, NFC
Stop exposing the storage for `MCAssembler::Symbols`, and have
`MCAssembler` add symbols directly to its list instead of using a hook
in `MCSymbolData`.  This opens up room for a follow-up commit to switch
from a linked list to a vector.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237486 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-15 22:33:34 +00:00
Pete Cooper
fc9bfcd184 Remove MCAssembler.h include from MCStreamer.h and fix users of MCStreamer.h
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237483 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-15 22:19:42 +00:00
Pete Cooper
39aa893201 Remove 3 includes from MCInstrDesc.h and explicitly include them where needed
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237481 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-15 21:58:42 +00:00
Pete Cooper
9e514203d1 Move some methods to a new MCInstrDesc.cpp file to allow includes to be trimmed. NFC.
MCInstrDesc.h includes things like MCInst.h which i can now remove after this.  That will be a future commit.

Reviewed by Jim Grosbach.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237478 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-15 21:29:43 +00:00
Jim Grosbach
21a996a0e3 MC: MCCodeGenInfo naming update. NFC.
s/InitMCCodeGenInfo/initMCCodeGenInfo/

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237471 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-15 19:13:31 +00:00
Jim Grosbach
251a66ec37 MC: Update MCCodeEmitter naming. NFC.
s/EncodeInstruction/encodeInstruction/

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237469 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-15 19:13:16 +00:00
Jim Grosbach
8b22e9c00a MC: Update MCFixup naming. NFC.
s/MCFixup::Create/MCFixup::create/

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237468 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-15 19:13:05 +00:00
Justin Bogner
47ccfa7de8 MC: Avoid some UB caused by left shifting a negative value. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237408 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-14 23:54:49 +00:00
Andy Ayers
edd2bb863e Don't omit the constant when computing a cross-section relative relocation.
Differential Revision: http://reviews.llvm.org/D9692

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237327 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-14 01:10:41 +00:00
Jim Grosbach
db703aaedd MC: Modernize MCOperand API naming. NFC.
MCOperand::Create*() methods renamed to MCOperand::create*().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237275 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-13 18:37:00 +00:00
Yaron Keren
e49e65326a Update ELFObjectWriter::reset() following r236255.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237261 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-13 15:17:19 +00:00
Michael Kuperstein
66112dd7f8 Reverting r237234, "Use std::bitset for SubtargetFeatures"
The buildbots are still not satisfied.
MIPS and ARM are failing (even though at least MIPS was expected to pass).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237245 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-13 10:28:46 +00:00
Michael Kuperstein
1336daad86 Use std::bitset for SubtargetFeatures
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 two times this was committed (r229831, r233055), it caused several buildbot failures. 
At least some of the ARM and MIPS ones were due to gcc/binutils issues, and should now be fixed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237234 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-13 08:27:08 +00:00
Keith Walker
09f089a39e [DWARF] Add CIE header fields address_size and segment_size when generating dwarf-4
The DWARF-4 specification added 2 new fields in the CIE header called
address_size and segment_size.
Create these 2 new fields when generating dwarf-4 CIE entries, print out
the new fields when dumping the CIE and update tests

Differential Revision: http://reviews.llvm.org/D9558


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237145 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-12 15:25:08 +00:00
Duncan P. N. Exon Smith
a414ba7844 MC: Skip names of temporary symbols in object streamer
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.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236642 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-06 21:34:34 +00:00
Keno Fischer
9cffebf3f8 Respect object format choice on Darwin
Summary:
The object format can be set to something other than MachO, e.g.
to use ELF-on-Darwin for MCJIT. This already works on Windows, so
there's no reason it shouldn't on Darwin.

Reviewers: lhames, grosbach

Subscribers: rafael, grosbach, t.p.northover, llvm-commits

Differential Revision: http://reviews.llvm.org/D6185

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236455 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-04 20:03:01 +00:00
Colin LeMahieu
a036240a88 [Hexagon] Adding expression MC emission and removing XFAIL from test that hits this code path.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236348 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-01 21:14:21 +00:00
Rafael Espindola
b6b3a92b97 Remove unnecessary break.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236275 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 22:41:12 +00:00
Rafael Espindola
a55dd52dc8 Simplify the creation of compressed debug sections.
This is actually fairly simple in the current code layout: Check if we should
compress just before writing out and everything else just works.

This removes the last case in which the object writer was creating a
fragment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236267 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 21:51:58 +00:00
Rafael Espindola
15953ff2df Replace unreachable code with llvm_unreachable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236261 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 21:20:06 +00:00
Rafael Espindola
d80f5165d1 Don't create a MCSectionData when we don't have to.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236260 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 21:10:06 +00:00
Rafael Espindola
494f112fbc Avoid an extra loop over the sections.
Add string to the section header string table as we add sections.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236257 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 20:57:14 +00:00
Rafael Espindola
b65870f3f5 Make the section table a member of ELFObjectWriter.
This avoids passing it around and lets us build a small helper to add
a section to the table.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236255 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 20:53:27 +00:00
Rafael Espindola
4ed1491bc9 Nothing inherits from this, drop the protected:
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236253 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 20:37:36 +00:00
Rafael Espindola
76e71bd66e Write sections mostly in one pass.
During ELF writing, there is no need to further relax the sections, so we
should not be creating fragments. This patch avoids doing so in all cases
but debug section compression (that is next).

Also, the ELF format is fairly simple to write. We can do a single pass over
the sections to write them out and compute the section header table.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236235 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 14:21:49 +00:00
Aaron Ballman
8c54c84ae7 Silencing an "enumeral and non-enumeral type in conditional expression" warning; NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236234 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 14:03:12 +00:00
Rafael Espindola
4689501178 Store relocations in a map from MCSectionELF.
Saves finding the MCSectionData just to do a map lookup.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236189 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 00:45:46 +00:00
Rafael Espindola
1e95f2152f Write relocations directly to the output stream. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236187 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-30 00:30:40 +00:00
Rafael Espindola
a19abeb7ab Inline FragmentWriter into the only user.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236158 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-29 21:13:30 +00:00
Rafael Espindola
5fc3769ddc Write the symbol table directly to the output file.
There is no need to first accumulate it in fragments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236157 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-29 21:09:32 +00:00
Rafael Espindola
840bb0f332 Use pwrite to write the number of sections.
This avoids having to compute the number upfront, which will be used in the
next patch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236153 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-29 20:39:37 +00:00
Rafael Espindola
4fa3a17472 Write the string table directly to the output file.
There is no need to accumulate it in fragments first.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236148 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-29 20:34:31 +00:00
Douglas Katzman
1b88927253 [Sparc] Really add sparcel architecture support.
Mostly copy-and-paste from Sparc v8 architecture.

Differential Revision: http://reviews.llvm.org/D8741

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236146 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-29 20:30:57 +00:00
Rafael Espindola
58a854d447 Write the section header string table directly to the output stream.
Instead of accumulating the content in a fragment first, just write it
to the output stream.

Also put it first in the section table, so that we never have to worry
about its index being >= SHN_LORESERVE.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236145 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-29 20:25:24 +00:00
Rafael Espindola
4a43cd24af Avoid a few const_cast.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236141 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-29 19:20:10 +00:00
Rafael Espindola
5acccb16a8 Map directly from signature symbol to group index. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236058 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-28 22:59:58 +00:00
Rafael Espindola
b89275550c Remove redundant temporary std::vector.
New sections are added to the end of the list, so the RelSections array was
redundant.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236053 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-28 22:26:19 +00:00
Rafael Espindola
f75160b8d9 Avoid one more walk over all sections. NFC.
Set the group section index as they are created.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236049 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-28 22:03:22 +00:00
Rafael Espindola
7aff72189a Use a range loop. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236047 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-28 21:58:05 +00:00
Rafael Espindola
f23613a3cd Avoid an extra walk over the sections just to assign sections to groups.
Assign the sections in the same pass we compute the index.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236045 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-28 21:52:33 +00:00
Rafael Espindola
923bffd675 Remove the GroupMapTy DenseMap. NFC.
Instead use the Group symbol of MCSectionELF.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236033 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-28 21:07:28 +00:00
Rafael Espindola
032f234969 Use range loops. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236028 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-28 20:23:35 +00:00
Rafael Espindola
5052130d6a Avoid adding to SectionIndexMap sections that we never lookup. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236026 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-28 20:09:13 +00:00
Rafael Espindola
3813ef6886 Use a range loop. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236015 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-28 19:07:16 +00:00
Rafael Espindola
a34b8b2e55 Use a std::vector to record the offsets of the sections. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235995 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-28 15:26:21 +00:00
Rafael Espindola
39dfabd785 Avoid an extra loop for computing the section size. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235994 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-28 15:04:09 +00:00
Rafael Espindola
9924357175 Use CIE version 4 for dwarf4.
According to http://www.dwarfstd.org/doc/DWARF4.pdf appendix F the CIE
version for dwarf 4 is 4.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235988 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-28 13:55:31 +00:00
Ahmed Bougacha
e1f835ab59 [MC] Use LShr for constant evaluation of ">>" on ELF/arm64--darwin.
This matches other assemblers and is less unexpected (e.g. PR23227).
On ELF, I tried binutils gas v2.24 and nasm 2.10.09, and they both
agree on LShr.  On COFF, I couldn't get my hands on an assembler yet,
so don't change the behavior.  For now, don't change it on non-AArch64
Darwin either, as the other assembler is gas v1.38, which does an AShr.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235963 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-28 01:37:11 +00:00
Ahmed Bougacha
dac39b1fef [MC] Split MCBinaryExpr::Shr into LShr and AShr.
Defaulting to AShr without consulting the target MCAsmInfo isn't OK.
Add a flag to fix that.  Keep it off for now: target migrations will
follow in separate commits.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235951 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-28 00:21:32 +00:00
Ahmed Bougacha
07bcfe929e [MC] Move getBinOpPrecedence into AsmParser. NFC.
In preparation for a future patch.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235950 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-28 00:17:39 +00:00
Rafael Espindola
b8def5a8d1 Use CIE version 1 for .eh_frame.
According to

http://www.linuxbase.org/betaspecs/lsb/LSB-Core-generic/LSB-Core-generic/ehframechpt.html

we should always use 1.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235923 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-27 22:04:24 +00:00
Toma Tabacu
0b5a15b779 [MC] [IAS] Add support for the \@ .macro pseudo-variable.
Summary:
When used, it is substituted with the number of .macro instantiations we've done up to that point in time.
So if this is the 1st time we've instantiated a .macro (any .macro, regardless of name), \@ will instantiate to 0, if it's the 2nd .macro instantiation, it will instantiate to 1 etc.

It can only be used inside a .macro definition, an .irp definition or an .irpc definition (those last 2 uses are undocumented).

Reviewers: echristo, rafael

Reviewed By: rafael

Subscribers: dsanders, llvm-commits

Differential Revision: http://reviews.llvm.org/D9197

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235862 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-27 10:50:29 +00:00
Matt Arsenault
b638e142b4 Revert accidentally committed "MC: Allow targets to stop symbol name quoting"
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235672 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-23 23:34:51 +00:00
Matt Arsenault
6ec2992aca MC: Allow targets to stop symbol name quoting
Currently symbol names are printed in quotes if it contains something
outside of the arbitrary set of characters that isAcceptableChar tests
for. On somem targets, it is never OK to print a symbol name in quotes
so allow targets to opt out of this behavior.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235670 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-23 23:34:05 +00:00
Toma Tabacu
203a9224ff [mips] [IAS] Implement the .asciiz directive.
Summary:
This directive is exactly the same as .asciz, except it's only used by MIPS.
It is used to store null terminated strings in object files.

Reviewers: rafael, dsanders, echristo

Reviewed By: dsanders, echristo

Subscribers: echristo, llvm-commits

Differential Revision: http://reviews.llvm.org/D7530

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235382 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-21 11:50:52 +00:00
Derek Schuff
a49508cb92 [MC] When using bundle aligment, align sections to bundle size
Summary:
Bundle aligment requires that the functions always start at an aligned address.
Usually this is ensured by the compiler, but assembly code does not always
begin with a .align directive.

This change ensures that sections get the correct alignment if they contain
any instructions and bundling is enabled. (It also makes LLVM match the
behavior of GNU as).

Differential Revision: http://reviews.llvm.org/D9131

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235365 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-21 00:14:25 +00:00
Rafael Espindola
ca3837369f Look past locals in comdats.
We have to avoid converting a reference to a global into a reference to a local,
but it is fine to look past a local.

Patch by Vasileios Kalintiris.

I just moved the comment and added thet test.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235300 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-20 12:44:06 +00:00
Rafael Espindola
fb118bd226 Compute A-B when A or B is weak.
Similar to r235222, but for the weak symbol case.

In an "ideal" assembler/object format an expression would always refer to the
final value and A-B would only be computed from a section in the same
comdat as A and B with A and B strong.

Unfortunately that is not the case with debug info on ELF, so we need an
heuristic.  Since we need an heuristic, we may as well use the same one as
gas:

* call weak_sym : produces a relocation, even if in the same section.
* A - weak_sym and weak_sym -A: don't produce a relocation if we can
  compute it.

This fixes pr23272 and changes the fix of pr22815 to match what gas does.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235227 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-17 21:15:17 +00:00
Rafael Espindola
560d73a4cc Compute A-B if both A and B are in the same comdat section.
Part of pr23272.

A small annoyance with the assembly syntax we implement is that given an
expression there is no way to know if what is desired is the value of that
expression for the symbols in this file or for the final values of those
symbols in a link.

The first case is useful for use in sections that get discarded or ignored
if the section they are describing is discarded.

For axample, consider A-B where A and B are in the same comdat section.

We can compute the value of the difference in the section that is present in
the current .o and if that section survives to the final DSO the value will
still will be correct.

But the section is in a comdat. Another section from another object file
might be used istead. We know that that section will define A and B, but
we have no idea what the value of A-B might be.

In practice we have to assume that the intention is to compute the value
in the current section since otherwise the is no way to create something like
the debug aranges section.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235222 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-17 20:05:17 +00:00
Rafael Espindola
db244041cd Move AliasedSymbol to MachObjectWriter.
It was only used by MachO.
Part of pr19627.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235185 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-17 12:28:43 +00:00
Rafael Espindola
c59decb902 Add a proper fix for pr23025.
Instead of avoiding looking past every global symbol, only do so
if the symbol is in a comdat.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235181 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-17 11:27:13 +00:00
Benjamin Kramer
1e5490b167 [mc] Clean up emission of byte sequences
No functional change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235178 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-17 11:12:43 +00:00
Rafael Espindola
2298ce3d6a Don't walk aliases from global to local symbols in comdats.
This fixes pr23196.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235167 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-17 08:46:11 +00:00
Rafael Espindola
b4b0b34181 Write relocation sections contiguously.
Linkers normally read all the relocations upfront to compute the references
between sections. Putting them together is a bit more cache friendly.

I benchmarked linking a Release+Asserts clang with gold on a vm. I tried all
4 combinations of --gc-sections/no --gc-section hot and cold cache.

I cleared the cache with

echo 3 > /proc/sys/vm/drop_caches

and warmed it up by running the link once before timing the subsequent ones.

With cold cache and --gc-sections the time goes from

1.86130781665 +- 0.01713126697463843 seconds
to
1.82370735105 +- 0.014127522318814516 seconds

With cold cache and no --gc-sections the time goes from

1.6087245435500002 +- 0.012999066825178644 seconds
to
1.5687122041500001 +- 0.013145850126026619 seconds

With hot cache and no --gc-sections the time goes from

0.926200939 ( +-  0.33% ) seconds
to
0.907200079 ( +-  0.31% ) seconds

With hot cache and gc sections the time goes from

1.183038049 ( +-  0.34% ) seconds
to
1.147355862 ( +-  0.39% ) seconds

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235165 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-17 08:11:38 +00:00
Rafael Espindola
50b935707f Write section and section table entries in the same order.
We had two different orders, which has no value.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235004 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-15 13:07:47 +00:00
Richard Trieu
64b905a58d Change range-based for-loops to be -Wrange-loop-analysis clean.
No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234963 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-15 01:21:15 +00:00
Rafael Espindola
83ed6b7814 Use the ability to pwrite to simplify the ELF writer.
Now we don't have to do 2 synchronized passes to compute offsets and then
write the file.

This also includes a fix for the corner case of seeking in /dev/null. It
is not an error, but on some systems (Linux) the returned offset is
always 0. An error is signaled by returning -1. This is checked by
the existing tests now that "clang -o /dev/null ..." seeks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234952 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 22:54:16 +00:00
Rafael Espindola
c98092e28d Use raw_pwrite_stream in the object writer/streamer.
The ELF object writer will take advantage of that in the next commit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234950 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 22:14:34 +00:00
Petar Jovanovic
01b026b023 Re-enable target-specific relocation table sorting and use it for Mips
Some targets (ie. Mips) have additional rules for ordering the relocation
table entries. Allow them to override generic sortRelocs(), which sorts
entries by Offset.
Then override this function for Mips, to emit HI16 and GOT16 relocations
against the local symbol in pair with the corresponding LO16 relocation.

Patch by Vladimir Stefanovic.

Differential Revision: http://reviews.llvm.org/D7414


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234883 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-14 13:23:34 +00:00
Petr Hosek
054db7df5b [MC] Write padding into fragments when -mc-relax-all flag is used
Summary:
When instruction bundling is enabled and the -mc-relax-all flag is
set, we can write bundle padding directly into fragments and avoid
creating large number of fragments significantly reducing LLVM MC
memory usage.

Test Plan: Regression test attached

Reviewers: eliben

Subscribers: jfb, mseaborn

Differential Revision: http://reviews.llvm.org/D8072

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234714 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-12 23:42:25 +00:00
Alexander Kornienko
c16fc54851 Use 'override/final' instead of 'virtual' for overridden methods
The patch is generated using clang-tidy misc-use-override check.

This command was used:

  tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \
    -checks='-*,misc-use-override' -header-filter='llvm|clang' \
    -j=32 -fix -format

http://reviews.llvm.org/D8925



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234679 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-11 02:11:45 +00:00
Rafael Espindola
427c073035 Simplify use of formatted_raw_ostream.
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 :-)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234535 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09 21:06:08 +00:00
Rafael Espindola
8ee55c79f2 Define a function with "... llvm::func...".
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234515 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09 18:08:15 +00:00
Rafael Espindola
63905ba56a Nothing inherits from the asm streamer.
Make that explicit and remove protected:

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234484 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09 13:04:20 +00:00
Rafael Espindola
4b72aeb95c Remove unused variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234426 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-08 20:04:20 +00:00
Rafael Espindola
541279fdf9 Write the section header in the end.
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234400 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-08 11:41:24 +00:00
NAKAMURA Takumi
e93f977e8d ELFObjectWriter.cpp: Prune obsolete \param since r234342. [-Wdocumentation]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234377 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-08 00:38:50 +00:00
Rafael Espindola
13c7f90285 Delete commented code. Don't repeat name in comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234370 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-07 22:35:40 +00:00
Rafael Espindola
872266937b Don't subtract the header size just to add it back.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234362 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-07 21:51:41 +00:00
Rafael Espindola
696a3454de Remove dead code. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234352 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-07 20:38:45 +00:00
Rafael Espindola
8a781bee00 Remove intermediate variables.
The name of these variables was completely out of date with the information
stored in them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234345 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-07 19:17:47 +00:00
Rafael Espindola
c78f07ad00 Remove unused argument.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234342 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-07 19:00:17 +00:00
Rafael Espindola
6ba6e554c7 Use a comma after the unique keyword.
H.J. Lu noted that all .section options are separated by a comma.

This patch changes the syntax of unique to require one.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234174 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-06 16:34:41 +00:00
Rafael Espindola
e17e7a2400 Remove unnecessary uses of AliasedSymbol.
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234169 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-06 16:10:05 +00:00
Rafael Espindola
9428f184be Be consistent when deciding if a relocation is needed.
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234165 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-06 15:27:57 +00:00
Rafael Espindola
83be4429b2 Store the sh_link of ARM_EXIDX directly in MCSectionELF.
This avoids some pretty horrible and broken name based section handling.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234142 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-06 04:25:18 +00:00
Rafael Espindola
6254dcc14b Simplify this function a bit. NFC.
The case values are not a tidy enum we can fully cover. They even ovelap
over the various extension.

Just use a default:

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234140 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-06 03:16:51 +00:00
Rafael Espindola
01183f6492 Simplify mapping from relocation sections to relocated sections.
Just store the section in MCSectionELF. This avoids multiple hash lookups.

This will also be used by ARM_EXIDX.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234139 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-06 03:09:30 +00:00
Rafael Espindola
d15c1cfeb1 Don't mix overload and default values.
It makes it hard to see which one is being called.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234100 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-04 18:16:01 +00:00
Rafael Espindola
903f4a2051 Implement unique sections with an unique ID.
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234099 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-04 18:02:01 +00:00
Peter Collingbourne
c39f5dd0e2 MC: For variable symbols, maintain MCSymbol::Section as a cache.
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233995 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-03 01:46:11 +00:00
Peter Collingbourne
a8432640e8 Revert r233595, "MC: For variable symbols, maintain MCSymbol::Section as a cache."
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233898 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-02 07:02:51 +00:00
Craig Topper
0a4630d104 Don't print an error message when looking up the scheduling model if user specified -mcpu=help.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233884 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-02 04:27:50 +00:00
David Majnemer
64386621ec [WinEH] Generate .xdata for catch handlers
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233767 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-31 22:35:44 +00:00
Craig Topper
9a7c0031de Make llc use getHostCPUFeatures when 'native' is specified for cpu.
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233673 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-31 05:52:57 +00:00
Eric Christopher
e2424b02b2 Replace the MCSubtargetInfo parameter with a Triple when creating
an MCInstPrinter. Update all callers and use where we wanted a Triple
previously.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233648 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-31 00:10:04 +00:00
Eric Christopher
910e36d7bc Rename const char *Triple argument to TT to avoid shadowing llvm::Triple.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233615 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 22:31:14 +00:00
Peter Collingbourne
07ee8d2fc1 MC: For variable symbols, maintain MCSymbol::Section as a cache.
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233595 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 20:41:21 +00:00
Yaron Keren
6e92e7b09a Remove more superfluous .str() and replace std::string concatenation with Twine.
Following r233392, http://llvm.org/viewvc/llvm-project?rev=233392&view=rev.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233555 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 15:42:36 +00:00
Rafael Espindola
fd45ac4635 Save a std::string.
The group names are always symbol names, so we can use a StringRef.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233545 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 13:59:06 +00:00
Rafael Espindola
0bd11cd898 Special case the creation of relocation sections.
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233539 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 13:39:16 +00:00
Craig Topper
5ce6ef629e Convert feature strings to lowercase even if they have a '+'/'-' in front of them.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233475 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-28 04:59:14 +00:00
Craig Topper
74381e237b Update comment to match code behavior.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233470 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-28 03:24:19 +00:00
Rafael Espindola
0ac75919e1 Add two small structs for readability in place of std::pair and std::tuple. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233422 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-27 21:34:24 +00:00
Akira Hatanaka
f09378397e [MCInstPrinter] Enable MCInstPrinter to change its behavior based on the
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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233411 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-27 20:36:02 +00:00
Rafael Espindola
121eb4257d Close unique sections when switching away from them.
It is not possible to switch back to unique secitons, so close them
automatically when switching away.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233380 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-27 15:01:40 +00:00
Rafael Espindola
9d2f0da138 Fix PR23025.
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233318 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-26 21:11:00 +00:00
Rafael Espindola
55f6e3b963 clang-format bits of code to make another patch readable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233203 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-25 19:24:39 +00:00
Rafael Espindola
d033c4b576 Fix fixup evaluation when deciding what to relocate with.
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).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233187 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-25 13:16:53 +00:00
Rafael Espindola
41509f4261 Fix warning on non-assert build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233158 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-25 00:45:41 +00:00
Rafael Espindola
49dba99a89 Produce an error instead of asserting on invalid .sleb128/.uleb128.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233155 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-25 00:25:37 +00:00
Rafael Espindola
4e86f54fdb Don't be over eager in evaluating a subtraction with a weak symbol.
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233139 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-24 23:48:44 +00:00
Rafael Espindola
45eaa023df Reset the CFA offset at the start of every FDE.
This fixes PR21515.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233120 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-24 21:47:31 +00:00
Michael Kuperstein
765aab84d6 Revert "Use std::bitset for SubtargetFeatures"
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233068 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-24 12:56:59 +00:00
Michael Kuperstein
d3ab717935 Use std::bitset for SubtargetFeatures
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233055 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-24 09:17:25 +00:00
Rafael Espindola
79cd79b1e6 Refactor how passes get a symbol at the end of a section.
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233026 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-23 21:22:04 +00:00
Rafael Espindola
aad1687e0f Update variable name and reuse existing variable. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233014 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-23 20:25:31 +00:00
Benjamin Kramer
1bfcd1f675 Re-sort includes with sort-includes.py and insert raw_ostream.h where it's used.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232998 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-23 19:32:43 +00:00
Yaron Keren
8b9cc2da07 Add missing ELFObjectWriter::reset() override, like other MC classes.
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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232982 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-23 18:35:01 +00:00
Rafael Espindola
d80979b25d Don't declare all text sections at the start of the .s
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232842 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 20:00:01 +00:00
Rafael Espindola
c7c4c36694 Split the object streamer callback in one per file format.
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232699 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-19 01:50:16 +00:00
Rafael Espindola
bd23c08119 Add a default implementation of createObjectStreamer.
This removes duplicated code from backends that don't need to do anything
fancy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232658 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-18 19:08:20 +00:00
Sid Manning
b243a3a556 Add support for .ifnes psuedo-op.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232636 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-18 14:20:54 +00:00
Yaron Keren
703b185464 Remove many superfluous SmallString::str() calls.
Now that SmallString is a first-class citizen, most SmallString::str()
calls are not required. This patch removes a whole bunch of them, yet
there are lots more.

There are two use cases where str() is really needed:
1) To use one of StringRef member functions which is not available in
SmallString.
2) To convert to std::string, as StringRef implicitly converts while 
SmallString do not. We may wish to change this, but it may introduce
ambiguity.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232622 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-18 10:17:07 +00:00
Rafael Espindola
b415e6b2f2 Centralize the handling of unique ids for temporary labels.
Before this patch code wanting to create temporary labels for a given entity
(function, cu, exception range, etc) had to keep its own counter to have stable
symbol names.

createTempSymbol would still add a suffix to make sure a new symbol was always
returned, but it kept a single counter. Because of that, if we were to use
just createTempSymbol("cu_begin"), the label could change from cu_begin42 to
cu_begin43 because some other code started using temporary labels.

Simplify this by just keeping one counter per prefix and removing the various
specialized counters.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232535 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-17 20:07:06 +00:00
Yaron Keren
6279aae989 Remove LookupSymbol(StringRef) and optimize LookupSymbol(Twine).
Same as MakeArgString in r232465, keep only LookupSymbol(Twine)
while making sure it handles the StringRef like cases efficiently
using twine::toStringRef.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232517 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-17 18:55:30 +00:00
Yaron Keren
0401f798d1 Teach Twine to support SmallString.
Enable removing .str() member calls for these frequent cases. 

 http://reviews.llvm.org/D6372



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232465 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-17 09:51:17 +00:00
David Blaikie
7610ba7d24 Fix uses of reserved identifiers starting with an underscore followed by an uppercase letter
This covers essentially all of llvm's headers and libs. One or two weird
cases I wasn't sure were worth/appropriate to fix.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232394 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-16 18:06:57 +00:00
Gabor Horvath
05dd2d9019 Fix build failure on MSVC compilers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232368 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-16 10:19:53 +00:00
Gabor Horvath
1fc0a8da34 [llvm] Replacing asserts with static_asserts where appropriate
Summary:
This patch consists of the suggestions of clang-tidy/misc-static-assert check.


Reviewers: alexfh

Reviewed By: alexfh

Subscribers: xazax.hun, llvm-commits

Differential Revision: http://reviews.llvm.org/D8343

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232366 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-16 09:53:42 +00:00
Frederic Riss
02c39fa277 [MCDwarf] Do not emit useless line table opcode.
No need to emit a DW_LNS_advance_pc with a 0 increment. Found out while
comparing dsymutil's and LLVM's line table encoding. Not a correctenss
fix, just a small encoding size optimization.

I'm not sure how to generate a sequence that triggers this, and moreover
llvm-dwardump doesn't dump the line table program, thus the effort
involved in creating a testcase for this trivial patch seemed out of
proportion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232332 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-15 20:45:39 +00:00
Daniel Sanders
547ba56bd0 Recommit r232027 with PR22883 fixed: Add infrastructure for support of multiple memory constraints.
The operand flag word for ISD::INLINEASM nodes now contains a 15-bit
memory constraint ID when the operand kind is Kind_Mem. This constraint
ID is a numeric equivalent to the constraint code string and is converted
with a target specific hook in TargetLowering.

This patch maps all memory constraints to InlineAsm::Constraint_m so there
is no functional change at this point. It just proves that using these
previously unused bits in the encoding of the flag word doesn't break
anything.

The next patch will make each target preserve the current mapping of
everything to Constraint_m for itself while changing the target independent
implementation of the hook to return Constraint_Unknown appropriately. Each
target will then be adapted in separate patches to use appropriate
Constraint_* values.

PR22883 was caused the matching operands copying the whole of the operand flags
for the matched operand. This included the constraint id which needed to be
replaced with the operand number. This has been fixed with a conversion
function. Following on from this, matching operands also used the operand
number as the constraint id. This has been fixed by looking up the matched
operand and taking it from there. 



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232165 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-13 12:45:09 +00:00
Jingyue Wu
3ea0adcdd5 [NVPTXAsmPrinter] do not print .align on function headers
Summary:
PTX does not allow .align directives on function headers.

Fixes PR21551.

Test Plan: test/Codegen/NVPTX/function-align.ll

Reviewers: eliben, jholewinski

Reviewed By: eliben, jholewinski

Subscribers: llvm-commits, eliben, jpienaar, jholewinski

Differential Revision: http://reviews.llvm.org/D8274

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232004 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-12 01:50:30 +00:00
Rafael Espindola
a5415bcc57 Don't print labels that on ELF are never used.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231904 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-11 04:20:31 +00:00
Rafael Espindola
658236dec2 Print section start labels when first switching to the section.
This is less brittle and avoids polluting the start of the file with every
debug section.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231898 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-11 00:51:37 +00:00
Rafael Espindola
e58e7e6476 Add missing section symbol to COFF's .debug_types.dwo.
Should bring the cygwin bots back.

I added a triple to the test that was failing so that it would have failed
on Linux.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231882 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-10 23:06:32 +00:00