Commit Graph

3163 Commits

Author SHA1 Message Date
Nico Weber
d8f6d5cdd7 Make WinCOFFObjectWriter.cpp's timestamp writing not use ENABLE_TIMESTAMPS
LLVM_ENABLE_TIMESTAMPS controls if timestamps are embedded into llvm's
binaries. Turning it off is useful for deterministic builds.

r246905 made it so that the define suddenly also controls if the binaries that
the llvm binaries _create_ embed timestamps or not – but this shouldn't be a
configure-time option. r256203/r256204 added a driver option to toggle this on
and off, so this patch now passes this driver option in LLVM_ENABLE_TIMESTAMPS
builds so that if LLVM_ENABLE_TIMESTAMPS is set, the build of LLVM is
deterministic – but the built clang can still write timestamps into other
executables when requested.

This also allows removing some of the test machinery added in r292012 to work
around this problem.

See PR24740 for background.
http://reviews.llvm.org/D15783


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256958 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-06 19:05:19 +00:00
Artyom Skrobov
176a9b2a53 (NFC) Change SubtargetFeatures::ToggleFeature and
SubtargetFeatures::ApplyFeatureFlag to be static, so that
MCSubtargetInfo doesn't need to instantiate SubtargetFeatures
for nothing. Also change the return type to void, as it
wasn't ever used.

This is a partial commit of http://reviews.llvm.org/D15746

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256823 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-05 10:25:56 +00:00
Paul Robinson
d84e2865f6 Clang-format my previous change (r256313)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256764 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-04 18:49:15 +00:00
Jeroen Ketema
0abac95f65 [MC] Fix file name in file header
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256749 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-04 12:22:34 +00:00
Craig Topper
2e085133b3 Use an ArrayRef to simplify repeated calculation of the array end. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256702 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-03 08:45:36 +00:00
Craig Topper
4d0731f505 Use std::is_sorted instead of manual loops. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256701 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-03 07:33:45 +00:00
Chandler Carruth
a202d8ec2d [ptr-traits] Provide a real MCFragment address for the sentinel instead
of casting the integer '4' to such a pointer. There is no reason to
expect '4' to be a portable or reliable pointer of this form. The only
reason this ever worked is because the PointerIntPair that this actually
gets used with has an artificially *low* presumed alignment that allowed
it to work. When the alignment of PointerIntPair is derived from the
actual type's alignment, the asserts start firing on this pointer. I'm
amazed we never managed to do anything that triggered the alignment
sanitizer with it, as this is just flat out UB.

If folks dislike this approach to providing a sentinel fragment address,
there are a myriad of other alternatives, suggestions welcome. But this
one has the distinct advantage of not requiring the friend dance of
ilist's sentinel (which I'll point out is *also* in play for
MCFragment!) and seems to be using a nicely provided facility in
MCFragment to establish just such dummy nodes.

This is part of a series of patches to allow LLVM to check for complete
pointee types when computing its pointer traits. This is absolutely
necessary to get correct (or reproducible) results for things like how
many low bits are guaranteed to be zero.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256552 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-29 09:32:18 +00:00
Chandler Carruth
24cdab76e0 [ptr-traits] Split the MCFragment type hierarchy out of the MCAssembler
header to its own header, allowing users of fragments to have a narrower
header file, and avoid circular header dependencies when getting the
definition of MCSection prior to inspecting traits on MCSection
pointers.

This is part of a series of patches to allow LLVM to check for complete
pointee types when computing its pointer traits. This is absolutely
necessary to get correct (or reproducible) results for things like how
many low bits are guaranteed to be zero.

Note that this doesn't in any way change the design of MC, it is just
moving code around to allow the *header files* to be more fine grained.
Without this, it is impossible to get a complete type for MCSection
where it is needed.

If anyone would prefer a different slicing of the header files, I'm
happy to oblige of course. =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256548 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-29 09:06:16 +00:00
Eric Christopher
8d5b76e5d4 Accept dwarf version 5 for CIE versions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256527 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-28 23:02:42 +00:00
Paul Robinson
073a62bc1d Form reform for MCDwarf.
MCDwarf emits a canned abbreviation table, but was not emitting proper
forms for DWARF version 4, which is the default after r249655.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256313 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-23 01:57:31 +00:00
David Majnemer
f31d06a13f [MC] Don't use the architecture to govern which object file format to use
InitMCObjectFileInfo was trying to override the triple in awkward ways.
For example, a triple specifying COFF but not Windows was forced as ELF.
This makes it easy for internal invariants to get violated, such as
those which triggered PR25912.

This fixes PR25912.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256226 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-22 01:39:04 +00:00
David Majnemer
56afa6e660 [MC, COFF] Support link /incremental conditionally
Today, we always take into account the possibility that object files
produced by MC may be consumed by an incremental linker.  This results
in us initialing fields which vary with time (TimeDateStamp) which harms
hermetic builds (e.g. verifying a self-host went well) and produces
sub-optimal code because we cannot assume anything about the relative
position of functions within a section (call sites can get redirected
through incremental linker thunks).

Let's provide an MCTargetOption which controls this behavior so that we
can disable this functionality if we know a-priori that the build will
not rely on /incremental.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256203 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-21 22:09:27 +00:00
Dan Gohman
1a81ad967f Teach MCOperand::print how to print FPImm operands.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256163 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-21 16:47:10 +00:00
David Majnemer
827bc7fe53 [MC, COFF] Unbreak support for COFF timestamps
Support for COFF timestamps was unintentionally broken in r246905 when
it was conditionally available depending on whether or not LLVM was
configured with LLVM_ENABLE_TIMESTAMPS.  However, Config/config.h was
never included which essentially broke the feature.  Due to lax testing,
the breakage was never identified until we observed strange failures
during incremental links of Chromium.

This issue is resolved by simply including Config/config.h in
WinCOFFObjectWriter and teaching lit that the MC/COFF/timestamp.s test
is conditionally supported depending on LLVM_ENABLE_TIMESTAMPS.  With
this in place, we can strengthen the test to ensure that it will not
accidentally get broken in the future.

This fixes PR25891.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256137 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-21 08:03:07 +00:00
Krzysztof Parzyszek
4aba1843f2 Recognize strings for Hexagon-specific variant kinds
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256007 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-18 18:47:27 +00:00
Rafael Espindola
cdfe790540 Avoid explicit relocation sorting most of the time.
These days relocations are created and stored in a deterministic way.
The order they are created is also suitable for the .o file, so we don't
need an explicit sort.

The last remaining exception is MIPS.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255902 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-17 16:22:06 +00:00
Rafael Espindola
f50f96be5d Always sort by offset first. NFC.
Every target changing sortRelocs was first calling the parent
implementation. Just run that first.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255898 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-17 15:08:24 +00:00
Rafael Espindola
0d2b021de6 Use std::unique_ptr. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255852 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-16 23:49:14 +00:00
Michael Zuckerman
be7b5146ad [X86][inline asm] support even directive
The .even directive aligns content to an evan-numbered address.

In at&t syntax .even 
In Microsoft syntax even (without the dot).

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255462 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-13 17:07:23 +00:00
Craig Topper
79402ee6f9 Replace uint16_t with the MCPhysReg typedef in many places. A lot of physical register arrays already use this typedef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254843 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-05 07:13:35 +00:00
David Blaikie
543e02b438 [llvm-dwp] Support debug_tu_index
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254827 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-05 03:05:45 +00:00
Justin Bogner
51b567dc4b MC: Make sure to clear *all* of MCMachOStreamer's state
The CreatedADWARFSection flag was added in r232842, but isn't cleared
properly when resetting the streamer's state. Fix that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254571 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-03 00:52:20 +00:00
David Blaikie
5001b2a939 [llvm-dwp] Emit a rather fictional debug_cu_index
This is very rudimentary support for debug_cu_index, but it is enough to
allow llvm-dwarfdump to find the offsets for  contributions and
correctly dump debug_info.

It will need to actually find the real signature of the unit and build
the real hash table with the right number of buckets, as per the DWP
specification.

It will also need to be expanded to cover the tu_index as well.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254489 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-02 06:21:34 +00:00
Peter Collingbourne
41984d3288 MC: Simplify handling of temporary symbols in COFF writer.
The COFF object writer was previously adding unnecessary symbols to its
temporary data structures and cleaning them up later. This made the code
harder to understand and caused a bug (aliases classed as temporary symbols
would cause an assertion failure). A much simpler way of handling such
symbols is to ask the layout for their section-relative position when needed.

Tested with a bootstrap on Windows and by building Chrome.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254183 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-26 23:29:27 +00:00
Manuel Klimek
fc0981ecbc Fix bug where WinCOFFObjectWriter would assume starting from an empty output.
Starting on an input stream that is not at offset 0 would trigger the
assert in WinCOFFObjectWriter.cpp:1065:

  assert(getStream().tell() <= (*i)->Header.PointerToRawData &&
               "Section::PointerToRawData is insane!");

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253464 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-18 15:24:17 +00:00
Rafael Espindola
cfc74b78b1 Stop producing .data.rel sections.
If a section is rw, it is irrelevant if the dynamic linker will write to
it or not.

It looks like llvm implemented this because gcc was doing it. It looks
like gcc implemented this in the hope that it would put all the
relocated items close together and speed up the dynamic linker.

There are two problem with this:
* It doesn't work. Both bfd and gold will map .data.rel to .data and
  concatenate the input sections in the order they are seen.
* If we want a feature like that, it can be implemented directly in the
  linker since it knowns where the dynamic relocations are.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253436 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-18 06:02:15 +00:00
Oliver Stannard
99ab11202f [Assembler] Make fatal assembler errors non-fatal
Currently, if the assembler encounters an error after parsing (such as an
out-of-range fixup), it reports this as a fatal error, and so stops after the
first error. However, for most of these there is an obvious way to recover
after emitting the error, such as emitting the fixup with a value of zero. This
means that we can report on all of the errors in a file, not just the first
one. MCContext::reportError records the fact that an error was encountered, so
we won't actually emit an object file with the incorrect contents.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253328 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-17 10:00:43 +00:00
Oliver Stannard
43f1dd7a00 [Assembler] Allow non-fatal errors after parsing
This adds reportError to MCContext, which can be used as an alternative to
reportFatalError when the assembler wants to try to continue processing the
rest of the file after the error is reported, so that all of the errors ina
file can be reported. It records the fact that an error was encountered, so we
can avoid emitting an object file if any errors occurred.

This patch doesn't add any uses of this function (a later patch will convert
most uses of reportFatalError to use it), but there is a small functional
change: we use the SourceManager to print the error message, even if we have a
null SMLoc. This means that we get a SourceManager-style message, with the file
and line information shown as <unknown>, rather than the "LLVM ERROR" style
used by report_fatal_error.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253327 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-17 09:58:07 +00:00
Rafael Espindola
8dcaa9fb08 Drop prelink support.
The way prelink used to work was

* The compiler decides if a given section only has relocations that
are know to point to the same DSO. If so, it names it
.data.rel.ro.local<something>.
* The static linker puts all of these together.
* The prelinker program assigns addresses to each library and resolves
the local relocations.

There are many problems with this:
* It is incompatible with address space randomization.
* The information passed by the compiler is redundant. The linker
knows if a given relocation is in the same DSO or not. If could sort
by that if so desired.
* There are newer ways of speeding up DSO (gnu hash for example).
* Even if we want to implement this again in the compiler, the previous
  implementation is pretty broken. It talks about relocations that are
  "resolved by the static linker". If they are resolved, there are none
  left for the prelinker. What one needs to track is if an expression
  will require only dynamic relocations that point to the same DSO.

At this point it looks like the prelinker is an historical curiosity.
For example, fedora has retired it because it failed to build for two
releases
(http://pkgs.fedoraproject.org/cgit/prelink.git/commit/?id=eb43100a8331d91c801ee3dcdb0a0bb9babfdc1f)

This patch removes support for it. That is, it stops printing the
".local" sections.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253280 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-17 00:51:23 +00:00
Oliver Stannard
20bb042d74 [ARM,AArch64] Store source location of asm constant pool entries
Storing the source location of the expression that created a constant pool
entry allows us to emit better error messages if we later discover that the
expression cannot be represented by a relocation.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253220 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-16 16:25:47 +00:00
Bradley Smith
7c1b77248b [ARM] Introduce subtarget features per ARM architecture.
This allows for accurate architecture targeting as well as removing
duplicate information (hardcoded feature strings) from MCTargetDesc.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253196 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-16 11:10:19 +00:00
Akira Hatanaka
55c0268714 Reduce the size of MCRelaxableFragment.
MCRelaxableFragment previously kept a copy of MCSubtargetInfo and
MCInst to enable re-encoding the MCInst later during relaxation. A copy
of MCSubtargetInfo (instead of a reference or pointer) was needed
because the feature bits could be modified by the parser.

This commit replaces the MCSubtargetInfo copy in MCRelaxableFragment
with a constant reference to MCSubtargetInfo. The copies of
MCSubtargetInfo are kept in MCContext, and the target parsers are now
responsible for asking MCContext to provide a copy whenever the feature
bits of MCSubtargetInfo have to be toggled.
 
With this patch, I saw a 4% reduction in peak memory usage when I
compiled verify-uselistorder.lto.bc using llc.

rdar://problem/21736951

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253127 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-14 06:35:56 +00:00
Akira Hatanaka
ff528b6f03 [MCTargetAsmParser] Move the member varialbes that reference
MCSubtargetInfo in the subclasses into MCTargetAsmParser and define a
member function getSTI.

This is done in preparation for making changes to shrink the size of
MCRelaxableFragment. (see http://reviews.llvm.org/D14346).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253124 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-14 05:20:05 +00:00
Daniel Sanders
7056b68970 Implement .reloc (constant offset only) with support for R_MIPS_NONE and R_MIPS_32.
Summary:
Support for R_MIPS_NONE allows us to parse MIPS16's usage of .reloc.
R_MIPS_32 was included to be able to better test the directive.

Targets can add their relocations by overriding MCAsmBackend::getFixupKind().

Subscribers: grosbach, rafael, majnemer, dsanders, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252888 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-12 13:33:00 +00:00
Ahmed Bougacha
5d2b5c7d99 [MC] Use LShr for constant evaluation of ">>" on non-arm64 darwin.
Follow-up to r235963: this matches other assemblers and is less
unexpected (e.g. PR23227).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252681 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-11 00:51:36 +00:00
Colin LeMahieu
1539acf27c [AsmParser] Backends can parameterize ASM tokenization.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252439 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-09 00:31:07 +00:00
Colin LeMahieu
ca453aba57 [AsmParser] Provide target direct access to mnemonic token. Allow assignment parsing to be hooked by target. Allow target to specify if identifier is a label.
Differential Revision:  http://reviews.llvm.org/D14255

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252435 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-09 00:15:45 +00:00
Colin LeMahieu
84774ba424 [AsmParser] Allow tokens to be put back in to the token stream.
Differential Revision: http://reviews.llvm.org/D14252

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252432 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-08 23:48:23 +00:00
Rafael Espindola
012d959bc5 Bring r252305 back with a test fix.
We now create the .eh_frame section early, just like every other special
section.

This means that the special flags are visible in code that explicitly
asks for ".eh_frame".

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252313 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-06 15:30:45 +00:00
Rafael Espindola
f7b07fc667 Revert "Simplify the creation of .eh_frame/.debug_frame sections."
This reverts commit r252305.

Investigating a test failure.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252306 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-06 14:51:09 +00:00
Rafael Espindola
e48fa8c07e Simplify the creation of .eh_frame/.debug_frame sections.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252305 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-06 14:47:44 +00:00
Rafael Espindola
8ebb149114 git clang-format and fix variable names. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252304 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-06 14:12:17 +00:00
Rafael Espindola
20db473172 Use SHT_X86_64_UNWIND on every OS.
That is the ABI required type. Linkers still check the section name, so
everything should still work.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252300 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-06 13:35:35 +00:00
Rafael Espindola
ee3332fb71 Pass SectionStart directly to the one function that uses it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252299 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-06 13:14:59 +00:00
Rafael Espindola
bf27814484 Simplify the alignment handling in FDE emission.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252271 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-06 03:02:51 +00:00
Rafael Espindola
63ab0b3c13 Delete dead store. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252270 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-06 02:44:22 +00:00
Rafael Espindola
26697a6d48 Use a range loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252260 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-06 01:25:56 +00:00
Rafael Espindola
6e83ede607 Pass the streamer to the constructor instead of every other method. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252246 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-06 00:05:57 +00:00
Rafael Espindola
2dc6188e7a Simplify the constructor. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252243 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-05 23:55:51 +00:00
Rafael Espindola
618c595954 git-clang-format an area I am about to change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252241 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-05 23:54:18 +00:00