platform/upstream/llvm.git
6 years ago[InstCombine] Fold (C - X) ^ signmask -> (C + signmask - X).
Craig Topper [Sat, 5 Aug 2017 20:00:44 +0000 (20:00 +0000)]
[InstCombine] Fold (C - X) ^ signmask -> (C + signmask - X).

llvm-svn: 310186

6 years ago[InstCombine] Teach the code that pulls logical operators through constant shifts...
Craig Topper [Sat, 5 Aug 2017 20:00:42 +0000 (20:00 +0000)]
[InstCombine] Teach the code that pulls logical operators through constant shifts to handle vector splats too.

llvm-svn: 310185

6 years ago[InstCombine] Support vector splats in foldSelectICmpAnd.
Craig Topper [Sat, 5 Aug 2017 20:00:41 +0000 (20:00 +0000)]
[InstCombine] Support vector splats in foldSelectICmpAnd.

Unfortunately, it looks like there's some other missed optimizations in the generated code for some of these cases. I'll try to look at some of those next.

llvm-svn: 310184

6 years ago[SLPVectorizer] Add extra parameter to setInsertPointAfterBundle to handle different...
Dinar Temirbulatov [Sat, 5 Aug 2017 18:43:52 +0000 (18:43 +0000)]
[SLPVectorizer] Add extra parameter to setInsertPointAfterBundle to handle different opcodes, NFCI.

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

llvm-svn: 310183

6 years agoAdd NetBSD support in sanitizer_errno.h
Kamil Rytarowski [Sat, 5 Aug 2017 18:10:51 +0000 (18:10 +0000)]
Add NetBSD support in sanitizer_errno.h

Summary:
NetBSD ships with __errno (value for __errno_location) like Android.

Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, vitalybuka, fjricci, kcc, filcab

Reviewed By: vitalybuka

Subscribers: llvm-commits, srhines, kubamracek, #sanitizers

Tags: #sanitizers

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

llvm-svn: 310182

6 years ago[InstCombine] refactor trunc(binop) transforms; NFCI
Sanjay Patel [Sat, 5 Aug 2017 15:19:18 +0000 (15:19 +0000)]
[InstCombine] refactor trunc(binop) transforms; NFCI

In addition to moving the shift transforms over, we may want to
detect too-wide rotate patterns here (PR34046).

llvm-svn: 310181

6 years ago[ARM] The ARM backend is MachineVerifier clean now.
Florian Hahn [Sat, 5 Aug 2017 15:14:06 +0000 (15:14 +0000)]
[ARM] The ARM backend is MachineVerifier clean now.

Summary: Thanks everyone involved in fixing the outstanding issues.

Reviewers: rovka, MatzeB, efriedma

Reviewed By: MatzeB

Subscribers: aemerson, javed.absar, llvm-commits, kristof.beyls

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

llvm-svn: 310180

6 years agoAdd NetBSD support in sanitizer_unwind_linux_libcdep.cc
Kamil Rytarowski [Sat, 5 Aug 2017 13:36:49 +0000 (13:36 +0000)]
Add NetBSD support in sanitizer_unwind_linux_libcdep.cc

Summary:
NetBSD is a POSIX-like and BSD-family system.

Reuse FreeBSD and Linux code.

NetBSD uses DWARF ExceptionHandler.

Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, kcc, filcab, vitalybuka

Reviewed By: vitalybuka

Subscribers: srhines, emaste, llvm-commits, kubamracek, aprantl, #sanitizers

Tags: #sanitizers

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

llvm-svn: 310179

6 years ago[ARM] Add registers to debuginfo MIR test cases.
Florian Hahn [Sat, 5 Aug 2017 12:13:13 +0000 (12:13 +0000)]
[ARM] Add registers to debuginfo MIR test cases.

Summary:
MIRParserImpl::computeFunctionProperties uses MRI.getNumVirtRegs() to
set the NoVReg property. By adding a bunch of registers to the MIR test
cases, the NoVReg property is not set when importing the MIR. Otherwise
NoVReg is set after instruction selection while the machine instructions
still contain virtual registers, causing expensive checks to fail.

Reviewers: efriedma, MatzeB, aprantl

Reviewed By: MatzeB, aprantl

Subscribers: aemerson, javed.absar, kristof.beyls, llvm-commits

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

llvm-svn: 310178

6 years agoAdd forgotten CMakeLists.txt file in unit-test
Tobias Grosser [Sat, 5 Aug 2017 09:44:11 +0000 (09:44 +0000)]
Add forgotten CMakeLists.txt file in unit-test

llvm-svn: 310177

6 years agoFix spelling error in previous commit
Tobias Grosser [Sat, 5 Aug 2017 09:39:00 +0000 (09:39 +0000)]
Fix spelling error in previous commit

llvm-svn: 310176

6 years ago[unittests] Add unittest for getPartialTilePrefixes
Tobias Grosser [Sat, 5 Aug 2017 09:38:09 +0000 (09:38 +0000)]
[unittests] Add unittest for getPartialTilePrefixes

In https://reviews.llvm.org/D36278 it was pointed out that the behavior of
getPartialTilePrefixes is not very well understood. To allow for a better
understanding, we first provide some basic unittests.

llvm-svn: 310175

6 years ago[LCG] Remove yet another variable only used inside of asserts.
Chandler Carruth [Sat, 5 Aug 2017 08:33:16 +0000 (08:33 +0000)]
[LCG] Remove yet another variable only used inside of asserts.

llvm-svn: 310174

6 years ago[LCG] Fold otherwise unused variable into assert.
Benjamin Kramer [Sat, 5 Aug 2017 08:28:48 +0000 (08:28 +0000)]
[LCG] Fold otherwise unused variable into assert.

No functionality change intended.

llvm-svn: 310173

6 years agoIPRA: Don't crash on null getCallPreservedMask
Matt Arsenault [Sat, 5 Aug 2017 07:50:18 +0000 (07:50 +0000)]
IPRA: Don't crash on null getCallPreservedMask

Kernels aren't callable, so they don't have a call preserved mask.

llvm-svn: 310172

6 years ago[LCG] Completely remove the parent set and leaf tracking for RefSCCs.
Chandler Carruth [Sat, 5 Aug 2017 07:37:00 +0000 (07:37 +0000)]
[LCG] Completely remove the parent set and leaf tracking for RefSCCs.

After the previous series of patches, this is now trivial and deletes
a pretty astonishing amount of complexity. This has been a long time
coming, as the move toward a PO sequence of RefSCCs started eroding the
underlying use cases for this half of the data structure.

Among the biggest advantages here is that now there aren't two
independent data structures that need to stay in sync.

Some of my profiling has also indicated that updating the parent sets
was among the most expensive parts of the lazy call graph. Eliminating
it whole sale is likely to be a nice win in terms of compile time.

Last but not least, I had discussed with some folks previously keeping
it around for asserts and other correctness checking, but once the
fundamentals of the parent and child checking were implemented without
the parent sets their value in correctness checking was tiny and no
where near worth the cost of the complexity required to keep everything
up-to-date.

llvm-svn: 310171

6 years ago[LCG] Re-implement the basic isParentOf, isAncestorOf, isChildOf, and
Chandler Carruth [Sat, 5 Aug 2017 06:24:09 +0000 (06:24 +0000)]
[LCG] Re-implement the basic isParentOf, isAncestorOf, isChildOf, and
isDescendantOf methods on RefSCCs in terms of the forward edges rather
than the parent sets.

This is technically slower, but probably not interestingly slower, and
all of these routines were already so expensive that they're guarded
behind both !NDEBUG and EXPENSIVE_CHECKS.

This removes another non-critical usage of parent sets.

I've also added some comments to try and help clarify to any potential
users the costs of these routines. They're mostly useful for debugging,
asserts, or other queries.

llvm-svn: 310170

6 years ago[LCG] Add the concept of a "dead" node and use it to avoid a complex
Chandler Carruth [Sat, 5 Aug 2017 05:47:37 +0000 (05:47 +0000)]
[LCG] Add the concept of a "dead" node and use it to avoid a complex
walk over the parent set.

When removing a single function from the call graph, we previously would
walk the entire RefSCC's parent set and then walk every outgoing edge
just to find the ones to remove. In addition to this being quite high
complexity in theory, it is also the last fundamental use of the parent
sets.

With this change, when we remove a function we transform the node
containing it to be recognizably "dead" and then teach the edge
iterators to recognize edges to such nodes and skip them the same way
they skip null edges.

We can't move fully to using "dead" nodes -- when disconnecting two live
nodes we need to null out the edge. But the complexity this adds to the
edge sequence isn't too bad and the simplification of lazily handling
this seems like a significant win.

llvm-svn: 310169

6 years ago[lld] Allow rel iplt symbols with dynamic symbol table
Shoaib Meenai [Sat, 5 Aug 2017 05:01:07 +0000 (05:01 +0000)]
[lld] Allow rel iplt symbols with dynamic symbol table

Emit these symbols as long as we're building in a static configuration,
even if we're emitting a dynamic symbol table. This is consistent with
both bfd and gold.

Ordinarily, the combination of -static and -export-dynamic wouldn't make
much sense. Unfortunately, cmake versions prior to 3.4 forcefully
injected -rdynamic [1], so it seems worthwhile to support.

[1] https://cmake.org/cmake/help/v3.4/policy/CMP0065.html

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

llvm-svn: 310168

6 years ago[AArch64] LSE Atomics reorg - part 1
Joel Jones [Sat, 5 Aug 2017 04:30:55 +0000 (04:30 +0000)]
[AArch64] LSE Atomics reorg - part 1

Add memory synchronization semantics to LSE Atomics.

The memory semantics feature will be added in a subsequent patch.

In this patch, several corrections were added to the existing LSE Atomics
implementation, based on the ARM Errata D11904 from 05/12/2017.

Patch by: steleman

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

llvm-svn: 310167

6 years agoReplace CRLF.
Rui Ueyama [Sat, 5 Aug 2017 04:07:21 +0000 (04:07 +0000)]
Replace CRLF.

llvm-svn: 310166

6 years ago[LCG] Replace an implicit bool operator with a named function. (NFC)
Chandler Carruth [Sat, 5 Aug 2017 04:04:06 +0000 (04:04 +0000)]
[LCG] Replace an implicit bool operator with a named function. (NFC)

The definition of 'false' here was already pretty vague and debatable,
and I'm about to add another potential 'false' that would actually make
much more sense in a bool operator. Especially given how rarely this is
used, a nicely named method seems better.

llvm-svn: 310165

6 years ago[LCG] When removing a dead function and clearing out the data
Chandler Carruth [Sat, 5 Aug 2017 03:37:39 +0000 (03:37 +0000)]
[LCG] When removing a dead function and clearing out the data
structures, actually null out the graph pointers as well. We won't ever
update these, and we certainly shouldn't be calling any methods on them,
so it seems good to defensively nuke them.

llvm-svn: 310164

6 years ago[LCG] Rather than walking the directed graph structure to update graph
Chandler Carruth [Sat, 5 Aug 2017 03:37:39 +0000 (03:37 +0000)]
[LCG] Rather than walking the directed graph structure to update graph
pointers in node objects, just walk the map from function to node.

It doesn't have stable ordering, but works just as well and is much
simpler. We don't need ordering when just updating internal pointers.

llvm-svn: 310163

6 years ago[LCG] Remove the complex walk of the parent sets to update graph
Chandler Carruth [Sat, 5 Aug 2017 03:37:38 +0000 (03:37 +0000)]
[LCG] Remove the complex walk of the parent sets to update graph
pointers.

This is completely unnecessary as we have a trivial list of RefSCCs now
that we can walk.

llvm-svn: 310162

6 years ago[LCG] Remove the use of the parent sets to compute connectivity when
Chandler Carruth [Sat, 5 Aug 2017 03:37:37 +0000 (03:37 +0000)]
[LCG] Remove the use of the parent sets to compute connectivity when
merging RefSCCs.

The logic to directly use the reference edges is simpler and not
substantially slower (despite the comments to the contrary) because this
is not actually an especially hot part of LCG in practice.

llvm-svn: 310161

6 years ago[OpenCL] Remove extra select functions from opencl-c.h
Yaxun Liu [Sat, 5 Aug 2017 02:23:47 +0000 (02:23 +0000)]
[OpenCL] Remove extra select functions from opencl-c.h

OpenCL spec v2.0 s6.13.6:

gentype select (gentype a,
gentype b,
igentype c)

gentype select (gentype a,
gentype b,
ugentype c)

igentype and ugentype must have the same number
of elements and bits as gentype.

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

llvm-svn: 310160

6 years ago[InstCombine] In foldSelectICmpAnd, if we need to to truncate from the 'and' type...
Craig Topper [Sat, 5 Aug 2017 01:45:17 +0000 (01:45 +0000)]
[InstCombine] In foldSelectICmpAnd, if we need to to truncate from the 'and' type to the 'select' type, do it after shifting right instead of just bailing.

Previously we were always trying to emit the zext or truncate before any shift. This meant if the 'and' mask was larger than the size of the truncate we would skip the transformation.

Now we shift the result of the and right first leaving the bit within the range of the truncate.

This matches what we are doing in foldSelectICmpAndOr for the same problem.

llvm-svn: 310159

6 years ago[ODRHash] Treat some non-templated classes as templated.
Richard Trieu [Sat, 5 Aug 2017 00:54:19 +0000 (00:54 +0000)]
[ODRHash] Treat some non-templated classes as templated.

When using nested classes, if the inner class is not templated, but the outer
class is templated, the inner class will not be templated, but may have some
traits as if it were.  This is particularly evident if the inner class
refers to the outer class in some fashion.  Treat any class that is in the
context of a templated class as also a templated class.

llvm-svn: 310158

6 years ago[libcxx] [test] Untabify stringstream.cons/string.pass.cpp. NFC.
Stephan T. Lavavej [Sat, 5 Aug 2017 00:44:27 +0000 (00:44 +0000)]
[libcxx] [test] Untabify stringstream.cons/string.pass.cpp. NFC.

llvm-svn: 310157

6 years ago[libcxx] [test] Fix URLs in comments and make them HTTPS. NFC.
Stephan T. Lavavej [Sat, 5 Aug 2017 00:44:24 +0000 (00:44 +0000)]
[libcxx] [test] Fix URLs in comments and make them HTTPS. NFC.

llvm-svn: 310156

6 years ago[libcxx] [test] Consistently list "c++98, c++03" in chronological order. NFC.
Stephan T. Lavavej [Sat, 5 Aug 2017 00:44:19 +0000 (00:44 +0000)]
[libcxx] [test] Consistently list "c++98, c++03" in chronological order. NFC.

llvm-svn: 310155

6 years agoRevert "[Coverage] Precise region termination with deferred regions"
Vedant Kumar [Sat, 5 Aug 2017 00:34:10 +0000 (00:34 +0000)]
Revert "[Coverage] Precise region termination with deferred regions"

This reverts commit r310010. I don't think there's anything wrong with
this commit, but it's causing clang to generate output that llvm-cov
doesn't do a good job with and the fix isn't immediately clear.

See Eli's comment in D36250 for more context.

I'm reverting the clang change so the coverage bot can revert back to
producing sensible output, and to give myself some time to investigate
what went wrong in llvm.

llvm-svn: 310154

6 years agoCommit the local change I had to make my test pass
Reid Kleckner [Sat, 5 Aug 2017 00:15:40 +0000 (00:15 +0000)]
Commit the local change I had to make my test pass

llvm-svn: 310153

6 years ago[X86] Teach fastisel to select calls to dllimport functions
Reid Kleckner [Sat, 5 Aug 2017 00:10:43 +0000 (00:10 +0000)]
[X86] Teach fastisel to select calls to dllimport functions

Summary:
Direct calls to dllimport functions are very common Windows. We should
add them to the -O0 fast path.

Reviewers: rafael

Subscribers: llvm-commits, hiraditya

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

llvm-svn: 310152

6 years ago[libFuzzer] use the in-binary pc table (instead of PCs captured at run-time) to imple...
Kostya Serebryany [Fri, 4 Aug 2017 23:49:53 +0000 (23:49 +0000)]
[libFuzzer] use the in-binary pc table (instead of PCs captured at run-time) to implement -exit_on_src_pos

llvm-svn: 310151

6 years ago[X86] Regenerate the fsin/fcos instruction test using update_llc_test_checks.py. NFC
Craig Topper [Fri, 4 Aug 2017 23:36:03 +0000 (23:36 +0000)]
[X86] Regenerate the fsin/fcos instruction test using update_llc_test_checks.py. NFC

This looks to have been converted from a grep based test at some point in a really strange way.

llvm-svn: 310150

6 years ago[llvm][llvm-objcopy] When outputting to binary don't output segments that cover no...
Petr Hosek [Fri, 4 Aug 2017 23:18:18 +0000 (23:18 +0000)]
[llvm][llvm-objcopy] When outputting to binary don't output segments that cover no sections

Sometimes LLD will produce a PT_LOAD segment that only covers the
headers (and covers no sections). GNU objcopy does not output the
segment contents for these sections. In particular this is an issue in
building magenta because the final link step for the kernel would
produce just such a PT_LOAD segment. This change is to support this case
and to match what GNU objcopy does in this case.

Patch by Jake Ehrlich

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

llvm-svn: 310149

6 years ago[libFuzzer] print PCs using the in-binary PC-table instead of relying on PCs captured...
Kostya Serebryany [Fri, 4 Aug 2017 23:13:58 +0000 (23:13 +0000)]
[libFuzzer] print PCs using the in-binary PC-table instead of relying on PCs captured at run-time

llvm-svn: 310148

6 years agoDebug Info: Set the DICompileUnit's isOptimized flag when compiling with LTO.
Adrian Prantl [Fri, 4 Aug 2017 23:08:57 +0000 (23:08 +0000)]
Debug Info: Set the DICompileUnit's isOptimized flag when compiling with LTO.

rdar://problem/27640939

llvm-svn: 310147

6 years ago[DeLICM] Refactor ZoneAlgorithm into ZoneAlgo.cpp. NFC.
Michael Kruse [Fri, 4 Aug 2017 22:51:23 +0000 (22:51 +0000)]
[DeLICM] Refactor ZoneAlgorithm into ZoneAlgo.cpp. NFC.

Extract ZoneAlgorithm from DeLICM.cpp into its own file.
It will gain a second use by the load forwarding part of
-polly-optree.

llvm-svn: 310146

6 years agoClean up some lambda conversion operator code, NFC
Reid Kleckner [Fri, 4 Aug 2017 22:38:06 +0000 (22:38 +0000)]
Clean up some lambda conversion operator code, NFC

We don't need special handling in CodeGenFunction::GenerateCode for
lambda block pointer conversion operators anymore. The conversion
operator emission code immediately calls back to the generic
EmitFunctionBody.

Rename EmitLambdaStaticInvokeFunction to EmitLambdaStaticInvokeBody for
better consistency with the other Emit*Body methods.

I'm preparing to do something about PR28299, which touches this code.

llvm-svn: 310145

6 years agoEnable llvm-pdbutil to list enumerations using native PDB reader
Adrian McCarthy [Fri, 4 Aug 2017 22:37:58 +0000 (22:37 +0000)]
Enable llvm-pdbutil to list enumerations using native PDB reader

This extends the native reader to enable llvm-pdbutil to list the enums in a
PDB and it includes a simple test. It does not yet list the values in the
enumerations, which requires an actual implementation of
NativeEnumSymbol::FindChildren.

To exercise this code, use a command like:

    llvm-pdbutil pretty -native -enums foo.pdb

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

llvm-svn: 310144

6 years agoAdd NetBSD support in sanitizer_linux_libcdep.cc
Kamil Rytarowski [Fri, 4 Aug 2017 22:32:46 +0000 (22:32 +0000)]
Add NetBSD support in sanitizer_linux_libcdep.cc

Summary:
When possible reuse FreeBSD and Linux code.

Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, kcc, vitalybuka, filcab

Reviewed By: vitalybuka

Subscribers: srhines, emaste, kubamracek, llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 310143

6 years agoMove File from SymbolBody to Symbol.
Rafael Espindola [Fri, 4 Aug 2017 22:31:42 +0000 (22:31 +0000)]
Move File from SymbolBody to Symbol.

With this Symbol has the same size as before, but DefinedRegular goes
from 72 to 64 bytes.

I also find this a bit easier to read. There are fewer places
initializing File for example.

This has a small but measurable speed improvement on all tests (1%
max).

llvm-svn: 310142

6 years ago[InstCombine] narrow truncated add/sub/mul with constant
Sanjay Patel [Fri, 4 Aug 2017 22:30:34 +0000 (22:30 +0000)]
[InstCombine] narrow truncated add/sub/mul with constant

Name: narrow_sub
  %sub = sub i32 C1, %x
  %r = trunc i32 %sub to i8
  =>
  %xn = trunc i32 %x to i8
  %narrowC = trunc i32 C1 to i8
  %r = sub i8 %narrowC, %xn

Name: narrow_add
  %add = add i32 %x, C1
  %r = trunc i32 %add to i8
  =>
  %xn = trunc i32 %x to i8
  %narrowC = trunc i32 C1 to i8
  %r = add i8 %xn, %narrowC

Name: narrow_mul
  %mul = mul i32 %x, C1
  %r = trunc i32 %mul to i8
  =>
  %xn = trunc i32 %x to i8
  %narrowC = trunc i32 C1 to i8
  %r = mul i8 %xn, %narrowC

http://rise4fun.com/Alive/QpS

This doesn't solve PR34046 (failure to recognize rotate):
https://bugs.llvm.org/show_bug.cgi?id=34046
...but it reduces an extra complication in the description examples
to a form that we can more easily match.

llvm-svn: 310141

6 years agoAdd NetBSD support in interception.h
Kamil Rytarowski [Fri, 4 Aug 2017 22:27:01 +0000 (22:27 +0000)]
Add NetBSD support in interception.h

Summary:
Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, kcc, filcab, vitalybuka

Reviewed By: vitalybuka

Subscribers: llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 310140

6 years agoAdd NetBSD support in sanitizer_syscall_generic.inc
Kamil Rytarowski [Fri, 4 Aug 2017 22:23:52 +0000 (22:23 +0000)]
Add NetBSD support in sanitizer_syscall_generic.inc

Summary:
This adds:
 - NetBSD specific aliases for renamed syscalls,
 - differentiate internal_syscall, internal_syscall64, internal_syscall_ptr as there are various types of syscalls on NetBSD.

Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas.

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, kcc, vitalybuka, filcab

Reviewed By: vitalybuka

Subscribers: kubamracek, llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 310139

6 years ago[libclang] Determinize order of platform availability attrs
Reid Kleckner [Fri, 4 Aug 2017 21:52:25 +0000 (21:52 +0000)]
[libclang] Determinize order of platform availability attrs

Previously this code was doing std::sort on IdentifierInfo pointers. Now
it sorts alphabetically by platform name.

This should de-flake clang/test/Index/availability.c, which was failing
non-deterministically for me.

llvm-svn: 310138

6 years ago[Support] Use FILE_SHARE_DELETE to fix RemoveFileOnSignal on Windows
Reid Kleckner [Fri, 4 Aug 2017 21:52:00 +0000 (21:52 +0000)]
[Support] Use FILE_SHARE_DELETE to fix RemoveFileOnSignal on Windows

Summary:
Tools like clang that use RemoveFileOnSignal on their output files
weren't actually able to clean up their outputs before this change.  Now
the call to llvm::sys::fs::remove succeeds and the temporary file is
deleted. This is a stop-gap to fix clang before implementing the
solution outlined in PR34070.

Reviewers: davide

Subscribers: llvm-commits, hiraditya

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

llvm-svn: 310137

6 years ago[libFuzzer] add -fsanitize-coverage-pc-table to -fsanitize=fuzzer
Kostya Serebryany [Fri, 4 Aug 2017 21:35:11 +0000 (21:35 +0000)]
[libFuzzer] add -fsanitize-coverage-pc-table to -fsanitize=fuzzer

llvm-svn: 310136

6 years agoRevert "[OPENMP][DEBUG] Set proper address space info if required by target."
Alexey Bataev [Fri, 4 Aug 2017 21:27:11 +0000 (21:27 +0000)]
Revert "[OPENMP][DEBUG] Set proper address space info if required by target."

This reverts commit r310104.

llvm-svn: 310135

6 years agoRevert "[OPENMP] Fix for pacify buildbots, NFC."
Alexey Bataev [Fri, 4 Aug 2017 21:26:25 +0000 (21:26 +0000)]
Revert "[OPENMP] Fix for pacify buildbots, NFC."

This reverts commit r310120.

llvm-svn: 310134

6 years ago[asan] Fix unsupported test on Android
Kostya Kortchinsky [Fri, 4 Aug 2017 21:26:20 +0000 (21:26 +0000)]
[asan] Fix unsupported test on Android

Summary:
`pvalloc` appears to not be available on Android. Mark the failing test as
unsupported on that platform.

Reviewers: alekseyshl, vitalybuka

Reviewed By: alekseyshl, vitalybuka

Subscribers: srhines, kubamracek, llvm-commits

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

llvm-svn: 310133

6 years agoReland "CFI: blacklist STL allocate() from unrelated-casts"
Vlad Tsyrklevich [Fri, 4 Aug 2017 21:21:00 +0000 (21:21 +0000)]
Reland "CFI: blacklist STL allocate() from unrelated-casts"

Reland r310097 with a fix for a debug assertion in NamedDecl.getName()

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

llvm-svn: 310132

6 years agoMore PDB buildbot fixes.
Zachary Turner [Fri, 4 Aug 2017 21:18:17 +0000 (21:18 +0000)]
More PDB buildbot fixes.

llvm-svn: 310131

6 years agoFix broken PDB tests.
Zachary Turner [Fri, 4 Aug 2017 21:15:12 +0000 (21:15 +0000)]
Fix broken PDB tests.

llvm-svn: 310130

6 years agoBlockPlacement: add a flag to force cold block outlining w/o a profile.
Kyle Butt [Fri, 4 Aug 2017 21:13:41 +0000 (21:13 +0000)]
BlockPlacement: add a flag to force cold block outlining w/o a profile.

NFC.

llvm-svn: 310129

6 years ago[pdbutil] When dumping section contribs, show the section name.
Zachary Turner [Fri, 4 Aug 2017 21:10:04 +0000 (21:10 +0000)]
[pdbutil] When dumping section contribs, show the section name.

llvm-svn: 310128

6 years agoReland "[llvm][llvm-objcopy] Added support for outputting to binary in llvm-objcopy"
Petr Hosek [Fri, 4 Aug 2017 21:09:26 +0000 (21:09 +0000)]
Reland "[llvm][llvm-objcopy] Added support for outputting to binary in llvm-objcopy"

This change adds the "-O binary" flag which directs llvm-objcopy to
output the object file to the same format as GNU objcopy does when given
the flag "-O binary". This was done by splitting the Object class into
two subclasses ObjectELF and ObjectBianry which each output a different
format but relay on the same code to read in the Object in Object.

Patch by Jake Ehrlich

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

llvm-svn: 310127

6 years ago[libFuzzer] re-enable fuzzer-printcovpcs.test
Kostya Serebryany [Fri, 4 Aug 2017 20:47:22 +0000 (20:47 +0000)]
[libFuzzer] re-enable fuzzer-printcovpcs.test

llvm-svn: 310126

6 years agoRemove unused include directive and un-break the module build.
Adrian Prantl [Fri, 4 Aug 2017 20:41:37 +0000 (20:41 +0000)]
Remove unused include directive and un-break the module build.

llvm-svn: 310124

6 years agoRevert r310055, it caused PR34074.
Nico Weber [Fri, 4 Aug 2017 20:40:38 +0000 (20:40 +0000)]
Revert r310055, it caused PR34074.

llvm-svn: 310123

6 years ago[InstCombine] add vector tests for truncated math; NFC
Sanjay Patel [Fri, 4 Aug 2017 20:38:33 +0000 (20:38 +0000)]
[InstCombine] add vector tests for truncated math; NFC

llvm-svn: 310122

6 years agoRevert "Reland "CFI: blacklist STL allocate() from unrelated-casts""
Vlad Tsyrklevich [Fri, 4 Aug 2017 20:37:49 +0000 (20:37 +0000)]
Revert "Reland "CFI: blacklist STL allocate() from unrelated-casts""

This reverts commit r310105.

llvm-svn: 310121

6 years ago[OPENMP] Fix for pacify buildbots, NFC.
Alexey Bataev [Fri, 4 Aug 2017 20:29:52 +0000 (20:29 +0000)]
[OPENMP] Fix for pacify buildbots, NFC.

llvm-svn: 310120

6 years ago[asan] Check for pvalloc overlow
Kostya Kortchinsky [Fri, 4 Aug 2017 20:28:59 +0000 (20:28 +0000)]
[asan] Check for pvalloc overlow

Summary:
Last one of the `pvalloc` overflow checks!

`CheckForPvallocOverflow` was introduced with D35818 to detect when `pvalloc`
would wrap when rounding up to the next multiple of the page size.

Add this check to ASan's `pvalloc` implementation.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: llvm-commits, kubamracek

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

llvm-svn: 310119

6 years agoRevert r310058, it caused PR34073.
Nico Weber [Fri, 4 Aug 2017 20:24:13 +0000 (20:24 +0000)]
Revert r310058, it caused PR34073.

llvm-svn: 310118

6 years ago[SCEV] Preserve NSW information for sext(subtract).
Amara Emerson [Fri, 4 Aug 2017 20:19:46 +0000 (20:19 +0000)]
[SCEV] Preserve NSW information for sext(subtract).

Pushes the sext onto the operands of a Sub if NSW is present.
Also adds support for propagating the nowrap flags of the
llvm.ssub.with.overflow intrinsic during analysis.

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

llvm-svn: 310117

6 years agoAdd NetBSD support in sanitizer_procmaps_freebsd.cc
Kamil Rytarowski [Fri, 4 Aug 2017 20:17:24 +0000 (20:17 +0000)]
Add NetBSD support in sanitizer_procmaps_freebsd.cc

Summary:
This adds NetBSD specific:
 - ReadProcMaps()
 - MemoryMappingLayout::Next()

This code is largely shared with FreeBSD.

Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas.

Sponsored by <The NetBSD Foundation>

Reviewers: kcc, joerg, filcab, vitalybuka, fjricci

Reviewed By: fjricci

Subscribers: emaste, kubamracek, mgorny, llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 310116

6 years ago[GlobalISel] Remove the GISelAccessor API.
Quentin Colombet [Fri, 4 Aug 2017 20:15:46 +0000 (20:15 +0000)]
[GlobalISel] Remove the GISelAccessor API.

Its sole purpose was to avoid spreading around ifdefs related to
building global-isel. Since r309990, GlobalISel is not optional anymore,
thus, we can get rid of this mechanism all together.

NFC.

llvm-svn: 310115

6 years ago[GlobalISel] Remove a stall comment in CMake.
Quentin Colombet [Fri, 4 Aug 2017 20:15:41 +0000 (20:15 +0000)]
[GlobalISel] Remove a stall comment in CMake.

Thanks to Diana Picus <diana.picus@linaro.org> for noticing.

NFC

llvm-svn: 310114

6 years ago[libFuzzer] make a test more robust
Kostya Serebryany [Fri, 4 Aug 2017 20:09:15 +0000 (20:09 +0000)]
[libFuzzer] make a test more robust

llvm-svn: 310113

6 years agoFix build breakage.
Zachary Turner [Fri, 4 Aug 2017 20:07:08 +0000 (20:07 +0000)]
Fix build breakage.

llvm-svn: 310112

6 years agominor grammar fix
Nico Weber [Fri, 4 Aug 2017 20:06:03 +0000 (20:06 +0000)]
minor grammar fix

llvm-svn: 310111

6 years ago[libFuzzer] remove the now redundant 'LLVMFuzzer-' prefix from libFuzzer tests
Kostya Serebryany [Fri, 4 Aug 2017 20:05:25 +0000 (20:05 +0000)]
[libFuzzer] remove the now redundant 'LLVMFuzzer-' prefix from libFuzzer tests

llvm-svn: 310110

6 years agoCFI: Move STL allocator blacklist to clang
Vlad Tsyrklevich [Fri, 4 Aug 2017 20:04:01 +0000 (20:04 +0000)]
CFI: Move STL allocator blacklist to clang

Summary:
The regular expression to match STL allocators can't easily account for
C++ mangling compression and fails to match some valid instances of STL
allocators. Perform this logic in clang instead.

Motivated by crbug.com/751385.

Reviewers: pcc, kcc, llvm-commits

Reviewed By: pcc

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

llvm-svn: 310109

6 years ago[lld] Write the absolute PDB path to the debug directory.
Zachary Turner [Fri, 4 Aug 2017 20:02:55 +0000 (20:02 +0000)]
[lld] Write the absolute PDB path to the debug directory.

This matches the behavior of MSVC's linker.

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

llvm-svn: 310108

6 years ago[llvm-pdbutil] Dump image section headers.
Zachary Turner [Fri, 4 Aug 2017 20:02:38 +0000 (20:02 +0000)]
[llvm-pdbutil] Dump image section headers.

Image section headers are stored in the DBI stream, but we
had no way to dump them.  This patch adds dumping support,
along with some tests that LLD actually dumps them correctly.

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

llvm-svn: 310107

6 years ago[libFuzzer] split one test into several
Kostya Serebryany [Fri, 4 Aug 2017 20:01:04 +0000 (20:01 +0000)]
[libFuzzer] split one test into several

llvm-svn: 310106

6 years agoReland "CFI: blacklist STL allocate() from unrelated-casts"
Vlad Tsyrklevich [Fri, 4 Aug 2017 19:50:39 +0000 (19:50 +0000)]
Reland "CFI: blacklist STL allocate() from unrelated-casts"

Reland r310097 with a unit test fix for MS ABI build bots.

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

llvm-svn: 310105

6 years ago[OPENMP][DEBUG] Set proper address space info if required by target.
Alexey Bataev [Fri, 4 Aug 2017 19:46:10 +0000 (19:46 +0000)]
[OPENMP][DEBUG] Set proper address space info if required by target.

Arguments, passed to the outlined function, must have correct address
space info for proper Debug info support. Patch sets global address
space for arguments that are mapped and passed by reference.

Also, cuda-gdb does not handle reference types correctly, so reference
arguments are represented as pointers.

llvm-svn: 310104

6 years ago[PPCGCodeGeneration] [NFC] Log every location from which PPCGCodegen bails.
Siddharth Bhat [Fri, 4 Aug 2017 19:36:40 +0000 (19:36 +0000)]
[PPCGCodeGeneration] [NFC] Log every location from which PPCGCodegen bails.

This is useful when trying to understand why no GPU code was produced.

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

llvm-svn: 310103

6 years ago[InstCombine] auto-generate test checks; NFC
Sanjay Patel [Fri, 4 Aug 2017 19:29:32 +0000 (19:29 +0000)]
[InstCombine] auto-generate test checks; NFC

llvm-svn: 310101

6 years ago[libFuzzer tests] Only enable libFuzzer tests if
George Karpenkov [Fri, 4 Aug 2017 19:29:16 +0000 (19:29 +0000)]
[libFuzzer tests] Only enable libFuzzer tests if
-DLIBFUZZER_ENABLE_TESTS=ON is set.

llvm-svn: 310100

6 years agoRevert "CFI: blacklist STL allocate() from unrelated-casts"
Vlad Tsyrklevich [Fri, 4 Aug 2017 19:17:16 +0000 (19:17 +0000)]
Revert "CFI: blacklist STL allocate() from unrelated-casts"

This reverts commit r310097.

llvm-svn: 310099

6 years ago[OPENMP] Unify generation of outlined function calls.
Alexey Bataev [Fri, 4 Aug 2017 19:10:54 +0000 (19:10 +0000)]
[OPENMP] Unify generation of outlined function calls.

llvm-svn: 310098

6 years agoCFI: blacklist STL allocate() from unrelated-casts
Vlad Tsyrklevich [Fri, 4 Aug 2017 19:10:11 +0000 (19:10 +0000)]
CFI: blacklist STL allocate() from unrelated-casts

Summary:
Previously, STL allocators were blacklisted in compiler_rt's
cfi_blacklist.txt because they mandated a cast from void* to T* before
object initialization completed. This change moves that logic into the
front end because C++ name mangling supports a substitution compression
mechanism for symbols that makes it difficult to blacklist the mangled
symbol for allocate() using a regular expression.

Motivated by crbug.com/751385.

Reviewers: pcc, kcc

Reviewed By: pcc

Subscribers: cfe-commits

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

llvm-svn: 310097

6 years ago[clang-tidy] Added clang-tidy test cases related to rL310095
Florian Gross [Fri, 4 Aug 2017 19:01:56 +0000 (19:01 +0000)]
[clang-tidy] Added clang-tidy test cases related to rL310095

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

llvm-svn: 310096

6 years ago[ASTMatcher] Add handling for DeducedType to HasDeclarationMatcher
Florian Gross [Fri, 4 Aug 2017 18:59:19 +0000 (18:59 +0000)]
[ASTMatcher] Add handling for DeducedType to HasDeclarationMatcher

HasDeclarationMatcher did not handle DeducedType, it always returned false for deduced types.

So with code like this:
struct X{};
auto x = X{};

This did no longer match:
varDecl(hasType(recordDecl(hasName("X"))))

Because HasDeclarationMatcher didn't resolve the DeducedType of x.

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

llvm-svn: 310095

6 years ago[SystemZ] Add support for 128-bit atomic load/store/cmpxchg
Ulrich Weigand [Fri, 4 Aug 2017 18:57:58 +0000 (18:57 +0000)]
[SystemZ] Add support for 128-bit atomic load/store/cmpxchg

This adds support for the main 128-bit atomic operations,
using the SystemZ instructions LPQ, STPQ, and CDSG.

Generating these instructions is a bit more complex than usual
since the i128 type is not legal for the back-end.  Therefore,
we have to hook the LowerOperationWrapper and ReplaceNodeResults
TargetLowering callbacks.

llvm-svn: 310094

6 years ago[SystemZ] Eliminate unnecessary serialization operations
Ulrich Weigand [Fri, 4 Aug 2017 18:53:35 +0000 (18:53 +0000)]
[SystemZ] Eliminate unnecessary serialization operations

We currently emit a serialization operation (bcr 14, 0) before every
atomic load and after every atomic store.  This is overly conservative.
The SystemZ architecture actually does not require any serialization
for atomic loads, and a serialization after an atomic store only if
we need to enforce sequential consistency.  This is what other compilers
for the platform implement as well.

llvm-svn: 310093

6 years agoFix PR33514
Evgeny Stupachenko [Fri, 4 Aug 2017 18:46:13 +0000 (18:46 +0000)]
Fix PR33514

Summary:
The bug was uncovered after fix of  PR23384 (part 3 of 3).
The patch restricts pointer multiplication in SCEV computaion for ICmpZero.

Reviewers: qcolombet

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

From: Evgeny Stupachenko <evstupac@gmail.com>
                         <evgeny.v.stupachenko@intel.com>
llvm-svn: 310092

6 years ago[libFuzzer] make trace-pc.test more reliable
Kostya Serebryany [Fri, 4 Aug 2017 18:43:39 +0000 (18:43 +0000)]
[libFuzzer] make trace-pc.test more reliable

llvm-svn: 310091

6 years agoSimplify. NFC.
Rafael Espindola [Fri, 4 Aug 2017 18:42:04 +0000 (18:42 +0000)]
Simplify. NFC.

llvm-svn: 310090

6 years ago[compiler-rt] Check for empty buffer in Addr2LineProcess::ReadFromSymbolizer
Alex Shlyapnikov [Fri, 4 Aug 2017 18:39:36 +0000 (18:39 +0000)]
[compiler-rt] Check for empty buffer in Addr2LineProcess::ReadFromSymbolizer

This fixes a bug in the ReadFromSymbolizer method of the
Addr2LineProcess class; if the input is too large, the returned buffer
will be null and will consequently fail the CHECK. The proposed fix is
to simply check if the buffer consists of only a null-terminator and
return if so (in effect skipping that frame). I tested by running one of
the unit tests both before and after my change.

Submitted on behalf of david-y-lam.

Reviewers: eugenis, alekseyshl, kcc

Reviewed By: alekseyshl

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

llvm-svn: 310089

6 years ago[AMDGPU] Implement llvm.amdgcn.set.inactive intrinsic
Connor Abbott [Fri, 4 Aug 2017 18:36:54 +0000 (18:36 +0000)]
[AMDGPU] Implement llvm.amdgcn.set.inactive intrinsic

Summary:
This intrinsic lets us set inactive lanes to an identity value when
implementing wavefront reductions. In combination with Whole Wavefront
Mode, it lets inactive lanes be skipped over as required by GLSL/Vulkan.
Lowering the intrinsic needs to happen post-RA so that RA knows that the
destination isn't completely overwritten due to the EXEC shenanigans, so
we need another pseudo-instruction to represent the un-lowered
intrinsic.

Reviewers: tstellar, arsenm

Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye

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

llvm-svn: 310088

6 years ago[AMDGPU] Add support for Whole Wavefront Mode
Connor Abbott [Fri, 4 Aug 2017 18:36:52 +0000 (18:36 +0000)]
[AMDGPU] Add support for Whole Wavefront Mode

Summary:
Whole Wavefront Wode (WWM) is similar to WQM, except that all of the
lanes are always enabled, regardless of control flow. This is required
for implementing wavefront reductions in non-uniform control flow, where
we need to use the inactive lanes to propagate intermediate results, so
they need to be enabled. We need to propagate WWM to uses (unless
they're explicitly marked as exact) so that they also propagate
intermediate results correctly. We do the analysis and exec mask munging
during the WQM pass, since there are interactions with WQM for things
that require both WQM and WWM. For simplicity, WWM is entirely
block-local -- blocks are never WWM on entry or exit of a block, and WWM
is not propagated to the block level.  This means that computations
involving WWM cannot involve control flow, but we only ever plan to use
WWM for a few limited purposes (none of which involve control flow)
anyways.

Shaders can ask for WWM using the @llvm.amdgcn.wwm intrinsic. There
isn't yet a way to turn WWM off -- that will be added in a future
change.

Finally, it turns out that turning on inactive lanes causes a number of
problems with register allocation. While the best long-term solution
seems like teaching LLVM's register allocator about predication, for now
we need to add some hacks to prevent ourselves from getting into trouble
due to constraints that aren't currently expressed in LLVM. For the gory
details, see the comments at the top of SIFixWWMLiveness.cpp.

Reviewers: arsenm, nhaehnle, tpr

Subscribers: kzhuravl, wdng, mgorny, yaxunl, dstuttard, t-tye, llvm-commits

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

llvm-svn: 310087

6 years ago[AMDGPU] refactor WQM pass in preparation for WWM (NFCI)
Connor Abbott [Fri, 4 Aug 2017 18:36:50 +0000 (18:36 +0000)]
[AMDGPU] refactor WQM pass in preparation for WWM (NFCI)

Summary:
Right now, the WQM pass conflates two different things when tracking the
Needs of an instruction:

1. Needs can be StateWQM, which is propagated to other instructions, and
means that this instruction (and everything it depends on) must be
calculated in WQM.
2. Needs can be StateExact, which is not propagated to other
instructions, and means that this instruction must not be calculated in
WQM and WQM-ness must not be propagated past this instruction.

This works now because there are only two different states, but in the
future we want to be able to express things like "calculate this in WQM,
but please disable WWM and don't propagate it" (to implement
@llvm.amdgcn.set.inactive). In order to do this, we need to split the
per-instruction Needs field in two: a new Needs field, which can only
contain StateWQM (and in the future, StateWWM) and is propagated to
sources, and a Disables field, which can also contain just StateWQM or
nothing for now.

We keep the per-block tracking the same for now, by translating
Needs/Disables to the old representation with only StateWQM or
StateExact. The other place that needs special handling is when we
emit the state transitions. We could just translate back to the old
representation there as well, which we almost do, but instead of 0 as a
placeholder value for "any state," we explicitly or together all the
states an instruction is allowed to be in. This lets us refactor the
code in preparation for WWM, where we'll need to be able to handle
things like "this instruction must be in Exact or WQM, but not WWM."

Reviewers: arsenm, nhaehnle, tpr

Subscribers: kzhuravl, wdng, yaxunl, dstuttard, t-tye, llvm-commits

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

llvm-svn: 310086

6 years ago[AMDGPU] Add an llvm.amdgcn.wqm intrinsic for WQM
Connor Abbott [Fri, 4 Aug 2017 18:36:49 +0000 (18:36 +0000)]
[AMDGPU] Add an llvm.amdgcn.wqm intrinsic for WQM

Summary:
Previously, we assumed that certain types of instructions needed WQM in
pixel shaders, particularly DS instructions and image sampling
instructions. This was ok because with OpenGL, the assumption was
correct. But we want to start using DPP instructions for derivatives as
well as other things, so the assumption that we can infer whether to use
WQM based on the instruction won't continue to hold. This intrinsic lets
frontends like Mesa indicate what things need WQM based on their
knowledge of the API, rather than second-guessing them in the backend.
We need to keep around the old method of enabling WQM, but eventually we
should remove it once Mesa catches up. For now, this will let us use DPP
instructions for computing derivatives correctly.

Reviewers: arsenm, tpr, nhaehnle

Subscribers: kzhuravl, wdng, yaxunl, dstuttard, llvm-commits, t-tye

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

llvm-svn: 310085