platform/upstream/llvm.git
7 years ago[ORC] Add missing file from r300155.
Lang Hames [Thu, 13 Apr 2017 01:06:45 +0000 (01:06 +0000)]
[ORC] Add missing file from r300155.

llvm-svn: 300157

7 years agoUpdate tests -verify error messages after r300140.
Eric Fiselier [Thu, 13 Apr 2017 01:03:41 +0000 (01:03 +0000)]
Update tests -verify error messages after r300140.

llvm-svn: 300156

7 years ago[ORC] Use native Errors rather than converted std::error_codes for ORC RPC.
Lang Hames [Thu, 13 Apr 2017 01:03:06 +0000 (01:03 +0000)]
[ORC] Use native Errors rather than converted std::error_codes for ORC RPC.

llvm-svn: 300155

7 years agoFix more bad member swap definitions in unordered_map.
Eric Fiselier [Thu, 13 Apr 2017 01:02:41 +0000 (01:02 +0000)]
Fix more bad member swap definitions in unordered_map.

The __unordered_map_equal and __unordered_map_hash wrappers
attempt to swap const qualified predicates whenever the predicate
is empty, and is subject to the EBO.

Swapping const values seems blatently incorrect. This patch removes
the const qualifier so the values are swapped as non-const.

llvm-svn: 300154

7 years ago[IR] Take func, ret, and arg attrs separately in AttributeList::get
Reid Kleckner [Thu, 13 Apr 2017 00:58:09 +0000 (00:58 +0000)]
[IR] Take func, ret, and arg attrs separately in AttributeList::get

This seems like a much more natural API, based on Derek Schuff's
comments on r300015. It further hides the implementation detail of
AttributeList that function attributes come last and appear at index
~0U, which is easy for the user to screw up. git diff says it saves code
as well: 97 insertions(+), 137 deletions(-)

This also makes it easier to change the implementation, which I want to
do next.

llvm-svn: 300153

7 years agoFix the default constructibility of __compressed_pair.
Eric Fiselier [Thu, 13 Apr 2017 00:50:45 +0000 (00:50 +0000)]
Fix the default constructibility of __compressed_pair.

This patch fixes a bug where the =default default ctor for
__compressed_pair was incorrect for const qualified types.

llvm-svn: 300152

7 years agoFix broken test. We can't assume that 2MB of args is enough to require a response...
Richard Smith [Thu, 13 Apr 2017 00:46:50 +0000 (00:46 +0000)]
Fix broken test. We can't assume that 2MB of args is enough to require a response file.

This test has apparently been broken for years, but we never noticed before
because it's a long test and long tests approximately never get run.

llvm-svn: 300151

7 years ago[msan] Fix msan_test broken after r299884.
Vitaly Buka [Thu, 13 Apr 2017 00:36:03 +0000 (00:36 +0000)]
[msan] Fix msan_test broken after r299884.

Bind to ANY as some machines may have IPv6 support but without IPv6 on loopback
interface.

Reviewers: eugenis

Subscribers: llvm-commits

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

llvm-svn: 300150

7 years ago[msan] Fix invalid use of vector constructor introduced by r299884.
Vitaly Buka [Thu, 13 Apr 2017 00:36:02 +0000 (00:36 +0000)]
[msan] Fix invalid use of vector constructor introduced by r299884.

llvm-svn: 300149

7 years agoFix most failures caused by r300140
Eric Fiselier [Thu, 13 Apr 2017 00:34:24 +0000 (00:34 +0000)]
Fix most failures caused by r300140

r300140 introduced a bunch of failures by changing the internal
interface provided by __compressed_pair. This patch fixes all of
the failures caused by the new interface by changing the existing
code to use it.

In addition to those changes this patch also fixes two separate
issues causing test failures:

1) Fix the member swap definition for __map_value_compare. Previously
   the swap was incorrectly configured to swap the comparator as const.

2) Fix an assertion failure in futures.task.members/ctor_func_alloc.pass.cpp
that incorrectly expected a move to take place when a single copy is sufficient.

There is one remaining failure regarding make_shared. I'll commit a fix for that
shortly.

llvm-svn: 300148

7 years agoDo not initialize this->SoName with this->DefaultSoName.
Rui Ueyama [Thu, 13 Apr 2017 00:23:32 +0000 (00:23 +0000)]
Do not initialize this->SoName with this->DefaultSoName.

This patch uses DefaultSoName in getSoName instead of in parseSoName.
I think this is more readable. This patch also add comments.

llvm-svn: 300147

7 years ago[IR] Remove the APIntMoveTy typedef from ConstantRange. Use APInt type directly.
Craig Topper [Thu, 13 Apr 2017 00:20:31 +0000 (00:20 +0000)]
[IR] Remove the APIntMoveTy typedef from ConstantRange. Use APInt type directly.

This typedef used to be conditional based on whether rvalue references were supported. Looks like it got left behind when we switched to always having rvalue references with c++11. I don't think it provides any value now.

llvm-svn: 300146

7 years agoExternalASTMerger.cpp: Silence another warning. [-Wunused-lambda-capture]
NAKAMURA Takumi [Thu, 13 Apr 2017 00:17:28 +0000 (00:17 +0000)]
ExternalASTMerger.cpp: Silence another warning. [-Wunused-lambda-capture]

llvm-svn: 300145

7 years agoWork around MSVC rejects-valid bug related to C++11 narrowing conversions.
Richard Smith [Thu, 13 Apr 2017 00:14:39 +0000 (00:14 +0000)]
Work around MSVC rejects-valid bug related to C++11 narrowing conversions.

llvm-svn: 300144

7 years agoFix compiler error in Attributes.cpp
Konstantin Zhuravlyov [Wed, 12 Apr 2017 23:57:37 +0000 (23:57 +0000)]
Fix compiler error in Attributes.cpp
```
Compiling Attributes.cpp ...
../../../Attributes.cpp: In member function 'std::__1::pair<unsigned int, llvm::Optional<unsigned int> > llvm::AttributeSet::getAllocSizeArgs() const':
../../../Attributes.cpp:542:69: error: operands to ?: have different types 'std::__1::pair<unsigned int, llvm::Optional<unsigned int> >' and 'std::__1::pair<int, int>'
   return SetNode ? SetNode->getAllocSizeArgs() : std::make_pair(0, 0);
                                                                     ^
../../../Attributes.cpp:543:1: error: control reaches end of non-void function [-Werror=return-type]
 }
 ^
```

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

llvm-svn: 300143

7 years agoAMDGPU : Fix common dominator of two incoming blocks terminates with uniform branch...
Wei Ding [Wed, 12 Apr 2017 23:51:47 +0000 (23:51 +0000)]
AMDGPU : Fix common dominator of two incoming blocks terminates with uniform branch issue.

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

llvm-svn: 300142

7 years agoUpdate to match LLVM r300135.
Richard Smith [Wed, 12 Apr 2017 23:51:20 +0000 (23:51 +0000)]
Update to match LLVM r300135.

llvm-svn: 300141

7 years ago[libcxx] Fix __compressed_pair so it doesn't copy the argument multiple times, and...
Eric Fiselier [Wed, 12 Apr 2017 23:45:53 +0000 (23:45 +0000)]
[libcxx] Fix __compressed_pair so it doesn't copy the argument multiple times, and add constexpr.

Summary:
__compressed_pair takes and passes it's constructor arguments by value. This causes arguments to be moved 3 times instead of once. This patch addresses that issue and fixes `constexpr` on the constructors.

I would rather have this fix than D27564, and I'm fairly confident it's not ABI breaking but I'm not 100% sure.

I prefer this solution because it removes a lot of code and makes the implementation *much* smaller.

Reviewers: mclow.lists, K-ballo

Reviewed By: K-ballo

Subscribers: K-ballo, cfe-commits

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

llvm-svn: 300140

7 years agoFix some ArgList uses after API change in r300135.
Richard Smith [Wed, 12 Apr 2017 23:43:58 +0000 (23:43 +0000)]
Fix some ArgList uses after API change in r300135.

llvm-svn: 300139

7 years agoUse two LC_NOTE load commands for identifying the main binary that
Jason Molenda [Wed, 12 Apr 2017 23:33:30 +0000 (23:33 +0000)]
Use two LC_NOTE load commands for identifying the main binary that
lldb should use when given a corefile.

This uses an LC_NOTE "main bin spec" or an LC_NOTE "kern ver str"
if they are present in a Mach-O core file.

Core files may have multiple different binaries -- different kernels,
or a mix of user process and kernel binaries -- and it can be
difficult for lldb to detect the correct one to use simply by looking
at the pages of memory.  These two new LC_NOTE load commands allow
for the correct binary to be recorded unambiguously.

<rdar://problem/20878266>

llvm-svn: 300138

7 years agoFix initialization order of class members.
Zachary Turner [Wed, 12 Apr 2017 23:27:43 +0000 (23:27 +0000)]
Fix initialization order of class members.

llvm-svn: 300137

7 years agoUpdate to match LLVM r300135.
Richard Smith [Wed, 12 Apr 2017 23:21:25 +0000 (23:21 +0000)]
Update to match LLVM r300135.

Remove "REQUIRES: long_tests" from test/Driver/response-file.c since it is now about 10x faster. (We can add that back if it's still too slow for some buildbot.)

llvm-svn: 300136

7 years agoArgList: cache index ranges containing arguments with each ID
Richard Smith [Wed, 12 Apr 2017 23:19:51 +0000 (23:19 +0000)]
ArgList: cache index ranges containing arguments with each ID

Improve performance of argument list parsing with large numbers of IDs and
large numbers of arguments, by tracking a conservative range of indexes within
the argument list that might contain an argument with each ID. In the worst
case (when the first and last argument with a given ID are at the opposite ends
of the argument list), this still results in a linear-time walk of the list,
but it helps substantially in the common case where each ID occurs only once,
or a few times close together in the list.

This gives a ~10x speedup to clang's `test/Driver/response-file.c`, which
constructs a very large set of command line arguments and feeds them to the
clang driver.

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

llvm-svn: 300135

7 years ago[llvm-pdbdump] Minor prepatory refactor of Class Def Dumper.
Zachary Turner [Wed, 12 Apr 2017 23:18:51 +0000 (23:18 +0000)]
[llvm-pdbdump] Minor prepatory refactor of Class Def Dumper.

In a followup patch I intend to introduce an additional dumping
mode which dumps a graphical representation of a class's layout.
In preparation for this, the text-based layout printer needs to
be split out from the graphical layout printer, and both need
to be able to use the same code for printing the intro and outro
of a class's definition (e.g. base class list, etc).

This patch does so, and in the process introduces a skeleton
definition for the graphical printer, while currently making
the graphical printer just print nothing.

NFC

llvm-svn: 300134

7 years ago[llvm-pdbdump] More advanced class definition dumping.
Zachary Turner [Wed, 12 Apr 2017 23:18:21 +0000 (23:18 +0000)]
[llvm-pdbdump] More advanced class definition dumping.

Previously the dumping of class definitions was very primitive,
and it made it hard to do more than the most trivial of output
formats when dumping.  As such, we would only dump one line for
each field, and then dump non-layout items like nested types
and enums.

With this patch, we do a complete analysis of the object
hierarchy including aggregate types, bases, virtual bases,
vftable analysis, etc.  The only immediately visible effects
of this are that a) we can now dump a line for the vfptr where
before we would treat that as padding, and b) we now don't
treat virtual bases that come at the end of a class as padding
since we have a more detailed analysis of the class's storage
usage.

In subsequent patches, we should be able to use this analysis
to display a complete graphical view of a class's layout including
recursing arbitrarily deep into an object's base class / aggregate
member hierarchy.

llvm-svn: 300133

7 years agoFix test failures with older Clang versions
Eric Fiselier [Wed, 12 Apr 2017 23:17:17 +0000 (23:17 +0000)]
Fix test failures with older Clang versions

llvm-svn: 300132

7 years agoAllow expressions in MEMORY command.
Rui Ueyama [Wed, 12 Apr 2017 23:16:52 +0000 (23:16 +0000)]
Allow expressions in MEMORY command.

Previously, we allowed only integers in this context. Now you can
write expressions there. LLD is now able to handle the following
linker, for example.

  MEMORY { rom (rx) : ORIGIN = (1024 * 1024) }

llvm-svn: 300131

7 years agoMake intentional typos look more obvious.
Rui Ueyama [Wed, 12 Apr 2017 23:16:33 +0000 (23:16 +0000)]
Make intentional typos look more obvious.

We do not check for similarities when handling unknown tokens in
linker scripts, so "ORIGI" and "LENTH" are not good tokens as a test
for unknown tokens, as I was tempted to "fix" them.

llvm-svn: 300130

7 years agoRemove redundant spaces.
Rui Ueyama [Wed, 12 Apr 2017 23:16:13 +0000 (23:16 +0000)]
Remove redundant spaces.

llvm-svn: 300129

7 years agoRemove useless 0x prefixes.
Rui Ueyama [Wed, 12 Apr 2017 23:15:55 +0000 (23:15 +0000)]
Remove useless 0x prefixes.

llvm-svn: 300128

7 years ago[libFuzzer] XFAIL fuzzer-oom.test on Darwin.
Akira Hatanaka [Wed, 12 Apr 2017 23:15:10 +0000 (23:15 +0000)]
[libFuzzer] XFAIL fuzzer-oom.test on Darwin.

The test fails on Darwin because Fuzzer::DeathCallback (which calls
DumpCurrentUnit("crash-")) is called before DumpCurrentUnit("oom-") is
called in Fuzzer::RssLimitCallback. DeathCallback is transitively called
from __sanitizer_print_memory_profile.

This should fix the fuzzer bot that has been failing for a while:

http://lab.llvm.org:8080/green/job/libFuzzer/

llvm-svn: 300127

7 years ago[libc++] Implement LWG 2911 - add an is_aggregate type-trait
Eric Fiselier [Wed, 12 Apr 2017 23:08:46 +0000 (23:08 +0000)]
[libc++] Implement LWG 2911 - add an is_aggregate type-trait

Summary:
This patch implements http://cplusplus.github.io/LWG/lwg-defects.html#2911.

I'm putting this up for review until __is_aggregate is added to clang (See D31513)

Reviewers: mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

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

llvm-svn: 300126

7 years ago[InstSimplify] Don't try to constant fold AllocaInsts since it won't do anything.
Craig Topper [Wed, 12 Apr 2017 22:54:24 +0000 (22:54 +0000)]
[InstSimplify] Don't try to constant fold AllocaInsts since it won't do anything.

Should give a small compile time improvement.

llvm-svn: 300125

7 years agoAdditional test file for r300123
Marshall Clow [Wed, 12 Apr 2017 22:51:56 +0000 (22:51 +0000)]
Additional test file for r300123

llvm-svn: 300124

7 years agoImplement part of LWG#2857 - any/optional. Still to do - variant. Reviewed as https...
Marshall Clow [Wed, 12 Apr 2017 22:51:27 +0000 (22:51 +0000)]
Implement part of LWG#2857 - any/optional. Still to do - variant. Reviewed as https://reviews.llvm.org/D31956

llvm-svn: 300123

7 years ago[clang-cl] Make all sanitizer flags available in clang-cl
Reid Kleckner [Wed, 12 Apr 2017 22:50:51 +0000 (22:50 +0000)]
[clang-cl] Make all sanitizer flags available in clang-cl

Summary:
Use a tablegen let {} block so that new sanitizer flags are available by
default in all driver modes. This should cut down on time wasted with
bugs like http://crbug.com/710928.

Reviewers: vitalybuka, hans

Subscribers: kcc, llvm-commits

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

llvm-svn: 300122

7 years agoFix incorrectly qualified return type from unique_ptr::get_deleter().
Eric Fiselier [Wed, 12 Apr 2017 22:43:49 +0000 (22:43 +0000)]
Fix incorrectly qualified return type from  unique_ptr::get_deleter().

For reference deleter types the const qualifier on the return type
of get_deleter() should be ignored, and a non-const deleter should
be returned.

This patch fixes a bug where "const deleter_type&" is incorrectly
formed.

llvm-svn: 300121

7 years agoMake a few tests shorter. NFC.
Rui Ueyama [Wed, 12 Apr 2017 22:38:02 +0000 (22:38 +0000)]
Make a few tests shorter. NFC.

llvm-svn: 300120

7 years ago[IR] Make AttributeSet constructor from AttributeSetNode* explicit
Reid Kleckner [Wed, 12 Apr 2017 22:30:37 +0000 (22:30 +0000)]
[IR] Make AttributeSet constructor from AttributeSetNode* explicit

llvm-svn: 300119

7 years ago[ValueTracking] Teach GetUnderlyingObject to stop when it reachs an alloca instruction.
Craig Topper [Wed, 12 Apr 2017 22:29:23 +0000 (22:29 +0000)]
[ValueTracking] Teach GetUnderlyingObject to stop when it reachs an alloca instruction.

Previously it tried to call SimplifyInstruction which doesn't know anything about alloca so defers to constant folding which also doesn't do anything with alloca. This results in wasted cycles making calls that won't do anything. Given the frequency with which this function is called this time adds up.

llvm-svn: 300118

7 years ago[IR] Assert that we never create an empty AttributeListImpl, NFC
Reid Kleckner [Wed, 12 Apr 2017 22:22:01 +0000 (22:22 +0000)]
[IR] Assert that we never create an empty AttributeListImpl, NFC

Delete following conditional that is always true as a result.

llvm-svn: 300117

7 years ago[Sema] Add __is_aggregate type-trait
Eric Fiselier [Wed, 12 Apr 2017 22:12:15 +0000 (22:12 +0000)]
[Sema] Add __is_aggregate type-trait

Summary:
[LWG 2911](http://cplusplus.github.io/LWG/lwg-defects.html#2911) adds `std::is_aggregate` to the library, which requires a new builtin trait. This patch implements `__is_aggregate`.

Reviewers: rsmith, majnemer, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: STL_MSFT, cfe-commits

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

llvm-svn: 300116

7 years agoFix clang-tidy shared link with libc++
Eric Fiselier [Wed, 12 Apr 2017 22:07:47 +0000 (22:07 +0000)]
Fix clang-tidy shared link with libc++

Currently the ClangTidyMain.cpp fails to link against shared LLVM/Clang libraries
due to the missing symbol:

  clang::tooling::operator<(clang::tooling::Replacement const&,
                            clang::tooling::Replacement const&);

This patch fixes the issue by correctly linking clangToolingCore which contains
the definition.

llvm-svn: 300115

7 years ago[analyzer] Add a check for IvarRegion in getExtraInvalidatedValues
Alexander Shaposhnikov [Wed, 12 Apr 2017 22:00:13 +0000 (22:00 +0000)]
[analyzer] Add a check for IvarRegion in getExtraInvalidatedValues

This diff adds a defensive check in getExtraInvalidatedValues
for the case when there are no regions for the ivar associated with
a property. Corresponding test case added.

Test plan:
make check-clang
make check-clang-analysis

llvm-svn: 300114

7 years agoAMDGPU: Fix invalid copies when copying i1 to phys reg
Matt Arsenault [Wed, 12 Apr 2017 21:58:23 +0000 (21:58 +0000)]
AMDGPU: Fix invalid copies when copying i1 to phys reg

Insert a VReg_1 virtual register so the i1 workaround pass
can handle it.

llvm-svn: 300113

7 years ago[NFC] Adding a new wrapper for getaddrinfo
Chris Bieneman [Wed, 12 Apr 2017 21:56:33 +0000 (21:56 +0000)]
[NFC] Adding a new wrapper for getaddrinfo

Summary: This patch adds a new wrapper for getaddrinfo which returns a std::vector of SocketAddresses. While this patch doesn't add any uses of the new function, I have two separable patches that are dependent on this, so I put it in its own patch.

Reviewers: zturner

Reviewed By: zturner

Subscribers: lldb-commits

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

llvm-svn: 300112

7 years agoSupport Unit Testing debugserver
Chris Bieneman [Wed, 12 Apr 2017 21:56:29 +0000 (21:56 +0000)]
Support Unit Testing debugserver

Summary:
This patch refactors the CMake build system's support for building debugserver to allow us to build the majority of debugserver's sources into the debugserverCommon library which can then be reused by unit tests.

The first unit test I've written tests debug server's ability to accept incoming connections from LLDB. The test forks the process, and one side creates a listening socket using debugserver's socket API, the other side creates a transmitting socket using LLDB's TCPSocket class.

I have no clue where to even start getting this connected into the LLDB Xcode project, so for now these tests are CMake-only.

Reviewers: zturner, labath, jasonmolenda

Subscribers: lldb-commits, mgorny

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

llvm-svn: 300111

7 years ago[modules] Delay calling DeclMustBeEmitted until it's safe.
Vassil Vassilev [Wed, 12 Apr 2017 21:56:05 +0000 (21:56 +0000)]
[modules] Delay calling DeclMustBeEmitted until it's safe.

This patch implements the suggestion in D29753 that calling DeclMustBeEmitted in
the middle of deserialization should be avoided and that the actual check should
be deferred until it's safe to do so.

This patch fixes a crash when accessing the invalid redecl chains while trying
to evaluate the value of a const VarDecl that contains a function call.

Patch by Raphael Isemann (D30793)!

llvm-svn: 300110

7 years ago[Driver] Add compiler option to generate a reproducer
Bruno Cardoso Lopes [Wed, 12 Apr 2017 21:46:20 +0000 (21:46 +0000)]
[Driver] Add compiler option to generate a reproducer

One way to currently test the reproducers is to setup
"FORCE_CLANG_DIAGNOSTICS_CRASH=1" before invoking clang. This simulates
a crash and produces the same contents needed by the reproducers.  The
reproducers are specially useful when triaging Modules issues, not only
on crashes, but also for reproducing misleading warnings, errors, etc.

Add a '-gen-reproducer' driver option to clang (or any similar name) and
give users a flag option.

Note that clang already has a -fno-crash-diagnostics, which disables the
crash reproducers. I've decided not to propose "-fcrash-diagnostics"
since it doesn't convey the ideia of reproduction despite a crash.

rdar://problem/24114619

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

llvm-svn: 300109

7 years ago[Modules] Enable local submodule visibility for ObjC/C
Bruno Cardoso Lopes [Wed, 12 Apr 2017 21:46:16 +0000 (21:46 +0000)]
[Modules] Enable local submodule visibility for ObjC/C

Remove the restriction where this is only valid with C++

rdar://problem/29055656

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

llvm-svn: 300108

7 years agoCache size per class size in SizeClassAllocatorXLocalCache.
Alex Shlyapnikov [Wed, 12 Apr 2017 21:44:56 +0000 (21:44 +0000)]
Cache size per class size in SizeClassAllocatorXLocalCache.

Summary:
Allocator::ClassIdToSize() is not free and calling it in every
Allocate/Deallocate has noticeable impact on perf.

Reviewers: eugenis, kcc

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 300107

7 years agoModular Codegen: Include testing for inline asm as well as some commentary on the...
David Blaikie [Wed, 12 Apr 2017 21:14:04 +0000 (21:14 +0000)]
Modular Codegen: Include testing for inline asm as well as some commentary on the implementaiton choice.

llvm-svn: 300106

7 years agoFix up test to handle the now split -fmodules-codegen and -fmodules-debuginfo flags
David Blaikie [Wed, 12 Apr 2017 21:09:34 +0000 (21:09 +0000)]
Fix up test to handle the now split -fmodules-codegen and -fmodules-debuginfo flags

llvm-svn: 300105

7 years agoModular Codegen: Separate flags for function and debug info support
David Blaikie [Wed, 12 Apr 2017 20:58:33 +0000 (20:58 +0000)]
Modular Codegen: Separate flags for function and debug info support

This allows using and testing these two features separately. (noteably,
debug info is, so far as I know, always a win (basically). But function
modular codegen is currently a loss for highly optimized code - where
most of the linkonce_odr definitions are optimized away, so providing
weak_odr definitions is only overhead)

llvm-svn: 300104

7 years agoAvoid calling SizeClassMap::MaxCachedHint on hot path, it's not free.
Alex Shlyapnikov [Wed, 12 Apr 2017 20:51:42 +0000 (20:51 +0000)]
Avoid calling SizeClassMap::MaxCachedHint on hot path, it's not free.

Summary: Remove unecessary SizeClassMap::MaxCachedHint call.

Reviewers: eugenis

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 300103

7 years ago[AMDGPU] Generate range metadata for workitem id
Stanislav Mekhanoshin [Wed, 12 Apr 2017 20:48:56 +0000 (20:48 +0000)]
[AMDGPU] Generate range metadata for workitem id

If workgroup size is known inform llvm about range returned by local
id  and local size queries.

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

llvm-svn: 300102

7 years agoRemove readnone from invariant.group.barrier
Piotr Padlewski [Wed, 12 Apr 2017 20:45:12 +0000 (20:45 +0000)]
Remove readnone from invariant.group.barrier

Summary:
Readnone attribute would cause CSE of two barriers with
the same argument, which is invalid by example:

    struct Base {
          virtual int foo() { return 42; }
    };

    struct Derived1 : Base {
          int foo() override { return 50; }
    };

    struct Derived2 : Base {
          int foo() override { return 100; }
    };

    void foo() {
        Base *x = new Base{};
        new (x) Derived1{};
        int a = std::launder(x)->foo();
        new (x) Derived2{};
        int b = std::launder(x)->foo();
    }

Here 2 calls of std::launder will produce @llvm.invariant.group.barrier,
which would be merged into one call, causing devirtualization
to devirtualize second call into Derived1::foo() instead of
Derived2::foo()

Reviewers: chandlerc, dberlin, hfinkel

Subscribers: llvm-commits, rsmith, amharc

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

llvm-svn: 300101

7 years agoAppend -w when LLVM_ENABLE_WARNINGS is Off.
Vassil Vassilev [Wed, 12 Apr 2017 20:43:11 +0000 (20:43 +0000)]
Append -w when LLVM_ENABLE_WARNINGS is Off.

Reviewed by rnk (D31702)!

llvm-svn: 300100

7 years agoBitcode: Move version and global value module code parsers to separate functions...
Peter Collingbourne [Wed, 12 Apr 2017 20:02:09 +0000 (20:02 +0000)]
Bitcode: Move version and global value module code parsers to separate functions. NFCI.

This will make it easier to teach this code about the string table.

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

llvm-svn: 300099

7 years ago[Support] Add support for unique_ptr<> to Casting.h.
Zachary Turner [Wed, 12 Apr 2017 19:59:37 +0000 (19:59 +0000)]
[Support] Add support for unique_ptr<> to Casting.h.

Often you have a unique_ptr<T> where T supports LLVM's
casting methods, and you wish to cast it to a unique_ptr<U>.
Prior to this patch, this requires doing hacky things like:

unique_ptr<U> Casted;
if (isa<U>(Orig.get()))
  Casted.reset(cast<U>(Orig.release()));

This is overly verbose, and it would be nice to just be able
to use unique_ptr directly with cast and dyn_cast.  To this end,
this patch updates cast<> to work directly with unique_ptr<T>,
so you can now write:

auto Casted = cast<U>(std::move(Orig));

Since it's possible for dyn_cast<> to fail, however, we choose
to use a slightly different API here, because it's awkward to
write

if (auto Casted = dyn_cast<U>(std::move(Orig))) {}

when Orig may end up not having been moved at all.  So the
interface for dyn_cast is

if (auto Casted = unique_dyn_cast<U>(Orig)) {}

Where the inclusion of `unique` in the name of the cast operator
re-affirms that regardless of success of or fail of the casting,
exactly one of the input value and the return value will contain
a non-null result.

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

llvm-svn: 300098

7 years ago[libc++] Use more appropriate conditional for ABI macro definition
Shoaib Meenai [Wed, 12 Apr 2017 19:56:37 +0000 (19:56 +0000)]
[libc++] Use more appropriate conditional for ABI macro definition

The inline function definition ABI macro is gated on COFF dllexport
semantics, so it's more appropriate to mark it with the object file
format macro rather than the generic _WIN32 macro. We now have no uses
of _WIN32 apart from those used to define the other Windows macros :)

Clarify the ABI macro comment and make the object file format check
exhaustive while I'm here.

llvm-svn: 300097

7 years agoRemove svnprop eol-style:native from Casting.h
Zachary Turner [Wed, 12 Apr 2017 19:52:47 +0000 (19:52 +0000)]
Remove svnprop eol-style:native from Casting.h

llvm-svn: 300096

7 years ago[InstCombine] Teach SimplifyMultipleUseDemandedBits to handle And/Or/Xor known bits...
Craig Topper [Wed, 12 Apr 2017 19:32:47 +0000 (19:32 +0000)]
[InstCombine] Teach SimplifyMultipleUseDemandedBits to handle And/Or/Xor known bits using the LHS/RHS known bits it already acquired without recursing back into computeKnownBits.

This replicates the known bits and constant creation code from the single use case for these instructions and adds it here. The computeKnownBits and constant creation code for other instructions is now in the default case of the opcode switch.

llvm-svn: 300094

7 years ago[InstCombine] Remove unreachable code for turning an And where all demanded bits...
Craig Topper [Wed, 12 Apr 2017 19:08:03 +0000 (19:08 +0000)]
[InstCombine] Remove unreachable code for turning an And where all demanded bits on both sides are known to be zero into a constant 0.

We already handled a superset check that included the known ones too and folded to a constant that may include ones. But it can also handle the case of no ones.

llvm-svn: 300093

7 years ago[InstCombine] fix wrong undef handling when converting select to shuffle
Sanjay Patel [Wed, 12 Apr 2017 18:39:53 +0000 (18:39 +0000)]
[InstCombine] fix wrong undef handling when converting select to shuffle

As discussed in:
https://bugs.llvm.org/show_bug.cgi?id=32486
...the canonicalization of vector select to shufflevector does not hold up
when undef elements are present in the condition vector.

Try to make the undef handling clear in the code and the LangRef.

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

llvm-svn: 300092

7 years ago[SelectionDAG] Use APInt move assignment to avoid 2 memory allocations and copies...
Craig Topper [Wed, 12 Apr 2017 18:39:27 +0000 (18:39 +0000)]
[SelectionDAG] Use APInt move assignment to avoid 2 memory allocations and copies when bit width is larger than 64-bits.

llvm-svn: 300091

7 years ago[coff] default to multiple parallel ThinLTO jobs
Bob Haarman [Wed, 12 Apr 2017 18:36:13 +0000 (18:36 +0000)]
[coff] default to multiple parallel ThinLTO jobs

Summary:
lld-link allows the number of parallel ThinLTO jobs to be specified
using /opt:lldltojobs=N. If left unspecified, the implementation
conservatively defaults to 1. This leads to very long link times. This
change makes it so that the default is to automatically set the
parallelism, as we do in the ELF linker.

Reviewers: ruiu, hans

Reviewed By: ruiu, hans

Subscribers: pcc, mehdi_amini, Prazek, llvm-commits

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

llvm-svn: 300089

7 years agoCodeGen: BlockPlacement: Add comment about DenseMap Safety.
Kyle Butt [Wed, 12 Apr 2017 18:30:32 +0000 (18:30 +0000)]
CodeGen: BlockPlacement: Add comment about DenseMap Safety.

The use of a DenseMap in precomputeTriangleChains does not cause
non-determinism, even though it is iterated over, as the only thing the
iteration does is to insert entries into a new DenseMap, which is not iterated.
Comment only change.

llvm-svn: 300088

7 years agoAccept not only lld-link but also LLD-LINK, for example.
Rui Ueyama [Wed, 12 Apr 2017 18:29:52 +0000 (18:29 +0000)]
Accept not only lld-link but also LLD-LINK, for example.

Filenames are case-insensitive on Windows, so when we dispatch based
on argv0, we need to handle it case-insensitively.

Fixes https://bugs.llvm.org/show_bug.cgi?id=32637.

llvm-svn: 300087

7 years agollvm-lto2: Add a dump-symtab subcommand.
Peter Collingbourne [Wed, 12 Apr 2017 18:27:00 +0000 (18:27 +0000)]
llvm-lto2: Add a dump-symtab subcommand.

This allows us to test the symbol table APIs for LTO input files.

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

llvm-svn: 300086

7 years ago[InstCombine] In SimplifyMultipleUseDemandedBits, use a switch instead of cascaded...
Craig Topper [Wed, 12 Apr 2017 18:25:25 +0000 (18:25 +0000)]
[InstCombine] In SimplifyMultipleUseDemandedBits, use a switch instead of cascaded ifs on opcode. NFC

llvm-svn: 300085

7 years ago[InstCombine] Teach SimplifyDemandedInstructionBits that even if we reach an instruct...
Craig Topper [Wed, 12 Apr 2017 18:17:46 +0000 (18:17 +0000)]
[InstCombine] Teach SimplifyDemandedInstructionBits that even if we reach an instruction that has multiple uses, if we know all the bits for the demanded bits for this context we can go ahead and create a constant.

Currently if we reach an instruction with multiples uses we know we can't do any optimizations to that instruction itself since we only have the demanded bits for one of the users. But if we know all of the bits are zero/one for that one user we can still go ahead and create a constant to give to that user.

This might then reduce the instruction to having a single use and allow additional optimizations on the other path.

This picks up an additional case that r300075 didn't catch.

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

llvm-svn: 300084

7 years agoMachineScheduler: Skip acyclic latency heuristic for in-order cores
Matthias Braun [Wed, 12 Apr 2017 18:09:05 +0000 (18:09 +0000)]
MachineScheduler: Skip acyclic latency heuristic for in-order cores

The current heuristic is triggered on `InFlightCount > BufferLimit`
which isn't really helpful on in-order cores where BufferLimit is zero.

Note that we already get latency hiding effects for in order cores
by instructions staying in the pending queue on stalls; The additional
latency scheduling heuristics only have minimal effects after that while
occasionally increasing register pressure too much resulting in extra
spills.

My motivation here is additional spills/reloads ending up in a loop in
464.h264ref / BlockMotionSearch function resulting in a 4% overal
regression on an in order core. rdar://30264380

llvm-svn: 300083

7 years ago[InstCombine] Move portion of SimplifyDemandedUseBits that deals with instructions...
Craig Topper [Wed, 12 Apr 2017 18:05:21 +0000 (18:05 +0000)]
[InstCombine] Move portion of SimplifyDemandedUseBits that deals with instructions with multiple uses out to a separate method. NFCI

llvm-svn: 300082

7 years ago[SystemZ] Fix more target specific tests
Renato Golin [Wed, 12 Apr 2017 18:03:09 +0000 (18:03 +0000)]
[SystemZ] Fix more target specific tests

llvm-svn: 300081

7 years agoFix memory leaks in address sanitizer darwin tests
Francis Ricci [Wed, 12 Apr 2017 17:31:41 +0000 (17:31 +0000)]
Fix memory leaks in address sanitizer darwin tests

Summary: These leaks are detected by leak sanitizer for darwin.

Reviewers: glider, kubamracek, kcc, alekseyshl

Subscribers: llvm-commits

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

llvm-svn: 300080

7 years ago[libcxx] [test] Avoid Clang's -Wunused-const-variable in is_constructible.pass.cpp.
Stephan T. Lavavej [Wed, 12 Apr 2017 17:16:38 +0000 (17:16 +0000)]
[libcxx] [test] Avoid Clang's -Wunused-const-variable in is_constructible.pass.cpp.

This happens when using Clang with MSVC's STL, so there are no actual uses of this variable.

Fixes D31966.

llvm-svn: 300079

7 years ago[SystemZ] Fix target specific tests
Renato Golin [Wed, 12 Apr 2017 17:14:46 +0000 (17:14 +0000)]
[SystemZ] Fix target specific tests

llvm-svn: 300078

7 years ago[clangd] Rename ClangDMain.cpp -> ClangdMain.cpp, NFC
Krasimir Georgiev [Wed, 12 Apr 2017 17:13:08 +0000 (17:13 +0000)]
[clangd] Rename ClangDMain.cpp -> ClangdMain.cpp, NFC

llvm-svn: 300077

7 years ago[AMDGPU][MC] Added support for several VI-specific opcodes (s_wakeup, etc)
Dmitry Preobrazhensky [Wed, 12 Apr 2017 17:10:07 +0000 (17:10 +0000)]
[AMDGPU][MC] Added support for several VI-specific opcodes (s_wakeup, etc)

Added support for VI:

- s_endpgm_saved
- s_wakeup
- s_rfe_restore_b64
- v_perm_b32

Enabled for VI:

- v_mov_fed_b32
- v_mov_fed_b32_e64

See bug 32593: https://bugs.llvm.org//show_bug.cgi?id=32593

Reviewers: artem.tamazov, vpykhtin

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

llvm-svn: 300076

7 years agoTeach SimplifyDemandedUseBits that adding or subtractings 0s from every bit below...
Craig Topper [Wed, 12 Apr 2017 16:49:59 +0000 (16:49 +0000)]
Teach SimplifyDemandedUseBits that adding or subtractings 0s from every bit below the highest demanded bit can be simplified

If we are adding/subtractings 0s below the highest demanded bit we can just use the other operand and remove the operation.

My primary motivation is observing that we can call ShrinkDemandedConstant for the add/sub and create a 0 constant, rather than removing the add completely. In the case I saw, we modified the constant on an add instruction to a 0, but the add is not put into the worklist. So we didn't revisit it until the next InstCombine iteration. This caused an IR modification to remove add and a subsequent iteration to be ran.

With this change we get bypass the add in the first iteration and prevent the second iteration from changing anything.

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

llvm-svn: 300075

7 years agoRevert r300001 "Revert r298824 & r298816, recommit r298742 & r298754"
Hans Wennborg [Wed, 12 Apr 2017 16:40:26 +0000 (16:40 +0000)]
Revert r300001 "Revert r298824 & r298816, recommit r298742 & r298754"

It caused PR32640.

llvm-svn: 300074

7 years ago[AMDGPU][MC] Corrected parsing of v_cmp_class* and v_cmpx_class*
Dmitry Preobrazhensky [Wed, 12 Apr 2017 16:31:18 +0000 (16:31 +0000)]
[AMDGPU][MC] Corrected parsing of v_cmp_class* and v_cmpx_class*

Fixed bug 32565: https://bugs.llvm.org//show_bug.cgi?id=32565

Reviewers: vpykhtin

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

llvm-svn: 300073

7 years ago[WebAssembly] Update use of Attributes after r299875
Derek Schuff [Wed, 12 Apr 2017 16:03:00 +0000 (16:03 +0000)]
[WebAssembly] Update use of Attributes after r299875

This fixes the failing WebAssemblyLowerEmscriptenEHSjLj tests

llvm-svn: 300072

7 years agoMoving a C++ test out of Sema and into SemaCXX; NFC.
Aaron Ballman [Wed, 12 Apr 2017 15:56:02 +0000 (15:56 +0000)]
Moving a C++ test out of Sema and into SemaCXX; NFC.

llvm-svn: 300071

7 years ago[AMDGPU][MC] Corrected encoding of V_MQSAD_U32_U8 for CI
Dmitry Preobrazhensky [Wed, 12 Apr 2017 15:36:09 +0000 (15:36 +0000)]
[AMDGPU][MC] Corrected encoding of V_MQSAD_U32_U8 for CI

Corrected encoding of V_MQSAD_U32_U8 for CI

See bug 32552: https://bugs.llvm.org//show_bug.cgi?id=32552

Reviewers: vpykhtin

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

llvm-svn: 300070

7 years agoFix the bootstrap failure caused by r299986.
Easwaran Raman [Wed, 12 Apr 2017 15:26:15 +0000 (15:26 +0000)]
Fix the bootstrap failure caused by r299986.

llvm-svn: 300069

7 years ago[x86] fix AVX FP cmp intrinsic documentation (PR28110)
Sanjay Patel [Wed, 12 Apr 2017 15:19:08 +0000 (15:19 +0000)]
[x86] fix AVX FP cmp intrinsic documentation (PR28110)

This copies the text used in the #define statements to the code comments.
The conflicting text comes from AMD manuals, but those are wrong. Sadly,
that FP cmp text has not been updated even after some docs were updated
for Zen:
http://support.amd.com/en-us/search/tech-docs
( AMD64 Architecture Programmer's Manual Volume 4 )

See PR28110 for more discussion:
https://bugs.llvm.org/show_bug.cgi?id=28110

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

llvm-svn: 300068

7 years ago[InstCombine] morph an existing instruction instead of creating a new one
Sanjay Patel [Wed, 12 Apr 2017 15:11:33 +0000 (15:11 +0000)]
[InstCombine] morph an existing instruction instead of creating a new one

One potential way to make InstCombine (very slightly?) faster is to recycle instructions
when possible instead of creating new ones. It's not explicitly stated AFAIK, but we don't
consider this an "InstSimplify". We could, however, make a new layer to house transforms
like this if that makes InstCombine more manageable (just throwing out an idea; not sure
how much opportunity is actually here).

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

llvm-svn: 300067

7 years ago[AMDGPU][MC] Corrected ds_wrxchg2* to support two offsets
Dmitry Preobrazhensky [Wed, 12 Apr 2017 14:29:45 +0000 (14:29 +0000)]
[AMDGPU][MC] Corrected ds_wrxchg2* to support two offsets

Fixed bug 28227: https://bugs.llvm.org//show_bug.cgi?id=28227

Reviewers: vpykhtin

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

llvm-svn: 300066

7 years agoUse 0-padding for i386 and arm print format specifiers
Francis Ricci [Wed, 12 Apr 2017 14:25:28 +0000 (14:25 +0000)]
Use 0-padding for i386 and arm print format specifiers

Summary:
This is used for the other architectures in print_address, but is
missing from i386 and arm.

Reviewers: m.ostapenko, spetrovic

Subscribers: aemerson, rengolin, llvm-commits, kubamracek

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

llvm-svn: 300065

7 years agoFix a RUN line in new test.
Jonas Paulsson [Wed, 12 Apr 2017 14:25:08 +0000 (14:25 +0000)]
Fix a RUN line in new test.

Use '2>&1 |' and not '|&' to pipe debug output to FileCheck

Hopefully handles a "shell parser error" on
llvm-clang-x86_64-expensive-checks-win

test/Transforms/SLPVectorizer/SystemZ/SLP-cmp-cost-query.ll

llvm-svn: 300064

7 years agoRemove redundant type casts
Serge Pavlov [Wed, 12 Apr 2017 14:13:00 +0000 (14:13 +0000)]
Remove redundant type casts

llvm-svn: 300063

7 years agoFix detection of backtrace() availability on FreeBSD
Ed Maste [Wed, 12 Apr 2017 13:51:00 +0000 (13:51 +0000)]
Fix detection of backtrace() availability on FreeBSD

On FreeBSD backtrace is not part of libc and depends on libexecinfo
being available. Instead of using manual checks we can use the builtin
CMake module FindBacktrace.cmake to detect availability of backtrace()
in a portable way.

Patch By: Alex Richardson
Differential Revision: https://reviews.llvm.org/D27143

llvm-svn: 300062

7 years ago[SLPVectorizer] Pass the right type argument to getCmpSelInstrCost()
Jonas Paulsson [Wed, 12 Apr 2017 13:29:25 +0000 (13:29 +0000)]
[SLPVectorizer]  Pass the right type argument to getCmpSelInstrCost()

In getEntryCost(), make the scalar type for a compare instruction that of the
operands, not i1. This is needed in order to call getCmpSelInstrCost() for a
compare in a sensible way, the same way as the LoopVectorizer does.

New test: test/Transforms/SLPVectorizer/SystemZ/SLP-cmp-cost-query.ll

Review: Matthew Simpson
https://reviews.llvm.org/D31601

llvm-svn: 300061

7 years ago[MachineBlockPlacment] Add an assert to ensure there is no order dependency on DenseM...
Benjamin Kramer [Wed, 12 Apr 2017 13:26:31 +0000 (13:26 +0000)]
[MachineBlockPlacment] Add an assert to ensure there is no order dependency on DenseMap iteration order.

llvm-svn: 300060

7 years ago[MachineBlockPlacement] Clean up data structures a bit.
Benjamin Kramer [Wed, 12 Apr 2017 13:26:28 +0000 (13:26 +0000)]
[MachineBlockPlacement] Clean up data structures a bit.

No functionality change intended.

llvm-svn: 300059

7 years ago[LoopVectorizer] Improve handling of branches during cost estimation.
Jonas Paulsson [Wed, 12 Apr 2017 13:13:15 +0000 (13:13 +0000)]
[LoopVectorizer]  Improve handling of branches during cost estimation.

The cost for a branch after vectorization is very different depending on if
the vectorizer will if-convert the block (branch is eliminated), or if
scalarized and predicated blocks will be produced (branch duplicated before
each block). There is also the case of remaining scalar branches, such as the
back-edge branch.

This patch handles these cases differently with TTI based cost estimates.

Review: Matthew Simpson
https://reviews.llvm.org/D31175

llvm-svn: 300058

7 years ago[GlobalIsel][X86] support G_CONSTANT selection.
Igor Breger [Wed, 12 Apr 2017 12:54:54 +0000 (12:54 +0000)]
[GlobalIsel][X86] support G_CONSTANT selection.

Summary: [GlobalISel][X86] support G_CONSTANT selection. Add regbank select tests.

Reviewers: zvi, guyblank

Reviewed By: guyblank

Subscribers: llvm-commits, dberris, rovka, kristof.beyls

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

llvm-svn: 300057

7 years ago[LoopVectorizer, TTI] New method supportsEfficientVectorElementLoadStore()
Jonas Paulsson [Wed, 12 Apr 2017 12:41:37 +0000 (12:41 +0000)]
[LoopVectorizer, TTI]  New method supportsEfficientVectorElementLoadStore()

Since SystemZ supports vector element load/store instructions, there is no
need for extracts/inserts if a vector load/store gets scalarized.

This patch lets Target specify that it supports such instructions by means of
a new TTI hook that defaults to false.

The use for this is in the LoopVectorizer getScalarizationOverhead() method,
which will with this patch produce a smaller sum for a vector load/store on
SystemZ.

New test: test/Transforms/LoopVectorize/SystemZ/load-store-scalarization-cost.ll

Review: Adam Nemet
https://reviews.llvm.org/D30680

llvm-svn: 300056