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

2812 Commits

Author SHA1 Message Date
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
Rafael Espindola
3882872dda Move AliasedSymbol to MachObjectWriter.
It was only used by MachO.
Part of pr19627.

llvm-svn: 235185
2015-04-17 12:28:43 +00:00
Rafael Espindola
62fe6f40a9 Add a proper fix for pr23025.
Instead of avoiding looking past every global symbol, only do so
if the symbol is in a comdat.

llvm-svn: 235181
2015-04-17 11:27:13 +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
Richard Trieu
5eedf6b231 Change range-based for-loops to be -Wrange-loop-analysis clean.
No functionality change.

llvm-svn: 234963
2015-04-15 01:21:15 +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
Petr Hosek
bbb668b972 [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

llvm-svn: 234714
2015-04-12 23:42:25 +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
a7ececf04c 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 :-)

llvm-svn: 234535
2015-04-09 21:06:08 +00:00
Rafael Espindola
58833403e8 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.

llvm-svn: 234515
2015-04-09 18:08:15 +00:00
Rafael Espindola
4fb23cdd75 Nothing inherits from the asm streamer.
Make that explicit and remove protected:

llvm-svn: 234484
2015-04-09 13:04:20 +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
Rafael Espindola
ec14e44418 Don't subtract the header size just to add it back.
llvm-svn: 234362
2015-04-07 21:51:41 +00:00
Rafael Espindola
8f03168a86 Remove dead code. NFC.
llvm-svn: 234352
2015-04-07 20:38:45 +00:00
Rafael Espindola
805877cf68 Remove intermediate variables.
The name of these variables was completely out of date with the information
stored in them.

llvm-svn: 234345
2015-04-07 19:17:47 +00:00
Rafael Espindola
15d6cc9af3 Remove unused argument.
llvm-svn: 234342
2015-04-07 19:00:17 +00:00
Rafael Espindola
6fa49967ca 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.

llvm-svn: 234174
2015-04-06 16:34:41 +00:00
Rafael Espindola
fd9484628a 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.

llvm-svn: 234169
2015-04-06 16:10:05 +00:00
Rafael Espindola
91f7164378 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.

llvm-svn: 234165
2015-04-06 15:27:57 +00:00
Rafael Espindola
5574b26c05 Store the sh_link of ARM_EXIDX directly in MCSectionELF.
This avoids some pretty horrible and broken name based section handling.

llvm-svn: 234142
2015-04-06 04:25:18 +00:00
Rafael Espindola
3d38779bcb 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:

llvm-svn: 234140
2015-04-06 03:16:51 +00:00
Rafael Espindola
61955a1dba 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.

llvm-svn: 234139
2015-04-06 03:09:30 +00:00
Rafael Espindola
afb68f165d Don't mix overload and default values.
It makes it hard to see which one is being called.

llvm-svn: 234100
2015-04-04 18:16:01 +00:00
Rafael Espindola
0601e2fab8 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.

llvm-svn: 234099
2015-04-04 18:02:01 +00:00
Peter Collingbourne
b2266efe11 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

llvm-svn: 233995
2015-04-03 01:46:11 +00:00
Peter Collingbourne
08b6124ef0 Revert r233595, "MC: For variable symbols, maintain MCSymbol::Section as a cache."
llvm-svn: 233898
2015-04-02 07:02:51 +00:00
Craig Topper
c61d7739c0 Don't print an error message when looking up the scheduling model if user specified -mcpu=help.
llvm-svn: 233884
2015-04-02 04:27:50 +00:00
David Majnemer
e7ba02b466 [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.

llvm-svn: 233767
2015-03-31 22:35:44 +00:00
Craig Topper
ebe4611b72 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.

llvm-svn: 233673
2015-03-31 05:52:57 +00:00
Eric Christopher
fdc8ea88a6 Replace the MCSubtargetInfo parameter with a Triple when creating
an MCInstPrinter. Update all callers and use where we wanted a Triple
previously.

llvm-svn: 233648
2015-03-31 00:10:04 +00:00
Eric Christopher
aebda1a8dc Rename const char *Triple argument to TT to avoid shadowing llvm::Triple.
llvm-svn: 233615
2015-03-30 22:31:14 +00:00
Peter Collingbourne
937a5dc713 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

llvm-svn: 233595
2015-03-30 20:41:21 +00:00
Yaron Keren
5d3d22628b Remove more superfluous .str() and replace std::string concatenation with Twine.
Following r233392, http://llvm.org/viewvc/llvm-project?rev=233392&view=rev.

llvm-svn: 233555
2015-03-30 15:42:36 +00:00
Rafael Espindola
b3d1830f61 Save a std::string.
The group names are always symbol names, so we can use a StringRef.

llvm-svn: 233545
2015-03-30 13:59:06 +00:00
Rafael Espindola
2ad29cd28b 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.

llvm-svn: 233539
2015-03-30 13:39:16 +00:00
Craig Topper
e151edea57 Convert feature strings to lowercase even if they have a '+'/'-' in front of them.
llvm-svn: 233475
2015-03-28 04:59:14 +00:00
Craig Topper
af2ca77cd6 Update comment to match code behavior.
llvm-svn: 233470
2015-03-28 03:24:19 +00:00
Rafael Espindola
d8d85455b3 Add two small structs for readability in place of std::pair and std::tuple. NFC.
llvm-svn: 233422
2015-03-27 21:34:24 +00:00
Akira Hatanaka
6a2e278ec7 [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.

llvm-svn: 233411
2015-03-27 20:36:02 +00:00
Rafael Espindola
7bdf3f2e35 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.

llvm-svn: 233380
2015-03-27 15:01:40 +00:00
Rafael Espindola
6888158ab6 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.

llvm-svn: 233318
2015-03-26 21:11:00 +00:00
Rafael Espindola
9448b64d9c clang-format bits of code to make another patch readable.
llvm-svn: 233203
2015-03-25 19:24:39 +00:00
Rafael Espindola
bfef1fc433 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).

llvm-svn: 233187
2015-03-25 13:16:53 +00:00
Rafael Espindola
249b878ed5 Fix warning on non-assert build.
llvm-svn: 233158
2015-03-25 00:45:41 +00:00
Rafael Espindola
b167831202 Produce an error instead of asserting on invalid .sleb128/.uleb128.
llvm-svn: 233155
2015-03-25 00:25:37 +00:00
Rafael Espindola
0f74449354 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.

llvm-svn: 233139
2015-03-24 23:48:44 +00:00
Rafael Espindola
4d759582ac Reset the CFA offset at the start of every FDE.
This fixes PR21515.

llvm-svn: 233120
2015-03-24 21:47:31 +00:00
Michael Kuperstein
1278cdeb94 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.

llvm-svn: 233068
2015-03-24 12:56:59 +00:00
Michael Kuperstein
c6ff005c9e 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

llvm-svn: 233055
2015-03-24 09:17:25 +00:00
Rafael Espindola
497f3f85f5 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.

llvm-svn: 233026
2015-03-23 21:22:04 +00:00
Rafael Espindola
d63afc96b5 Update variable name and reuse existing variable. NFC.
llvm-svn: 233014
2015-03-23 20:25:31 +00:00
Benjamin Kramer
6a9aa608f1 Re-sort includes with sort-includes.py and insert raw_ostream.h where it's used.
llvm-svn: 232998
2015-03-23 19:32:43 +00:00
Yaron Keren
da3be4cd62 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

llvm-svn: 232982
2015-03-23 18:35:01 +00:00
Rafael Espindola
06353319f0 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.

llvm-svn: 232842
2015-03-20 20:00:01 +00:00
Rafael Espindola
dcba9c010c 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.

llvm-svn: 232699
2015-03-19 01:50:16 +00:00
Rafael Espindola
5462815f32 Add a default implementation of createObjectStreamer.
This removes duplicated code from backends that don't need to do anything
fancy.

llvm-svn: 232658
2015-03-18 19:08:20 +00:00
Sid Manning
7d4dc00131 Add support for .ifnes psuedo-op.
llvm-svn: 232636
2015-03-18 14:20:54 +00:00
Yaron Keren
1bbcf55645 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.

llvm-svn: 232622
2015-03-18 10:17:07 +00:00
Rafael Espindola
fe83cbe6f6 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.

llvm-svn: 232535
2015-03-17 20:07:06 +00:00
Yaron Keren
167e29e58f 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.

llvm-svn: 232517
2015-03-17 18:55:30 +00:00
Yaron Keren
44f97787a1 Teach Twine to support SmallString.
Enable removing .str() member calls for these frequent cases. 

 http://reviews.llvm.org/D6372

llvm-svn: 232465
2015-03-17 09:51:17 +00:00
David Blaikie
9465551fc2 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.

llvm-svn: 232394
2015-03-16 18:06:57 +00:00
Gabor Horvath
13e6443c9c Fix build failure on MSVC compilers.
llvm-svn: 232368
2015-03-16 10:19:53 +00:00
Gabor Horvath
e3a1ff29d9 [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

llvm-svn: 232366
2015-03-16 09:53:42 +00:00
Frederic Riss
2065721bd8 [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.

llvm-svn: 232332
2015-03-15 20:45:39 +00:00
Daniel Sanders
b2b69459a8 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. 

llvm-svn: 232165
2015-03-13 12:45:09 +00:00
Jingyue Wu
764ac5a7c6 [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

llvm-svn: 232004
2015-03-12 01:50:30 +00:00
Rafael Espindola
4ef6243723 Don't print labels that on ELF are never used.
llvm-svn: 231904
2015-03-11 04:20:31 +00:00
Rafael Espindola
6932b2f8e9 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.

llvm-svn: 231898
2015-03-11 00:51:37 +00:00
Rafael Espindola
f82eef0fce 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.

llvm-svn: 231882
2015-03-10 23:06:32 +00:00
Rafael Espindola
96f9d3dd7f Create symbols marking the start of a section earlier.
This lets us pass the symbol to the constructor and avoid the mutable field.

This also opens the way for outputting the symbol only when needed, instead
of outputting them at the start of the file.

llvm-svn: 231859
2015-03-10 22:00:25 +00:00
Rafael Espindola
ca2a87b2b9 Move a non-trivial virtual function out of line.
llvm-svn: 231853
2015-03-10 21:35:16 +00:00
Rafael Espindola
525d4a858f clang-format code that is about to change.
llvm-svn: 231848
2015-03-10 21:16:18 +00:00
David Blaikie
350b9cbf65 Simplify expressions involving boolean constants with clang-tidy
Patch by Richard (legalize at xmission dot com).

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

llvm-svn: 231617
2015-03-09 01:57:13 +00:00
Benjamin Kramer
38504f768a Make constant arrays that are passed to functions as const.
In theory this allows the compiler to skip materializing the array on
the stack. In practice clang often fails to do that, but that's a
different story. NFC.

llvm-svn: 231571
2015-03-07 17:41:00 +00:00
Rafael Espindola
22f2e68861 Use the generic Lfunc_begin label on ppc.
This removes yet another custom label to mark the start of a function.

llvm-svn: 231390
2015-03-05 18:55:50 +00:00
Reid Kleckner
d0e0d012a0 Replace llvm.frameallocate with llvm.frameescape
Turns out it's pretty straightforward and simplifies the implementation.

Reviewers: andrew.w.kaylor

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

llvm-svn: 231386
2015-03-05 18:26:34 +00:00
Rafael Espindola
d3d45e96c8 Expand variables when evaluating absolute expressions.
This allows for variables to be used in .size.
This matches gnu AS functionality.

llvm-svn: 231295
2015-03-04 22:03:21 +00:00
Davide Italiano
02e7db63b7 [MC][Target] Implement support for R_X86_64_SIZE{32,64}.
Differential Revision:	D7990
Reviewed by:	rafael, majnemer

llvm-svn: 231216
2015-03-04 06:49:39 +00:00
Pete Cooper
a0f6bd0d3b Remove MCStreamer include which isn't used here. NFC
llvm-svn: 231195
2015-03-04 01:24:26 +00:00
Pete Cooper
b101a03b5e This file should always have included MCAssembler and not MCStreamer. NFC
llvm-svn: 231194
2015-03-04 01:24:24 +00:00
Pete Cooper
4a534a2133 Remove MCStreamer.h include from MCContext.h and explictly include it where necessary. NFC
llvm-svn: 231193
2015-03-04 01:24:11 +00:00
Paul Robinson
72c3b630b2 Remove useless .debug_macinfo section setup.
llvm-svn: 231001
2015-03-02 19:52:42 +00:00
Benjamin Kramer
91412d675f Make some non-constant static variables non-static or fully const.
Otherwise we have to emit thread-safe initialization for them. NFC.

llvm-svn: 230894
2015-03-01 18:09:56 +00:00
Rafael Espindola
95e3cfd5ed Centralize handling of the eh_begin and eh_end labels.
This removes a bit of duplicated code and more importantly, remembers the
labels so that they don't need to be looked up by name.

This in turn allows for any name to be used and avoids a crash if the name
we wanted was already taken.

llvm-svn: 230772
2015-02-27 18:18:39 +00:00
Frederic Riss
488b0c1489 [MC] Use the non-EH register mapping in the debug_frame section.
On 32bits x86 Darwin, the register mappings for the eh_frane and
debug_frame sections are different. Thus the same CFI instructions
should result in different registers in the object file. The
problem isn't target specific though, but it requires that the
mappings for EH register numbers be different from the standard
Dwarf one.

The patch looks a bit clumsy. LLVM uses the EH mapping as
canonical for everything frame related. Thus we need to do a
double conversion EH -> LLVM -> Non-EH, when emitting the
debug_frame section.

Fixes PR22363.

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

llvm-svn: 230670
2015-02-26 19:48:07 +00:00
NAKAMURA Takumi
35bc21d0bf Fix UTF8 chars to ASCII.
llvm-svn: 230479
2015-02-25 11:02:00 +00:00
David Majnemer
06399dc38d COFF: Add 'IMAGE_SCN_CNT_INITIALIZED_DATA' to all DWARF sections
The CodeView debug info section, .debug$S, also has this set.  MinGW
sets this bit for their DWARF sections as well.

llvm-svn: 230156
2015-02-22 02:35:27 +00:00
David Majnemer
35c2154c17 COFF: Consistently format the DWARF sections
llvm-svn: 230155
2015-02-22 02:35:22 +00:00
Benjamin Kramer
01ee460319 MC: Allow multiple comma-separated expressions on the .uleb128 directive.
For compatiblity with GNU as. Binutils documents this as
'.uleb128 expressions'. Subtle, isn't it?

llvm-svn: 229911
2015-02-19 20:24:04 +00:00