platform/upstream/llvm.git
7 years agoAddress http://bugs.llvm.org/pr30994 so that a non-friend can properly replace a...
Yaron Keren [Mon, 17 Apr 2017 08:51:20 +0000 (08:51 +0000)]
Address bugs.llvm.org/pr30994 so that a non-friend can properly replace a friend, and a visible friend can properly replace an invisible friend but not vice verse, and definitions are not replaced. This fixes the two FIXME in SemaTemplate/friend-template.cpp.

The code implements Richard Smith suggestion in comment 3 of the PR.

reviewer: Vassil Vassilev

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

llvm-svn: 300443

7 years ago[BPI] NFC: reorder ifs to bail out earlier
Serguei Katkov [Mon, 17 Apr 2017 06:39:47 +0000 (06:39 +0000)]
[BPI] NFC: reorder ifs to bail out earlier

This is non-functional change to re-order if statements to bail out earlier
from unreachable and ColdCall heuristics.

Reviewers: sanjoy, reames, junbuml, vsk, chandlerc

Reviewed By: chandlerc

Subscribers: llvm-commits

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

llvm-svn: 300442

7 years ago[LoopPeeling] Fix condition for phi-eliminating peeling
Max Kazantsev [Mon, 17 Apr 2017 05:38:28 +0000 (05:38 +0000)]
[LoopPeeling] Fix condition for phi-eliminating peeling

When peeling loops basing on phis becoming invariants, we make a wrong loop size check.
UP.Threshold should be compared against the total numbers of instructions after the transformation,
which is equal to 2 * LoopSize in case of peeling one iteration.
We should also check that the maximum allowed number of peeled iterations is not zero.

Reviewers: sanjoy, anna, reames, mkuper

Reviewed By: mkuper

Subscribers: llvm-commits

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

llvm-svn: 300441

7 years ago[BPI] Use metadata info before any other heuristics
Serguei Katkov [Mon, 17 Apr 2017 04:33:04 +0000 (04:33 +0000)]
[BPI] Use metadata info before any other heuristics

Metadata potentially is more precise than any heuristics we use, so
it makes sense to use first metadata info if it is available. However it makes
sense to examine it against other strong heuristics like unreachable one.
If edge coming to unreachable block has higher probability then it is expected
by unreachable heuristic then we use heuristic and remaining probability is
distributed among other reachable blocks equally.

An example where metadata might be more strong then unreachable heuristic is
as follows: it is possible that there are two branches and for the branch A
metadata says that its probability is (0, 2^25). For the branch B
the probability is (1, 2^25).
So the expectation is that first edge of B is hotter than first edge of A
because first edge of A did not executed at least once.
If first edge of A points to the unreachable block then using the unreachable
heuristics we'll set the probability for A to (1, 2^20) and now edge of A
becomes hotter than edge of B.
This is unexpected behavior.

This fixed the biggest part of https://bugs.llvm.org/show_bug.cgi?id=32214

Reviewers: sanjoy, junbuml, vsk, chandlerc

Reviewed By: chandlerc

Subscribers: llvm-commits, reames, davidxl

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

llvm-svn: 300440

7 years ago[InstCombine] Simplify 1/X for vectors.
Craig Topper [Mon, 17 Apr 2017 03:41:47 +0000 (03:41 +0000)]
[InstCombine] Simplify 1/X for vectors.

llvm-svn: 300439

7 years ago[InstCombine] Add test cases for missing support for simplifying 1/X for vectors...
Craig Topper [Mon, 17 Apr 2017 03:41:44 +0000 (03:41 +0000)]
[InstCombine] Add test cases for missing support for simplifying 1/X for vectors. NFC

llvm-svn: 300438

7 years ago[InstCombine] Add support for vector srem->urem.
Craig Topper [Mon, 17 Apr 2017 01:51:24 +0000 (01:51 +0000)]
[InstCombine] Add support for vector srem->urem.

llvm-svn: 300437

7 years ago[InstCombine] Add missing testcases for srem->urem conversion. The vector version...
Craig Topper [Mon, 17 Apr 2017 01:51:21 +0000 (01:51 +0000)]
[InstCombine] Add missing testcases for srem->urem conversion. The vector version isn't currently supported. NFC

llvm-svn: 300436

7 years ago[InstCombine] Add support for turning vector sdiv into udiv.
Craig Topper [Mon, 17 Apr 2017 01:51:19 +0000 (01:51 +0000)]
[InstCombine] Add support for turning vector sdiv into udiv.

llvm-svn: 300435

7 years ago[InstCombine] Add test cases for missing support for turning vector sdiv into udiv...
Craig Topper [Mon, 17 Apr 2017 01:51:16 +0000 (01:51 +0000)]
[InstCombine] Add test cases for missing support for turning vector sdiv into udiv. NFC

llvm-svn: 300434

7 years ago[LCSSA] Simplify a loop. NFCI.
Davide Italiano [Mon, 17 Apr 2017 00:02:45 +0000 (00:02 +0000)]
[LCSSA] Simplify a loop. NFCI.

llvm-svn: 300433

7 years ago[InstCombine][ValueTracking] When computing known bits for Srem make sure we don...
Craig Topper [Sun, 16 Apr 2017 21:46:12 +0000 (21:46 +0000)]
[InstCombine][ValueTracking] When computing known bits for Srem make sure we don't compute known bits for the LHS twice.

If we already called computeKnownBits for the RHS being a constant power of 2, we've already computed everything we can and should just stop. I think previously we would still recurse if we had determined the result was negative or had not determined the sign bit at all.

llvm-svn: 300432

7 years ago[LCSSA] Fix non-determinism due to iterating over a SmallPtrSet.
Davide Italiano [Sun, 16 Apr 2017 21:07:04 +0000 (21:07 +0000)]
[LCSSA] Fix non-determinism due to iterating over a SmallPtrSet.

Use a SmallSetVector instead.

llvm-svn: 300431

7 years ago[InstCombine] In SimplifyDemandedUseBits, don't bother to mask known bits of constant...
Craig Topper [Sun, 16 Apr 2017 20:55:58 +0000 (20:55 +0000)]
[InstCombine] In SimplifyDemandedUseBits, don't bother to mask known bits of constants with DemandedMask.

Just because we didn't demand them doesn't mean they aren't known.

llvm-svn: 300430

7 years ago[X86] Remove special handling for 16 bit for A asm constraints.
Benjamin Kramer [Sun, 16 Apr 2017 20:13:08 +0000 (20:13 +0000)]
[X86] Remove special handling for 16 bit for A asm constraints.

Our 16 bit support is assembler-only + the terrible hack that is
.code16gcc. Simply using 32 bit registers does the right thing for the
latter.

Fixes PR32681.

llvm-svn: 300429

7 years agoMemorySSA: Stop tracking def-or-use blocks.
Bryant Wong [Sun, 16 Apr 2017 19:45:51 +0000 (19:45 +0000)]
MemorySSA: Stop tracking def-or-use blocks.

The tracking is unused, since MemoryPhis are not pruned as of r282419.

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

llvm-svn: 300428

7 years ago[clang] Register isConstexpr matcher
Alexander Shaposhnikov [Sun, 16 Apr 2017 19:05:17 +0000 (19:05 +0000)]
[clang] Register isConstexpr matcher

This diff registers isConstexpr matcher.

Test plan:
make check-all
check that "match varDecl(isConstexpr())"
works in clang-query

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

llvm-svn: 300427

7 years ago[InstSimplify] improve getTrue/getFalse; NFCI
Sanjay Patel [Sun, 16 Apr 2017 17:43:11 +0000 (17:43 +0000)]
[InstSimplify] improve getTrue/getFalse; NFCI

The ConstantInt version has the same assert, and using null/allOnes is likely less efficient.
The only advantage of these local variants (and there's probably a better way to achieve this?)
is to save typing "ConstantInt::" over and over.

llvm-svn: 300426

7 years agoGarbage collect HAVE_EXECINFO_H from config.h.cmake after r300062. NFCI.
Dimitry Andric [Sun, 16 Apr 2017 17:22:44 +0000 (17:22 +0000)]
Garbage collect HAVE_EXECINFO_H from config.h.cmake after r300062. NFCI.

llvm-svn: 300425

7 years ago[Constants] simplify get true/false code; NFCI
Sanjay Patel [Sun, 16 Apr 2017 17:00:21 +0000 (17:00 +0000)]
[Constants] simplify get true/false code; NFCI

llvm-svn: 300424

7 years agoUse setUsedForHeaderGuard() accessor function instead of direcly accessing UsedForHea...
Yaron Keren [Sun, 16 Apr 2017 15:53:19 +0000 (15:53 +0000)]
Use setUsedForHeaderGuard() accessor function instead of direcly accessing UsedForHeaderGuard.

llvm-svn: 300423

7 years ago[X86][X86 intrinsics]Folding cmp(sub(a,b),0) into cmp(a,b) optimization
Michael Zuckerman [Sun, 16 Apr 2017 13:26:08 +0000 (13:26 +0000)]
[X86][X86 intrinsics]Folding cmp(sub(a,b),0) into cmp(a,b) optimization

This patch adds new optimization (Folding cmp(sub(a,b),0) into cmp(a,b))
to instCombineCall pass and was written specific for X86 CMP intrinsics.

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

llvm-svn: 300422

7 years agoRevert r300420 - [coroutines] Fix building of new/delete expressions when get_return_...
Eric Fiselier [Sun, 16 Apr 2017 09:34:28 +0000 (09:34 +0000)]
Revert r300420 - [coroutines] Fix building of new/delete expressions when get_return_object_on_allocation_failure() is present

llvm-svn: 300421

7 years ago[coroutines] Fix building of new/delete expressions when get_return_object_on_allocat...
Eric Fiselier [Sun, 16 Apr 2017 09:19:59 +0000 (09:19 +0000)]
[coroutines] Fix building of new/delete expressions when get_return_object_on_allocation_failure() is present.

Summary:
This patch implements [dcl.fct.def.coroutine]p8:
> The unqualified-id get_return_object_on_allocation_failure is looked up in the scope of
> class P by class member access lookup (3.4.5). If a declaration is found, ..., and if a
> global allocation function is selected, the ::operator new(size_t, nothrow_t) form shall be used.
> [...]
> The allocation function used in this case must have a non-throwing noexcept-specification.

Reviewers: GorNishanov, rsmith, majnemer, aaron.ballman

Reviewed By: GorNishanov

Subscribers: cfe-commits

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

llvm-svn: 300420

7 years ago[CMake][libunwind] Fix the -target and -gcc-toolchain flag handling
Petr Hosek [Sun, 16 Apr 2017 06:08:44 +0000 (06:08 +0000)]
[CMake][libunwind] Fix the -target and -gcc-toolchain flag handling

CMake has the problem with the single dash variant because of the
space, so use the double dash with equal sign version. The compile
flag handling had a typo which caused these flag not to be properly
include. We also don't have to pass the target triple when checking
for compiler-rt since that flag is already included in compile flags
now.

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

llvm-svn: 300419

7 years ago[CMake][libcxxabi] Fix the -target and -gcc-toolchain flag handling
Petr Hosek [Sun, 16 Apr 2017 06:08:34 +0000 (06:08 +0000)]
[CMake][libcxxabi] Fix the -target and -gcc-toolchain flag handling

CMake has the problem with the single dash variant because of the
space, so use the double dash with equal sign version. These flag
need to be included in compile flags to propagate correctly. We also
don't have to pass the target triple when checking for compiler-rt
since that flag is already included in compile flags now.

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

llvm-svn: 300418

7 years agoCleanup one more <forward_list> test
Eric Fiselier [Sun, 16 Apr 2017 04:05:15 +0000 (04:05 +0000)]
Cleanup one more <forward_list> test

llvm-svn: 300417

7 years agoThreadSanitizer plugin: Support Swift access races and fix how external races are...
Kuba Mracek [Sun, 16 Apr 2017 04:02:45 +0000 (04:02 +0000)]
ThreadSanitizer plugin: Support Swift access races and fix how external races are displayed.

llvm-svn: 300416

7 years agoReplace _LIBCPP_HAS_NO_<C++03 feature> with _LIBCPP_CXX03_LANG in <forward_list>
Eric Fiselier [Sun, 16 Apr 2017 04:02:01 +0000 (04:02 +0000)]
Replace _LIBCPP_HAS_NO_<C++03 feature> with _LIBCPP_CXX03_LANG in <forward_list>

llvm-svn: 300415

7 years agoReplace _LIBCPP_HAS_NO_<C++03 feature> with _LIBCPP_CXX03_LANG in <list>
Eric Fiselier [Sun, 16 Apr 2017 03:45:35 +0000 (03:45 +0000)]
Replace _LIBCPP_HAS_NO_<C++03 feature> with _LIBCPP_CXX03_LANG in <list>

llvm-svn: 300414

7 years agoReplace _LIBCPP_HAS_NO_<C++03 feature> with _LIBCPP_CXX03_LANG in deque
Eric Fiselier [Sun, 16 Apr 2017 03:17:01 +0000 (03:17 +0000)]
Replace _LIBCPP_HAS_NO_<C++03 feature> with _LIBCPP_CXX03_LANG in deque

llvm-svn: 300413

7 years agoReplace _LIBCPP_HAS_NO_<C++03 feature> with _LIBCPP_CXX03_LANG in <array>
Eric Fiselier [Sun, 16 Apr 2017 02:50:40 +0000 (02:50 +0000)]
Replace _LIBCPP_HAS_NO_<C++03 feature> with _LIBCPP_CXX03_LANG in <array>

llvm-svn: 300412

7 years agoWorkaround Clang bug regarding template template parameters
Eric Fiselier [Sun, 16 Apr 2017 02:47:46 +0000 (02:47 +0000)]
Workaround Clang bug regarding template template parameters

llvm-svn: 300411

7 years agoReplace _LIBCPP_HAS_NO_<C++03 feature> with _LIBCPP_CXX03_LANG in vector.
Eric Fiselier [Sun, 16 Apr 2017 02:40:45 +0000 (02:40 +0000)]
Replace _LIBCPP_HAS_NO_<C++03 feature> with _LIBCPP_CXX03_LANG in vector.

This patch cleans up all usages of the following feature test macros inside
<vector> and its tests:

* _LIBCPP_HAS_NO_RVALUE_REFERENCES
* _LIBCPP_HAS_NO_VARIADICS
* _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

Where needed the above guards were replaced with _LIBCPP_CXX03_LANG.

llvm-svn: 300410

7 years ago[CMake][libcxx] Fix the --target and --gcc-toolchain flag handling
Petr Hosek [Sun, 16 Apr 2017 02:25:55 +0000 (02:25 +0000)]
[CMake][libcxx] Fix the --target and --gcc-toolchain flag handling

CMake has the problem with the single dash variant because of the
space, so use the double dash with equal sign version. We also
don't have to pass the target triple when checking for compiler-rt
since that flag is already included in compile flags now.

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

llvm-svn: 300409

7 years agoCleanup and better scope unique_ptr internals
Eric Fiselier [Sun, 16 Apr 2017 02:14:31 +0000 (02:14 +0000)]
Cleanup and better scope unique_ptr internals

llvm-svn: 300408

7 years agoCleanup default_delete specializations
Eric Fiselier [Sun, 16 Apr 2017 02:06:25 +0000 (02:06 +0000)]
Cleanup default_delete specializations

llvm-svn: 300407

7 years agoOverhaul unique_ptr - Implement LWG 2801, 2905, 2520.
Eric Fiselier [Sun, 16 Apr 2017 01:51:04 +0000 (01:51 +0000)]
Overhaul unique_ptr - Implement LWG 2801, 2905, 2520.

This patch overhauls both specializations of unique_ptr while implementing
the following LWG issues:

* LWG 2801 - This issue constrains unique_ptr's constructors when the deleter type
  is not default constructible. Additionally it adds SFINAE conditions
  to unique_ptr<T[]>::unique_ptr(Up).

* LWG 2905 - This issue reworks the unique_ptr(pointer, /* see below */ deleter)
  constructors so that they correctly SFINAE when the deleter argument cannot
  be used to construct the stored deleter.

* LWG 2520 - This issue fixes initializing unique_ptr<T[]> from nullptr.
  Libc++ had previously implemented this issue, but the suggested resolution
  still broke initialization from NULL. This patch re-works the
  unique_ptr<T[]>(Up, deleter) overloads so that they accept NULL as well
  as nullptr.

llvm-svn: 300406

7 years ago[APInt] Fix a bug in lshr by a value more than 64 bits above the bit width.
Craig Topper [Sun, 16 Apr 2017 01:03:51 +0000 (01:03 +0000)]
[APInt] Fix a bug in lshr by a value more than 64 bits above the bit width.

This was throwing an assert because we determined the intra-word shift amount by subtracting the size of the full word shift from the total shift amount. But we failed to account for the fact that we clipped the full word shifts by total words first. To fix this just calculate the intra-word shift as the remainder of dividing by bits per word.

llvm-svn: 300405

7 years agoUse correct registers for "A" inline asm constraint
Dimitry Andric [Sat, 15 Apr 2017 22:15:01 +0000 (22:15 +0000)]
Use correct registers for "A" inline asm constraint

Summary:
In PR32594, inline assembly using the 'A' constraint on x86_64 causes
llvm to crash with a "Cannot select" stack trace.  This is because
`X86TargetLowering::getRegForInlineAsmConstraint` hardcodes that 'A'
means the EAX and EDX registers.

However, on x86_64 it means the RAX and RDX registers, and on 16-bit x86
(ia16?) it means the old AX and DX registers.

Add new register classes in `X86RegisterInfo.td` to support these cases,
and amend the logic in `getRegForInlineAsmConstraint` to cope with
different subtargets.  Also add a test case, derived from PR32594.

Reviewers: craig.topper, qcolombet, RKSimon, ab

Reviewed By: ab

Subscribers: ab, emaste, royger, llvm-commits

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

llvm-svn: 300404

7 years agoImplement LWG 2857 for variant. Tests from Casey Carter @ Microsoft.
Eric Fiselier [Sat, 15 Apr 2017 19:32:02 +0000 (19:32 +0000)]
Implement LWG 2857 for variant. Tests from Casey Carter @ Microsoft.

Also mark LWG 2857 as complete, since the changes to optional and
any were completed by Marshall earlier.

llvm-svn: 300403

7 years ago[InstCombine] allow (X != C1 && X != C2) and similar patterns to match splat vector...
Sanjay Patel [Sat, 15 Apr 2017 17:55:06 +0000 (17:55 +0000)]
[InstCombine] allow (X != C1 && X != C2) and similar patterns to match splat vector constants

llvm-svn: 300402

7 years ago[InstCombine] add tests to show missing transforms for vectors; NFC
Sanjay Patel [Sat, 15 Apr 2017 17:50:45 +0000 (17:50 +0000)]
[InstCombine] add tests to show missing transforms for vectors; NFC

llvm-svn: 300401

7 years agoAdd isStaticStorageClass to the dynamic matcher registry so that it can be used from...
Aaron Ballman [Sat, 15 Apr 2017 12:53:20 +0000 (12:53 +0000)]
Add isStaticStorageClass to the dynamic matcher registry so that it can be used from clang-query.

Patch by Dave Lee.

llvm-svn: 300400

7 years agoSimplify test helper
Eric Fiselier [Sat, 15 Apr 2017 12:05:11 +0000 (12:05 +0000)]
Simplify test helper

llvm-svn: 300399

7 years agoUpdate isl bindings to latest version (+ Polly extensions)
Tobias Grosser [Sat, 15 Apr 2017 08:15:54 +0000 (08:15 +0000)]
Update isl bindings to latest version (+ Polly extensions)

After the isl C++ binding generator is now close to being upstreamed to isl, we
synchronize the latest changes to Polly. These are mostly formatting changes
plus a small interface change for the foreach callback function and some naming
changes in isl::boolean.

llvm-svn: 300398

7 years agoFix PR32642 - string::insert and string::append don't work with move_iterator.
Eric Fiselier [Sat, 15 Apr 2017 06:49:02 +0000 (06:49 +0000)]
Fix PR32642 - string::insert and string::append don't work with move_iterator.

llvm-svn: 300397

7 years ago[ObjC] Use empty Objective-C collection literal constants when
Akira Hatanaka [Sat, 15 Apr 2017 06:42:00 +0000 (06:42 +0000)]
[ObjC] Use empty Objective-C collection literal constants when
available.

Original patch by Douglas Gregor with minor modifications.

This recommits r300389, which broke bots because there have been API
changes since the original patch was written.

rdar://problem/20689633

llvm-svn: 300396

7 years agoWhen we turn on vsx it should also turn on altivec explicitly, same
Eric Christopher [Sat, 15 Apr 2017 06:15:00 +0000 (06:15 +0000)]
When we turn on vsx it should also turn on altivec explicitly, same
with disabling it as well as disabling all vsx specific features when
turning off altivec.

Fixes PR32663.

llvm-svn: 300395

7 years agoTidy checking for the soft float attribute.
Eric Christopher [Sat, 15 Apr 2017 06:14:52 +0000 (06:14 +0000)]
Tidy checking for the soft float attribute.

llvm-svn: 300394

7 years agoCache the DataLayout rather than looking it up frequently.
Eric Christopher [Sat, 15 Apr 2017 06:14:50 +0000 (06:14 +0000)]
Cache the DataLayout rather than looking it up frequently.

llvm-svn: 300393

7 years agoDo not run tests for crash recovery if libstdc++ safe mode is enabled
Serge Pavlov [Sat, 15 Apr 2017 05:53:49 +0000 (05:53 +0000)]
Do not run tests for crash recovery if libstdc++ safe mode is enabled

If expensive checks are enabled, safe mode of libstdc++ is enabled too.
In this mode the library uses more complex data that allow additional
checks, for instance, a container may keep list of iterators that points
to it. If a code crashes it can leave these complex library objects in
inconsistent state. It occurs in a few tests that check error recovery
if compiler crashes. These test hang in expensive check mode, as the
library tries to synchronize access to the iterators pointing to some
container, but corresponding mutex remains locked after the crash.

This fix marks these tests as unsupported if clang is built with
libstdc++ safe mode enabled.

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

llvm-svn: 300392

7 years agoRevert "[ObjC] Use empty Objective-C collection literal constants when"
Akira Hatanaka [Sat, 15 Apr 2017 05:44:27 +0000 (05:44 +0000)]
Revert "[ObjC] Use empty Objective-C collection literal constants when"

This reverts commit r300389. There were mistakes in the changes I made
to CodeGen.

llvm-svn: 300391

7 years ago[libcxx] Fix check-cxx-abilist on OS X
Eric Fiselier [Sat, 15 Apr 2017 05:41:45 +0000 (05:41 +0000)]
[libcxx] Fix check-cxx-abilist on OS X

Summary:
Recent commits broke the check-cxx-abilist by changing the default OS X to use `-rexport_library` instead of `-reexport_symbol_list`. Apparently `-reexport_library` doesn't export the symbols into `libc++.dylib`s symbol table, whereas `-reexport_symbol_list` does.

This means the change removed ~500 symbols from the symbol table. I've been told this change is non ABI breaking, but it does make it harder to maintain the ABI lists, and hence the ABI.

This patch fixes the issue by switching back to `-reexport_symbol_list`. It still avoid the issues fixed in r299052 by putting the new/delete symbols in a different symbol list file, which is only exported when LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS in OFF.

Reviewers: mehdi_amini, smeenai, dexonsmith

Reviewed By: smeenai

Subscribers: mgorny, cfe-commits

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

llvm-svn: 300390

7 years ago[ObjC] Use empty Objective-C collection literal constants when
Akira Hatanaka [Sat, 15 Apr 2017 05:31:35 +0000 (05:31 +0000)]
[ObjC] Use empty Objective-C collection literal constants when
available.

Original patch by Douglas Gregor with minor modifications.

rdar://problem/20689633

llvm-svn: 300389

7 years agoRewrite and cleanup unique_ptr tests.
Eric Fiselier [Sat, 15 Apr 2017 05:28:06 +0000 (05:28 +0000)]
Rewrite and cleanup unique_ptr tests.

This patch almost entirely rewrites the unique_ptr tests. There are a couple
of reasons for this:

A) Most of the *.fail.cpp tests were either incorrect or could be better written
  as a *.pass.cpp test that uses <type_traits> to check if certain operations
  are valid (Ex. Using static_assert(!std::is_copy_constructible_v<T>) instead
  of writing a failure test).

B) [unique.ptr.runtime] has very poor test coverage. Many of the constructors
  and assignment operators have to tests at all. The special members that have
  tests have very few test cases and are typically way out of date.

C) The tests for [unique.ptr.single] and [unique.ptr.runtime] are largely
  duplicates of each other. This means common requirements have two different
  sets of tests in two different test files. This makes the tests harder to
  maintain than if there was a single copy.

To address (A) this patch changes almost all of the *.fail.cpp tests into
.pass.cpp tests using type traits; Allowing the *.fail.cpp tests to be removed.

The address (B) and (C) the tests for [unique.ptr.single] and [unique.ptr.runtime]
have been combined into a single directory, allowing both specializations to share
common tests. Tests specific to the single/runtime specializations are given the
suffix "*.single.pass.cpp" or "*.runtime.pass.cpp".

Finally the unique.ptr test have been moved into the correct directory according
to the standard. Specifically they have been removed from "utilities/memory" into
"utilities/smartptr".

PS. This patch also adds newly written tests for upcoming unique_ptr changes/fixes.
However since these tests don't currently pass they are guarded by the macro
TEST_WORKAROUND_UPCOMING_UNIQUE_PTR_CHANGES. This allows other STL's to validate
the tests before libc++ implements the changes. The relevant libc++ changes should
land in the next week.

llvm-svn: 300388

7 years agoMake clang-format use C++03 syntax
Eric Fiselier [Sat, 15 Apr 2017 02:45:43 +0000 (02:45 +0000)]
Make clang-format use C++03 syntax

llvm-svn: 300387

7 years agoFix crash when completing in the current directory.
Zachary Turner [Sat, 15 Apr 2017 02:44:53 +0000 (02:44 +0000)]
Fix crash when completing in the current directory.

llvm-svn: 300386

7 years ago[MachO/X86_64] Simplify isDataInCodeTransition().
Davide Italiano [Sat, 15 Apr 2017 01:50:51 +0000 (01:50 +0000)]
[MachO/X86_64] Simplify isDataInCodeTransition().

llvm-svn: 300385

7 years ago[MachO/AArch64] Merge multiple switch cases into one. NFCI.
Davide Italiano [Sat, 15 Apr 2017 01:42:55 +0000 (01:42 +0000)]
[MachO/AArch64] Merge multiple switch cases into one. NFCI.

llvm-svn: 300384

7 years ago[profile] Sync up InstrProfData.inc (NFC)
Vedant Kumar [Sat, 15 Apr 2017 00:10:33 +0000 (00:10 +0000)]
[profile] Sync up InstrProfData.inc (NFC)

llvm-svn: 300383

7 years ago[Coverage] Use the new getInstrProfSectionName API (NFC)
Vedant Kumar [Sat, 15 Apr 2017 00:10:05 +0000 (00:10 +0000)]
[Coverage] Use the new getInstrProfSectionName API (NFC)

llvm-svn: 300382

7 years ago[ProfileData] Unify getInstrProf*SectionName helpers
Vedant Kumar [Sat, 15 Apr 2017 00:09:57 +0000 (00:09 +0000)]
[ProfileData] Unify getInstrProf*SectionName helpers

This is a version of D32090 that unifies all of the
`getInstrProf*SectionName` helper functions. (Note: the build failures
which D32090 would have addressed were fixed with r300352.)

We should unify these helper functions because they are hard to use in
their current form. E.g we recently introduced more helpers to fix
section naming for COFF files. This scheme doesn't totally succeed at
hiding low-level details about section naming, so we should switch to an
API that is easier to maintain.

This is not an NFC commit because it fixes llvm-cov's testing support
for COFF files (this falls out of the API change naturally). This is an
area where we lack tests -- I will see about adding one as a follow up.

Testing: check-clang, check-profile, check-llvm.

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

llvm-svn: 300381

7 years agoModules: Do not serialize #pragma pack state
Duncan P. N. Exon Smith [Sat, 15 Apr 2017 00:07:57 +0000 (00:07 +0000)]
Modules: Do not serialize #pragma pack state

The modules side of r299226, which serializes #pragma pack state,
doesn't work well.

The main purpose was to make -include and -include-pch match semantics
(the PCH side).  We also started serializing #pragma pack in PCMs, in
the hopes of making modules and non-modules builds more consistent.  But
consider:

    $ cat a.h
    $ cat b.h
    #pragma pack(push, 2)
    $ cat module.modulemap
    module M {
        module a { header "a.h" }
        module b { header "b.h" }
    }
    $ cat t.cpp
    #include "a.h"
    #pragma pack(show)

As of r299226, the #pragma pack(show) gives "2", even though we've only
included "a.h".

- With -fmodules-local-submodule-visibility, this is clearly wrong.  We
  should get the default state (8 on x86_64).

- Without -fmodules-local-submodule-visibility, this kind of matches how
  other things work (as if include-the-whole-module), but it's still
  really terrible, and it doesn't actually make modules and non-modules
  builds more consistent.

This commit disables the serialization for modules, essentially a
partial revert of r299226.

Going forward:

 1. Having this #pragma pack stuff escape is terrible design (or, more
    often, a horrible bug).  We should prioritize adding warnings (maybe
    -Werror by default?).

 2. If we eventually reintroduce this for modules, it should only apply
    to -fmodules-local-submodule-visibility, and it should be tracked on
    a per-submodule basis.

llvm-svn: 300380

7 years agoGeneralize SCEV's unit testing helper a bit
Sanjoy Das [Fri, 14 Apr 2017 23:47:53 +0000 (23:47 +0000)]
Generalize SCEV's unit testing helper a bit

llvm-svn: 300379

7 years ago[Interpreter] Make a static func a lambda and remove always_inline.
Davide Italiano [Fri, 14 Apr 2017 22:36:08 +0000 (22:36 +0000)]
[Interpreter] Make a static func a lambda and remove always_inline.

The attribute was fairly dubious as: a) we shouldn't tell the compiler
when to inline functions, b) GCC complains that the function may be
not always inlinable.

llvm-svn: 300377

7 years ago[InstCombine] MakeAnd/Or/Xor handling to reuse previous APInt computations
Craig Topper [Fri, 14 Apr 2017 22:34:14 +0000 (22:34 +0000)]
[InstCombine] MakeAnd/Or/Xor handling to reuse previous APInt computations

When checking if we should return a constant, we create some temporary APInts to see if we know all bits. But the exact computations we do are needed in several other locations in the same code.

This patch moves them to named temporaries so we can reuse them.

Ideally we'd write directly to KnownZero/One, but we currently seem to only write those variables after all the simplifications checks and I didn't want to change that with this patch.

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

llvm-svn: 300376

7 years ago[ARM/Emulation] Remove an unneeded comparison and simplify. NFCI.
Davide Italiano [Fri, 14 Apr 2017 22:27:28 +0000 (22:27 +0000)]
[ARM/Emulation] Remove an unneeded comparison and simplify. NFCI.

reg0 is always zero and comparison to an unsigned always yields
true.

llvm-svn: 300375

7 years agoFix bot breakage from r300372
Chris Bieneman [Fri, 14 Apr 2017 22:20:36 +0000 (22:20 +0000)]
Fix bot breakage from r300372

Use #cmakedefine instead of #cmakedefine01 because the uses are ifndef instead of if.

llvm-svn: 300374

7 years ago[Process/Utility] Remove dead code. NFCI.
Davide Italiano [Fri, 14 Apr 2017 22:04:05 +0000 (22:04 +0000)]
[Process/Utility] Remove dead code. NFCI.

llvm-svn: 300373

7 years ago[CMake] Support generating Config.h
Chris Bieneman [Fri, 14 Apr 2017 22:03:45 +0000 (22:03 +0000)]
[CMake] Support generating Config.h

Summary:
This patch removes the hand maintained config files in favor of auto-generating the config file. We will still need to maintain the defines for the Xcode builds on Mac, but all CMake builds use the generated header instead.

This will enable finer grained platform support tests and enable supporting LLDB on more platforms with less manual maintenance.

I have only tested this patch on Darwin, and any help testing it out on other platforms would be greatly appreciated. I've probably messed something up somewhere.

Reviewers: labath, zturner

Reviewed By: labath

Subscribers: krytarowski, emaste, srhines, lldb-commits, mgorny

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

llvm-svn: 300372

7 years ago[ubsan] Don't check alignment if the alignment is 1
Vedant Kumar [Fri, 14 Apr 2017 22:03:37 +0000 (22:03 +0000)]
[ubsan] Don't check alignment if the alignment is 1

If a pointer is 1-byte aligned, there's no use in checking its
alignment. Somewhat surprisingly, ubsan can spend a significant amount
of time doing just that!

This loosely depends on D30283.

Testing: check-clang, check-ubsan, and a stage2 ubsan build.

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

llvm-svn: 300371

7 years ago[ubsan] Reduce alignment checking of C++ object pointers
Vedant Kumar [Fri, 14 Apr 2017 22:03:34 +0000 (22:03 +0000)]
[ubsan] Reduce alignment checking of C++ object pointers

This patch teaches ubsan to insert an alignment check for the 'this'
pointer at the start of each method/lambda. This allows clang to emit
significantly fewer alignment checks overall, because if 'this' is
aligned, so are its fields.

This is essentially the same thing r295515 does, but for the alignment
check instead of the null check. One difference is that we keep the
alignment checks on member expressions where the base is a DeclRefExpr.
There's an opportunity to diagnose unaligned accesses in this situation
(as pointed out by Eli, see PR32630).

Testing: check-clang, check-ubsan, and a stage2 ubsan build.

Along with the patch from D30285, this roughly halves the amount of
alignment checks we emit when compiling X86FastISel.cpp. Here are the
numbers from patched/unpatched clangs based on r298160.

  ------------------------------------------
  | Setup          | # of alignment checks |
  ------------------------------------------
  | unpatched, -O0 |                 24326 |
  | patched, -O0   |                 12717 | (-47.7%)
  ------------------------------------------

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

llvm-svn: 300370

7 years ago[RDF] No longer ignore implicit defs or uses on any instructions
Krzysztof Parzyszek [Fri, 14 Apr 2017 21:19:17 +0000 (21:19 +0000)]
[RDF] No longer ignore implicit defs or uses on any instructions

This used to be a Hexagon-specific treatment, but is no longer needed
since it's switched to subregister liveness tracking.

llvm-svn: 300369

7 years ago[RDF] Correctly enumerate reg units for reg masks
Krzysztof Parzyszek [Fri, 14 Apr 2017 21:17:36 +0000 (21:17 +0000)]
[RDF] Correctly enumerate reg units for reg masks

llvm-svn: 300368

7 years ago[IR] Make paramHasAttr to use arg indices instead of attr indices
Reid Kleckner [Fri, 14 Apr 2017 20:19:02 +0000 (20:19 +0000)]
[IR] Make paramHasAttr to use arg indices instead of attr indices

This avoids the confusing 'CS.paramHasAttr(ArgNo + 1, Foo)' pattern.

Previously we were testing return value attributes with index 0, so I
introduced hasReturnAttr() for that use case.

llvm-svn: 300367

7 years ago[libFuzzer] more trophies
Kostya Serebryany [Fri, 14 Apr 2017 20:11:16 +0000 (20:11 +0000)]
[libFuzzer] more trophies

llvm-svn: 300366

7 years ago[WebAssembly] Improve readobj and nm support for wasm
Sam Clegg [Fri, 14 Apr 2017 19:50:44 +0000 (19:50 +0000)]
[WebAssembly] Improve readobj and nm support for wasm

Now that the libObect support for wasm is better we can
have readobj and nm produce more useful output too.

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

llvm-svn: 300365

7 years ago[InstCombine] (X != C1 && X != C2) --> (X | (C1 ^ C2)) != C2
Sanjay Patel [Fri, 14 Apr 2017 19:23:50 +0000 (19:23 +0000)]
[InstCombine] (X != C1 && X != C2) --> (X | (C1 ^ C2)) != C2
...when C1 differs from C2 by one bit and C1 <u C2:
http://rise4fun.com/Alive/Vuo

And move related folds to a helper function. This reduces code duplication and
will make it easier to remove the scalar-only restriction as a follow-up step.

llvm-svn: 300364

7 years ago[InstCombine] Support folding a subtract with a constant LHS into a phi node
Craig Topper [Fri, 14 Apr 2017 19:20:12 +0000 (19:20 +0000)]
[InstCombine] Support folding a subtract with a constant LHS into a phi node

We currently only support folding a subtract into a select but not a PHI. This fixes that.

I had to fix an assumption in FoldOpIntoPhi that assumed the PHI node was always in operand 0. Now we pass it in like we do for FoldOpIntoSelect. But we still require some dancing to find the Constant when we create the BinOp or ConstantExpr. This is based code is similar to what we do for selects.

Since I touched all call sites, this also renames FoldOpIntoPhi to foldOpIntoPhi to match coding standards.

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

llvm-svn: 300363

7 years ago[AMDGPU] set read_only access qualifier for pointers
Stanislav Mekhanoshin [Fri, 14 Apr 2017 19:11:40 +0000 (19:11 +0000)]
[AMDGPU] set read_only access qualifier for pointers

If a kernel's pointer argument is known to be readonly
set access qualifier accordingly. This allows RT not to
flush caches before dispatches.

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

llvm-svn: 300362

7 years ago[Test commit] Cleanup some whitespace in a test file
Sam Clegg [Fri, 14 Apr 2017 18:43:57 +0000 (18:43 +0000)]
[Test commit] Cleanup some whitespace in a test file

llvm-svn: 300361

7 years ago[InstCombine] Regenerate test checks using script. NFC
Craig Topper [Fri, 14 Apr 2017 18:42:55 +0000 (18:42 +0000)]
[InstCombine] Regenerate test checks using script. NFC

llvm-svn: 300360

7 years ago[ELF] Remove unused member [NFC]
Rui Ueyama [Fri, 14 Apr 2017 18:38:38 +0000 (18:38 +0000)]
[ELF] Remove unused member [NFC]

Patch by Alexander Richardson.

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

llvm-svn: 300359

7 years ago[ubsan] Use the correct tool name in diagnostics
Vedant Kumar [Fri, 14 Apr 2017 18:24:35 +0000 (18:24 +0000)]
[ubsan] Use the correct tool name in diagnostics

When using ASan and UBSan together, the common sanitizer tool name is
set to "AddressSanitizer". That means that when a UBSan diagnostic is
printed out, it looks like this:

  SUMMARY: AddressSanitizer: ...

This can confuse users. Fix it so that we always use the correct tool
name when printing out UBSan diagnostics.

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

llvm-svn: 300358

7 years ago[InstCombine] add/move tests for and/or-of-icmps equality folds; NFC
Sanjay Patel [Fri, 14 Apr 2017 18:19:27 +0000 (18:19 +0000)]
[InstCombine] add/move tests for and/or-of-icmps equality folds; NFC

llvm-svn: 300357

7 years ago[clang-move] Create ClangMoveActionFactory on stack
Alexander Shaposhnikov [Fri, 14 Apr 2017 18:12:11 +0000 (18:12 +0000)]
[clang-move] Create ClangMoveActionFactory on stack

This diff removes unnecessary using of unique_ptr with ClangMoveActionFactory (pico cleanup).
NFC

Test plan: make check-clang-tools

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

llvm-svn: 300356

7 years ago[ValueTracking] Avoid undefined behavior in unittest by not making a named ArrayRef...
Craig Topper [Fri, 14 Apr 2017 17:59:19 +0000 (17:59 +0000)]
[ValueTracking] Avoid undefined behavior in unittest by not making a named ArrayRef from a std::initializer_list

One of the ValueTracking unittests creates a named ArrayRef initialized by a std::initializer_list. The underlying array for an std::initializer_list is only guaranteed to have a lifetime as long as the initializer_list object itself. So this can leave the ArrayRef pointing at an array that no long exists.

This fixes this to just create an explicit array instead of an ArrayRef.

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

llvm-svn: 300354

7 years ago[InstCombine] Refactor SimplifyUsingDistributiveLaws to more explicitly skip code...
Craig Topper [Fri, 14 Apr 2017 17:55:41 +0000 (17:55 +0000)]
[InstCombine] Refactor SimplifyUsingDistributiveLaws to more explicitly skip code when LHS/RHS aren't BinaryOperators

Currently this code always makes 2 or 3 calls to tryFactorization regardless of whether the LHS/RHS are BinaryOperators. We make 3 calls when both operands are BinaryOperators with the same opcode. Or surprisingly, when neither are BinaryOperators. This is because getBinOpsForFactorization returns Instruction::BinaryOpsEnd when the operand is not a BinaryOperator. If both LHS and RHS are not BinaryOperators then they both have an Opcode of Instruction::BinaryOpsEnd. When this happens we rely on tryFactorization to early out due to A/B/C/D being null. Similar behavior occurs for the other calls, we rely on getBinOpsForFactorization having made A/B or C/D null to get tryFactorization to early out.

We also rely on these null checks to check the result of getIdentityValue and early out for it.

This patches refactors this to pull these checks up to SimplifyUsingDistributiveLaws so we don't rely on BinaryOpsEnd as a sentinel or this A/B/C/D null behavior. I think this makes this code easier to reason about. Should also give a tiny performance improvement for cases where the LHS or RHS isn't a BinaryOperator.

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

llvm-svn: 300353

7 years ago[Profile] Make host tool aware of object format when quering prof section names
Xinliang David Li [Fri, 14 Apr 2017 17:48:40 +0000 (17:48 +0000)]
[Profile] Make host tool aware of object format when quering prof section names

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

llvm-svn: 300352

7 years agoUpdate tests for the patch.
Alexey Bataev [Fri, 14 Apr 2017 17:47:07 +0000 (17:47 +0000)]
Update tests for the patch.

llvm-svn: 300351

7 years agoUse range-for in a few places
Sanjoy Das [Fri, 14 Apr 2017 17:42:12 +0000 (17:42 +0000)]
Use range-for in a few places

llvm-svn: 300350

7 years agoRewrite SCEV Normalization using SCEVRewriteVisitor; NFC
Sanjoy Das [Fri, 14 Apr 2017 17:42:10 +0000 (17:42 +0000)]
Rewrite SCEV Normalization using SCEVRewriteVisitor; NFC

Removes all of the boilerplate, cache management etc. from
ScalarEvolutionNormalization, and keeps only the interesting bits.

llvm-svn: 300349

7 years agoMake SCEVRewriteVisitor smarter about when it trys to create SCEVs
Sanjoy Das [Fri, 14 Apr 2017 17:42:08 +0000 (17:42 +0000)]
Make SCEVRewriteVisitor smarter about when it trys to create SCEVs

This change really saves just one foldingset lookup, but makes
SCEVRewriteVisitor "feature compatible" with the handwritten logic in
ScalarEvolutionNormalization, so that I can change
ScalarEvolutionNormalization to use SCEVRewriteVisitor in a next step.

This is a non-functional change, but _may_ improve performance in some
pathological cases, but that's unlikely.

llvm-svn: 300348

7 years agoRemoving a redundant, but harmless, %s; NFC.
Aaron Ballman [Fri, 14 Apr 2017 17:37:29 +0000 (17:37 +0000)]
Removing a redundant, but harmless, %s; NFC.

llvm-svn: 300347

7 years agoAdd missing #include
Sanjoy Das [Fri, 14 Apr 2017 17:25:23 +0000 (17:25 +0000)]
Add missing #include

Again, caught by the modules build.

llvm-svn: 300346

7 years ago[RDF] Switch RegisterAggr to a bit vector of register units
Krzysztof Parzyszek [Fri, 14 Apr 2017 17:25:13 +0000 (17:25 +0000)]
[RDF] Switch RegisterAggr to a bit vector of register units

This avoids many complications related to the complex register
aliasing schemes.

llvm-svn: 300345

7 years ago[FunctionImport] assert(false) -> llvm_unreachable(). NFCI.
Davide Italiano [Fri, 14 Apr 2017 17:22:02 +0000 (17:22 +0000)]
[FunctionImport] assert(false) -> llvm_unreachable(). NFCI.

llvm-svn: 300344

7 years agoIncrease the packet timeout for the jModulesInfo since it can take longer than the...
Greg Clayton [Fri, 14 Apr 2017 17:10:04 +0000 (17:10 +0000)]
Increase the packet timeout for the jModulesInfo since it can take longer than the default 1 second timeout on some linux versions when many shared libraries are involved.

llvm-svn: 300342

7 years agoFixed to disassemble new packets and fixed the dumping of the 'x' packets.
Greg Clayton [Fri, 14 Apr 2017 17:05:21 +0000 (17:05 +0000)]
Fixed to disassemble new packets and fixed the dumping of the 'x' packets.

llvm-svn: 300341