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

7 years agoAMDGPU: Set StackGrowsUp in MCAsmInfo
Matt Arsenault [Mon, 24 Apr 2017 19:40:51 +0000 (19:40 +0000)]
AMDGPU: Set StackGrowsUp in MCAsmInfo

Not sure what this does though.

llvm-svn: 301229

7 years ago[AMDGPU] Merge M0 initializations
Stanislav Mekhanoshin [Mon, 24 Apr 2017 19:37:54 +0000 (19:37 +0000)]
[AMDGPU] Merge M0 initializations

Merges equivalent initializations of M0 and hoists them into a common
dominator block. Technically the same code can be used with any
register, physical or virtual.

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

llvm-svn: 301228

7 years agoHandle invariant.group.barrier in BasicAA
Piotr Padlewski [Mon, 24 Apr 2017 19:37:17 +0000 (19:37 +0000)]
Handle invariant.group.barrier in BasicAA

Summary:
llvm.invariant.group.barrier returns pointer that mustalias
pointer it takes. It can't be marked with `returned` attribute,
because it would be remove easily. The other reason is that
only Alias Analysis can know about this, because if any other
pass would know it, then the result would be replaced with it's
argument, which would be invalid.

We can think about returned pointer as something that mustalias, but
it doesn't have to be bitwise the same as the argument.

Reviewers: dberlin, chandlerc, hfinkel, sanjoy

Subscribers: reames, nlewycky, rsmith, anna, amharc

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

llvm-svn: 301227

7 years ago[asan] Let the frontend disable gc-sections optimization for asan globals.
Evgeniy Stepanov [Mon, 24 Apr 2017 19:34:13 +0000 (19:34 +0000)]
[asan] Let the frontend disable gc-sections optimization for asan globals.

Also extend -asan-globals-live-support flag to all binary formats.

llvm-svn: 301226

7 years ago[asan] Disable ASan global-GC depending on the target and compiler flags.
Evgeniy Stepanov [Mon, 24 Apr 2017 19:34:12 +0000 (19:34 +0000)]
[asan] Disable ASan global-GC depending on the target and compiler flags.

llvm-svn: 301225

7 years ago[analyzer] Improve suppression for inlined defensive checks before operator &.
Artem Dergachev [Mon, 24 Apr 2017 19:30:33 +0000 (19:30 +0000)]
[analyzer] Improve suppression for inlined defensive checks before operator &.

Null dereferences are suppressed if the lvalue was constrained to 0 for the
first time inside a sub-function that was inlined during analysis, because
such constraint is a valid defensive check that does not, by itself,
indicate that null pointer case is anyhow special for the caller.

If further operations on the lvalue are performed, the symbolic lvalue is
collapsed to concrete null pointer, and we need to track where does the null
pointer come from.

Improve such tracking for lvalue operations involving operator &.

rdar://problem/27876009

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

llvm-svn: 301224

7 years ago[OpenMP] Initial implementation of code generation for pragma 'distribute parallel...
Carlo Bertolli [Mon, 24 Apr 2017 19:26:11 +0000 (19:26 +0000)]
[OpenMP] Initial implementation of code generation for pragma 'distribute parallel for' on host

https://reviews.llvm.org/D29508

This patch makes the following additions:

1. It abstracts away loop bound generation code from procedures associated with pragma 'for' and loops in general, in such a way that the same procedures can be used for 'distribute parallel for' without the need for a full re-implementation.
2. It implements code generation for 'distribute parallel for' and adds regression tests. It includes tests for clauses.

It is important to notice that most of the clauses are implemented as part of existing procedures. For instance, firstprivate is already implemented for 'distribute' and 'for' as separate pragmas. As the implementation of 'distribute parallel for' is based on the same procedures, then we automatically obtain implementation for such clauses without the need to add new code. However, this requires regression tests that verify correctness of produced code.

Looking forward to comments.

llvm-svn: 301223

7 years ago[SimplifyCFG] Fix for non-determinism in codegen
Mandeep Singh Grang [Mon, 24 Apr 2017 19:20:45 +0000 (19:20 +0000)]
[SimplifyCFG] Fix for non-determinism in codegen

Summary: This patch fixes issues in codegen uncovered due to https://reviews.llvm.org/D26718

Reviewers: majnemer, chenli, davide

Reviewed By: davide

Subscribers: davide, arsenm, llvm-commits

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

llvm-svn: 301222

7 years agoMove size and alignment information of regclass to TargetRegisterInfo
Krzysztof Parzyszek [Mon, 24 Apr 2017 18:55:33 +0000 (18:55 +0000)]
Move size and alignment information of regclass to TargetRegisterInfo

1. RegisterClass::getSize() is split into two functions:
   - TargetRegisterInfo::getRegSizeInBits(const TargetRegisterClass &RC) const;
   - TargetRegisterInfo::getSpillSize(const TargetRegisterClass &RC) const;
2. RegisterClass::getAlignment() is replaced by:
   - TargetRegisterInfo::getSpillAlignment(const TargetRegisterClass &RC) const;

This will allow making those values depend on subtarget features in the
future.

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

llvm-svn: 301221

7 years agoDon't test setting sticky bits on files for modern BSDs
Dimitry Andric [Mon, 24 Apr 2017 18:54:48 +0000 (18:54 +0000)]
Don't test setting sticky bits on files for modern BSDs

Summary: In rL297945, jhenderson added methods for setting permissions
to sys::fs, but some of the unittests that attempt to set sticky bits
(01000) on files fail on modern BSDs, such as FreeBSD, NetBSD and
OpenBSD.  This is because those systems do not allow regular users to
set sticky bits on files, only on directories.  Fix it by disabling
these particular tests on modern BSDs.

Reviewers: emaste, brad, jhenderson

Reviewed By: jhenderson

Subscribers: joerg, krytarowski, llvm-commits

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

llvm-svn: 301220

7 years agoDon't emit CFI instructions at the end of a function
Adrian Prantl [Mon, 24 Apr 2017 18:45:59 +0000 (18:45 +0000)]
Don't emit CFI instructions at the end of a function

When functions are terminated by unreachable instructions, the last
instruction might trigger a CFI instruction to be generated. However,
emitting it would be be illegal since the function (and thus the FDE
the CFI is in) has already ended with the previous instruction.

Darwin's dwarfdump --verify --eh-frame complains about this and the
specification supports this.
Relevant bits from the DWARF 5 standard (6.4 Call Frame Information):

"[The] address_range [field in an FDE]: The number of bytes of
 program instructions described by this entry."

"Row creation instructions: [...]
 The new location value is always greater than the current one."
The first quotation implies that a CFI cannot describe a target
address outside of the enclosing FDE's range.

rdar://problem/26244988

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

llvm-svn: 301219

7 years agoPragma: Fix DebugOverflowStack() resulting in endless loop.
Matthias Braun [Mon, 24 Apr 2017 18:41:00 +0000 (18:41 +0000)]
Pragma: Fix DebugOverflowStack() resulting in endless loop.

Drive-by fix (noticed while working on https://reviews.llvm.org/D32205):
DebugOverflowStack() is supposed to provoke a stack overflow, however
LLVM was smart enough to use the red-zone and fold the load into a tail
jump on x86_64 optimizing this to an endless loop instead of a stack
overflow.

llvm-svn: 301218

7 years agoUpdates documentation for a syntax sugar libfuzzer flag,
George Karpenkov [Mon, 24 Apr 2017 18:39:52 +0000 (18:39 +0000)]
Updates documentation for a syntax sugar libfuzzer flag,

as implemented in https://reviews.llvm.org/D32193

llvm-svn: 301217

7 years agoRemove erroneous driver test for -fsanitize=fuzzer flag
George Karpenkov [Mon, 24 Apr 2017 18:36:31 +0000 (18:36 +0000)]
Remove erroneous driver test for -fsanitize=fuzzer flag

libfuzzer is not available on all platforms, and hence we can not always
rely that it was compiled.

llvm-svn: 301216

7 years agoCodeGen: Add a hook for getFenceOperandTy
Yaxun Liu [Mon, 24 Apr 2017 18:26:27 +0000 (18:26 +0000)]
CodeGen: Add a hook for getFenceOperandTy

Currently the operand type for ATOMIC_FENCE assumes value type of a pointer in address space 0.
This is fine for most targets. However for amdgcn target, the size of pointer in address space 0
depends on triple environment. For amdgiz environment, it is 64 bit but for other environment it is
32 bit. On the other hand, amdgcn target expects 32 bit fence operands independent of the target
triple environment. Therefore a hook is need in target lowering for getting the fence operand type.

This patch has no effect on targets other than amdgcn.

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

llvm-svn: 301215

7 years agoRevert "Compute safety information in a much finer granularity."
Evgeniy Stepanov [Mon, 24 Apr 2017 18:25:07 +0000 (18:25 +0000)]
Revert "Compute safety information in a much finer granularity."

Use-after-free in llvm::isGuaranteedToExecute.

llvm-svn: 301214

7 years ago[InstSimplify] move (A & ~B) | (A ^ B) -> (A ^ B) from InstCombine
Sanjay Patel [Mon, 24 Apr 2017 18:24:36 +0000 (18:24 +0000)]
[InstSimplify] move (A & ~B) | (A ^ B) -> (A ^ B) from InstCombine

This is a straight cut and paste, but there's a bigger problem: if this
fold exists for simplifyOr, there should be a DeMorganized version for
simplifyAnd. But more than that, we have a patchwork of ad hoc logic
optimizations in InstCombine. There should be some structure to ensure
that we're not missing sibling folds across and/or/xor.

llvm-svn: 301213