platform/upstream/llvm.git
7 years ago[debug info] Minor cleanup from D27170/r288399
David Blaikie [Thu, 1 Dec 2016 21:59:09 +0000 (21:59 +0000)]
[debug info] Minor cleanup from D27170/r288399

llvm-svn: 288421

7 years ago[SelectionDAG] getRawSubclassData should not return HasDebugValue.
Chih-Hung Hsieh [Thu, 1 Dec 2016 21:56:33 +0000 (21:56 +0000)]
[SelectionDAG] getRawSubclassData should not return HasDebugValue.

This change fixes a regression in r279537 and
makes getRawSubclassData behave like r279536.
Without this change, the fp128-g.ll test case will have an
infinite loop involving SoftenFloatRes_LOAD.

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

llvm-svn: 288420

7 years agoAdd an assert instead of ignoring an impossible condition.
Rui Ueyama [Thu, 1 Dec 2016 21:41:06 +0000 (21:41 +0000)]
Add an assert instead of ignoring an impossible condition.

llvm-svn: 288419

7 years agoAArch64: fix 128-bit cmpxchg at -O0 (again, again).
Tim Northover [Thu, 1 Dec 2016 21:31:59 +0000 (21:31 +0000)]
AArch64: fix 128-bit cmpxchg at -O0 (again, again).

This time the issue is fortunately just a simple mistake rather than a horrible
design spectre. I thought SUBS/SBCS provided sufficient NZCV flags for
comparing two 64-bit values, but they don't.

The fix is slightly clunkier in AArch64 because we can't use conditional
execution to emit a pair of CMPs. Traditionally an "icmp ne i128" would map to
an EOR/EOR/ORR/CBNZ, but that uses more registers so it's easier to go with a
CSET/CINC/CBNZ combination. Slightly less efficient, but this is -O0 anyway.

Thanks to Anton Korobeynikov for pointing out the issue.

llvm-svn: 288418

7 years agoImprove documentation on MSVC workaround for AlignedCharArray (NFC)
Mehdi Amini [Thu, 1 Dec 2016 20:54:29 +0000 (20:54 +0000)]
Improve documentation on MSVC workaround for AlignedCharArray (NFC)

The comment only mentioned "old version of MSVC".

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

llvm-svn: 288417

7 years agoFix unused variable warning in Release builds. NFC.
Benjamin Kramer [Thu, 1 Dec 2016 20:49:34 +0000 (20:49 +0000)]
Fix unused variable warning in Release builds. NFC.

llvm-svn: 288416

7 years ago[PR29121] Don't fold if it would produce atomic vector loads or stores
Philip Reames [Thu, 1 Dec 2016 20:17:06 +0000 (20:17 +0000)]
[PR29121] Don't fold if it would produce atomic vector loads or stores

The instcombine code which folds loads and stores into their use types can trip up if the use is a bitcast to a type which we can't directly load or store in the IR. In principle, such types shouldn't exist, but in practice they do today. This is a workaround to avoid a bug while we work towards the long term goal.

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

llvm-svn: 288415

7 years agoAdd a space in a run line. NFC.
George Burgess IV [Thu, 1 Dec 2016 20:16:56 +0000 (20:16 +0000)]
Add a space in a run line. NFC.

llvm-svn: 288414

7 years agoFactor out common parts of LVI and Float2Int into ConstantRange [NFCI]
Philip Reames [Thu, 1 Dec 2016 20:08:47 +0000 (20:08 +0000)]
Factor out common parts of LVI and Float2Int into ConstantRange [NFCI]

This just extracts out the transfer rules for constant ranges into a single shared point. As it happens, neither bit of code actually overlaps in terms of the handled operators, but with this change that could easily be tweaked in the future.

I also want to have this separated out to make experimenting with a eager value info implementation and possibly a ValueTracking-like fixed depth recursion peephole version. There's no reason all four of these can't share a common implementation which reduces the chances of bugs.

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

llvm-svn: 288413

7 years ago[SLP] Fix for PR6246: vectorization for scalar ops on vector elements.
Alexey Bataev [Thu, 1 Dec 2016 20:06:53 +0000 (20:06 +0000)]
[SLP] Fix for PR6246: vectorization for scalar ops on vector elements.

When trying to vectorize trees that start at insertelement instructions
function tryToVectorizeList() uses vectorization factor calculated as
MinVecRegSize/ScalarTypeSize. But sometimes it does not work as tree
cost for this fixed vectorization factor is too high.
Patch tries to improve the situation. It tries different vectorization
factors from max(PowerOf2Floor(NumberOfVectorizedValues),
MinVecRegSize/ScalarTypeSize) to MinVecRegSize/ScalarTypeSize and tries
to choose the best one.

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

llvm-svn: 288412

7 years ago[WebAssembly] Define more wasm binary encoding constants.
Dan Gohman [Thu, 1 Dec 2016 20:02:12 +0000 (20:02 +0000)]
[WebAssembly] Define more wasm binary encoding constants.

llvm-svn: 288411

7 years agoRefactored X86InterleavedAccess into a class. NFCI.
David L Kreitzer [Thu, 1 Dec 2016 19:56:39 +0000 (19:56 +0000)]
Refactored X86InterleavedAccess into a class. NFCI.

Patch by Farhana Aleen

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

llvm-svn: 288410

7 years agoUpdates file comments and variable names.
Rui Ueyama [Thu, 1 Dec 2016 19:45:22 +0000 (19:45 +0000)]
Updates file comments and variable names.

Use "color" instead of "group id" to describe the ICF algorithm.

llvm-svn: 288409

7 years ago[tablegen] Delete duplicates from a vector without skipping elements
Vedant Kumar [Thu, 1 Dec 2016 19:38:50 +0000 (19:38 +0000)]
[tablegen] Delete duplicates from a vector without skipping elements

Tablegen's -gen-instr-info pass has a bug in its emitEnums() routine.
The function intends for values in a vector to be deduplicated, but it
accidentally skips over elements after performing a deletion.

I think there are smarter ways of doing this deduplication, but we can
do that in a follow-up commit if there's interest. See the thread:
[PATCH] TableGen InstrMapping Bug fix.

Patch by Tyler Kenney!

llvm-svn: 288408

7 years agoRemove unused header, NFC.
Vedant Kumar [Thu, 1 Dec 2016 19:38:48 +0000 (19:38 +0000)]
Remove unused header, NFC.

llvm-svn: 288407

7 years agoSend compiler output to /dev/null in defsym.s test.
Artem Belevich [Thu, 1 Dec 2016 19:34:35 +0000 (19:34 +0000)]
Send compiler output to /dev/null in defsym.s test.

Fixes test failures if tests are run in a read-only source tree.

llvm-svn: 288406

7 years agoMove most EH from MachineModuleInfo to MachineFunction
Matthias Braun [Thu, 1 Dec 2016 19:32:15 +0000 (19:32 +0000)]
Move most EH from MachineModuleInfo to MachineFunction

Recommitting r288293 with some extra fixes for GlobalISel code.

Most of the exception handling members in MachineModuleInfo is actually
per function data (talks about the "current function") so it is better
to keep it at the function instead of the module.

This is a necessary step to have machine module passes work properly.

Also:
- Rename TidyLandingPads() to tidyLandingPads()
- Use doxygen member groups instead of "//===- EH ---"... so it is clear
  where a group ends.
- I had to add an ugly const_cast at two places in the AsmPrinter
  because the available MachineFunction pointers are const, but the code
  wants to call tidyLandingPads() in between
  (markFunctionEnd()/endFunction()).

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

llvm-svn: 288405

7 years ago[CodeGen][ARM] Make sure the value and type used to create a bitcast
Akira Hatanaka [Thu, 1 Dec 2016 19:25:14 +0000 (19:25 +0000)]
[CodeGen][ARM] Make sure the value and type used to create a bitcast
have the same size.

This fixes an asset that is triggered when an address of a boolean
variable is passed to __builtin_arm_ldrex or __builtin_arm_strex.

rdar://problem/29269006

llvm-svn: 288404

7 years agoHandle empty strings when looking for a CFString's encoding.
Sean Callanan [Thu, 1 Dec 2016 19:14:55 +0000 (19:14 +0000)]
Handle empty strings when looking for a CFString's encoding.
Should fix the bots.

llvm-svn: 288403

7 years agoFix a bug with llvm-size and the -m option with multiple files not printing the file...
Kevin Enderby [Thu, 1 Dec 2016 19:12:55 +0000 (19:12 +0000)]
Fix a bug with llvm-size and the -m option with multiple files not printing the file names.

llvm-svn: 288402

7 years agoFix unused variable warning in Release builds. NFC.
Benjamin Kramer [Thu, 1 Dec 2016 19:10:10 +0000 (19:10 +0000)]
Fix unused variable warning in Release builds. NFC.

llvm-svn: 288401

7 years agoFix module map to create a module for the configured header Config/abi-breaking.h
Mehdi Amini [Thu, 1 Dec 2016 19:08:38 +0000 (19:08 +0000)]
Fix module map to create a module for the configured header Config/abi-breaking.h

A client of a header that relies on ABI breaking should get the macro
exported there.
Before this, the unittest for Support/Error including Support/Error.h
didn't get the macro exported by the Support module, because the
latter only re-export its submodules and included module, not
textual headers.

Hopefully, it'll also fix the build with local submodule visibility,
since the LLVM_Utils contains two submodules: ADT and Support. They
both include abi-breaking.h that defines a symbol. The textual
inclusion lead to a double definition of the symbol which broke
the parent module.

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

llvm-svn: 288400

7 years agoThis change removes the dependency on DwarfDebug that was used for DW_FORM_ref_addr...
Greg Clayton [Thu, 1 Dec 2016 18:56:29 +0000 (18:56 +0000)]
This change removes the dependency on DwarfDebug that was used for DW_FORM_ref_addr by making a new DIEUnit class in DIE.cpp.

The DIEUnit class represents a compile or type unit and it owns the unit DIE as an instance variable. This allows anyone with a DIE, to get the unit DIE, and then get back to its DIEUnit without adding any new ivars to the DIE class. Why was this needed? The DIE class has an Offset that is always the CU relative DIE offset, not the "offset in debug info section" as was commented in the header file (the comment has been corrected). This is great for performance because most DIE references are compile unit relative and this means most code that accessed the DIE's offset didn't need to make it into a compile unit relative offset because it already was. When we needed to emit a DW_FORM_ref_addr though, we needed to find the absolute offset of the DIE by finding the DIE's compile/type unit. This class did have the absolute debug info/type offset and could be added to the CU relative offset to compute the absolute offset. With this change we can easily get back to a DIE's DIEUnit which will have this needed offset. Prior to this is required having a DwarfDebug and required calling:

DwarfCompileUnit *DwarfDebug::lookupUnit(const DIE *CU) const;
Now we can use the DIEUnit class to do so without needing DwarfDebug. All clients now use DIEUnit objects (the DwarfDebug stack and the DwarfLinker). A follow on patch for the DWARF generator will also take advantage of this.

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

llvm-svn: 288399

7 years ago[SLP] Fixed cost model for horizontal reduction.
Alexey Bataev [Thu, 1 Dec 2016 18:42:42 +0000 (18:42 +0000)]
[SLP] Fixed cost model for horizontal reduction.

Currently when cost of scalar operations is evaluated the vector type is
used for scalar operations. Patch fixes this issue and fixes evaluation
of the vector operations cost.
Several test showed that vector cost model is too optimistic. It
allowed vectorization of 8 or less add/fadd operations, though scalar
code is faster. Actually, only for 16 or more operations vector code
provides better performance.

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

llvm-svn: 288398

7 years ago[clang] Implement support for -defsym assembler option
Mandeep Singh Grang [Thu, 1 Dec 2016 18:42:16 +0000 (18:42 +0000)]
[clang] Implement support for -defsym assembler option

Summary:
Adds support for -Wa,-defsym,abc=1 option.

Related llvm patch: https://reviews.llvm.org/D26214

Reviewers: rafael, t.p.northover, colinl, echristo, compnerd, rengolin

Subscribers: mehdi_amini

Tags: #clang-c

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

llvm-svn: 288397

7 years ago[llvm] Implement support for -defsym assembler option
Mandeep Singh Grang [Thu, 1 Dec 2016 18:42:04 +0000 (18:42 +0000)]
[llvm] Implement support for -defsym assembler option

Summary:
Changes to llvm-mc to move common logic to separate function.

Related clang patch: https://reviews.llvm.org/D26213

Reviewers: rafael, t.p.northover, colinl, echristo, rengolin

Subscribers: llvm-commits

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

llvm-svn: 288396

7 years ago[X86][SSE] Moved shuffle mask widening/narrowing helper functions earlier in the...
Simon Pilgrim [Thu, 1 Dec 2016 18:27:19 +0000 (18:27 +0000)]
[X86][SSE] Moved shuffle mask widening/narrowing helper functions earlier in the file.

Will be necessary for a future patch.

llvm-svn: 288395

7 years agoswiftcc: Add an api to query whether a target ABI stores swifterror in a register
Arnold Schwaighofer [Thu, 1 Dec 2016 18:07:38 +0000 (18:07 +0000)]
swiftcc: Add an api to query whether a target ABI stores swifterror in a register

llvm-svn: 288394

7 years agoFix VS2015 build of clang-format-vsix by using NuGet to pull in required assemblies
Hans Wennborg [Thu, 1 Dec 2016 18:05:41 +0000 (18:05 +0000)]
Fix VS2015 build of clang-format-vsix by using NuGet to pull in required assemblies

Also added a gitignore to help track the right items to commit.

Patch by Antonio Maiorano <amaiorano@gmail.com>!

llvm-svn: 288393

7 years ago[libFuzzer] add a test for r288389 (-rss_limit_mb=0 means no limit).
Kostya Serebryany [Thu, 1 Dec 2016 18:02:07 +0000 (18:02 +0000)]
[libFuzzer] add a test for r288389 (-rss_limit_mb=0 means no limit).

llvm-svn: 288392

7 years ago[SystemZ] Fix fallout from r288374
Ulrich Weigand [Thu, 1 Dec 2016 18:00:50 +0000 (18:00 +0000)]
[SystemZ] Fix fallout from r288374

Avoid undefined behavior due to too-large shift count.

llvm-svn: 288391

7 years ago[AsmParser] Diagnose empty symbol for .set directive
Weiming Zhao [Thu, 1 Dec 2016 18:00:36 +0000 (18:00 +0000)]
[AsmParser] Diagnose empty symbol for .set directive

Summary: Diagnose empty symbol to avoid hitting assertion in MCContext::getOrCreateSymbol

Reviewers: eli.friedman, rengolin

Subscribers: llvm-commits

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

llvm-svn: 288390

7 years ago[libFuzzer] treat -rss_limit_mb=0 as no limit
Kostya Serebryany [Thu, 1 Dec 2016 17:56:15 +0000 (17:56 +0000)]
[libFuzzer] treat -rss_limit_mb=0 as no limit

llvm-svn: 288389

7 years ago[TableGen] Ignore fake args for parsing-related arg counts.
George Burgess IV [Thu, 1 Dec 2016 17:52:39 +0000 (17:52 +0000)]
[TableGen] Ignore fake args for parsing-related arg counts.

We should complain about the following:

```
void foo() __attribute__((unavailable("a", "b")));
```

Instead, we currently just ignore "b". (...We also end up ignoring "a",
because we assume elsewhere that this attribute can only have 1 or 0
args.)

This happens because `unavailable` has a fake enum arg, and
`AttributeList::{getMinArgs,getMaxArgs}` include fake args in their
counts.

llvm-svn: 288388

7 years agoRemove another hack from the android toolchain file
Pavel Labath [Thu, 1 Dec 2016 17:48:51 +0000 (17:48 +0000)]
Remove another hack from the android toolchain file

This is no longer an issue with recent versions of the android ndk.

llvm-svn: 288387

7 years agoHandle UTF-16 and UTF-32 constant CFStrings
Sean Callanan [Thu, 1 Dec 2016 17:46:51 +0000 (17:46 +0000)]
Handle UTF-16 and UTF-32 constant CFStrings

We have a longstanding issue where the expression parser does not handle wide CFStrings (e.g., @"凸凹") correctly, producing the useless error message

Internal error [IRForTarget]: An Objective-C constant string's string initializer is not an array
error: warning: expression result unused
error: The expression could not be prepared to run in the target

This is just a side effect of the fact that we don't handle wide string constants when converting these to CFStringCreateWithBytes. That function takes the string's encoding as an argument, so I made it work and added a testcase.

https://reviews.llvm.org/D27291
<rdar://problem/13190557>

llvm-svn: 288386

7 years agoRecommit r287403 (reverted in r287804): [lit] When setting SDKROOT on Darwin, use...
Kuba Mracek [Thu, 1 Dec 2016 17:45:22 +0000 (17:45 +0000)]
Recommit r287403 (reverted in r287804): [lit] When setting SDKROOT on Darwin, use '--sdk macosx' to find the right SDK path.

This shouls now be safe and not break any more bots.  It's strictly better to use '--sdk macosx', otherwise xcrun can return weird things for example when you have Command Line Tools or the SDK installed into '/'.

llvm-svn: 288385

7 years agoAdd a blank line to make sphinx happy.
Malcolm Parsons [Thu, 1 Dec 2016 17:38:54 +0000 (17:38 +0000)]
Add a blank line to make sphinx happy.

llvm-svn: 288384

7 years agoProtect sequences test under libcpp-no-exceptions
Roger Ferrer Ibanez [Thu, 1 Dec 2016 17:36:41 +0000 (17:36 +0000)]
Protect sequences test under libcpp-no-exceptions

Replace throw with TEST_THROW and protect tests that do throw. Also add missing assert(false).

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

llvm-svn: 288383

7 years agoProtect futures test under libcpp-no-exceptions
Roger Ferrer Ibanez [Thu, 1 Dec 2016 17:34:57 +0000 (17:34 +0000)]
Protect futures test under libcpp-no-exceptions

Skip tests that expect an exception be thrown.

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

llvm-svn: 288382

7 years ago[GVN, OptDiag] Print the interesting instructions involved in missed load-elimination
Adam Nemet [Thu, 1 Dec 2016 17:34:50 +0000 (17:34 +0000)]
[GVN, OptDiag] Print the interesting instructions involved in missed load-elimination

[recommitting after the fix in r288307]

This includes the intervening store and the load/store that we're trying
to forward from in the optimization remark for the missed load
elimination.

This is hooked up under a new mode in ORE that allows for compile-time
budget for a bit more analysis to print more insightful messages.  This
mode is currently enabled for -fsave-optimization-record (-Rpass is
trickier since it is controlled in the front-end).

With this we can now print the red remark in http://lab.llvm.org:8080/artifacts/opt-view_test-suite/build/SingleSource/Benchmarks/Dhrystone/CMakeFiles/dry.dir/html/_org_test-suite_SingleSource_Benchmarks_Dhrystone_dry.c.html#L446

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

llvm-svn: 288381

7 years ago[GVN, OptDiag] Include the value that is forwarded in load elimination
Adam Nemet [Thu, 1 Dec 2016 17:34:44 +0000 (17:34 +0000)]
[GVN, OptDiag] Include the value that is forwarded in load elimination

[recommitting after the fix in r288307]

This requires some changes to the opt-diag API.  Hal and I have
discussed this at the Dev Meeting and came up with a streaming delimiter
(setExtraArgs) to solve this.

Arguments after this delimiter are only included in the optimization
records and not in the remarks printed in the compiler output.  (Note,
how in the test the content of the YAML file changes but the remarks on
the compiler output don't.)

This implements the green GVN message with a bug fix at line
http://lab.llvm.org:8080/artifacts/opt-view_test-suite/build/SingleSource/Benchmarks/Dhrystone/CMakeFiles/dry.dir/html/_org_test-suite_SingleSource_Benchmarks_Dhrystone_dry.c.html#L446

The fix is that now we properly include the constant value in the
message: "load of type i32 eliminated in favor of 7"

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

llvm-svn: 288380

7 years agoProtect optional test under libcpp-no-exceptions
Roger Ferrer Ibanez [Thu, 1 Dec 2016 17:33:36 +0000 (17:33 +0000)]
Protect optional test under libcpp-no-exceptions

Replace throw with TEST_THROW and skip tests that throw exceptions

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

llvm-svn: 288379

7 years agoProtect std::ostream::sentry test under libcpp-no-exceptions
Roger Ferrer Ibanez [Thu, 1 Dec 2016 17:31:38 +0000 (17:31 +0000)]
Protect std::ostream::sentry test under libcpp-no-exceptions

Skip test that throws an exception.

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

llvm-svn: 288378

7 years ago[SLP] Additional tests with the cost of vector operations.
Alexey Bataev [Thu, 1 Dec 2016 17:26:54 +0000 (17:26 +0000)]
[SLP] Additional tests with the cost of vector operations.

llvm-svn: 288377

7 years ago[change-namespace] don't generate replacements for files that don't match file pattern.
Eric Liu [Thu, 1 Dec 2016 17:25:55 +0000 (17:25 +0000)]
[change-namespace] don't generate replacements for files that don't match file pattern.

Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 288376

7 years ago[clang-tidy] Rename modernize-use-default to modernize-use-equals-default
Malcolm Parsons [Thu, 1 Dec 2016 17:24:42 +0000 (17:24 +0000)]
[clang-tidy] Rename modernize-use-default to modernize-use-equals-default

Reviewers: angelgarcia, aaron.ballman, alexfh

Subscribers: JDevlieghere, Prazek, mgorny, cfe-commits

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

llvm-svn: 288375

7 years ago[SystemZ] Fix applyFixup for 12-bit fixups
Ulrich Weigand [Thu, 1 Dec 2016 17:10:27 +0000 (17:10 +0000)]
[SystemZ] Fix applyFixup for 12-bit fixups

Now that we have fixups that only fill parts of a byte, it turns
out we have to mask off the bits outside the fixup area when
applying them.  Failing to do so caused invalid object code to
be emitted for bprp with a negative 12-bit displacement.

llvm-svn: 288374

7 years agoParallelize ICF to make LLD's ICF really fast.
Rui Ueyama [Thu, 1 Dec 2016 17:09:04 +0000 (17:09 +0000)]
Parallelize ICF to make LLD's ICF really fast.

ICF is short for Identical Code Folding. It is a size optimization to
identify two or more functions that happened to have the same contents
to merges them. It usually reduces output size by a few percent.

ICF is slow because it is computationally intensive process. I tried
to paralellize it before but failed because I couldn't make a
parallelized version produce consistent outputs. Although it didn't
create broken executables, every invocation of the linker generated
slightly different output, and I couldn't figure out why.

I think I now understand what was going on, and also came up with a
simple algorithm to fix it. So is this patch.

The result is very exciting. Chromium for example has 780,662 input
sections in which 20,774 are reducible by ICF. LLD previously took
7.980 seconds for ICF. Now it finishes in 1.065 seconds.

As a result, LLD can now link a Chromium binary (output size 1.59 GB)
in 10.28 seconds on my machine with ICF enabled. Compared to gold
which takes 40.94 seconds to do the same thing, this is an amazing
number.

From here, I'll describe what we are doing for ICF, what was the
previous problem, and what I did in this patch.

In ICF, two sections are considered identical if they have the same
section flags, section data, and relocations. Relocations are tricky,
becuase two relocations are considered the same if they have the same
relocation type, values, and if they point to the same section _in
terms of ICF_.

Here is an example. If foo and bar defined below are compiled to the
same machine instructions, ICF can (and should) merge the two,
although their relocations point to each other.

  void foo() { bar(); }
  void bar() { foo(); }

This is not an easy problem to solve.

What we are doing in LLD is some sort of coloring algorithm. We color
non-identical sections using different colors repeatedly, and sections
in the same color when the algorithm terminates are considered
identical. Here is the details:

  1. First, we color all sections using their hash values of section
  types, section contents, and numbers of relocations. At this moment,
  relocation targets are not taken into account. We just color
  sections that apparently differ in different colors.

  2. Next, for each color C, we visit sections having color C to see
  if their relocations are the same. Relocations are considered equal
  if their targets have the same color. We then recolor sections that
  have different relocation targets in new colors.

  3. If we recolor some section in step 2, relocations that were
  previously pointing to the same color targets may now be pointing to
  different colors. Therefore, repeat 2 until a convergence is
  obtained.

Step 2 is a heavy operation. For Chromium, the first iteration of step
2 takes 2.882 seconds, and the second iteration takes 1.038 seconds,
and in total it needs 23 iterations.

Parallelizing step 1 is easy because we can color each section
independently. This patch does that.

Parallelizing step 2 is tricky. We could work on each color
independently, but we cannot recolor sections in place, because it
will break the invariance that two possibly-identical sections must
have the same color at any moment.

Consider sections S1, S2, S3, S4 in the same color C, where S1 and S2
are identical, S3 and S4 are identical, but S2 and S3 are not. Thread
A is about to recolor S1 and S2 in C'. After thread A recolor S1 in
C', but before recolor S2 in C', other thread B might observe S1 and
S2. Then thread B will conclude that S1 and S2 are different, and it
will split thread B's sections into smaller groups wrongly. Over-
splitting doesn't produce broken results, but it loses a chance to
merge some identical sections. That was the cause of indeterminism.

To fix the problem, I made sections have two colors, namely current
color and next color. At the beginning of each iteration, both colors
are the same. Each thread reads from current color and writes to next
color. In this way, we can avoid threads from reading partial
results. After each iteration, we flip current and next.

This is a very simple solution and is implemented in less than 50
lines of code.

I tested this patch with Chromium and confirmed that this parallelized
ICF produces the identical output as the non-parallelized one.

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

llvm-svn: 288373

7 years ago[analyzer] Drop explicit mention of range constraint solver
Dominic Chen [Thu, 1 Dec 2016 17:06:39 +0000 (17:06 +0000)]
[analyzer] Drop explicit mention of range constraint solver

Summary: The basic constraint solver was dropped in rL162384, leaving the range constraint solver as the default and only constraint solver. Explicitly specifying it is unnecessary, and makes it difficult to test with other solver backends.

Reviewers: zaks.anna, dcoughlin

Subscribers: cfe-commits

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

llvm-svn: 288372

7 years agoRevert "[SLP] Additional tests with the cost of vector operations."
Alexey Bataev [Thu, 1 Dec 2016 16:45:04 +0000 (16:45 +0000)]
Revert "[SLP] Additional tests with the cost of vector operations."

This reverts commit a61718435fc4118c82f8aa6133fd81f803789c1e.

llvm-svn: 288371

7 years ago[GVN] Basic optimization remark support
Adam Nemet [Thu, 1 Dec 2016 16:40:32 +0000 (16:40 +0000)]
[GVN] Basic optimization remark support

[recommitting after the fix in r288307]

Follow-on patches will add more interesting cases.

The goal of this patch-set is to get the GVN messages printed in
opt-viewer from Dhrystone as was presented in my Dev Meeting talk.  This
is the optimization view for the function (the last remark in the
function has a bug which is fixed in this series):
http://lab.llvm.org:8080/artifacts/opt-view_test-suite/build/SingleSource/Benchmarks/Dhrystone/CMakeFiles/dry.dir/html/_org_test-suite_SingleSource_Benchmarks_Dhrystone_dry.c.html#L430

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

llvm-svn: 288370

7 years ago[SLP] Additional tests with the cost of vector operations.
Alexey Bataev [Thu, 1 Dec 2016 16:11:48 +0000 (16:11 +0000)]
[SLP] Additional tests with the cost of vector operations.

llvm-svn: 288369

7 years agofixed type in Windows-specific code
Andrey Churbanov [Thu, 1 Dec 2016 16:08:52 +0000 (16:08 +0000)]
fixed type in Windows-specific code

llvm-svn: 288368

7 years ago[X86][SSE] Classify AND bitmasks as variable shuffle masks
Simon Pilgrim [Thu, 1 Dec 2016 16:00:14 +0000 (16:00 +0000)]
[X86][SSE] Classify AND bitmasks as variable shuffle masks

They are loading the bitmasks from the constant pool so the cost is similar to loading a shuffle mask.

llvm-svn: 288367

7 years agoAdds hasUnqualifiedDesugaredType to allow matching through type sugar.
Manuel Klimek [Thu, 1 Dec 2016 15:45:06 +0000 (15:45 +0000)]
Adds hasUnqualifiedDesugaredType to allow matching through type sugar.

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

llvm-svn: 288366

7 years ago[X86][SSE] Add support for combining AND bitmasks to shuffles.
Simon Pilgrim [Thu, 1 Dec 2016 15:41:40 +0000 (15:41 +0000)]
[X86][SSE] Add support for combining AND bitmasks to shuffles.

llvm-svn: 288365

7 years agoRemove iostream include from WasmObjectFile
Pavel Labath [Thu, 1 Dec 2016 15:20:34 +0000 (15:20 +0000)]
Remove iostream include from WasmObjectFile

The file does not seems to use c++ iostreams (and is is llvm policy to avoid
that). Committing as obvious.

llvm-svn: 288364

7 years ago[LMT] Restrict nop length to one
Asaf Badouh [Thu, 1 Dec 2016 15:19:10 +0000 (15:19 +0000)]
[LMT] Restrict nop length to one
not all lakemont MCU support long nop.
we can't assume we can generate long nop by default for MCU.

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

llvm-svn: 288363

7 years ago[X86][SSE] Tidied up filecheck prefixes for uitofp fast-math tests.
Simon Pilgrim [Thu, 1 Dec 2016 14:56:48 +0000 (14:56 +0000)]
[X86][SSE] Tidied up filecheck prefixes for uitofp fast-math tests.

They should be in 'narrowing' order from common to more specific test prefixes.

llvm-svn: 288338

7 years agoSilence GCC's -Wenum-compare after r288335 in the same way it is done
Daniel Jasper [Thu, 1 Dec 2016 14:33:50 +0000 (14:33 +0000)]
Silence GCC's -Wenum-compare after r288335 in the same way it is done
in X86FastISel.cpp.

llvm-svn: 288337

7 years ago[SelectionDAG] Rename and clarify visitFMULForFMADCombine (NFC)
Nicolai Haehnle [Thu, 1 Dec 2016 14:04:13 +0000 (14:04 +0000)]
[SelectionDAG] Rename and clarify visitFMULForFMADCombine (NFC)

Summary: Suggested by @spatel in D26602.

Reviewers: spatel, hfinkel

Subscribers: spatel, llvm-commits

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

llvm-svn: 288336

7 years ago[X86][SSE] Add support for combining target shuffles to AND bitmasks.
Simon Pilgrim [Thu, 1 Dec 2016 13:47:02 +0000 (13:47 +0000)]
[X86][SSE] Add support for combining target shuffles to AND bitmasks.

llvm-svn: 288335

7 years ago[ObjC] Avoid a @try/@finally/@autoreleasepool fixit when parsing an expression
Alex Lorenz [Thu, 1 Dec 2016 12:14:38 +0000 (12:14 +0000)]
[ObjC] Avoid a @try/@finally/@autoreleasepool fixit when parsing an expression

This patch ensures that the typo fixit for the @try/@finally/@autoreleasepool {}
directive is shown only when we're parsing an actual statement where such
directives can actually be present.

rdar://19669565

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

llvm-svn: 288334

7 years ago[X86][SSE] Add support for combining ISD::AND with shuffles.
Simon Pilgrim [Thu, 1 Dec 2016 11:52:37 +0000 (11:52 +0000)]
[X86][SSE] Add support for combining ISD::AND with shuffles.

Attempts to convert an AND with a vector of 255 or 0 values into a shuffle (blend) mask.

llvm-svn: 288333

7 years ago[OpenCL] Refactor read_only/write_only pipes.
Joey Gouly [Thu, 1 Dec 2016 11:30:49 +0000 (11:30 +0000)]
[OpenCL] Refactor read_only/write_only pipes.

This adds the access qualifier to the Pipe Type, rather than using a class
hierarchy.

It also fixes mergeTypes for Pipes, by disallowing merges. Only identical
pipe types can be merged. The test case in invalid-pipes-cl2.0.cl is added
to check that.

llvm-svn: 288332

7 years agoRemove a hack from the Android toolchain file
Pavel Labath [Thu, 1 Dec 2016 11:30:08 +0000 (11:30 +0000)]
Remove a hack from the Android toolchain file

Summary:
The fix is to make sure llvm does not pull in dlopen() in configurations where it
is not available.

Reviewers: tberghammer, beanz

Subscribers: danalbert, srhines, lldb-commits, mgorny

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

llvm-svn: 288331

7 years ago[X86][SSE] Added tests showing missed combines of shuffles with ANDs.
Simon Pilgrim [Thu, 1 Dec 2016 11:26:07 +0000 (11:26 +0000)]
[X86][SSE] Added tests showing missed combines of shuffles with ANDs.

llvm-svn: 288330

7 years ago[NFC] Check for feasibility prior to the profitability check
Johannes Doerfert [Thu, 1 Dec 2016 11:12:14 +0000 (11:12 +0000)]
[NFC] Check for feasibility prior to the profitability check

Feasibility is checked late on its own but early it is hidden behind
the "PollyProcessUnprofitable" guard. This change will make sure we opt
out early if the runtime context is infeasible anyway.

llvm-svn: 288329

7 years ago[FIX] Do not try to hoist obviously overwritten loads
Johannes Doerfert [Thu, 1 Dec 2016 11:10:45 +0000 (11:10 +0000)]
[FIX] Do not try to hoist obviously overwritten loads

llvm-svn: 288328

7 years agoFix crash with unsupported architectures in Linux/Gnu target triples.
Florian Hahn [Thu, 1 Dec 2016 11:02:59 +0000 (11:02 +0000)]
Fix crash with unsupported architectures in Linux/Gnu target triples.

Summary: This patch adds a check and an error message to gnutools::Linker::ConstructJob in case the architecture is not supported. For most other operating systems, the error message is created in lib/Basic/Targets.cpp:AllocateTarget, but when construction the linker arguments for the gnutools linker a supported architecture is required.

Reviewers: rafael, joerg, echristo

Subscribers: mehdi_amini, joerg, dschuff, cfe-commits

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

llvm-svn: 288327

7 years agoUse Timeout<> in Process::RunThreadPlan
Pavel Labath [Thu, 1 Dec 2016 10:57:30 +0000 (10:57 +0000)]
Use Timeout<> in Process::RunThreadPlan

Summary:
Since the function is way too big already, I tried at least to factor out the
timeout computation stuff into a separate function. I've tried to make the new
code semantically equivalent, and it also makes sense when I look at it as a done
deal.

Reviewers: jingham

Subscribers: lldb-commits

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

llvm-svn: 288326

7 years ago[SCCP] Switch over to DEBUG() and drop an #ifdef.
Davide Italiano [Thu, 1 Dec 2016 08:48:14 +0000 (08:48 +0000)]
[SCCP] Switch over to DEBUG() and drop an #ifdef.

llvm-svn: 288325

7 years ago[SCCP] Prefer `auto` when the type is obvious. NFCI.
Davide Italiano [Thu, 1 Dec 2016 08:36:12 +0000 (08:36 +0000)]
[SCCP] Prefer `auto` when the type is obvious. NFCI.

llvm-svn: 288324

7 years agoAdd newline at end of debug print
Tobias Grosser [Thu, 1 Dec 2016 08:08:47 +0000 (08:08 +0000)]
Add newline at end of debug print

In '[DBG] Allow to emit the RTC value at runtime' the diagnostics were printed
without a newline at the end of each diagnostic. We add such a newline to
improve readability.

llvm-svn: 288323

7 years agoTemporarily Revert "Move most EH from MachineModuleInfo to MachineFunction"
Eric Christopher [Thu, 1 Dec 2016 07:50:12 +0000 (07:50 +0000)]
Temporarily Revert "Move most EH from MachineModuleInfo to MachineFunction"

This apprears to have broken the global isel bot:
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-globalisel_build/5174/console

This reverts commit r288293.

llvm-svn: 288322

7 years agoObject: Set SF_Indirect in ModuleSymbolTable.
Peter Collingbourne [Thu, 1 Dec 2016 07:00:35 +0000 (07:00 +0000)]
Object: Set SF_Indirect in ModuleSymbolTable.

This lets us remove the last use of IRObjectFile::getSymbolGV() in llvm-nm.

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

llvm-svn: 288321

7 years agoObject: Add SF_Executable symbol flag.
Peter Collingbourne [Thu, 1 Dec 2016 06:53:47 +0000 (06:53 +0000)]
Object: Add SF_Executable symbol flag.

This allows us to remove a few uses of IRObjectFile::getSymbolGV() in
llvm-nm.

While here change host-dependent logic in llvm-nm to target-dependent
logic.

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

llvm-svn: 288320

7 years agoObject: Extract a ModuleSymbolTable class from IRObjectFile.
Peter Collingbourne [Thu, 1 Dec 2016 06:51:47 +0000 (06:51 +0000)]
Object: Extract a ModuleSymbolTable class from IRObjectFile.

This class represents a symbol table built from in-memory IR. It provides
access to GlobalValues and should only be used if such access is required
(e.g. in the LTO implementation). We will eventually change IRObjectFile
to read from a bitcode symbol table rather than using ModuleSymbolTable,
so it would not be able to expose the module.

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

llvm-svn: 288319

7 years agoBitcode: The index used by ModuleSummaryIndexBitcodeReader is now required, so make...
Peter Collingbourne [Thu, 1 Dec 2016 06:21:08 +0000 (06:21 +0000)]
Bitcode: The index used by ModuleSummaryIndexBitcodeReader is now required, so make it a reference. NFCI.

llvm-svn: 288318

7 years agoBitcode: Introduce BitcodeModule::{has,get}Summary().
Peter Collingbourne [Thu, 1 Dec 2016 06:00:53 +0000 (06:00 +0000)]
Bitcode: Introduce BitcodeModule::{has,get}Summary().

These are equivalent to hasGlobalValueSummary() and getModuleSummaryIndex().

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

llvm-svn: 288317

7 years agoLTO: Remove ModuleLoader, make loadModuleFromBuffer static and move into its only...
Peter Collingbourne [Thu, 1 Dec 2016 05:52:32 +0000 (05:52 +0000)]
LTO: Remove ModuleLoader, make loadModuleFromBuffer static and move into its only client, ThinLTOCodeGenerator.

This is no longer the recommended way to load modules for importing, so it should not be public API.

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

llvm-svn: 288316

7 years agoBitcode: Correctly handle Fixed and VBR arrays in BitstreamCursor::skipRecord().
Peter Collingbourne [Thu, 1 Dec 2016 05:47:58 +0000 (05:47 +0000)]
Bitcode: Correctly handle Fixed and VBR arrays in BitstreamCursor::skipRecord().

The assertions were wrong; we need to call getEncodingData() on the element,
not the array. While here, simplify the skipRecord() implementation for Fixed
and Char6 arrays. This is tested by the code I added to llvm-bcanalyzer
which makes sure that we can skip any record.

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

llvm-svn: 288315

7 years agoAdd `isRelExprOneOf` helper
Sean Silva [Thu, 1 Dec 2016 05:43:48 +0000 (05:43 +0000)]
Add `isRelExprOneOf` helper

In various places in LLD's hot loops, we have expressions of the form
"E == R_FOO || E == R_BAR || ..." (E is a RelExpr).

Some of these expressions are quite long, and even though they usually go just
a very small number of ways and so should be well predicted, they can still
occupy branch predictor resources harming other parts of the code, or they
won't be predicted well if they overflow branch predictor resources or if the
branches are too dense and the branch predictor can't track them all (the
compiler can in theory avoid this, at a cost in text size). And some of these
expressions are so large and executed so frequently that even when
well-predicted they probably still have a nontrivial cost.

This speedup should be pretty portable. The cost of these simple bit tests is
independent of:

- the target we are linking for
- the distribution of RelExpr's for a given link (which can depend on how the
  input files were compiled)
- what compiler was used to compile LLD (it is just a simple bit test;
  hopefully the compiler gets it right!)
- adding new target-dependent relocations (e.g. needsPlt doesn't pay any extra
  cost checking R_PPC_PLT_OPD on x86-64 builds)

I did some rough measurements on clang-fsds and this patch gives over about 4%
speedup for a regular -O1 link, about 2.5% for -O3 --gc-sections and over 5%
for -O0. Sorry, I don't have my current machine set up for doing really
accurate measurements right now.

This also is just a bit cleaner. Thanks for Joerg for suggesting for
this approach.

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

llvm-svn: 288314

7 years agoTeach ConstantBuilder how to emit a reference to the current position
John McCall [Thu, 1 Dec 2016 05:33:30 +0000 (05:33 +0000)]
Teach ConstantBuilder how to emit a reference to the current position
that will be filled in when the initializer is set.

llvm-svn: 288313

7 years agoRevert previous whitespace change
Philip Reames [Thu, 1 Dec 2016 04:37:35 +0000 (04:37 +0000)]
Revert previous whitespace change

llvm-svn: 288312

7 years agoTest commit of whitespace to check permissions.
Philip Reames [Thu, 1 Dec 2016 04:37:09 +0000 (04:37 +0000)]
Test commit of whitespace to check permissions.

llvm-svn: 288311

7 years agoSimplify ScriptParser.
Rui Ueyama [Thu, 1 Dec 2016 04:36:54 +0000 (04:36 +0000)]
Simplify ScriptParser.

 - Rename currentBuffer -> getCurrentMB to start it with verb.
 - Simplify containsString.
 - Add llvm_unreachable at end of getCurrentMB.

llvm-svn: 288310

7 years agoDo not name a variable Ret which is not a return value.
Rui Ueyama [Thu, 1 Dec 2016 04:36:51 +0000 (04:36 +0000)]
Do not name a variable Ret which is not a return value.

llvm-svn: 288309

7 years agoMake get{Line,Column}Number members of StringParser.
Rui Ueyama [Thu, 1 Dec 2016 04:36:49 +0000 (04:36 +0000)]
Make get{Line,Column}Number members of StringParser.

This patch also renames currentLocation getCurrentLocation.

llvm-svn: 288308

7 years ago[GVN] When merging blocks update LoopInfo if it's available
Adam Nemet [Thu, 1 Dec 2016 03:56:43 +0000 (03:56 +0000)]
[GVN] When merging blocks update LoopInfo if it's available

If LoopInfo is available during GVN, BasicAA will use it.  However
MergeBlockIntoPredecessor does not update LI as it merges blocks.

This didn't use to cause problems because LI was freed before
GVN/BasicAA.  Now with OptimizationRemarkEmitter, the lifetime of LI is
extended so LI needs to be kept up-to-date during GVN.

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

llvm-svn: 288307

7 years agoSplit getPos into getLineNumber and getColumnNumber.
Rui Ueyama [Thu, 1 Dec 2016 03:56:27 +0000 (03:56 +0000)]
Split getPos into getLineNumber and getColumnNumber.

llvm-svn: 288306

7 years agoP0012R1: add Itanium ABI support for throwing non-noexcept function pointers and...
Richard Smith [Thu, 1 Dec 2016 03:32:42 +0000 (03:32 +0000)]
P0012R1: add Itanium ABI support for throwing non-noexcept function pointers and catching as noexcept.

llvm-svn: 288305

7 years agoRevert r285664, cxx-abi-dev chose to go in a different direction for the ABI here.
Richard Smith [Thu, 1 Dec 2016 03:04:07 +0000 (03:04 +0000)]
Revert r285664, cxx-abi-dev chose to go in a different direction for the ABI here.

llvm-svn: 288304

7 years agoUse trigrams to speed up SpecialCaseList.
Ivan Krasin [Thu, 1 Dec 2016 02:54:54 +0000 (02:54 +0000)]
Use trigrams to speed up SpecialCaseList.

Summary:
it's often the case when the rules in the SpecialCaseList
are of the form hel.o*bar. That gives us a chance to build
trigram index to quickly discard 99% of inputs without
running a full regex. A similar idea was used in Google Code Search
as described in the blog post:
https://swtch.com/~rsc/regexp/regexp4.html

The check is defeated, if there's at least one regex
more complicated than that. In this case, all inputs
will go through the regex. That said, the real-world
rules are often simple or can be simplied. That considerably
speeds up compiling Chromium with CFI and UBSan.

As measured on Chromium's content_message_generator.cc:

before, CFI: 44 s
after, CFI: 23 s
after, CFI, no blacklist: 23 s (~1% slower, but 3 runs were unable to show the difference)
after, regular compilation to bitcode: 23 s

Reviewers: pcc

Subscribers: mgorny, llvm-commits

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

llvm-svn: 288303

7 years agoLTO: Remove Symbol::getIRName().
Peter Collingbourne [Thu, 1 Dec 2016 02:51:12 +0000 (02:51 +0000)]
LTO: Remove Symbol::getIRName().

Its only use was in the LTO implementation. Also document
Symbol::getName().

llvm-svn: 288302

7 years agoPR31081: ignore exception specifications when deducing function template
Richard Smith [Thu, 1 Dec 2016 02:11:49 +0000 (02:11 +0000)]
PR31081: ignore exception specifications when deducing function template
arguments from a declaration; despite what the standard says, this form of
deduction should not be considering exception specifications.

llvm-svn: 288301

7 years agorevert r288283 as it causes debug info (line numbers) to be lost in instrumented...
Kostya Serebryany [Thu, 1 Dec 2016 02:06:56 +0000 (02:06 +0000)]
revert r288283 as it causes debug info (line numbers) to be lost in instrumented code. also revert r288299 which was a workaround for the problem.

llvm-svn: 288300

7 years ago[libFuzzer] temporary disable a part of the test broken by r288283
Kostya Serebryany [Thu, 1 Dec 2016 01:33:44 +0000 (01:33 +0000)]
[libFuzzer] temporary disable a part of the test broken by r288283

llvm-svn: 288299

7 years agoDump Codeview type information correctly.
Rui Ueyama [Thu, 1 Dec 2016 01:22:48 +0000 (01:22 +0000)]
Dump Codeview type information correctly.

llvm-svn: 288298