1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
Commit Graph

407 Commits

Author SHA1 Message Date
Duncan P. N. Exon Smith
842194f532 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
2189cb98a5 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
4c0dd00c17 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
95c79d189f 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
1882033972 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
595a292f14 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
Yaron Keren
413d5fd1e4 Update ELFObjectWriter::reset() following r236255.
llvm-svn: 237261
2015-05-13 15:17:19 +00:00
Rafael Espindola
782fe11d94 Remove unnecessary break.
llvm-svn: 236275
2015-04-30 22:41:12 +00:00
Rafael Espindola
a0b480ab97 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.

llvm-svn: 236267
2015-04-30 21:51:58 +00:00
Rafael Espindola
4f365e26b8 Replace unreachable code with llvm_unreachable.
llvm-svn: 236261
2015-04-30 21:20:06 +00:00
Rafael Espindola
5eb4acbada Don't create a MCSectionData when we don't have to.
llvm-svn: 236260
2015-04-30 21:10:06 +00:00
Rafael Espindola
28b1577052 Avoid an extra loop over the sections.
Add string to the section header string table as we add sections.

llvm-svn: 236257
2015-04-30 20:57:14 +00:00
Rafael Espindola
bea43714cb 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.

llvm-svn: 236255
2015-04-30 20:53:27 +00:00
Rafael Espindola
52d84b33c1 Nothing inherits from this, drop the protected:
llvm-svn: 236253
2015-04-30 20:37:36 +00:00
Rafael Espindola
2375592ce3 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.

llvm-svn: 236235
2015-04-30 14:21:49 +00:00
Aaron Ballman
abe3091fb7 Silencing an "enumeral and non-enumeral type in conditional expression" warning; NFC.
llvm-svn: 236234
2015-04-30 14:03:12 +00:00
Rafael Espindola
f4d8e72cec Store relocations in a map from MCSectionELF.
Saves finding the MCSectionData just to do a map lookup.

llvm-svn: 236189
2015-04-30 00:45:46 +00:00
Rafael Espindola
b7841f3152 Write relocations directly to the output stream. NFC.
llvm-svn: 236187
2015-04-30 00:30:40 +00:00
Rafael Espindola
19a54bb9e0 Inline FragmentWriter into the only user.
llvm-svn: 236158
2015-04-29 21:13:30 +00:00
Rafael Espindola
078870f232 Write the symbol table directly to the output file.
There is no need to first accumulate it in fragments.

llvm-svn: 236157
2015-04-29 21:09:32 +00:00
Rafael Espindola
1b981dc4c3 Use pwrite to write the number of sections.
This avoids having to compute the number upfront, which will be used in the
next patch.

llvm-svn: 236153
2015-04-29 20:39:37 +00:00
Rafael Espindola
2c4ad3b0f1 Write the string table directly to the output file.
There is no need to accumulate it in fragments first.

llvm-svn: 236148
2015-04-29 20:34:31 +00:00
Rafael Espindola
a031c08f04 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.

llvm-svn: 236145
2015-04-29 20:25:24 +00:00
Rafael Espindola
c27f5fe6a9 Avoid a few const_cast.
llvm-svn: 236141
2015-04-29 19:20:10 +00:00
Rafael Espindola
edcabc9962 Map directly from signature symbol to group index. NFC.
llvm-svn: 236058
2015-04-28 22:59:58 +00:00
Rafael Espindola
8e0ffa1c13 Remove redundant temporary std::vector.
New sections are added to the end of the list, so the RelSections array was
redundant.

llvm-svn: 236053
2015-04-28 22:26:19 +00:00
Rafael Espindola
22b9bb10c1 Avoid one more walk over all sections. NFC.
Set the group section index as they are created.

llvm-svn: 236049
2015-04-28 22:03:22 +00:00
Rafael Espindola
dd57dbf6ee Use a range loop. NFC.
llvm-svn: 236047
2015-04-28 21:58:05 +00:00
Rafael Espindola
913cb962ab Avoid an extra walk over the sections just to assign sections to groups.
Assign the sections in the same pass we compute the index.

llvm-svn: 236045
2015-04-28 21:52:33 +00:00
Rafael Espindola
cb4f0eb485 Remove the GroupMapTy DenseMap. NFC.
Instead use the Group symbol of MCSectionELF.

llvm-svn: 236033
2015-04-28 21:07:28 +00:00
Rafael Espindola
00737f8728 Use range loops. NFC.
llvm-svn: 236028
2015-04-28 20:23:35 +00:00
Rafael Espindola
00ff8758ba Avoid adding to SectionIndexMap sections that we never lookup. NFC.
llvm-svn: 236026
2015-04-28 20:09:13 +00:00
Rafael Espindola
1892d87b54 Use a range loop. NFC.
llvm-svn: 236015
2015-04-28 19:07:16 +00:00
Rafael Espindola
d33ef76ab3 Use a std::vector to record the offsets of the sections. NFC.
llvm-svn: 235995
2015-04-28 15:26:21 +00:00
Rafael Espindola
797619b3db Avoid an extra loop for computing the section size. NFC.
llvm-svn: 235994
2015-04-28 15:04:09 +00:00
Rafael Espindola
4407c2f7d6 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.

llvm-svn: 235300
2015-04-20 12:44:06 +00:00
Rafael Espindola
2e994b78fe 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.

llvm-svn: 235227
2015-04-17 21:15:17 +00:00
Rafael Espindola
1d1bb5695a 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.

llvm-svn: 235222
2015-04-17 20:05:17 +00:00
Benjamin Kramer
f0e694a272 [mc] Clean up emission of byte sequences
No functional change intended.

llvm-svn: 235178
2015-04-17 11:12:43 +00:00
Rafael Espindola
332519bf88 Don't walk aliases from global to local symbols in comdats.
This fixes pr23196.

llvm-svn: 235167
2015-04-17 08:46:11 +00:00
Rafael Espindola
3b98c374cd 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

llvm-svn: 235165
2015-04-17 08:11:38 +00:00
Rafael Espindola
55bc28240e Write section and section table entries in the same order.
We had two different orders, which has no value.

llvm-svn: 235004
2015-04-15 13:07:47 +00:00
Rafael Espindola
cf2ab6b126 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.

llvm-svn: 234952
2015-04-14 22:54:16 +00:00
Rafael Espindola
aeb03deb16 Use raw_pwrite_stream in the object writer/streamer.
The ELF object writer will take advantage of that in the next commit.

llvm-svn: 234950
2015-04-14 22:14:34 +00:00
Petar Jovanovic
9a0a08ccc4 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

llvm-svn: 234883
2015-04-14 13:23:34 +00:00
Alexander Kornienko
71412ece39 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

llvm-svn: 234679
2015-04-11 02:11:45 +00:00
Rafael Espindola
43cb6b4775 Remove unused variable.
llvm-svn: 234426
2015-04-08 20:04:20 +00:00
Rafael Espindola
26a13bd558 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.

llvm-svn: 234400
2015-04-08 11:41:24 +00:00
NAKAMURA Takumi
fe98f22055 ELFObjectWriter.cpp: Prune obsolete \param since r234342. [-Wdocumentation]
llvm-svn: 234377
2015-04-08 00:38:50 +00:00
Rafael Espindola
212b8006f8 Delete commented code. Don't repeat name in comment.
llvm-svn: 234370
2015-04-07 22:35:40 +00:00