platform/upstream/llvm.git
7 years ago[WebAssembly] Read global index in init expression as LEB
Sam Clegg [Tue, 25 Apr 2017 17:11:56 +0000 (17:11 +0000)]
[WebAssembly] Read global index in init expression as LEB

Subscribers: jfb, dschuff

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

llvm-svn: 301330

7 years ago[InstSimplify] Handle (~A & ~B) | (~A ^ B) -> ~A ^ B
Craig Topper [Tue, 25 Apr 2017 17:01:32 +0000 (17:01 +0000)]
[InstSimplify] Handle (~A & ~B) | (~A ^ B) -> ~A ^ B

The code Sanjay Patel moved over from InstCombine doesn't work properly if the 'and' has both inputs as nots because we used a commuted op matcher on the 'and' first. But this will bind to the first 'not' on 'and' when there could be two 'not's. InstCombine could rely on DeMorgan to ensure the 'and' wouldn't have two 'not's eventually, but InstSimplify can't rely on that.

This patch matches the xor first then checks for the ands and allows a not of either operand of the xor.

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

llvm-svn: 301329

7 years ago[libclang] Check for a record declaration before a template specialization
Alex Lorenz [Tue, 25 Apr 2017 16:59:07 +0000 (16:59 +0000)]
[libclang] Check for a record declaration before a template specialization

Fixes PR32539.

Patch by Emilio Cobos Álvarez!

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

llvm-svn: 301328

7 years ago[PM] Run IndirectCallPromotion only when PGO is enabled.
Davide Italiano [Tue, 25 Apr 2017 16:54:45 +0000 (16:54 +0000)]
[PM] Run IndirectCallPromotion only when PGO is enabled.

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

llvm-svn: 301327

7 years ago[InstCombine] Remove superfluous curly braces around a single line if body. NFC
Craig Topper [Tue, 25 Apr 2017 16:48:19 +0000 (16:48 +0000)]
[InstCombine] Remove superfluous curly braces around a single line if body. NFC

llvm-svn: 301326

7 years ago[ValueTracking] Use APInt::operator|=(uint64_t) instead of creating a temporary APInt...
Craig Topper [Tue, 25 Apr 2017 16:48:14 +0000 (16:48 +0000)]
[ValueTracking] Use APInt::operator|=(uint64_t) instead of creating a temporary APInt. NFC

llvm-svn: 301325

7 years ago[ValueTracking] Use APInt instead of auto. NFC
Craig Topper [Tue, 25 Apr 2017 16:48:09 +0000 (16:48 +0000)]
[ValueTracking] Use APInt instead of auto. NFC

This is a pre-commit for a patch I'm working on to turn KnownZero/One into a struct. Once I do that the type here will be less obvious.

llvm-svn: 301324

7 years ago[ValueTracking] Use BitWidth local variable instead of re-reading it from KnownZero...
Craig Topper [Tue, 25 Apr 2017 16:48:03 +0000 (16:48 +0000)]
[ValueTracking] Use BitWidth local variable instead of re-reading it from KnownZero. NFC

This is a pre-commit for a patch that I'm working on to merge KnownZero/KnownOne into a KnownBits struct which would have had to touch this line.

llvm-svn: 301323

7 years ago[SelectionDAG] Added getBuildVector(ArrayRef<SDUse>) helper.
Simon Pilgrim [Tue, 25 Apr 2017 16:41:28 +0000 (16:41 +0000)]
[SelectionDAG] Added getBuildVector(ArrayRef<SDUse>) helper.

llvm-svn: 301322

7 years ago[OpenMP] Optimized default kernel launch parameters in CUDA plugin
George Rokos [Tue, 25 Apr 2017 16:34:13 +0000 (16:34 +0000)]
[OpenMP] Optimized default kernel launch parameters in CUDA plugin

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

llvm-svn: 301321

7 years ago[DAGCombiner] Refactor to make it easy to add support for vectors in a future patch...
Simon Pilgrim [Tue, 25 Apr 2017 16:16:03 +0000 (16:16 +0000)]
[DAGCombiner] Refactor to make it easy to add support for vectors in a future patch. NFCI.

llvm-svn: 301320

7 years ago[ELF] Improve error message for incompatible section flags
Rui Ueyama [Tue, 25 Apr 2017 16:00:44 +0000 (16:00 +0000)]
[ELF] Improve error message for incompatible section flags

Previously we were not printing out the flags of the incompatible
section which made it difficult to determine what the problem was.

The error message format has been change to the following:

  error: incompatible section flags for .bar
  >>> /foo/bar/incompatible-section-flags.s.tmp.o:(.bar): 0x403
  >>> output section .bar: 0x3

Patch by Alexander Richardson.

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

llvm-svn: 301319

7 years ago[OpenMP] Add missing parenthesis which triggers a compile error
George Rokos [Tue, 25 Apr 2017 15:55:39 +0000 (15:55 +0000)]
[OpenMP] Add missing parenthesis which triggers a compile error

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

llvm-svn: 301318

7 years agoResubmit r301309: [DebugInfo][X86] Fix handling of DBG_VALUE's in post-RA scheduler.
Andrew Ng [Tue, 25 Apr 2017 15:39:57 +0000 (15:39 +0000)]
Resubmit r301309: [DebugInfo][X86] Fix handling of DBG_VALUE's in post-RA scheduler.

This patch reapplies r301309 with the fix to the MIR test to fix the assertion
triggered by r301309. Had trimmed a little bit too much from the MIR!

llvm-svn: 301317

7 years ago[InstCombine] Add missing commute handling to (A | B) & (B ^ (~A)) -> (A & B)
Craig Topper [Tue, 25 Apr 2017 15:19:04 +0000 (15:19 +0000)]
[InstCombine] Add missing commute handling to (A | B) & (B ^ (~A)) -> (A & B)

The matching here wasn't able to handle all the possible commutes. It always assumed the not would be on the left of the xor, but that's not guaranteed.

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

llvm-svn: 301316

7 years ago[index] Index type source info for class specializations
Alex Lorenz [Tue, 25 Apr 2017 15:13:42 +0000 (15:13 +0000)]
[index] Index type source info for class specializations

rdar://31758344

llvm-svn: 301315

7 years ago[SelectionDAG] Use getBuildVector helper where possible. NFCI
Simon Pilgrim [Tue, 25 Apr 2017 15:10:47 +0000 (15:10 +0000)]
[SelectionDAG] Use getBuildVector helper where possible. NFCI

llvm-svn: 301314

7 years ago[AVR] Support the LDWRdPtr instruction with the same Src+Dst register
Dylan McKay [Tue, 25 Apr 2017 15:09:04 +0000 (15:09 +0000)]
[AVR] Support the LDWRdPtr instruction with the same Src+Dst register

llvm-svn: 301313

7 years agoRevert "[DebugInfo][X86] Fix handling of DBG_VALUE's in post-RA scheduler."
Andrew Ng [Tue, 25 Apr 2017 14:36:01 +0000 (14:36 +0000)]
Revert "[DebugInfo][X86] Fix handling of DBG_VALUE's in post-RA scheduler."

This reverts commit r301309 which is causing buildbot assertion failures.

llvm-svn: 301312

7 years agoBring back the ability opt out of padding zero-byte functions by not providing a...
Daniel Sanders [Tue, 25 Apr 2017 14:27:27 +0000 (14:27 +0000)]
Bring back the ability opt out of padding zero-byte functions by not providing a nop instruction.

Summary: No test case since I'm not aware of an in-tree target that needs this.

Reviewers: hans

Subscribers: llvm-commits

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

llvm-svn: 301311

7 years ago[index] Record the 'SpecializationOf' relation for function specializations
Alex Lorenz [Tue, 25 Apr 2017 14:22:29 +0000 (14:22 +0000)]
[index] Record the 'SpecializationOf' relation for function specializations

rdar://31603531

llvm-svn: 301310

7 years ago[DebugInfo][X86] Fix handling of DBG_VALUE's in post-RA scheduler.
Andrew Ng [Tue, 25 Apr 2017 13:39:49 +0000 (13:39 +0000)]
[DebugInfo][X86] Fix handling of DBG_VALUE's in post-RA scheduler.

This patch fixes a bug with the updating of DBG_VALUE's in
BreakAntiDependencies. Previously, it would only attempt to update the first
DBG_VALUE following the instruction whose register is being changed,
potentially leaving DBG_VALUE's referring to the wrong register. Now the code
will update all DBG_VALUE's that immediately follow the instruction.

This issue was detected as a result of an optimized codegen difference with
"-g" where an X86 byte/word fixup was not performed due to a DBG_VALUE
referencing the wrong register.

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

llvm-svn: 301309

7 years ago[SelectionDAG] Pull out repeated getValueType calls. NFCI.
Simon Pilgrim [Tue, 25 Apr 2017 13:39:07 +0000 (13:39 +0000)]
[SelectionDAG] Pull out repeated getValueType calls. NFCI.

Noticed in D32391.

llvm-svn: 301308

7 years ago[Compiler-rt][MIPS] Fix assert introduce with commit rl301171.
Nitesh Jain [Tue, 25 Apr 2017 13:25:40 +0000 (13:25 +0000)]
[Compiler-rt][MIPS] Fix assert introduce with commit rl301171.

llvm-svn: 301307

7 years agoRemove the home-grown android toolchain file and all references to it
Pavel Labath [Tue, 25 Apr 2017 12:58:49 +0000 (12:58 +0000)]
Remove the home-grown android toolchain file and all references to it

Summary:
The toolchain file has been deprecated in favor of the "official"
toolchain file present in the Android NDK. Also update the web
build instructions to reflect this.

Reviewers: eugene

Subscribers: srhines, mgorny, dgross, tberghammer, lldb-commits

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

llvm-svn: 301306

7 years ago[DAGCombiner] Add vector support for (srl (trunc (srl x, c1)), c2) combine.
Simon Pilgrim [Tue, 25 Apr 2017 12:40:45 +0000 (12:40 +0000)]
[DAGCombiner] Add vector support for (srl (trunc (srl x, c1)), c2) combine.

llvm-svn: 301305

7 years ago[SimplifyLibCalls] Fix infinite loop with fast-math optimization.
Andrew Ng [Tue, 25 Apr 2017 12:36:14 +0000 (12:36 +0000)]
[SimplifyLibCalls] Fix infinite loop with fast-math optimization.

One of the fast-math optimizations is to replace calls to standard double
functions with their float equivalents, e.g. exp -> expf. However, this can
cause infinite loops for the following:

  float expf(float val) { return (float) exp((double) val); }

A similar inline declaration exists in the MinGW-w64 math.h header file which
when compiled with -O2/3 and fast-math generates infinite loops.

So this fix checks that the calling function to the standard double function
that is being replaced does not match the float equivalent.

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

llvm-svn: 301304

7 years ago[SelectionDAG] Recognise splat vector isKnownToBeAPowerOfTwo one/sign bit shift cases.
Simon Pilgrim [Tue, 25 Apr 2017 12:29:07 +0000 (12:29 +0000)]
[SelectionDAG] Recognise splat vector isKnownToBeAPowerOfTwo one/sign bit shift cases.

llvm-svn: 301303

7 years agoFix fuzzer.c test on platforms where CLANG_DEFAULT_CXX_STDLIB is libc++
Ismail Donmez [Tue, 25 Apr 2017 11:24:14 +0000 (11:24 +0000)]
Fix fuzzer.c test on platforms where CLANG_DEFAULT_CXX_STDLIB is libc++

llvm-svn: 301302

7 years ago[DeLICM] Use Known information when comparing Existing.Occupied and Proposed.Occupied.
Michael Kruse [Tue, 25 Apr 2017 10:57:32 +0000 (10:57 +0000)]
[DeLICM] Use Known information when comparing Existing.Occupied and Proposed.Occupied.

Do not conflict if the value of Existing and Proposed are the same.

This change only affects unit tests, but no functional changes are
expected on LLVM-IR, as no Known information is yet extracted and
consequently this functionality is only triggered through unit tests.

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

llvm-svn: 301301

7 years ago[DAGCombiner] Use SDValue::getConstantOperandVal helper where possible. NFCI.
Simon Pilgrim [Tue, 25 Apr 2017 10:47:35 +0000 (10:47 +0000)]
[DAGCombiner] Use SDValue::getConstantOperandVal helper where possible. NFCI.

llvm-svn: 301300

7 years ago[PPCGCodeGeneration] Update PPCG Code Generation for OpenCL compatibility
Siddharth Bhat [Tue, 25 Apr 2017 08:08:29 +0000 (08:08 +0000)]
[PPCGCodeGeneration] Update PPCG Code Generation for OpenCL compatibility

Added a small change to the way pointer arguments are set in the kernel
code generation. The way the pointer is retrieved now, specifically requests
global address space to be annotated. This is necessary, if the IR should be
run through NVPTX to generate OpenCL compatible PTX.

The changes do not affect the PTX Strings generated for the CUDA target
(nvptx64-nvidia-cuda), but are necessary for OpenCL (nvptx64-nvidia-nvcl).

Additionally, the data layout has been updated to what the NVPTX Backend requests/recommends.

Contributed-by: Philipp Schaad
Reviewers: Meinersbur, grosser, bollu

Reviewed By: grosser, bollu

Subscribers: jlebar, pollydev, llvm-commits, nemanjai, yaxunl, Anastasia

Tags: #polly

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

llvm-svn: 301299

7 years ago[IVUsers] Don't bail out of normalizing non-affine add recs
Sanjoy Das [Tue, 25 Apr 2017 06:53:25 +0000 (06:53 +0000)]
[IVUsers] Don't bail out of normalizing non-affine add recs

Summary:
In a previous change I changed SCEV's normalization / denormalization
to work with non-affine add recs.  So the bailout in IVUsers can be
removed.

Reviewers: atrick, efriedma

Reviewed By: atrick

Subscribers: davide, mcrosier, llvm-commits

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

llvm-svn: 301298

7 years ago[InstCombine] Add test cases for missing commute handling in ((A ^ C) ^ B) & (B ...
Craig Topper [Tue, 25 Apr 2017 06:47:49 +0000 (06:47 +0000)]
[InstCombine] Add test cases for missing commute handling in ((A ^ C) ^ B) & (B ^ A) -> (B ^ A) & ~C

llvm-svn: 301297

7 years ago[InstCombine] Add test cases showing failures to handle commuted patterns after trick...
Craig Topper [Tue, 25 Apr 2017 06:22:17 +0000 (06:22 +0000)]
[InstCombine] Add test cases showing failures to handle commuted patterns after tricking the operand complexity sorting.

llvm-svn: 301296

7 years ago[LLDB][MIPS] Fix typo in TestStepOverWatchpoint.py.
Nitesh Jain [Tue, 25 Apr 2017 06:12:59 +0000 (06:12 +0000)]
[LLDB][MIPS] Fix typo in TestStepOverWatchpoint.py.

Subscribers: jaydeep, bhushan, lldb-commits, slthakur
llvm-svn: 301295

7 years ago[InstCombine] Use commutable matchers to reduce some code. NFC
Craig Topper [Tue, 25 Apr 2017 06:02:11 +0000 (06:02 +0000)]
[InstCombine] Use commutable matchers to reduce some code. NFC

llvm-svn: 301294

7 years ago[LV] Remove redundant basic block split
Gil Rapaport [Tue, 25 Apr 2017 05:57:22 +0000 (05:57 +0000)]
[LV] Remove redundant basic block split

This patch is part of D28975's breakdown.

Genreating the control-flow to guard predicated instructions modified to
only use SplitBlockAndInsertIfThen() for producing the if-then construct.

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

llvm-svn: 301293

7 years agoUpdate doc of the variadic version of getOrInsertFunction
Serge Guelton [Tue, 25 Apr 2017 05:45:37 +0000 (05:45 +0000)]
Update doc of the variadic version of getOrInsertFunction

It no longer needs a null terminator.

llvm-svn: 301292

7 years ago[CodeExtractor]: Fixup use refs of the old phi.
Xinliang David Li [Tue, 25 Apr 2017 04:51:19 +0000 (04:51 +0000)]
[CodeExtractor]: Fixup use refs of the old phi.

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

llvm-svn: 301291

7 years agoDefine __tls_get_addr as a hidden symbol even for ARM or MIPS.
Rui Ueyama [Tue, 25 Apr 2017 04:44:54 +0000 (04:44 +0000)]
Define __tls_get_addr as a hidden symbol even for ARM or MIPS.

addIgnored defines a given symbol even if there is no existing
symbol with the same name. So, even if libc provides __tls_get_addr,
we should still be able to call addIgnored.

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

llvm-svn: 301290

7 years ago[ObjCARC] Do not sink an objc_retain past a clang.arc.use.
Akira Hatanaka [Tue, 25 Apr 2017 04:06:35 +0000 (04:06 +0000)]
[ObjCARC] Do not sink an objc_retain past a clang.arc.use.

We need to do this to prevent a miscompile which sinks an objc_retain
past an objc_release that releases the object objc_retain retains. This
happens because the top-down and bottom-up traversals each determines
the insert point for retain or release individually without knowing
where the other instruction is moved.

For example, when the following IR is fed to the ARC optimizer, the
top-down traversal decides to insert objc_retain right before
objc_release and the bottom-up traversal decides to insert objc_release
right after clang.arc.use.

(IR before ARC optimizer)
%11 = call i8* @objc_retain(i8* %10)
call void (...) @clang.arc.use(%0* %5)
call void @llvm.dbg.value(...)
call void @objc_release(i8* %6)

This reverses the order of objc_release and objc_retain, which causes
the object to be destructed prematurely.

(IR after ARC optimizer)
call void (...) @clang.arc.use(%0* %5)
call void @objc_release(i8* %6)
call void @llvm.dbg.value(...)
%11 = call i8* @objc_retain(i8* %10)

rdar://problem/30530580

llvm-svn: 301289

7 years ago[SimplifyLibCalls] Remove a cl::opt that's been `true` for a long time.
Davide Italiano [Tue, 25 Apr 2017 03:48:47 +0000 (03:48 +0000)]
[SimplifyLibCalls] Remove a cl::opt that's been `true` for a long time.

llvm-svn: 301288

7 years agoAdd comments about Widnows .reloc section.
Rui Ueyama [Tue, 25 Apr 2017 03:31:10 +0000 (03:31 +0000)]
Add comments about Widnows .reloc section.

llvm-svn: 301287

7 years agoDo not create temporary files in the main source tree.
Rui Ueyama [Tue, 25 Apr 2017 03:30:50 +0000 (03:30 +0000)]
Do not create temporary files in the main source tree.

llvm-svn: 301286

7 years agoPlacate MSVC's narrowing conversion unhappiness.
Richard Smith [Tue, 25 Apr 2017 00:40:40 +0000 (00:40 +0000)]
Placate MSVC's narrowing conversion unhappiness.

llvm-svn: 301285

7 years ago[unittests] Derive Occupied from Unused when given.
Michael Kruse [Tue, 25 Apr 2017 00:30:42 +0000 (00:30 +0000)]
[unittests] Derive Occupied from Unused when given.

When both, OccupiedAndKnown and Unused are given, use the former only
for the Known values. The relation Unused \union Occupied must always
hold.

This allows us to specify Known independently of Occupied. It is needed
for an artificial test case in https://reviews.llvm.org/D32025.

llvm-svn: 301284

7 years ago[unittests] Add postcondition to completeLifetime.
Michael Kruse [Tue, 25 Apr 2017 00:30:32 +0000 (00:30 +0000)]
[unittests] Add postcondition to completeLifetime.

llvm-svn: 301283

7 years agoExport __progname even if a -dynamic-list is given.
Rui Ueyama [Tue, 25 Apr 2017 00:15:48 +0000 (00:15 +0000)]
Export __progname even if a -dynamic-list is given.

BSD's __progname symbol is defined in crt1.o and linked against main
executables. The libc expects that main executables export __progname
symbol via .dynsym sections. In order to handle this case, we scan
undefined symbols in DSOs and exported them by setting Sym->ExportDynamic
to true.

But it turned out that setting that variable is not enough to make sure
that symbols are exported in all use cases. If a -dynamic-list option is
given, all symbols not explicitly mentioned in a version script are
hidden by default. That hides __progname symbol. This patch fixes the issue.

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

llvm-svn: 301282

7 years agoTeach SCEV normalization to de/normalize non-affine add recs
Sanjoy Das [Tue, 25 Apr 2017 00:09:19 +0000 (00:09 +0000)]
Teach SCEV normalization to de/normalize non-affine add recs

Summary:
Before this change, SCEV Normalization would incorrectly normalize
non-affine add recurrences.  To work around this there was (still is)
a check in place to make sure we only tried to normalize affine add
recurrences.

We recently found a bug in aforementioned check to bail out of
normalizing non-affine add recurrences.  However, instead of fixing
the bailout, I have decided to teach SCEV normalization to work
correctly with non-affine add recurrences, making the bailout
unnecessary (I'll remove it in a subsequent change).

I've also added some unit tests (which would have failed before this
change).

Reviewers: atrick, sunfish, efriedma

Reviewed By: atrick

Subscribers: mcrosier, mzolotukhin, llvm-commits

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

llvm-svn: 301281

7 years agoName the C++ source files for two tests correctly.
Sean Callanan [Mon, 24 Apr 2017 23:58:36 +0000 (23:58 +0000)]
Name the C++ source files for two tests correctly.

llvm-svn: 301280

7 years agoReplace a binary .so with a text .s.
Rui Ueyama [Mon, 24 Apr 2017 23:51:18 +0000 (23:51 +0000)]
Replace a binary .so with a text .s.

Since LLD is now able to take version scripts, we no longer
have to keep a pre-generated binary file for a test.

llvm-svn: 301279

7 years agoRemove a useless temporary variable.
Rui Ueyama [Mon, 24 Apr 2017 23:50:58 +0000 (23:50 +0000)]
Remove a useless temporary variable.

llvm-svn: 301278

7 years agoFixed two bad Makefiles that might be breaking Linux.
Sean Callanan [Mon, 24 Apr 2017 23:49:06 +0000 (23:49 +0000)]
Fixed two bad Makefiles that might be breaking Linux.

llvm-svn: 301277

7 years agoInferAddressSpaces: Use reference arguments instead of pointers
Matt Arsenault [Mon, 24 Apr 2017 23:42:41 +0000 (23:42 +0000)]
InferAddressSpaces: Use reference arguments instead of pointers

llvm-svn: 301276

7 years ago[Object] Fix some Clang-tidy modernize and Include What You Use warnings; other minor...
Eugene Zelenko [Mon, 24 Apr 2017 23:21:38 +0000 (23:21 +0000)]
[Object] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 301275

7 years agoRevert r301089 "[builtins] Implement emulated TLS on Windows."
Hans Wennborg [Mon, 24 Apr 2017 23:16:49 +0000 (23:16 +0000)]
Revert r301089 "[builtins] Implement emulated TLS on Windows."

This broke the self-host build on Windows (PR32777).

Original commit message:

> [builtins] Implement emulated TLS on Windows.
>
> Summary:
> LLVM JIT needs to be able to use emulated TLS on all platforms, and this provides a reference one can compile to enable emutls for Linux/Mac/Windows.
>
> Reviewers: chh, howard.hinnant
>
> Reviewed By: chh
>
> Subscribers: mgorny, llvm-commits
>
> Differential Revision: https://reviews.llvm.org/D30787

llvm-svn: 301274

7 years ago[Expression parser] Return both types and variables
Sean Callanan [Mon, 24 Apr 2017 23:14:04 +0000 (23:14 +0000)]
[Expression parser] Return both types and variables

Many times a user wants to access a type when there's a variable of
the same name, or a variable when there's a type of the same name.
Depending on the precise context, currently the expression parser
can fail to resolve one or the other.

This is because ClangExpressionDeclMap has logic to limit the
amount of information it searches, and that logic sometimes cuts
down the search prematurely. This patch removes some of those early
exits.

In that sense, this patch trades performance (early exit is faster)
for correctness.

I've also included two new test cases showing examples of this
behavior – as well as modifying an existing test case that gets it
wrong.

llvm-svn: 301273

7 years ago[asan] Fix Windows global dead stripping tests
Reid Kleckner [Mon, 24 Apr 2017 23:13:47 +0000 (23:13 +0000)]
[asan] Fix Windows global dead stripping tests

Pass /Gw to clang-cl which is equivalent to -fdata-sections. This is now
necessary.

llvm-svn: 301272

7 years ago[modules ts] Diagnose 'export' declarations outside of a module interface.
Richard Smith [Mon, 24 Apr 2017 23:12:30 +0000 (23:12 +0000)]
[modules ts] Diagnose 'export' declarations outside of a module interface.

llvm-svn: 301271

7 years agoInferAddressSpaces: Remove redundant assert
Matt Arsenault [Mon, 24 Apr 2017 23:02:57 +0000 (23:02 +0000)]
InferAddressSpaces: Remove redundant assert

This is just asserting all the operations are handled in the
switch, which the unreachable already handles.

llvm-svn: 301270

7 years ago[ARM, x86] add more vector tests for bool math; NFC
Sanjay Patel [Mon, 24 Apr 2017 22:42:34 +0000 (22:42 +0000)]
[ARM, x86] add more vector tests for bool math; NFC

I'm proposing a fold for increment-of-sexted-bool in:
https://reviews.llvm.org/D31944
...so we need to know what happens in more cases like these.

llvm-svn: 301269

7 years ago[git-llvm] Remove CR from middle of svn propget output
Reid Kleckner [Mon, 24 Apr 2017 22:26:46 +0000 (22:26 +0000)]
[git-llvm] Remove CR from middle of svn propget output

llvm-svn: 301268

7 years agoMake getSlotAttributes return an AttributeSet instead of a wrapper list
Reid Kleckner [Mon, 24 Apr 2017 22:25:02 +0000 (22:25 +0000)]
Make getSlotAttributes return an AttributeSet instead of a wrapper list

Remove the temporary, poorly named getSlotSet method which did the same
thing. Also remove getSlotNode, which is a hold-over from when we were
dealing with AttributeSetNode* instead of AttributeSet.

llvm-svn: 301267

7 years ago[Polly] [DependenceInfo] change WAR generation, Read will not block Read
Siddharth Bhat [Mon, 24 Apr 2017 22:23:12 +0000 (22:23 +0000)]
[Polly] [DependenceInfo] change WAR generation, Read will not block Read

Earlier, the call to buildFlow was:
    WAR = buildFlow(Write, Read, MustWrite, Schedule).

This meant that Read could block another Read, since must-sources can
block each other.

Fixed the call to buildFlow to correctly compute Read. The resulting
code needs to do some ISL juggling to get the output we want.

Bug report: https://bugs.llvm.org/show_bug.cgi?id=32623

Reviewers: Meinersbur

Tags: #polly

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

llvm-svn: 301266

7 years agoMark a test as requiring a shell.
Rafael Espindola [Mon, 24 Apr 2017 22:20:22 +0000 (22:20 +0000)]
Mark a test as requiring a shell.

llvm-svn: 301265

7 years agoHandle _LINK_ env string as command line parameters.
Rui Ueyama [Mon, 24 Apr 2017 22:20:03 +0000 (22:20 +0000)]
Handle _LINK_ env string as command line parameters.

"_LINK_" environment varaible should be appended to the command line.
https://msdn.microsoft.com/en-us/library/6y6t9esh.aspx

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

llvm-svn: 301264

7 years ago[DWARF] Fix lookup in the abstract origins of inlined blocks/functions
Sean Callanan [Mon, 24 Apr 2017 22:11:10 +0000 (22:11 +0000)]
[DWARF] Fix lookup in the abstract origins of inlined blocks/functions

LLDB uses clang::DeclContexts for lookups, and variables get put into
the DeclContext for their abstract origin. (The abstract origin is a
DWARF pointer that indicates the unique definition of inlined code.)
When the expression parser is looking for variables, it locates the
DeclContext for the current context. This needs to be done carefully,
though, e.g.:

__attribute__ ((always_inline)) void f(int a) {
  {
    int b = a * 2;
  }
}

void g() {
  f(3);
}
Here, if we're stopped in the inlined copy of f, we have to find the
DeclContext corresponding to the definition of f – its abstract
origin. Clang doesn't allow multiple functions with the same name and
arguments to exist. It also means that any variables we see must be
placed in the appropriate DeclContext.

[Bug 1]: When stopped in an inline block, the function
GetDeclContextDIEContainingDIE for that block doesn't properly
construct a DeclContext for the abstract origin for inlined
subroutines. That means we get duplicated function DeclContexts, but
function arguments only get put in the abstract origin's DeclContext,
and as a result when we try to look for them in nested contexts they
aren't found.

[Bug 2]: When stopped in an inline block, the DWARF (for space
reasons) doesn't explicitly point to the abstract origin for that
block. This means that the function GetClangDeclContextForDIE returns
a different DeclContext for each place the block is inlined. However,
any variables defined in the block have abstract origins, so they
will only get placed in the DeclContext for their abstract origin.

In this fix, I've introduced a test covering both of these issues,
and fixed them.

Bug 1 could be resolved simply by making sure we look up the abstract
origin for inlined functions when looking up their DeclContexts on
behalf of nested blocks.

For Bug 2, I've implemented an algorithm that makes the DeclContext
for a block be the containing DeclContext for the closest entity we
would find during lookup that has an abstract origin pointer. That
means that in the following situation:

{ // block 1
  int a;
  { // block 2
    int b;
  }
}
if we looked up the DeclContext for block 2, we'd find the block
containing the abstract origin of b, and lookup would proceed
correctly because we'd see b and a. However, in the situation

{ // block 1
  int a;
  { // block 2
  }
}
since there isn't anything to look up in block 2, we can't determine
its abstract origin (and there is no such pointer in the DWARF for
blocks). However, we can walk up the parent chain and find a, and its
abstract origin lives in the abstract origin of block 1. So we simply
say that the DeclContext for block 2 is the same as the DeclContext
for block 1, which contains a. Lookups will return the same results.

Thanks to Jim Ingham for review and suggestions.

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

llvm-svn: 301263

7 years ago[git-llvm] Make `push` work on CRLF files with svn:eol-style=native
Reid Kleckner [Mon, 24 Apr 2017 22:09:08 +0000 (22:09 +0000)]
[git-llvm] Make `push` work on CRLF files with svn:eol-style=native

Summary:
`git apply` on Windows doesn't work for files that SVN checks out as
CRLF. There is no way to force SVN to check everything out with Unix
line endings on Windows. Files with svn:eol-style=native will always
come out with CRLF, breaking `git apply`, which wants Unix line endings.
My workaround is to list all files with this property set in the change,
and run `dos2unix` on them. SVN doesn't commit a massive line ending
change because the svn:eol-style property indicates that these are text
files.

Tested on r301245.

Reviewers: zturner, jlebar

Subscribers: llvm-commits

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

llvm-svn: 301262

7 years ago[Modules] Fix test to wipe out the cache before using it
Bruno Cardoso Lopes [Mon, 24 Apr 2017 21:58:13 +0000 (21:58 +0000)]
[Modules] Fix test to wipe out the cache before using it

This should appease bots:
http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental_check/35914

rdar://problem/31796737

llvm-svn: 301261

7 years ago[InstSimplify] use ConstantRange to simplify more and-of-icmps
Sanjay Patel [Mon, 24 Apr 2017 21:52:39 +0000 (21:52 +0000)]
[InstSimplify] use ConstantRange to simplify more and-of-icmps

We can simplify (and (icmp X, C1), (icmp X, C2)) to one of the icmps in many cases.
I had to check some of these with Alive to prove to myself it's right, but everything
seems to check out. Eg, the code in instcombine was completely ignoring predicates with
mismatched signedness.

Handling or-of-icmps would be a follow-up step.

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

llvm-svn: 301260

7 years agoRemove DefaultSoName.
Rafael Espindola [Mon, 24 Apr 2017 21:44:20 +0000 (21:44 +0000)]
Remove DefaultSoName.

We can just use the existing SoName member variable. It now initially
contains what was in DefaultSoName and is modified if the .so has an
actual soname.

llvm-svn: 301259

7 years ago[DAGCombiner] Use APInt::intersects to avoid tmp variable. NFCI.
Simon Pilgrim [Mon, 24 Apr 2017 21:43:21 +0000 (21:43 +0000)]
[DAGCombiner] Use APInt::intersects to avoid tmp variable. NFCI.

llvm-svn: 301258

7 years ago[cfi] Fix wrong CMake condition for WIN32.
Evgeniy Stepanov [Mon, 24 Apr 2017 21:27:47 +0000 (21:27 +0000)]
[cfi] Fix wrong CMake condition for WIN32.

llvm-svn: 301257

7 years ago[asan] Remove asanwrapper from Android test harness.
Evgeniy Stepanov [Mon, 24 Apr 2017 21:27:45 +0000 (21:27 +0000)]
[asan] Remove asanwrapper from Android test harness.

It is only necessary for pre-L and creates problems on newer builds.

llvm-svn: 301256

7 years agoAMDGPU: Slightly simplify prolog reserved register handling
Matt Arsenault [Mon, 24 Apr 2017 21:08:32 +0000 (21:08 +0000)]
AMDGPU: Slightly simplify prolog reserved register handling

Rely on MachineRegisterInfo's knowledge of used physical
registers.

Move flat_scratch initialization earlier, so the uses are visible
when making these decisions.

This will make it easier to add another reserved register
at the end for the stack pointer rather than handling another
special case.

llvm-svn: 301254

7 years agoCosmetic change.
Galina Kistanova [Mon, 24 Apr 2017 21:06:29 +0000 (21:06 +0000)]
Cosmetic change.

llvm-svn: 301253

7 years agoProfileData: clean up some stale declarations (NFC)
Saleem Abdulrasool [Mon, 24 Apr 2017 21:05:05 +0000 (21:05 +0000)]
ProfileData: clean up some stale declarations (NFC)

These were removed in SVN r300381.  Remove the declarations.

llvm-svn: 301252

7 years ago[analyzer] Improve subscripting null arrays for catching null dereferences.
Artem Dergachev [Mon, 24 Apr 2017 20:55:07 +0000 (20:55 +0000)]
[analyzer] Improve subscripting null arrays for catching null dereferences.

Array-to-pointer cast now works correctly when the pointer to the array
is concrete, eg. null, which allows further symbolic calculations involving
such values.

Inlined defensive checks are now detected correctly when the resulting null
symbol is being array-subscripted before dereference.

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

llvm-svn: 301251

7 years agoRemove a dead field. NFC.
Vedant Kumar [Mon, 24 Apr 2017 20:54:36 +0000 (20:54 +0000)]
Remove a dead field. NFC.

Suggested by Adam Folwarczny!

llvm-svn: 301250

7 years ago[Coverage] Avoid null deref in skipRegionMappingForDecl (fixes PR32761)
Vedant Kumar [Mon, 24 Apr 2017 20:52:04 +0000 (20:52 +0000)]
[Coverage] Avoid null deref in skipRegionMappingForDecl (fixes PR32761)

Patch by Adam Folwarczny!

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

llvm-svn: 301249

7 years agoSmall addition on how to add a builder.
Galina Kistanova [Mon, 24 Apr 2017 20:48:40 +0000 (20:48 +0000)]
Small addition on how to add a builder.

llvm-svn: 301248

7 years ago[AMDGPU][mc][tests][NFC] Bulk ISA tests: update for Gfx7/Gfx8, add for Gfx9.
Artem Tamazov [Mon, 24 Apr 2017 20:42:27 +0000 (20:42 +0000)]
[AMDGPU][mc][tests][NFC] Bulk ISA tests: update for Gfx7/Gfx8, add for Gfx9.

llvm-svn: 301247

7 years agoSpecify a target explicitly in libfuzzer driver flag test
George Karpenkov [Mon, 24 Apr 2017 20:38:56 +0000 (20:38 +0000)]
Specify a target explicitly in libfuzzer driver flag test

llvm-svn: 301246

7 years ago[Bitcode] Refactor attribute group writing to avoid getSlotAttributes
Reid Kleckner [Mon, 24 Apr 2017 20:38:30 +0000 (20:38 +0000)]
[Bitcode] Refactor attribute group writing to avoid getSlotAttributes

Summary:
That API creates a temporary AttributeList to carry an index and a
single AttributeSet. We need to carry the index in addition to the set,
because that is how attribute groups are currently encoded.

NFC

Reviewers: pcc

Subscribers: llvm-commits

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

llvm-svn: 301245

7 years agoUpdate profile during memory instrinsic optimization
Teresa Johnson [Mon, 24 Apr 2017 20:30:42 +0000 (20:30 +0000)]
Update profile during memory instrinsic optimization

Summary:
Ensure that the new merge BB (which contains the rest of the original BB
after the mem op being optimized) gets a profile frequency, in case
there are additional mem ops later in the BB. Otherwise they get skipped
as the merge BB looks cold.

Reviewers: davidxl, xur

Subscribers: llvm-commits

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

llvm-svn: 301244

7 years ago[asan] Use posix strerror_r interceptor on android.
Evgeniy Stepanov [Mon, 24 Apr 2017 20:25:39 +0000 (20:25 +0000)]
[asan] Use posix strerror_r interceptor on android.

This fixes a regression in r297315.

llvm-svn: 301243

7 years agoRevert "StructurizeCFG: Directly invert cmp instructions"
Matt Arsenault [Mon, 24 Apr 2017 20:25:01 +0000 (20:25 +0000)]
Revert "StructurizeCFG: Directly invert cmp instructions"

This reverts commit r300732. This breaks a few tests.
I think the problem is related to adding more uses of
the condition that don't yet exist at this point.

llvm-svn: 301242

7 years ago[LoopUnroll] Remove spurious newline.
Davide Italiano [Mon, 24 Apr 2017 20:17:38 +0000 (20:17 +0000)]
[LoopUnroll] Remove spurious newline.

Eli pointed out in the review, but I didn't squash the two commits
correctly. Pointy-hat to me.

llvm-svn: 301241

7 years agoRevert "Refactor DynamicLibrary so searching for a symbol will have a defined order"
Frederich Munch [Mon, 24 Apr 2017 20:16:01 +0000 (20:16 +0000)]
Revert "Refactor DynamicLibrary so searching for a symbol will have a defined order"
The i686-mingw32-RA-on-linux bot is still having errors.

This reverts commit r301236.

llvm-svn: 301240

7 years ago[LoopUnroll] Don't try to unroll non canonical loops.
Davide Italiano [Mon, 24 Apr 2017 20:14:11 +0000 (20:14 +0000)]
[LoopUnroll] Don't try to unroll non canonical loops.

The current Loop Unroll implementation works with loops having a
single latch that contains a conditional branch to a block outside
the loop (the other successor is, by defition of latch, the header).
If this precondition doesn't hold, avoid unrolling the loop as
the code is not ready to handle such circumstances.

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

llvm-svn: 301239

7 years ago[LIR] Obey non-integral pointer semantics
Sanjoy Das [Mon, 24 Apr 2017 20:12:10 +0000 (20:12 +0000)]
[LIR] Obey non-integral pointer semantics

Summary: See http://llvm.org/docs/LangRef.html#non-integral-pointer-type

Reviewers: haicheng

Reviewed By: haicheng

Subscribers: mcrosier, mzolotukhin, llvm-commits

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

llvm-svn: 301238

7 years agoAvoid unnecessary copies in some for loops
Saleem Abdulrasool [Mon, 24 Apr 2017 20:01:03 +0000 (20:01 +0000)]
Avoid unnecessary copies in some for loops

Use constant references rather than `const auto` which will cause the
copy constructor.  These particular cases cause issues for the swift
compiler.

llvm-svn: 301237

7 years agoRefactor DynamicLibrary so searching for a symbol will have a defined order and
Frederich Munch [Mon, 24 Apr 2017 19:55:16 +0000 (19:55 +0000)]
Refactor DynamicLibrary so searching for a symbol will have a defined order and
libraries are properly unloaded when llvm_shutdown is called.

Summary:
This was mostly affecting usage of the JIT, where storing the library handles in
a set made iteration unordered/undefined. This lead to disagreement between the
JIT and native code as to what the address and implementation of particularly on
Windows with stdlib functions:

JIT: putenv_s("TEST", "VALUE") // called msvcrt.dll, putenv_s
JIT: getenv("TEST") -> "VALUE" // called msvcrt.dll, getenv
Native: getenv("TEST") -> NULL // called ucrt.dll, getenv

Also fixed is the issue of DynamicLibrary::getPermanentLibrary(0,0) on Windows
not giving priority to the process' symbols as it did on Unix.

Reviewers: chapuni, v.g.vassilev, lhames

Reviewed By: lhames

Subscribers: danalbert, srhines, mgorny, vsk, llvm-commits

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

llvm-svn: 301236

7 years ago[cfi] Disable ThinLTO + CFI tests on Windows.
Evgeniy Stepanov [Mon, 24 Apr 2017 19:52:51 +0000 (19:52 +0000)]
[cfi] Disable ThinLTO + CFI tests on Windows.

PR32770.

llvm-svn: 301235

7 years agoMove value type list from TargetRegisterClass to TargetRegisterInfo
Krzysztof Parzyszek [Mon, 24 Apr 2017 19:51:12 +0000 (19:51 +0000)]
Move value type list from TargetRegisterClass to TargetRegisterInfo

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

llvm-svn: 301234

7 years agoRevert r301223
Carlo Bertolli [Mon, 24 Apr 2017 19:50:35 +0000 (19:50 +0000)]
Revert r301223

llvm-svn: 301233

7 years agoRevert r301231: Accidentally committed stale files
Krzysztof Parzyszek [Mon, 24 Apr 2017 19:48:51 +0000 (19:48 +0000)]
Revert r301231: Accidentally committed stale files

I forgot to commit local changes before commit.

llvm-svn: 301232

7 years agoMove value type list from TargetRegisterClass to TargetRegisterInfo
Krzysztof Parzyszek [Mon, 24 Apr 2017 19:43:45 +0000 (19:43 +0000)]
Move value type list from TargetRegisterClass to TargetRegisterInfo

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

llvm-svn: 301231

7 years agoAMDGPU: Select scratch mubuf offsets when pointer is a constant
Matt Arsenault [Mon, 24 Apr 2017 19:40:59 +0000 (19:40 +0000)]
AMDGPU: Select scratch mubuf offsets when pointer is a constant

In call sequence setups, there may not be a frame index base
and the pointer is a constant offset from the frame
pointer / scratch wave offset register.

llvm-svn: 301230