platform/upstream/llvm.git
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

7 years ago[ObjC] Fix lifetime markers of loop variable in EmitObjCForCollectionStmt [take 2]
Kuba Mracek [Fri, 14 Apr 2017 16:53:25 +0000 (16:53 +0000)]
[ObjC] Fix lifetime markers of loop variable in EmitObjCForCollectionStmt [take 2]

CodeGenFunction::EmitObjCForCollectionStmt currently emits lifetime markers for the loop variable in an inconsistent way:  lifetime.start is emitted before the loop is entered, but lifetime.end is emitted inside the loop. AddressSanitizer uses these markers to track out-of-scope accesses to local variables, and we get false positives in Obj-C foreach loops (in the 2nd iteration of the loop). This patch keeps the loop variable alive for the whole loop by extending ForScope and registering the cleanup function inside EmitAutoVarAlloca.

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

llvm-svn: 300340

7 years agoRemove "#if 0"ed out assert
Sanjoy Das [Fri, 14 Apr 2017 16:47:15 +0000 (16:47 +0000)]
Remove "#if 0"ed out assert

It won't compile after the recent changes I've made, and I think
keeping it in provides very little value.

Instead I've added (in an earlier commit) a C++ unit test to check the
Denormalize(Normalized(X)) == X property for specific instances of X,
which is what the assert was trying to do anyway.

llvm-svn: 300339

7 years agoDelete some unnecessary boilerplate
Sanjoy Das [Fri, 14 Apr 2017 16:47:12 +0000 (16:47 +0000)]
Delete some unnecessary boilerplate

The PostIncTransform class was not pulling its weight, so delete it
and use free functions instead.

This also makes the use of `function_ref` more idiomatic.  We were
storing an instance of function_ref in the PostIncTransform class
before, which was fine in that specific case, but the usage after this
change is more obviously okay.

llvm-svn: 300338

7 years ago[RDF] Refine propagation of reached uses in liveness computation
Krzysztof Parzyszek [Fri, 14 Apr 2017 16:33:54 +0000 (16:33 +0000)]
[RDF] Refine propagation of reached uses in liveness computation

llvm-svn: 300337

7 years agoAdd missing #include for STLExtras
Sanjoy Das [Fri, 14 Apr 2017 16:28:12 +0000 (16:28 +0000)]
Add missing #include for STLExtras

Looks like earlier I was relying on #include ordering in files that
used ScalarEvolutionNormalization.h.

Found thanks to the selfhost modules buildbot!

llvm-svn: 300336

7 years ago[Hexagon] Fix a latent problem with interpreting live-in lane masks
Krzysztof Parzyszek [Fri, 14 Apr 2017 16:21:55 +0000 (16:21 +0000)]
[Hexagon] Fix a latent problem with interpreting live-in lane masks

A non-zero lane mask on a register with no subregister means that the
whole register is live-in. It is equivalent to a full mask.

llvm-svn: 300335

7 years agoUse range for
Sanjoy Das [Fri, 14 Apr 2017 15:50:19 +0000 (15:50 +0000)]
Use range for

llvm-svn: 300334

7 years agoSimplify PostIncTransform further; NFC
Sanjoy Das [Fri, 14 Apr 2017 15:50:07 +0000 (15:50 +0000)]
Simplify PostIncTransform further; NFC

Instead of having two ways to check if an add recurrence needs to be
normalized, just pass in one predicate to decide that.

llvm-svn: 300333

7 years agoAdd a unit test for SCEV Normalization
Sanjoy Das [Fri, 14 Apr 2017 15:50:04 +0000 (15:50 +0000)]
Add a unit test for SCEV Normalization

llvm-svn: 300332

7 years agoTighten the API for ScalarEvolutionNormalization
Sanjoy Das [Fri, 14 Apr 2017 15:49:59 +0000 (15:49 +0000)]
Tighten the API for ScalarEvolutionNormalization

llvm-svn: 300331

7 years agoRemove NormalizeAutodetect; NFC
Sanjoy Das [Fri, 14 Apr 2017 15:49:53 +0000 (15:49 +0000)]
Remove NormalizeAutodetect; NFC

It is cleaner to have a callback based system where the logic of
whether an add recurrence is normalized or not lives on IVUsers.

This is one step in a multi-step cleanup.

llvm-svn: 300330

7 years ago[Hexagon] Make a couple of passes compliant with -opt-bisect-limit
Krzysztof Parzyszek [Fri, 14 Apr 2017 15:26:34 +0000 (15:26 +0000)]
[Hexagon] Make a couple of passes compliant with -opt-bisect-limit

llvm-svn: 300329

7 years agoMake Gentoo GNU GCC Config override whitespace tolerant
Erich Keane [Fri, 14 Apr 2017 15:21:18 +0000 (15:21 +0000)]
Make Gentoo GNU GCC Config override whitespace tolerant

The config-*triple* file handling isn't tolerant of
leading/trailing whitespace, making it not terribly
obvious when a single extraneous tab/space/etc will
cause the override to be ignored. This patch simply
trims the lines to ensure that it is tolerant of
whitespace.

llvm-svn: 300328

7 years ago[Bugpoint] Use boolean AND instead of bitwise AND (PR32660)
Simon Pilgrim [Fri, 14 Apr 2017 15:21:15 +0000 (15:21 +0000)]
[Bugpoint] Use boolean AND instead of bitwise AND (PR32660)

llvm-svn: 300327

7 years ago[X86][SSE] Update MOVNTDQA non-temporal loads to generic implementation (clang)
Simon Pilgrim [Fri, 14 Apr 2017 15:05:57 +0000 (15:05 +0000)]
[X86][SSE] Update MOVNTDQA non-temporal loads to generic implementation (clang)

MOVNTDQA non-temporal aligned vector loads can be correctly represented using generic builtin loads, allowing us to remove the existing x86 intrinsics.

LLVM companion patch: D31767.

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

llvm-svn: 300326

7 years ago[X86][SSE] Update MOVNTDQA non-temporal loads to generic implementation (LLVM)
Simon Pilgrim [Fri, 14 Apr 2017 15:05:35 +0000 (15:05 +0000)]
[X86][SSE] Update MOVNTDQA non-temporal loads to generic implementation (LLVM)

MOVNTDQA non-temporal aligned vector loads can be correctly represented using generic builtin loads, allowing us to remove the existing x86 intrinsics.

Clang companion patch: D31766.

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

llvm-svn: 300325

7 years agoSilence -Wlogical-op-parentheses warning NFC
Nirav Dave [Fri, 14 Apr 2017 14:36:45 +0000 (14:36 +0000)]
Silence -Wlogical-op-parentheses warning NFC

llvm-svn: 300324

7 years agoUse isl C++ foreach implementation
Tobias Grosser [Fri, 14 Apr 2017 13:39:40 +0000 (13:39 +0000)]
Use isl C++ foreach implementation

This commit switches Polly over to the isl::obj::foreach_* implementation, which
is part of the new isl bindings and follows the foreach pattern established in
Polly by Michael Kruse.

The original isl C function:

  isl_stat isl_union_set_foreach_set(__isl_keep isl_union_set *uset,
      isl_stat (*fn)(__isl_take isl_set *set, void *user), void *user);

which required the user to define a static callback function to which all
interesting parameters are passed via a 'void *' user-pointer, is on the
C++ side available as a function that takes a std::function<>, which can
carry any additional arguments without the need for a user pointer:

  stat UnionSet::foreach_set(const std::function<stat(set)> &fn) const;

The following code illustrates the use of the new C++ interface:

  auto Lambda = [=, &Result](isl::set Set) -> isl::stat {
    auto Shifted = shiftDimension(Set, Pos, Amount);
    Result = Result.add(Shifted);
    return isl::stat::ok;
  }

  UnionSet.foreach_set(Lambda);

Polly had some specialized foreach functions which did not require the lambdas
to return a status flag. We remove these functions in this commit to move Polly
completely over to the new isl interface. We may in the future discuss if
functors without return values can be supported easily.

Another extension proposed by Michael Kruse is the use of C++ iterators to allow
the use of normal for loops to iterate over these sets. Such an extension would
allow us to further simplify the code.

Reviewed-by: Michael Kruse <llvm@meinersbur.de>
Differential Revision: https://reviews.llvm.org/D30620

llvm-svn: 300323

7 years agoFix missing virtual destructor to silence build warning.
Nirav Dave [Fri, 14 Apr 2017 13:34:33 +0000 (13:34 +0000)]
Fix missing virtual destructor to silence build warning.

llvm-svn: 300322

7 years agoReorder StoreMergeCandidates to run faster. NFCI.
Nirav Dave [Fri, 14 Apr 2017 13:34:30 +0000 (13:34 +0000)]
Reorder StoreMergeCandidates to run faster. NFCI.

llvm-svn: 300321

7 years ago[clang-tidy] Fixes to misc-forwarding-reference-overload check.
Gabor Horvath [Fri, 14 Apr 2017 12:31:36 +0000 (12:31 +0000)]
[clang-tidy] Fixes to misc-forwarding-reference-overload check.

* Style fixes to tests
* Make it work consistently on all platforms

Patch by AndrĂ¡s Leitereg!

llvm-svn: 300320