Commit Graph

2865 Commits

Author SHA1 Message Date
Rafael Espindola 8324c2f8be Store a MCSection in MCFragment.
Part of the work to merge MCSectionData into MCSection.

llvm-svn: 238160
2015-05-25 23:48:22 +00:00
Rafael Espindola a554c05d95 Turn MCSectionData into a field of MCSection.
This also changes MCAssembler to store a vector of MCSections instead of an
iplist of MCSectionData.

llvm-svn: 238159
2015-05-25 23:14:17 +00:00
Rafael Espindola 09266bad7f Move MCSectionData to MCSection.h.
Another step in merging MCSectionData and MCSection.

llvm-svn: 238158
2015-05-25 22:57:48 +00:00
Rafael Espindola 08850b3a88 Make a few MCSectionELF& variables const. NFC.
This just reduces the noise from another patch.

llvm-svn: 238156
2015-05-25 21:56:55 +00:00
Rafael Espindola 25ffbe17c9 Insert MCSectionData into the section list directly in getOrCreateSectionData.
Removing the logic from the constructor will make it easier to merge
MCSectionData and MCSection.

llvm-svn: 238155
2015-05-25 20:39:23 +00:00
Rafael Espindola cd62518369 Move HasInstructions to MCSection.
llvm-svn: 238150
2015-05-25 18:34:26 +00:00
Rafael Espindola b028cc8098 Move bundle info from MCSectionData to MCSection.
llvm-svn: 238143
2015-05-25 15:04:26 +00:00
Rafael Espindola c1cd944854 Add a isBundleLocked helper to MCELFStreamer.
llvm-svn: 238142
2015-05-25 14:57:35 +00:00
Rafael Espindola b2ac19ed6e Move LayoutOrder to MCSection.
llvm-svn: 238141
2015-05-25 14:25:28 +00:00
Rafael Espindola 6e6820a7e6 Stop forwarding getOrdinal and setOrdinal.
llvm-svn: 238139
2015-05-25 14:12:48 +00:00
Rafael Espindola 1f02022027 Move Ordinal from MCSectionData to MCSection. NFC.
Part of the work to merge MCSectionData and MCSection.

llvm-svn: 238137
2015-05-25 14:00:56 +00:00
Rafael Espindola 5960cee1f5 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.

llvm-svn: 238073
2015-05-22 23:58:30 +00:00
Duncan P. N. Exon Smith 03656162a3 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.)

llvm-svn: 238005
2015-05-22 06:04:42 +00:00
Duncan P. N. Exon Smith 1247bbd82a 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`.

llvm-svn: 238001
2015-05-22 05:54:01 +00:00
Rafael Espindola 967d6a6914 Stop forwarding (get|set)Aligment from MCSectionData to MCSection.
llvm-svn: 237956
2015-05-21 21:02:35 +00:00
Rafael Espindola 0a82ad798c Stop creating MCSectionData is the ELF writer.
Now is is just its use of MCSymbolData that requires it to take a non const
MCAssembler.

llvm-svn: 237951
2015-05-21 20:43:13 +00:00
Rafael Espindola 883dec058f writeSymbolTable now only needs a MCContext.
It used to use an MCAssembler just to record the alignment of the sections.

llvm-svn: 237944
2015-05-21 19:54:44 +00:00
Rafael Espindola 1aa20fcb41 Pass a const MCAssembler to writeSectionHeader.
It never creates sections, so it can use Asm.getSectionData instead of
Asm.getOrCreateSectionData.

llvm-svn: 237943
2015-05-21 19:46:39 +00:00
Rafael Espindola e92c1bfa4b Remove unused argument. NFC.
llvm-svn: 237940
2015-05-21 19:42:35 +00:00
Rafael Espindola 286875874a Fetch alignment directly out of MCSection. NFC.
llvm-svn: 237938
2015-05-21 19:36:43 +00:00
Rafael Espindola 0709a7bd1a 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.

llvm-svn: 237936
2015-05-21 19:20:38 +00:00
Rafael Espindola fa160c7386 Fix warning on builds without asserts.
llvm-svn: 237915
2015-05-21 17:09:22 +00:00
Rafael Espindola e2fdf8d60e Avoid unnecessary section switching. NFC.
llvm-svn: 237913
2015-05-21 17:00:40 +00:00
Rafael Espindola e07467901b 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.

llvm-svn: 237912
2015-05-21 16:52:32 +00:00
Rafael Espindola beeacd1586 Use existing helper for adding a section. NFC.
llvm-svn: 237909
2015-05-21 16:19:32 +00:00
Duncan P. N. Exon Smith 0b73d71abb 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.)

llvm-svn: 237876
2015-05-21 02:41:23 +00:00
Duncan P. N. Exon Smith 5435aa464a 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.)

llvm-svn: 237873
2015-05-21 01:33:03 +00:00
Duncan P. N. Exon Smith 24f4775f71 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.

llvm-svn: 237867
2015-05-21 00:39:24 +00:00
Reid Kleckner 2632f0df48 [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.

llvm-svn: 237852
2015-05-20 23:08:04 +00:00
Duncan P. N. Exon Smith 92a699c50e MC: Remove most remaining uses of MCSymbolData::getSymbol(), NFC
Remove most remaining calls to `MCSymbolData::getSymbol()`, instead
using the already available `MCSymbol` directly.

llvm-svn: 237829
2015-05-20 20:18:16 +00:00
Duncan P. N. Exon Smith e8fb3a220a MC: Stop using MCSymbolData::getSymbol() in WinCOFF, NFC
Move APIs over from `MCSymbolData` to `MCSymbol`.

llvm-svn: 237826
2015-05-20 19:34:08 +00:00
Pete Cooper b78008171b 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.

llvm-svn: 237823
2015-05-20 19:12:14 +00:00
Duncan P. N. Exon Smith fd28abcf15 MC: Use MCSymbol in LocalCommon, NFC
Switch from MCSymbolData to MCSymbol in LocalCommon.

llvm-svn: 237816
2015-05-20 18:25:40 +00:00
Duncan P. N. Exon Smith c3e709e81f 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.

llvm-svn: 237807
2015-05-20 16:34:36 +00:00
Duncan P. N. Exon Smith fd27a1dc1b MC: Update MCAssembler to use MCSymbol, NFC
Use `MCSymbol` over `MCSymbolData` where both are needed.

llvm-svn: 237803
2015-05-20 16:02:11 +00:00
Duncan P. N. Exon Smith 08b8726de3 MC: Use MCSymbol in MachObjectWriter, NFC
Replace uses of `MCSymbolData` with `MCSymbol` where both are needed, so
we can remove the backpointer.

llvm-svn: 237799
2015-05-20 15:16:14 +00:00
Duncan P. N. Exon Smith 5266ad9bec MC: Use MCSymbol in MCObjectWriter::isWeak(), NFC
Continue to prefer `MCSymbol` when we need both.

llvm-svn: 237798
2015-05-20 15:10:03 +00:00
Duncan P. N. Exon Smith 469f9dbdb9 MC: Use MCSymbol in most of ELFObjectWriter, NFC
Stop using MCSymbolData where we also need MCSymbol.

llvm-svn: 237770
2015-05-20 04:39:01 +00:00
Duncan P. N. Exon Smith 99d8a8e8ac MC: Take MCSymbol in MachObjectWriter::getSymbolAddress(), NFC
Pass through an `MCSymbol` instead of an `MCSymbolData` so we can get
rid of the back pointer.

llvm-svn: 237750
2015-05-20 00:02:39 +00:00
Duncan P. N. Exon Smith 2a40483418 MC: Use MCSymbol in MCAsmLayout::getSymbolOffset(), NFC
Continue to canonicalize on MCSymbol instead of MCSymbolData when both
are needed.

llvm-svn: 237749
2015-05-19 23:53:20 +00:00
Jim Grosbach 008359ae4a MC: clang-format MCContext. NFC.
llvm-svn: 237595
2015-05-18 18:43:23 +00:00
Jim Grosbach 6f482000e9 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.

llvm-svn: 237594
2015-05-18 18:43:14 +00:00
Duncan P. N. Exon Smith 6e23e5a680 MC: Use MCSymbol in RelAndSymbol, NFC
Switch from `MCSymbolData` to `MCSymbol`.

llvm-svn: 237502
2015-05-16 01:14:19 +00:00
Duncan P. N. Exon Smith d81ba532ed 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.

llvm-svn: 237498
2015-05-16 01:01:55 +00:00
Duncan P. N. Exon Smith 09bfa58edd 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.

llvm-svn: 237497
2015-05-16 00:48:58 +00:00
Duncan P. N. Exon Smith f48de1cb7b 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`.

llvm-svn: 237496
2015-05-16 00:35:24 +00:00
Duncan P. N. Exon Smith e2eb3a5300 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.)

llvm-svn: 237490
2015-05-16 00:03:06 +00:00
Duncan P. N. Exon Smith 70528d7863 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.

llvm-svn: 237486
2015-05-15 22:33:34 +00:00
Pete Cooper 81902a3ae4 Remove MCAssembler.h include from MCStreamer.h and fix users of MCStreamer.h
llvm-svn: 237483
2015-05-15 22:19:42 +00:00
Pete Cooper 3de83e4098 Remove 3 includes from MCInstrDesc.h and explicitly include them where needed
llvm-svn: 237481
2015-05-15 21:58:42 +00:00