Commit Graph

192 Commits

Author SHA1 Message Date
Weiming Zhao
c4d3801c20 Reland r298901 with modifications (reverted in r298932)
Dont emit Mapping symbols for sections that contain only data.

Summary:
Dont emit mapping symbols for sections that contain only data.

Reviewers: rengolin, weimingz, kparzysz, t.p.northover, peter.smith

Reviewed By: t.p.northover

Patched by Shankar Easwaran <shankare@codeaurora.org>

Subscribers: alekseyshl, t.p.northover, llvm-commits

Differential Revision: https://reviews.llvm.org/D30724

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299392 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-03 21:50:04 +00:00
Weiming Zhao
13bfce64bc Revert "Dont emit Mapping symbols for sections that contain only data."
It breaks some lld tests.

This reverts commit 3a50eea6d9.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298932 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-28 17:15:11 +00:00
Weiming Zhao
3a50eea6d9 Dont emit Mapping symbols for sections that contain only data.
Summary:
Dont emit mapping symbols for sections that contain only data.

Patched by Shankar Easwaran <shankare@codeaurora.org>

Reviewers: rengolin, peter.smith, weimingz, kparzysz, t.p.northover

Reviewed By: t.p.northover

Subscribers: t.p.northover, llvm-commits

Differential Revision: https://reviews.llvm.org/D30724

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298901 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-28 05:40:36 +00:00
David Blaikie
1e54c56c2f Simplify/make more explicit (by making less explicit in some ways) some function calls
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297921 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-16 00:43:19 +00:00
Peter Collingbourne
6387bdabf7 MC: De-duplicate the object streamer implementations of EmitFileDirective into MCObjectStreamer. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296912 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-03 21:22:06 +00:00
Dan Gohman
d5cb2d625b [MC] Factor out non-COFF handling of COFF-specific directives.
Instead of requiring every non-COFF MCObjectStreamer to implement the
COFF hooks just to do an llvm_unreachable to say that they're not
supported, do the llvm_unreachable in the default implementation, as
suggested by rnk in https://reviews.llvm.org/D26722.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296403 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-27 22:44:37 +00:00
Rafael Espindola
940b0c036d Move some error handling down to MCStreamer.
This makes sure we get the same redefinition rules regardless of who
is printing (asm parser, codegen) and to what (asm, obj).

This fixes an unintentional regression in r293936.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294752 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-10 15:13:12 +00:00
Eugene Zelenko
f31871c702 [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294369 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-07 23:02:00 +00:00
Rafael Espindola
7931a61c18 Change how we handle section symbols on ELF.
On ELF every section can have a corresponding section symbol. When in
an assembly file we have

.quad .text

the '.text' refers to that symbol.

The way we used to handle them is to leave .text an undefined symbol
until the very end when the object writer would map them to the
actual section symbol.

The problem with that is that anything before the end would see an
undefined symbol. This could result in bad diagnostics
(test/MC/AArch64/label-arithmetic-diags-elf.s), or incorrect results
when using the asm streamer (est/MC/Mips/expansion-jal-sym-pic.s).

Fixing this will also allow using the section symbol earlier for
setting sh_link of SHF_METADATA sections.

This patch includes a few hacks to avoid changing our behaviour when
handling conflicts between section symbols and other symbols. I
reported pr31850 to track that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293936 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-02 21:26:06 +00:00
Dan Gohman
14b34deb68 [MC] Refactor emitELFSize to make usage more consistent. NFC.
Move the cast<MCSymbolELF> inside emitELFSize, so that: 
 - it's done in one place instead of at each call
 - it's more consistent with similar functions like EmitCOFFSafeSEH
 - ambiguity between cast<> and dyn_cast<> is avoided (which also
   eliminates an unnecessary dyn_cast call)

This also makes it easier to experiment with using ".size" directives on
non-ELF targets.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288437 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-01 23:39:08 +00:00
Reid Kleckner
d01756181c Fix instance of -Wdelete-incomplete
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273508 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 23:25:26 +00:00
Daniel Sanders
c8b0a11468 [mips] Use MipsMCExpr instead of MCSymbolRefExpr for all relocations.
Summary:
This is much closer to the way MIPS relocation expressions work
(%hi(foo + 2) rather than %hi(foo) + 2) and removes the need for the
various bodges in MipsAsmParser::evaluateRelocExpr().

Removing those bodges ensures that the constant stored in MCValue is the
full 32 or 64-bit (depending on ABI) offset from the symbol. This will be used
to correct the %hi/%lo matching needed to sort the relocation table correctly.

As part of this:
* Gave MCExpr::print() the ability to omit parenthesis when emitting a
  symbol reference inside a MipsMCExpr operator like %hi(X). Without this
  we print things like %lo(($L1)).
* %hi(%neg(%gprel(X))) is now three MipsMCExpr's instead of one. Most of
  the related special cases have been removed or moved to MipsMCExpr. We
  can remove the rest as we gain support for the less common relocations
  when they are not part of this specific combination.
* Renamed MipsMCExpr::VariantKind and the enum prefix ('VK_') to avoid confusion
  with MCSymbolRefExpr::VariantKind and its prefix (also 'VK_').
* fixup_Mips_GOT_Local and fixup_Mips_GOT_Global were found to be identical
  and merged into fixup_Mips_GOT.
* MO_GOT16 and MO_GOT turned out to be identical and have been merged into
  MO_GOT.
* VK_Mips_GOT and VK_Mips_GOT16 turned out to be the same thing so they
  have been merged into MEK_GOT

Reviewers: sdardis

Subscribers: dsanders, sdardis, llvm-commits

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268379 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-03 13:35:44 +00:00
Lang Hames
90ae214a17 [Object] Make .alt_entry directive parsing MachO specific.
ELF and COFF will now treat .alt_entry like any other unrecognized directive.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265975 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-11 18:33:45 +00:00
Lang Hames
62e3955adf [Object] Report an error if .alt_entry is used with ELF or COFF.
I'm looking into a better way to do this long-term, but for now at least don't
crash.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265815 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 17:38:51 +00:00
Lang Hames
875b7560fb [MachO] Add MachO alt-entry directive support.
This patch adds support for the MachO .alt_entry assembly directive, and uses
it for global aliases with non-zero GEP offsets. The alt_entry flag indicates
that a symbol should be layed out immediately after the preceding symbol.
Conceptually it introduces an alternate entry point for a function or data
structure. E.g.:

safe_foo:
  // check preconditions for foo
.alt_entry fast_foo
fast_foo:
  // body of foo, can assume preconditions.

The .alt_entry flag is also implicitly set on assembly aliases of the form:

a = b + C

where C is a non-zero constant, since these have the same effect as an
alt_entry symbol: they introduce a label that cannot be moved relative to the
preceding one. Setting the alt_entry flag on aliases of this form fixes
http://llvm.org/PR25381.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263521 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-15 01:43:05 +00:00
Colin LeMahieu
89dcdff198 [MC] Merge VK_PPC_TPREL in to generic VK_TPREL.
Differential Revision: http://reviews.llvm.org/D17038

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260401 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-10 18:32:01 +00:00
Rafael Espindola
556ddccf74 Don't create empty sections just to look like gas.
We are long past the time when this much bug for bug compatibility was
useful.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251970 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-03 20:02:22 +00:00
Rafael Espindola
49d691389e Delete dead code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251960 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-03 18:55:58 +00:00
Rafael Espindola
ca792d80c4 Simplify local common output.
We now create them as they are found and use higher level APIs.

This is a step in avoiding creating unnecessary sections.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251958 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-03 18:50:51 +00:00
Rafael Espindola
f026f70e79 Move code out of a loop and use a range loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251952 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-03 18:04:07 +00:00
Rafael Espindola
0eba49c22e Fix pr24486.
This extends the work done in r233995 so that now getFragment (in addition to
getSection) also works for variable symbols.

With that the existing logic to decide if a-b can be computed works even if
a or b are variables. Given that, the expression evaluation can avoid expanding
variables as aggressively and that in turn lets the relocation code see the
original variable.

In order for this to work with the asm streamer, there is now a dummy fragment
per section. It is used to assign a section to a symbol when no other fragment
exists.

This patch is a joint work by Maxim Ostapenko andy myself.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249303 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-05 12:07:05 +00:00
Craig Topper
634763c0f5 Cleanup places that passed SMLoc by const reference to pass it by value instead. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248135 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-20 23:35:59 +00:00
Yaron Keren
4b885ee8e2 Remove and forbid raw_svector_ostream::flush() calls.
After r244870 flush() will only compare two null pointers and return,
doing nothing but wasting run time. The call is not required any more
as the stream and its SmallString are always in sync.

Thanks to David Blaikie for reviewing.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244928 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-13 18:12:56 +00:00
Benjamin Kramer
d3c712e50b Fix some comment typos.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244402 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-08 18:27:36 +00:00
Pete Cooper
c821cef882 Devirtualize and pack MCFragment to reduce memory usage.
MCFragment didn't really need vtables.  The majority of virtual methods were just getters and setters.

This removes the vtables and uses dispatch on the kind to do things like delete which needs to
get the appropriate class.

This reduces memory on the verify use list order test case by about 2MB out of 800MB.

Reviewed by Rafael Espíndola

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239952 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-17 22:01:28 +00:00
Colin LeMahieu
2ca8f0f5d6 [MC] Common symbols weren't being checked for redeclaration which allowed an assembly file to generate an assertion in setCommon(): !isCommon(). This change allows redeclaration as long as the size and alignment match exactly, otherwise report a fatal error.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239227 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-06 20:12:40 +00:00
Gabor Ballabas
3e2318fbb5 Test commit access.
Fix trailing whitespace.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239058 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-04 17:30:26 +00:00
Rafael Espindola
c212856f78 Remove MCELFSymbolFlags.h. It is now internal to MCSymbolELF.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238996 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-04 00:47:43 +00:00
Rafael Espindola
96fdaa4f50 Convert BindingExplicitlySet into a MCSymbolELF field.
I will pack it better in a followup patch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238975 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-03 21:18:03 +00:00
Rafael Espindola
569f382a46 Merge MCELF.h into MCSymbolELF.h.
Now that we have a dedicated type for ELF symbol, these helper functions can
become member function of MCSymbolELF.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238864 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-02 20:38:46 +00:00
Rafael Espindola
f7e0685b9a Create a MCSymbolELF.
This create a MCSymbolELF class and moves SymbolSize since only ELF
needs a size expression.

This reduces the size of MCSymbol from 56 to 48 bytes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238801 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-02 00:25:12 +00:00
Jim Grosbach
586c0042da MC: Clean up MCExpr naming. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238634 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-30 01:25:56 +00:00
Rafael Espindola
cfac75ad0e Remove getData.
This completes the mechanical part of merging MCSymbol and MCSymbolData.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238617 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-29 21:45:01 +00:00
Rafael Espindola
5760c5fe31 Remove the MCSymbolData typedef.
The getData member function is next.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238611 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-29 20:41:47 +00:00
Rafael Espindola
f00654bc0f Rename getOrCreateSymbolData to registerSymbol and return void.
Another step in merging MCSymbol and MCSymbolData.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238607 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-29 20:21:02 +00:00
Rafael Espindola
5b68a837c7 Pass MCSymbols to the helper functions in MCELF.h.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238596 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-29 18:47:23 +00:00
Rafael Espindola
82fdcc0e7f Move common symbol related information from MCSectionData to MCSymbol.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238583 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-29 17:48:04 +00:00
Rafael Espindola
28afbf2421 Move SymbolSize from MCSymbolData to MCSymbol.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238580 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-29 17:24:52 +00:00
Rafael Espindola
9886da621d Remove a trivial forwarding function. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238506 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-28 21:36:02 +00:00
Rafael Espindola
792e158397 Rename and move getCurrentSectionData.
I think this concludes the merge of MCSectionData and MCSection.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238358 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-27 21:04:14 +00:00
Rafael Espindola
41cea417fa There is only one current section.
Both MCStreamer and MCObjectStreamer were maintaining a current section
variable and they were slightly out of sync. I don't think this was observable,
but was inefficient and error prone.

Changing this requires a few cascading changes:

* SwitchSection has to call ChangeSection earlier for ChangeSection to see
  the old section.
* With that change, ChangeSection cannot call EmitLabel, since during
  ChangeSection we are still in the old section.
* When the object streamer requires a begin label, just reused the existing
  generic support for begin labels instead of calling EmitLabel directly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238357 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-27 20:52:32 +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
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
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
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
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