platform/upstream/llvm.git
7 years ago[clang] Version support for UBSan handlers
Filipe Cabecinhas [Mon, 12 Dec 2016 16:18:40 +0000 (16:18 +0000)]
[clang] Version support for UBSan handlers

This adds a way for us to version any UBSan handler by itself.
The patch overrides D21289 for a better implementation (we're able to
rev up a single handler).

After this, then we can land a slight modification of D19667+D19668.

We probably don't want to keep all the versions in compiler-rt (maybe we
want to deprecate on one release and remove the old handler on the next
one?), but with this patch we will loudly fail to compile when mixing
incompatible handler calls, instead of silently compiling and then
providing bad error messages.

Reviewers: kcc, samsonov, rsmith, vsk

Subscribers: cfe-commits

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

llvm-svn: 289444

7 years ago[X86] Regenerate vector bitcast/widening tests.
Simon Pilgrim [Mon, 12 Dec 2016 16:15:45 +0000 (16:15 +0000)]
[X86] Regenerate vector bitcast/widening tests.

llvm-svn: 289443

7 years ago[InstCombine] fix bug when offsetting case values of a switch (PR31260)
Sanjay Patel [Mon, 12 Dec 2016 16:13:52 +0000 (16:13 +0000)]
[InstCombine] fix bug when offsetting case values of a switch (PR31260)

We could truncate the condition and then try to fold the add into the
original condition value causing wrong case constants to be used.

Move the offset transform ahead of the truncate transform and return
after each transform, so there's no chance of getting confused values.

Fix for:
https://llvm.org/bugs/show_bug.cgi?id=31260

llvm-svn: 289442

7 years ago[ThinLTO] Import only necessary DICompileUnit fields
Teresa Johnson [Mon, 12 Dec 2016 16:09:30 +0000 (16:09 +0000)]
[ThinLTO] Import only necessary DICompileUnit fields

Summary:
As discussed on mailing list, for ThinLTO importing we don't need
to import all the fields of the DICompileUnit. Don't import enums,
macros, retained types lists. Also only import local scoped imported
entities. Since we don't currently import any global variables,
we also don't need to import the list of global variables (added an
assert to verify none are being imported).

This is being done by pre-populating the value map entries to map
the unneeded metadata to nullptr. For the imported entities, we can
simply replace the source module's list with a new list containing
only those needed imported entities. This is done in the IRLinker
constructor so that value mapping automatically does the desired
mapping.

Reviewers: mehdi_amini, dexonsmith, dblaikie, aprantl

Subscribers: llvm-commits

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

llvm-svn: 289441

7 years ago[Driver] Attempt to fix new linux-ld tests on Windows
Michal Gorny [Mon, 12 Dec 2016 16:04:37 +0000 (16:04 +0000)]
[Driver] Attempt to fix new linux-ld tests on Windows

(broken by r289436)

llvm-svn: 289440

7 years ago[InstCombine] clean up range-for-loops in visitSwitchInst(); NFCI
Sanjay Patel [Mon, 12 Dec 2016 15:52:56 +0000 (15:52 +0000)]
[InstCombine] clean up range-for-loops in visitSwitchInst(); NFCI

llvm-svn: 289439

7 years ago[X86] Regenerate test.
Simon Pilgrim [Mon, 12 Dec 2016 15:47:53 +0000 (15:47 +0000)]
[X86] Regenerate test.

llvm-svn: 289438

7 years ago[InstCombine] add test to show PR31260 miscompile; NFC
Sanjay Patel [Mon, 12 Dec 2016 15:28:44 +0000 (15:28 +0000)]
[InstCombine] add test to show PR31260 miscompile; NFC

llvm-svn: 289437

7 years ago[Driver] Fix finding multilib gcc install on Gentoo (with gcc-config)
Michal Gorny [Mon, 12 Dec 2016 15:07:43 +0000 (15:07 +0000)]
[Driver] Fix finding multilib gcc install on Gentoo (with gcc-config)

Fix the gcc-config code to support multilib gcc installs properly. This
solves two problems: -mx32 using the 64-bit gcc directory (due to matching
installation triple), and -m32 not respecting gcc-config at all (due to
mismatched installation triple).

In order to fix the former issue, split the multilib scan out of
Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple() (the code
is otherwise unchanged), and call it for each installation found via
gcc-config.

In order to fix the latter issue, split the gcc-config processing out of
Generic_GCC::GCCInstallationDetector::init() and repeat it for all
triples, including extra and biarch triples. The only change
in the gcc-config code itself is adding the call to multilib scan.

Convert the gentoo_linux_gcc_multi_version_tree test input to multilib
x86_64+32+x32 install, and add appropriate tests to linux-header-search
and linux-ld.

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

llvm-svn: 289436

7 years ago[SCEVExpander] Add a test case related to r289412
Sanjoy Das [Mon, 12 Dec 2016 14:57:11 +0000 (14:57 +0000)]
[SCEVExpander] Add a test case related to r289412

llvm-svn: 289435

7 years ago[ScheduleOptimizer] Fix memory leak. NFC.
Michael Kruse [Mon, 12 Dec 2016 14:51:06 +0000 (14:51 +0000)]
[ScheduleOptimizer] Fix memory leak. NFC.

llvm-svn: 289434

7 years agoUse function_ref to avoid allocation in std::function. NFC.
Benjamin Kramer [Mon, 12 Dec 2016 14:41:19 +0000 (14:41 +0000)]
Use function_ref to avoid allocation in std::function. NFC.

llvm-svn: 289433

7 years ago[ELF][MIPS] Fix .MIPS.options ri_gp_value on MIPS64
Simon Atanasyan [Mon, 12 Dec 2016 14:30:18 +0000 (14:30 +0000)]
[ELF][MIPS] Fix .MIPS.options ri_gp_value on MIPS64

The VA of _gp was being truncated to 32 bits when calling getVa(), but
for 64bit MIPS we need to write a 64 bit value to .MIPS.options.

Patch by Alexander Richardson.

Differential revision: https://reviews.llvm.org/D27672

llvm-svn: 289432

7 years ago[StaticAnalysis] Remove unnecessary parameter in CallGraphNode::addCallee.
Haojian Wu [Mon, 12 Dec 2016 14:12:10 +0000 (14:12 +0000)]
[StaticAnalysis] Remove unnecessary parameter in CallGraphNode::addCallee.

Summary:
Remove the CallGraph in addCallee as it is not used in addCallee.
It decouples addCallee from CallGraph, so that we can use CallGraphNode
within our customized CallGraph.

Reviewers: bkramer

Subscribers: cfe-commits, ioeric

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

llvm-svn: 289431

7 years agoUpdate inline argument comment. NFCI.
Simon Pilgrim [Mon, 12 Dec 2016 13:43:15 +0000 (13:43 +0000)]
Update inline argument comment. NFCI.

combineX86ShufflesRecursively 'HasPSHUFB' flag has been the more generic 'HasVariableMask' flag for some time.

llvm-svn: 289430

7 years ago[X86][SSE] Add support for combining SSE VSHLI/VSRLI uniform constant shifts.
Simon Pilgrim [Mon, 12 Dec 2016 13:33:58 +0000 (13:33 +0000)]
[X86][SSE] Add support for combining SSE VSHLI/VSRLI uniform constant shifts.

Fixes some missed constant folding opportunities and allows us to combine shuffles that end with a logical bit shift.

llvm-svn: 289429

7 years agoclang-format: Separate out a language kind for ObjC.
Daniel Jasper [Mon, 12 Dec 2016 12:42:29 +0000 (12:42 +0000)]
clang-format: Separate out a language kind for ObjC.

While C(++) and ObjC are generally formatted the same way and can be
mixed, people might want to choose different styles based on the
language. This patch recognizes .m and .mm files as ObjC and also
implements a very crude detection of whether or not a .h file contains
ObjC code. This can be improved over time.

Also move most of the ObjC tests into their own test file to keep file
size maintainable.

llvm-svn: 289428

7 years agoRemove some annotations from TestMultipleTargets
Pavel Labath [Mon, 12 Dec 2016 11:37:42 +0000 (11:37 +0000)]
Remove some annotations from TestMultipleTargets

The test passes on linux. The i386 case is already handled by
skipIfHostIncompatibleWithRemote.

llvm-svn: 289427

7 years ago[X86][SSE] Lower suitably sign-extended mul vXi64 using PMULDQ
Simon Pilgrim [Mon, 12 Dec 2016 10:49:15 +0000 (10:49 +0000)]
[X86][SSE] Lower suitably sign-extended mul vXi64 using PMULDQ

PMULDQ returns the 64-bit result of the signed multiplication of the lower 32-bits of vXi64 vector inputs, we can lower with this if the sign bits stretch that far.

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

llvm-svn: 289426

7 years ago[SelectionDAG] Add support for EXTRACT_SUBVECTOR to ComputeNumSignBits
Simon Pilgrim [Mon, 12 Dec 2016 10:29:43 +0000 (10:29 +0000)]
[SelectionDAG] Add support for EXTRACT_SUBVECTOR to ComputeNumSignBits

Pre-commit as discussed on D27657

llvm-svn: 289425

7 years ago[X86] Teach selectScalarSSELoad to accept full 128-bit vector loads and the X86ISD...
Craig Topper [Mon, 12 Dec 2016 07:57:24 +0000 (07:57 +0000)]
[X86] Teach selectScalarSSELoad to accept full 128-bit vector loads and the X86ISD::VZEXT_LOAD opcode.

Disable peephole on some of the tests that no longer require it to properly fold scalar intrinsics.

llvm-svn: 289424

7 years ago[X86] Change CMPSS/CMPSD intrinsic instructions to use sse_load_f32/f64 as its memory...
Craig Topper [Mon, 12 Dec 2016 07:57:21 +0000 (07:57 +0000)]
[X86] Change CMPSS/CMPSD intrinsic instructions to use sse_load_f32/f64 as its memory pattern instead of full vector load.

These intrinsics only load a single element. We should use sse_loadf32/f64 to give more options of what loads it can match.

Currently these instructions are often only getting their load folded thanks to the load folding in the peephole pass. I plan to add more types of loads to sse_load_f32/64 so we can match without the peephole.

llvm-svn: 289423

7 years ago[Driver] Simplify ToolChain::GetCXXStdlibType (NFC)
Jonas Hahnfeld [Mon, 12 Dec 2016 07:53:47 +0000 (07:53 +0000)]
[Driver] Simplify ToolChain::GetCXXStdlibType (NFC)

I made the wrong assumption that execution would continue after an error Diag
which led to unneeded complex code.
This patch aligns with the better implementation of ToolChain::GetRuntimeLibType.

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

llvm-svn: 289422

7 years agobuild: add support for standalone lld build
Saleem Abdulrasool [Mon, 12 Dec 2016 05:47:40 +0000 (05:47 +0000)]
build: add support for standalone lld build

Enable building lld as a standalone project. This is motivated by the desire to
package lld for inclusion in a linux distribution. This allows building lld
against an existing paired llvm installation. Now that lld is usable on x86_64,
it makes sense to revive this configuration to allow distributions to package
it.

llvm-svn: 289421

7 years ago[XRay][CMake] Check target for XRay Flight Data Recorder
Petr Hosek [Mon, 12 Dec 2016 05:18:36 +0000 (05:18 +0000)]
[XRay][CMake] Check target for XRay Flight Data Recorder

This target doesn't currently do anything, but it is required by
the runtimes build.

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

llvm-svn: 289420

7 years ago[X86] Remove some intrinsic instructions from hasPartialRegUpdate
Craig Topper [Mon, 12 Dec 2016 05:07:17 +0000 (05:07 +0000)]
[X86] Remove some intrinsic instructions from hasPartialRegUpdate

Summary:
These intrinsic instructions are all selected from intrinsics that have well defined behavior for where the upper bits come from. It's not the same place as the lower bits.

As you can see we were suppressing load folding for these instructions in some cases. In none of the cases was the separate load helping avoid a partial dependency on the destination register. So we should just go ahead and allow the load to be folded.

Only foldMemoryOperand was suppressing folding for these. They all have patterns for folding sse_load_f32/f64 that aren't gated with OptForSize, but sse_load_f32/f64 doesn't allow 128-bit vector loads. It only allows scalar_to_vector and vzmovl of scalar loads to match. There's no reason we can't allow a 128-bit vector load to be narrowed so I would like to fix sse_load_f32/f64 to allow that. And if I do that it changes some of these same test cases to fold the load too.

Reviewers: spatel, zvi, RKSimon

Subscribers: llvm-commits

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

llvm-svn: 289419

7 years ago[libcxx][CMake] Move the warning to HandleOutOfTreeLLVM
Petr Hosek [Mon, 12 Dec 2016 05:05:46 +0000 (05:05 +0000)]
[libcxx][CMake] Move the warning to HandleOutOfTreeLLVM

This currently gives a warning when building libcxx under runtimes.

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

llvm-svn: 289418

7 years agoCOFF: Remove an unused mutex declaration.
Peter Collingbourne [Mon, 12 Dec 2016 03:16:18 +0000 (03:16 +0000)]
COFF: Remove an unused mutex declaration.

llvm-svn: 289415

7 years agoCOFF: Use a DenseSet instead of a map to atomic_flag to track which archive members...
Peter Collingbourne [Mon, 12 Dec 2016 03:16:14 +0000 (03:16 +0000)]
COFF: Use a DenseSet instead of a map to atomic_flag to track which archive members have been read.

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

llvm-svn: 289414

7 years agoAdd two new AST nodes to represent initialization of an array in terms of
Richard Smith [Mon, 12 Dec 2016 02:53:20 +0000 (02:53 +0000)]
Add two new AST nodes to represent initialization of an array in terms of
initialization of each array element:

 * ArrayInitLoopExpr is a prvalue of array type with two subexpressions:
   a common expression (an OpaqueValueExpr) that represents the up-front
   computation of the source of the initialization, and a subexpression
   representing a per-element initializer
 * ArrayInitIndexExpr is a prvalue of type size_t representing the current
   position in the loop

This will be used to replace the creation of explicit index variables in lambda
capture of arrays and copy/move construction of classes with array elements,
and also C++17 structured bindings of arrays by value (which inexplicably allow
copying an array by value, unlike all of C++'s other array declarations).

No uses of these nodes are introduced by this change, however.

llvm-svn: 289413

7 years ago[SCEVExpand] do not hoist divisions by zero (PR30935)
Sebastian Pop [Mon, 12 Dec 2016 02:52:51 +0000 (02:52 +0000)]
[SCEVExpand] do not hoist divisions by zero (PR30935)

SCEVExpand computes the insertion point for the components of a SCEV to be code
generated.  When it comes to generating code for a division, SCEVexpand would
not be able to check (at compilation time) all the conditions necessary to avoid
a division by zero.  The patch disables hoisting of expressions containing
divisions by anything other than non-zero constants in order to avoid hoisting
these expressions past conditions that should hold before doing the division.

The patch passes check-all on x86_64-linux.

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

llvm-svn: 289412

7 years ago[InstCombine][XOP] The instructions for the scalar frcz intrinsics are defined to...
Craig Topper [Sun, 11 Dec 2016 22:32:38 +0000 (22:32 +0000)]
[InstCombine][XOP] The instructions for the scalar frcz intrinsics are defined to put 0 in the upper bits, not pass bits through like other intrinsics. So we should return a zero vector instead.

llvm-svn: 289411

7 years agoCOFF: Use CachedHashStringRef in the symbol table.
Peter Collingbourne [Sun, 11 Dec 2016 22:15:30 +0000 (22:15 +0000)]
COFF: Use CachedHashStringRef in the symbol table.

This resulted in about a 1% perf improvement linking chrome_child.dll.

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

llvm-svn: 289410

7 years agoCOFF: Load inputs immediately instead of adding them to a queue.
Peter Collingbourne [Sun, 11 Dec 2016 22:15:25 +0000 (22:15 +0000)]
COFF: Load inputs immediately instead of adding them to a queue.

This patch replaces the symbol table's object and archive queues, as well as
the convergent loop in the linker driver, with a design more similar to the
ELF linker where symbol resolution directly causes input files to be added to
the link, including input files arising from linker directives. Effectively
this removes the last vestiges of the old parallel input file loader.

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

llvm-svn: 289409

7 years agoCOFF: Use a bit in SymbolBody to track which symbols are written to the symbol table.
Peter Collingbourne [Sun, 11 Dec 2016 22:15:20 +0000 (22:15 +0000)]
COFF: Use a bit in SymbolBody to track which symbols are written to the symbol table.

Using a set here caused us to take about 1 second longer to write the symbol
table when linking chrome_child.dll. With this I consistently get better
performance on Windows with the new symbol table.

Before r289280 and with r289183 reverted (median of 5 runs): 17.65s
After this change: 17.33s

On Linux things look even better:

Before: 10.700480444s
After: 5.735681610s

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

llvm-svn: 289408

7 years ago[X86][SSE] Add support for combining target shuffles to SHUFPD.
Simon Pilgrim [Sun, 11 Dec 2016 21:26:25 +0000 (21:26 +0000)]
[X86][SSE] Add support for combining target shuffles to SHUFPD.

llvm-svn: 289407

7 years ago[SCCP] Use the appropriate helper function. NFCI.
Davide Italiano [Sun, 11 Dec 2016 21:19:03 +0000 (21:19 +0000)]
[SCCP] Use the appropriate helper function. NFCI.

llvm-svn: 289406

7 years agoFix TBAA metadata
Sanjoy Das [Sun, 11 Dec 2016 21:10:11 +0000 (21:10 +0000)]
Fix TBAA metadata

The existing tbaa metadata in the test is ill-formed, and fails the
verifier after r289402.

llvm-svn: 289405

7 years ago[X86][AVX512] Add missing patterns for broadcast fallback in case load node has multi...
Ayman Musa [Sun, 11 Dec 2016 20:11:17 +0000 (20:11 +0000)]
[X86][AVX512] Add missing patterns for broadcast fallback in case load node has multiple uses (for v4i64 and v4f64).

When the load node which the broadcast instruction broadcasts has multiple uses, it cannot be folded.
A fallback pattern is added to catch these cases and provide another solution.

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

llvm-svn: 289404

7 years ago[TBAA] Don't generate invalid TBAA when merging nodes
Sanjoy Das [Sun, 11 Dec 2016 20:07:25 +0000 (20:07 +0000)]
[TBAA] Don't generate invalid TBAA when merging nodes

Summary:
Fix a corner case in `MDNode::getMostGenericTBAA` where we can sometimes
generate invalid TBAA metadata.

Reviewers: chandlerc, hfinkel, mehdi_amini, manmanren

Subscribers: mcrosier, llvm-commits

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

llvm-svn: 289403

7 years ago[Verifier] Add verification for TBAA metadata
Sanjoy Das [Sun, 11 Dec 2016 20:07:15 +0000 (20:07 +0000)]
[Verifier] Add verification for TBAA metadata

Summary:
This change adds some verification in the IR verifier around struct path
TBAA metadata.

Other than some basic sanity checks (e.g. we get constant integers where
we expect constant integers), this checks:

 - That by the time an struct access tuple `(base-type, offset)` is
   "reduced" to a scalar base type, the offset is `0`.  For instance, in
   C++ you can't start from, say `("struct-a", 16)`, and end up with
   `("int", 4)` -- by the time the base type is `"int"`, the offset
   better be zero.  In particular, a variant of this invariant is needed
   for `llvm::getMostGenericTBAA` to be correct.

 - That there are no cycles in a struct path.

 - That struct type nodes have their offsets listed in an ascending
   order.

 - That when generating the struct access path, you eventually reach the
   access type listed in the tbaa tag node.

Reviewers: dexonsmith, chandlerc, reames, mehdi_amini, manmanren

Subscribers: mcrosier, llvm-commits

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

llvm-svn: 289402

7 years ago[Constants] don't die processing non-ConstantInt GEP indices in isGEPWithNoNotionalOv...
Sanjay Patel [Sun, 11 Dec 2016 20:07:02 +0000 (20:07 +0000)]
[Constants] don't die processing non-ConstantInt GEP indices in isGEPWithNoNotionalOverIndexing() (PR31262)

This should fix:
https://llvm.org/bugs/show_bug.cgi?id=31262

llvm-svn: 289401

7 years ago[X86][AVX512] Add target shuffle test showing missing PSHUFPD combine.
Simon Pilgrim [Sun, 11 Dec 2016 19:41:23 +0000 (19:41 +0000)]
[X86][AVX512] Add target shuffle test showing missing PSHUFPD combine.

llvm-svn: 289400

7 years agoinstr-combiner: sum up all latencies of the transformed instructions
Sebastian Pop [Sun, 11 Dec 2016 19:39:32 +0000 (19:39 +0000)]
instr-combiner: sum up all latencies of the transformed instructions

We have found that -- when the selected subarchitecture has a scheduling model
and we are not optimizing for size -- the machine-instruction combiner uses a
too-simple algorithm to compute the cost of one of the two alternatives [before
and after running a combining pass on a section of code], and therefor it throws
away the combination results too often.

This fix has the potential to help any ISA with the potential to combine
instructions and for which at least one subarchitecture has a scheduling model.
As of now, this is only known to definitely affect AArch64 subarchitectures with
a scheduling model.

Regression tested on AMD64/GNU-Linux, new test case tested to fail on an
unpatched compiler and pass on a patched compiler.

Patch by Abe Skolnik and Sebastian Pop.

llvm-svn: 289399

7 years ago[X86][XOP] Add target shuffle tests showing missing PSHUFPD combine.
Simon Pilgrim [Sun, 11 Dec 2016 19:36:25 +0000 (19:36 +0000)]
[X86][XOP] Add target shuffle tests showing missing PSHUFPD combine.

llvm-svn: 289398

7 years ago[SCEVExpander] Explicitly expand AddRec starts into loop preheader
Sanjoy Das [Sun, 11 Dec 2016 19:02:21 +0000 (19:02 +0000)]
[SCEVExpander] Explicitly expand AddRec starts into loop preheader

This is NFC today, but won't be once D27216 (or an equivalent patch) is
in.

This change fixes a design problem in SCEVExpander -- it relied on a
hoisting optimization to generate correct code for add recurrences.
This meant changing the hoisting optimization to not kick in under
certain circumstances (to avoid speculating faulting instructions, say)
would break correctness.

The fix is to make the correctness requirements explicit, and have it
not rely on the hoisting optimization for correctness.

llvm-svn: 289397

7 years ago[X86] Regcall - Adding support for mask types
Oren Ben Simhon [Sun, 11 Dec 2016 14:10:52 +0000 (14:10 +0000)]
[X86] Regcall - Adding support for mask types

Regcall calling convention passes mask types arguments in x86 GPR registers.
The review includes the changes required in order to support v32i1, v16i1 and v8i1.

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

llvm-svn: 289383

7 years ago[FileCheck] Re-implement the logic to find each check prefix in the
Chandler Carruth [Sun, 11 Dec 2016 12:49:05 +0000 (12:49 +0000)]
[FileCheck] Re-implement the logic to find each check prefix in the
check file to not be unreasonably slow in the face of multiple check
prefixes.

The previous logic would repeatedly scan potentially large portions of
the check file looking for alternative prefixes. In the worst case this
would scan most of the file looking for a rare prefix between every
single occurance of a common prefix. Even if we bounded the scan, this
would do bad things if the order of the prefixes was "unlucky" and the
distant prefix was scanned for first.

None of this is necessary. It is straightforward to build a state
machine that recognizes the first, longest of the set of alternative
prefixes. That is in fact exactly whan a regular expression does.

This patch builds a regular expression once for the set of prefixes and
then uses it to search incrementally for the next prefix. This requires
some threading of state but actually makes the code dramatically
simpler. I've also added a big comment describing the algorithm as it
was not at all obvious to me when I started.

With this patch, several previously pathological test cases in
test/CodeGen/X86 are 5x and more faster. Overall, running all tests
under test/CodeGen/X86 uses 10% less CPU after this, and because all the
slowest tests were hitting this, finishes in 40% less wall time on my
system (going from just over 5.38s to just over 3.23s) on a release
build! This patch substantially improves the time of all 7 X86 tests
that were in the top 20 reported by --time-tests, 5 of them are
completely off the list and the remaining 2 are much lower. (Sadly, the
new tests on the list include 2 new X86 ones that are slow for unrelated
reasons, so the count stays at 4 of the top 20.)

It isn't clear how much this helps debug builds in aggregate in part
because of the noise, but it again makes mane of the slowest x86 tests
significantly faster (10% or more improvement).

llvm-svn: 289382

7 years ago[FileCheck] Remove a parameter that was simply always set to
Chandler Carruth [Sun, 11 Dec 2016 10:22:17 +0000 (10:22 +0000)]
[FileCheck] Remove a parameter that was simply always set to
a commandline flag and test the flag directly. NFC.

If we ever need this generality it can be added back.

llvm-svn: 289381

7 years ago[FileCheck] Clean up doxygen comments throughout. NFC.
Chandler Carruth [Sun, 11 Dec 2016 10:16:21 +0000 (10:16 +0000)]
[FileCheck] Clean up doxygen comments throughout. NFC.

llvm-svn: 289380

7 years ago[FileCheck] Run clang-format over this code. NFC.
Chandler Carruth [Sun, 11 Dec 2016 09:54:36 +0000 (09:54 +0000)]
[FileCheck] Run clang-format over this code. NFC.

This fixes one formatting goof I left in my previous commit and *many*
other inconsistencies.

I'm planning to make substantial changes here and so wanted to get to
a clean baseline.

llvm-svn: 289379

7 years agoRefactor FileCheck some to reduce memory allocation and copying. Also
Chandler Carruth [Sun, 11 Dec 2016 09:50:05 +0000 (09:50 +0000)]
Refactor FileCheck some to reduce memory allocation and copying. Also
make some readability improvements.

Both the check file and input file have to be fully buffered to
normalize their whitespace. But previously this would be done in a stack
SmallString and then copied into a heap allocated MemoryBuffer. That
seems pretty wasteful, especially for something like FileCheck where
there are only ever two such entities.

This just rearranges the code so that we can keep the canonicalized
buffers on the stack of the main function, use reasonably large stack
buffers to reduce allocation. A rough estimate seems to show that about
80% of LLVM's .ll and .s files will fit into a 4k buffer, so this should
completely avoid heap allocation for the buffer in those cases. My
system's malloc is fast enough that the allocations don't directly show
up in timings. However, on some very slow test cases, this saves 1% - 2%
by avoiding the copy into the heap allocated buffer.

This also splits out the code which checks the input into a helper much
like the code to build the checks as that made the code much more
readable to me. Nit picks and suggestions welcome here. It has really
exposed a *bunch* of stuff that could be cleaned up though, so I'm
probably going to go and spring clean all of this code as I have more
changes coming to speed things up.

llvm-svn: 289378

7 years ago[X86][InstCombine] Add support for scalar FMA intrinsics to SimplifyDemandedVectorElts.
Craig Topper [Sun, 11 Dec 2016 08:54:52 +0000 (08:54 +0000)]
[X86][InstCombine] Add support for scalar FMA intrinsics to SimplifyDemandedVectorElts.

This teaches SimplifyDemandedElts that the FMA can be removed if the lower element isn't used. It also teaches it that if upper elements of the first operand aren't used then we can simplify them.

llvm-svn: 289377

7 years ago[sanitizer] Make sure libmalloc doesn't remove the sanitizer zone from malloc_zones[0]
Kuba Mracek [Sun, 11 Dec 2016 08:45:36 +0000 (08:45 +0000)]
[sanitizer] Make sure libmalloc doesn't remove the sanitizer zone from malloc_zones[0]

In certain OS versions, it was possible that libmalloc replaced the sanitizer zone from being the default zone (i.e. being in malloc_zones[0]). This patch introduces a failsafe that makes sure we always stay the default zone. No testcase for this, because this doesn't reproduce under normal circumstances.

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

llvm-svn: 289376

7 years ago[sanitizer] Handle malloc_destroy_zone() on Darwin
Kuba Mracek [Sun, 11 Dec 2016 08:42:42 +0000 (08:42 +0000)]
[sanitizer] Handle malloc_destroy_zone() on Darwin

We currently have a interceptor for malloc_create_zone, which returns a new zone that redirects all the zone requests to our sanitizer zone. However, calling malloc_destroy_zone on that zone will cause libmalloc to print out some warning messages, because the zone is not registered in the list of zones. This patch handles this and adds a testcase for that.

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

llvm-svn: 289375

7 years ago[X86][InstCombine] Add the test cases for r289370, r289371, and r289372.
Craig Topper [Sun, 11 Dec 2016 08:00:51 +0000 (08:00 +0000)]
[X86][InstCombine] Add the test cases for r289370, r289371, and r289372.

I forgot to add the new files before commiting.

llvm-svn: 289374

7 years agoTweak the core loop in StringRef::find to avoid calling memcmp on every
Chandler Carruth [Sun, 11 Dec 2016 07:46:21 +0000 (07:46 +0000)]
Tweak the core loop in StringRef::find to avoid calling memcmp on every
iteration.

Instead, load the byte at the needle length, compare it directly, and
save it to use in the lookup table of lengths we can skip forward.

I also added an annotation to expect that the comparison fails so that
the loop gets laid out contiguously without the call to memcpy (and the
substantial register shuffling that the ABI requires of that call).

Finally, because this behaves especially badly with a needle length of
one (by calling memcmp with a zero length) special case that to directly
call memchr, which is what we should have been doing anyways.

This was motivated by the fact that there are a large number of test
cases in 'check-llvm' where FileCheck's performance is dominated by
calls to StringRef::find (in a release, no-asserts build). I'm working
on patches to generally improve matters there, but this alone was worth
a 12.5% improvement in one test case where FileCheck spent 92% of its
time in this routine.

I experimented a bunch with different minor variations on this theme,
for example setting the pointer *at* the last byte and indexing
backwards for the call to memcmp. That didn't improve anything on this
version and seemed more complex. I also tried other things to make the
loop flow more nicely and none worked. =/ It is a bit unfortunate, the
generated code here remains pretty gross, but I don't see any obvious
ways to improve it. At this point, most of my ideas would be really
elaborate:

1) While the remainder of the string is long enough, we could load
   a 16-byte or 32-byte vector at the address of the last byte and use
   palignr to rotate that and check the first 15- or 31-bytes at the
   front of the next segment, essentially pre-loading the first several
   bytes of the next iteration so we could quickly detect a mismatch in
   those bytes without an additional memory access. Down side would be
   the code complexity, having a fallback loop, and likely misaligned
   vector load. Plus it would make the common case of the last byte not
   matching somewhat slower (need some extraction from a vector).
2) While we have space, we could do an aligned load of a 16- or 32-byte
   vector that *contains* the end byte, and use any peceding bytes to
   have a more precise "no" test, and any subsequent bytes could be
   saved for the next iteration. This remove any unaligned load penalty,
   but still requires us to pay the overhead of vector extraction for
   the cases where we didn't need to do anything other than load and
   compare the last byte.
3) Try to walk from the last byte in a way that is more friendly to
   cache and/or memory pre-fetcher considering we have to poke the last
   byte anyways.

No idea if any of these are really worth pursuing though. They all seem
somewhat unlikely to yield big wins in practice and to be a lot of work
and complexity. So I settled here, which at least seems like a strict
improvement over the previous version.

llvm-svn: 289373

7 years ago[X86][InstCombine] Teach InstCombineCalls to simplify demanded elements for scalar...
Craig Topper [Sun, 11 Dec 2016 07:42:06 +0000 (07:42 +0000)]
[X86][InstCombine] Teach InstCombineCalls to simplify demanded elements for scalar FMA intrinsics.

These intrinsics don't read the upper bits of their second and third inputs so we can try to simplify them.

llvm-svn: 289372

7 years ago[AVX-512][InstCombine] Teach InstCombineCalls how to simplify demanded for scalar...
Craig Topper [Sun, 11 Dec 2016 07:42:04 +0000 (07:42 +0000)]
[AVX-512][InstCombine] Teach InstCombineCalls how to simplify demanded for scalar cmp intrinsics with masking and rounding.

These intrinsics don't read the upper elements of their first and second input. These are slightly different the the SSE version which does use the upper bits of its first element as passthru bits since the result goes to an XMM register. For AVX-512 the result goes to a mask register instead.

llvm-svn: 289371

7 years ago[AVX-512][InstCombine] Teach InstCombineCalls how to simplify demanded elements for...
Craig Topper [Sun, 11 Dec 2016 07:42:01 +0000 (07:42 +0000)]
[AVX-512][InstCombine] Teach InstCombineCalls how to simplify demanded elements for scalar add,div,mul,sub,max,min intrinsics with masking and rounding.

These intrinsics don't read the upper bits of their second input. And the third input is the passthru for masking and that only uses the lower element as well.

llvm-svn: 289370

7 years ago[AVR] Add calling convention CodeGen tests
Dylan McKay [Sun, 11 Dec 2016 07:09:45 +0000 (07:09 +0000)]
[AVR] Add calling convention CodeGen tests

This adds CodeGen tests for the AVR C calling convention.

llvm-svn: 289369

7 years ago[libFuzzer] don't depend on time in a test
Kostya Serebryany [Sun, 11 Dec 2016 06:28:09 +0000 (06:28 +0000)]
[libFuzzer] don't depend on time in a test

llvm-svn: 289368

7 years agoActually re-disable -Wsign-compare
Eric Fiselier [Sun, 11 Dec 2016 05:54:43 +0000 (05:54 +0000)]
Actually re-disable -Wsign-compare

llvm-svn: 289367

7 years agoRe-disable -Wsign-compare for now. I didn't catch all occurrences
Eric Fiselier [Sun, 11 Dec 2016 05:45:55 +0000 (05:45 +0000)]
Re-disable -Wsign-compare for now. I didn't catch all occurrences

llvm-svn: 289366

7 years agoFix signed comparison warning
Eric Fiselier [Sun, 11 Dec 2016 05:43:20 +0000 (05:43 +0000)]
Fix signed comparison warning

llvm-svn: 289365

7 years agoEnable the -Wsign-compare warning to better support MSVC
Eric Fiselier [Sun, 11 Dec 2016 05:31:00 +0000 (05:31 +0000)]
Enable the -Wsign-compare warning to better support MSVC

llvm-svn: 289363

7 years ago[AVR] Add a test to validate a simple 'blinking led' program
Dylan McKay [Sun, 11 Dec 2016 04:59:39 +0000 (04:59 +0000)]
[AVR] Add a test to validate a simple 'blinking led' program

llvm-svn: 289362

7 years ago[CrashReproducer] Setup a module collector callback for HeaderInclude
Bruno Cardoso Lopes [Sun, 11 Dec 2016 04:27:31 +0000 (04:27 +0000)]
[CrashReproducer] Setup a module collector callback for HeaderInclude

Collect missing include that cannot be fetched otherwise (e.g. when
using headermaps).

rdar://problem/27913709

llvm-svn: 289361

7 years ago[CrashReproducer] Collect headermap files
Bruno Cardoso Lopes [Sun, 11 Dec 2016 04:27:28 +0000 (04:27 +0000)]
[CrashReproducer] Collect headermap files

Include headermaps (.hmap files) in the .cache directory and
add VFS entries. All headermaps are known after HeaderSearch
setup, collect them right after.

rdar://problem/27913709

llvm-svn: 289360

7 years agoFix copy/paste errors introduced in r289358
Eric Fiselier [Sun, 11 Dec 2016 04:00:26 +0000 (04:00 +0000)]
Fix copy/paste errors introduced in r289358

llvm-svn: 289359

7 years agoFix undefined behavior in container swap tests.
Eric Fiselier [Sun, 11 Dec 2016 03:41:12 +0000 (03:41 +0000)]
Fix undefined behavior in container swap tests.

These swap tests were swapping non-POCS non-equal allocators which
is undefined behavior. This patch changes the tests to use allocators
which compare equal. In order to test that the allocators were not
swapped I added an "id" field to test_allocator which does not
participate in equality but does propagate across copies/swaps.

This patch is based off of D26623 which was submitted by STL.

llvm-svn: 289358

7 years agoFix yet another dynamic exception spec
Eric Fiselier [Sun, 11 Dec 2016 02:49:37 +0000 (02:49 +0000)]
Fix yet another dynamic exception spec

llvm-svn: 289357

7 years agoFix more uses of dynamic exception specifications in C++17
Eric Fiselier [Sun, 11 Dec 2016 02:47:36 +0000 (02:47 +0000)]
Fix more uses of dynamic exception specifications in C++17

llvm-svn: 289356

7 years agoFix count_new.hpp to work w/o dynamic exception specifications
Eric Fiselier [Sun, 11 Dec 2016 02:20:17 +0000 (02:20 +0000)]
Fix count_new.hpp to work w/o dynamic exception specifications

llvm-svn: 289355

7 years ago[AVX-512][InstCombine] Add 512-bit vpermilvar intrinsics to InstCombineCalls to match...
Craig Topper [Sun, 11 Dec 2016 01:59:36 +0000 (01:59 +0000)]
[AVX-512][InstCombine] Add 512-bit vpermilvar intrinsics to InstCombineCalls to match 128 and 256-bit.

llvm-svn: 289354

7 years agoWorkaround the removal of dynamic exception specifications in C++17
Eric Fiselier [Sun, 11 Dec 2016 01:35:55 +0000 (01:35 +0000)]
Workaround the removal of dynamic exception specifications in C++17

llvm-svn: 289353

7 years ago[X86] Fix a comment to say 'an FMA' instead of 'a FMA'. NFC
Craig Topper [Sun, 11 Dec 2016 01:28:08 +0000 (01:28 +0000)]
[X86] Fix a comment to say 'an FMA' instead of 'a FMA'. NFC

llvm-svn: 289352

7 years ago[AVX-512] Remove masking from 512-bit vpermil builtins. The backend now has versions...
Craig Topper [Sun, 11 Dec 2016 01:26:52 +0000 (01:26 +0000)]
[AVX-512] Remove masking from 512-bit vpermil builtins. The backend now has versions without masking so wrap it with select.

This will allow the backend to constant fold these to generic shuffle vectors like 128-bit and 256-bit without having to working about handling masking.

llvm-svn: 289351

7 years ago[X86] Remove masking from 512-bit VPERMIL intrinsics in preparation for being able...
Craig Topper [Sun, 11 Dec 2016 01:26:44 +0000 (01:26 +0000)]
[X86] Remove masking from 512-bit VPERMIL intrinsics in preparation for being able to constant fold them in InstCombineCalls like we do for 128/256-bit.

llvm-svn: 289350

7 years ago[AVR] Fix a signed vs unsigned compiler warning
Dylan McKay [Sun, 11 Dec 2016 00:24:13 +0000 (00:24 +0000)]
[AVR] Fix a signed vs unsigned compiler warning

llvm-svn: 289349

7 years ago[X86][InstCombine] Teach InstCombineCalls to turn pshufb intrinsic into a shufflevect...
Craig Topper [Sun, 11 Dec 2016 00:23:50 +0000 (00:23 +0000)]
[X86][InstCombine] Teach InstCombineCalls to turn pshufb intrinsic into a shufflevector if the indices are constant.

llvm-svn: 289348

7 years ago[libc++] Fix support for multibyte thousands_sep and decimal_point in moneypunct_byna...
Eric Fiselier [Sun, 11 Dec 2016 00:20:59 +0000 (00:20 +0000)]
[libc++] Fix support for multibyte thousands_sep and decimal_point in moneypunct_byname and numpunct_byname.

Summary:
The underlying C locales provide the `thousands_sep` and `decimal_point` as strings, possible with more than one character. We currently don't handle this case even for `wchar_t`.

This patch properly converts the mbs -> wide character for `moneypunct_byname<wchar_t>`. For the `moneypunct_byname<char>` case we attempt to narrow the WC and if that fails we also attempt to translate it to some reasonable value. For example we translate U00A0 (non-breaking space) into U0020 (regular space). If none of these conversions succeed then we simply allow the base class to provide a fallback value.

Reviewers: mclow.lists, EricWF

Subscribers: vangyzen, george.burgess.iv, cfe-commits

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

llvm-svn: 289347

7 years ago[AVR] Remove incorrect comment
Dylan McKay [Sat, 10 Dec 2016 23:50:30 +0000 (23:50 +0000)]
[AVR] Remove incorrect comment

This should've been removed in r289323.

llvm-svn: 289346

7 years ago[AVX-512] Remove masking from 512-bit pshufb builtin. The backend now has a version...
Craig Topper [Sat, 10 Dec 2016 23:09:52 +0000 (23:09 +0000)]
[AVX-512] Remove masking from 512-bit pshufb builtin. The backend now has a version without masking so wrap it with select.

This will allow the backend to constant fold these to generic shuffle vectors like 128-bit and 256-bit without having to working about handling masking.

llvm-svn: 289345

7 years ago[X86] Remove masking from 512-bit PSHUFB intrinsics in preparation for being able...
Craig Topper [Sat, 10 Dec 2016 23:09:43 +0000 (23:09 +0000)]
[X86] Remove masking from 512-bit PSHUFB intrinsics in preparation for being able to constant fold it in InstCombineCalls like we do for 128/256-bit.

llvm-svn: 289344

7 years ago[InstCombine] add helper for shift-by-shift folds; NFCI
Sanjay Patel [Sat, 10 Dec 2016 22:16:29 +0000 (22:16 +0000)]
[InstCombine] add helper for shift-by-shift folds; NFCI

These are currently limited to integer types, but we should
be able to extend to splat vectors and possibly general vectors.

llvm-svn: 289343

7 years ago[X86][SSE] Add tests for sign extended vXi64 multiplication
Simon Pilgrim [Sat, 10 Dec 2016 22:02:36 +0000 (22:02 +0000)]
[X86][SSE] Add tests for sign extended vXi64 multiplication

llvm-svn: 289342

7 years ago[X86][SSE] Ensure UNPCK inputs are a consistent value type in LowerHorizontalByteSum
Simon Pilgrim [Sat, 10 Dec 2016 21:16:45 +0000 (21:16 +0000)]
[X86][SSE] Ensure UNPCK inputs are a consistent value type in LowerHorizontalByteSum

llvm-svn: 289341

7 years ago[AVX-512] Remove 128/256 masked vpermil instrinsics and autoupgrade to a select aroun...
Craig Topper [Sat, 10 Dec 2016 21:15:52 +0000 (21:15 +0000)]
[AVX-512] Remove 128/256 masked vpermil instrinsics and autoupgrade to a select around the unmasked avx1 intrinsics.

llvm-svn: 289340

7 years ago[X86][IR] Move the autoupgrading of store intrinsics out of the main nested if/else...
Craig Topper [Sat, 10 Dec 2016 21:15:48 +0000 (21:15 +0000)]
[X86][IR] Move the autoupgrading of store intrinsics out of the main nested if/else chain. This should buy a little more time against the MSVC limit mentioned in PR31034.

The handlers for stores all return at the end of their block so they can be picked off early.

llvm-svn: 289339

7 years ago[AVX-512] Remove 128/256-bit masked vpermilvar builtins and replace with select and...
Craig Topper [Sat, 10 Dec 2016 20:27:39 +0000 (20:27 +0000)]
[AVX-512] Remove 128/256-bit masked vpermilvar builtins and replace with select and the avx unmasked builtins.

llvm-svn: 289338

7 years agoAMDGPU: Fix asan errors when folding operands
Matt Arsenault [Sat, 10 Dec 2016 19:58:00 +0000 (19:58 +0000)]
AMDGPU: Fix asan errors when folding operands

This was failing when trying to fold immediates into operand 1 of a
phi, which only has one statically known operand.

llvm-svn: 289337

7 years ago[X86][SSE] Move ZeroVector creation into the shuffle pattern case where its actually...
Simon Pilgrim [Sat, 10 Dec 2016 19:49:55 +0000 (19:49 +0000)]
[X86][SSE] Move ZeroVector creation into the shuffle pattern case where its actually used.

Also fix the ZeroVector's type - I've no idea how this hasn't caused problems........

llvm-svn: 289336

7 years ago[AVX-512] Add support for lowering (v2i64 (fp_to_sint (v2f32))) to vcvttps2uqq when...
Craig Topper [Sat, 10 Dec 2016 19:35:39 +0000 (19:35 +0000)]
[AVX-512] Add support for lowering (v2i64 (fp_to_sint (v2f32))) to vcvttps2uqq when AVX512DQ and AVX512VL are available.

llvm-svn: 289335

7 years ago[X86] Clarify indentation. NFC
Craig Topper [Sat, 10 Dec 2016 19:35:36 +0000 (19:35 +0000)]
[X86] Clarify indentation. NFC

llvm-svn: 289334

7 years ago[X86] Combine LowerFP_TO_SINT and LowerFP_TO_UINT. They only differ by a single boole...
Craig Topper [Sat, 10 Dec 2016 19:35:33 +0000 (19:35 +0000)]
[X86] Combine LowerFP_TO_SINT and LowerFP_TO_UINT. They only differ by a single boolean flag passed to a helper function. Just check the opcode and create the flag.

llvm-svn: 289333

7 years ago[InstSimplify] improve function name; NFC
Sanjay Patel [Sat, 10 Dec 2016 17:40:47 +0000 (17:40 +0000)]
[InstSimplify] improve function name; NFC

llvm-svn: 289332

7 years ago[mips] Eliminate else-after-return. NFC
Simon Atanasyan [Sat, 10 Dec 2016 17:30:09 +0000 (17:30 +0000)]
[mips] Eliminate else-after-return. NFC

llvm-svn: 289331

7 years agoCreate a TPI stream only when /debugpdb is given.
Rui Ueyama [Sat, 10 Dec 2016 17:23:23 +0000 (17:23 +0000)]
Create a TPI stream only when /debugpdb is given.

Adding type records to TPI stream is too time consuming.
It is reported that linking chrome_child.dll took 5 minutes.

llvm-svn: 289330

7 years ago[SelectionDAG] Add ability for computeKnownBits to peek through bitcasts from 'large...
Simon Pilgrim [Sat, 10 Dec 2016 17:00:00 +0000 (17:00 +0000)]
[SelectionDAG] Add ability for computeKnownBits to peek through bitcasts from 'large element' scalar/vector to 'small element' vector.

Extension to D27129 which already supported bitcasts from 'small element' vector to 'large element' scalar/vector types.

llvm-svn: 289329