platform/upstream/llvm.git
7 years ago[ODRHash] Support NestedNameSpecifier
Richard Trieu [Wed, 17 May 2017 03:23:35 +0000 (03:23 +0000)]
[ODRHash] Support NestedNameSpecifier

llvm-svn: 303233

7 years ago[coroutines] Handle spills before catchswitch
Gor Nishanov [Wed, 17 May 2017 03:09:22 +0000 (03:09 +0000)]
[coroutines] Handle spills before catchswitch

If we need to spill the result of the PHI instruction, we insert the spill after
all of the PHIs and EHPads, however, in a catchswitch block there is no
room to insert the spill. Make room by splitting away catchswitch into a separate
block.

Before the fix:

    catch.dispatch:
       %val = phi i32 [ 1, %if.then ], [ 2, %if.else ]
       %switch = catchswitch within none [label %catch] unwind label %cleanuppad

After:

    catch.dispatch:
       %val = phi i32 [ 1, %if.then ], [ 2, %if.else ]
       %tok = cleanuppad within none []
       ; spill goes here
       cleanupret from %tok unwind label %catch.dispatch.switch
    catch.dispatch.switch:
       %switch = catchswitch within none [label %catch] unwind label %cleanuppad

https://reviews.llvm.org/D31846

llvm-svn: 303232

7 years ago[ODRHash] Support more types in the ODR checker.
Richard Trieu [Wed, 17 May 2017 02:29:02 +0000 (02:29 +0000)]
[ODRHash] Support more types in the ODR checker.

Added support for TagType, TypeWithKeyword, and all children types.

llvm-svn: 303231

7 years ago[clang-tidy] Optimize misc-unused-parameters. NFCI
Alexander Kornienko [Wed, 17 May 2017 02:25:11 +0000 (02:25 +0000)]
[clang-tidy] Optimize misc-unused-parameters. NFCI

Don't traverse AST each time we need to find references to a certain function.
Traverse the AST once using RAV and cache the index of function references.

The speed up on a particular large file was about 1000x.

llvm-svn: 303230

7 years agoAdded LLVM_DUMP_METHOD attributes for MatchableInfo::dump(). Defined it only if dump...
Galina Kistanova [Wed, 17 May 2017 02:20:05 +0000 (02:20 +0000)]
Added LLVM_DUMP_METHOD attributes for MatchableInfo::dump(). Defined it only if dump is enabled.

llvm-svn: 303229

7 years ago(1) Fixed mismatch in intrinsics names in declarations and in doxygen comments.
Ekaterina Romanova [Wed, 17 May 2017 01:46:11 +0000 (01:46 +0000)]
(1) Fixed mismatch in intrinsics names in declarations and in doxygen comments.
(2) Removed uncessary anymore \c commands, since the same effect will be achived by <c> ... </c> sequence.

I got an OK from Eric Christopher to commit doxygen comments without prior code
review upstream.

llvm-svn: 303228

7 years agoBitVector: add iterators for set bits
Francis Visoiu Mistrih [Wed, 17 May 2017 01:07:53 +0000 (01:07 +0000)]
BitVector: add iterators for set bits

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

llvm-svn: 303227

7 years agoFix Windows buildbots.
Rui Ueyama [Wed, 17 May 2017 01:05:56 +0000 (01:05 +0000)]
Fix Windows buildbots.

llvm-svn: 303226

7 years agoGarbage collect dllimported symbols.
Rui Ueyama [Wed, 17 May 2017 00:35:50 +0000 (00:35 +0000)]
Garbage collect dllimported symbols.

Summary:
Previously, the garbage collector (enabled by default or by explicitly
passing /opt:ref) did not kill dllimported symbols. As a result,
dllimported symbols could be added to resulting executables' dllimport
list even if no one was actually using them.

This patch implements dllexported symbol garbage collection. Just like
COMDAT sections, dllimported symbols now have Live bits to manage their
liveness, and MarkLive marks reachable dllimported symbols.

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

Reviewers: pcc

Subscribers: llvm-commits

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

llvm-svn: 303225

7 years ago[modules] When creating a declaration, cache its owning module immediately
Richard Smith [Wed, 17 May 2017 00:24:14 +0000 (00:24 +0000)]
[modules] When creating a declaration, cache its owning module immediately
rather than waiting until it's queried.

Currently this is only applied to local submodule visibility mode, as we don't
yet allocate storage for the owning module in non-local-visibility modules
compilations.

This reinstates r302965, reverted in r303037, with a fix for the reported
crash, which occurred when reparenting a local declaration to be a child of
a hidden imported declaration (specifically during template instantiation).

llvm-svn: 303224

7 years ago[Expression parser] Look up module symbols before hunting globally
Sean Callanan [Tue, 16 May 2017 23:46:13 +0000 (23:46 +0000)]
[Expression parser] Look up module symbols before hunting globally

When it resolves symbol-only variables, the expression parser
currently looks only in the global module list. It should prefer
the current module.

I've fixed that behavior by making it search the current module
first, and only search globally if it finds nothing. I've also
added a test case.

After review, I moved the core of the lookup algorithm into
SymbolContext for use by other code that needs it.

Thanks to Greg Clayton and Pavel Labath for their help.

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

llvm-svn: 303223

7 years agoFix scope of namespaced DISubprograms when the function definition is out-of-line.
Adrian Prantl [Tue, 16 May 2017 23:46:10 +0000 (23:46 +0000)]
Fix scope of namespaced DISubprograms when the function definition is out-of-line.
This fixes a regression introduced in r302915.

Using the lexical decl context is not necessary here for what r302915
wast trying to achieve. Not canonicalizing the NamespaceDecl in
getOrCreateNamespace is suficient.

rdar://problem/29339538

llvm-svn: 303222

7 years ago[ADT] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC).
Eugene Zelenko [Tue, 16 May 2017 23:10:25 +0000 (23:10 +0000)]
[ADT] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC).

llvm-svn: 303221

7 years agoFix for compilers with older CRT header libraries.
Zachary Turner [Tue, 16 May 2017 22:59:34 +0000 (22:59 +0000)]
Fix for compilers with older CRT header libraries.

llvm-svn: 303220

7 years ago[Support] Ignore OutputDebugString exceptions in our crash recovery.
Zachary Turner [Tue, 16 May 2017 22:50:32 +0000 (22:50 +0000)]
[Support] Ignore OutputDebugString exceptions in our crash recovery.

Since we use AddVectoredExceptionHandler, we get notified of
every exception that gets raised by a program.  Sometimes these
are not necessarily errors though, and this can be especially
true when linking against a library that we have no control
over, and may raise an exception internally which it intends
to catch.

In particular, the Windows API OutputDebugString does exactly
this.  It raises an exception inside of a __try / __except,
giving the debugger a chance to handle the exception to print
the message to the debug console.

But this doesn't interoperate nicely with our vectored exception
handler, which just sees another exception and decides that we
need to terminate the program.

Add a special case for this so that we ignore ODS exceptions
and continue normally.

Note that a better fix is to simply not use vectored exception
handlers and use SEH instead, but given that MinGW doesn't support
SEH, this is the only solution for MinGW.

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

llvm-svn: 303219

7 years ago[IR] Prefer use_empty() to !hasNUsesOrMore(1) for clarity.
Davide Italiano [Tue, 16 May 2017 22:38:40 +0000 (22:38 +0000)]
[IR] Prefer use_empty() to !hasNUsesOrMore(1) for clarity.

llvm-svn: 303218

7 years ago[NewGVN] Re-enable test now that the nondeterminism has been fixed.
Davide Italiano [Tue, 16 May 2017 22:27:06 +0000 (22:27 +0000)]
[NewGVN] Re-enable test now that the nondeterminism has been fixed.

llvm-svn: 303217

7 years agollvm/test/Transforms/InstCombine/debuginfo-skip.ll REQUIRES +asserts.
NAKAMURA Takumi [Tue, 16 May 2017 22:19:56 +0000 (22:19 +0000)]
llvm/test/Transforms/InstCombine/debuginfo-skip.ll REQUIRES +asserts.

llvm-svn: 303216

7 years agoAdd test for FixedStreamArrayIterator::operator->
Adrian McCarthy [Tue, 16 May 2017 22:11:25 +0000 (22:11 +0000)]
Add test for FixedStreamArrayIterator::operator->

The operator-> implementation comes from iterator_facade_base, so it should
just work given that the iterator has a tested operator*.  But r302257 showed
that required careful handling of for the const qualifier.  This patch ensures
the fix in r302257 doesn't regress.

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

llvm-svn: 303215

7 years agoUpdate doxygen description of a method. NFC
Paul Robinson [Tue, 16 May 2017 21:53:30 +0000 (21:53 +0000)]
Update doxygen description of a method. NFC

llvm-svn: 303214

7 years ago[InstSimplify] add folds for constant mask of value shifted by constant
Sanjay Patel [Tue, 16 May 2017 21:51:04 +0000 (21:51 +0000)]
[InstSimplify] add folds for constant mask of value shifted by constant

We would eventually catch these via demanded bits and computing known bits in InstCombine,
but I think it's better to handle the simple cases as soon as possible as a matter of efficiency.

This fold allows further simplifications based on distributed ops transforms. eg:
  %a = lshr i8 %x, 7
  %b = or i8 %a, 2
  %c = and i8 %b, 1

InstSimplify can directly fold this now:
  %a = lshr i8 %x, 7

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

llvm-svn: 303213

7 years agoThe patch exclude a case from zero check skip in
Evgeny Stupachenko [Tue, 16 May 2017 21:44:59 +0000 (21:44 +0000)]
The patch exclude a case from zero check skip in
 CTLZ idiom recognition (r303102).

Summary:

The following case:
i = 1;
if(n)
  while (n >>= 1)
    i++;
use(i);

Was converted to:

i = 1;
if(n)
  i += builtin_ctlz(n >> 1, false);
use(i);

Which is not correct. The patch make it:

i = 1;
if(n)
  i += builtin_ctlz(n >> 1, true);
use(i);

From: Evgeny Stupachenko <evstupac@gmail.com>
llvm-svn: 303212

7 years agoRe-commit r302678, fixing PR33053.
Amara Emerson [Tue, 16 May 2017 21:29:22 +0000 (21:29 +0000)]
Re-commit r302678, fixing PR33053.

The issue was that the AArch64 TTI hook allowed unpacked integer cmp reductions
which didn't have a lowering.

llvm-svn: 303211

7 years ago[Inliner] Do not mix callsite and callee hotness based updates.
Easwaran Raman [Tue, 16 May 2017 21:18:09 +0000 (21:18 +0000)]
[Inliner] Do not mix callsite and callee hotness based updates.

Update threshold based on callee's hotness only when BFI is not available.
Otherwise use only callsite's hotness. This makes it easier to reason about
hotness related threshold updates.

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

llvm-svn: 303210

7 years ago[PPC] Add -ppc-asm-full-reg-names to atomic-2.ll. NFC.
Tim Shen [Tue, 16 May 2017 20:58:55 +0000 (20:58 +0000)]
[PPC] Add -ppc-asm-full-reg-names to atomic-2.ll. NFC.

Differential Revisions: https://reviews.llvm.org/D32763

llvm-svn: 303209

7 years agoTest for r303197
Matthias Braun [Tue, 16 May 2017 20:53:27 +0000 (20:53 +0000)]
Test for r303197

llvm-svn: 303208

7 years agobuiltins: fix guard __AEABI__ -> __ARM_EABI__
Saleem Abdulrasool [Tue, 16 May 2017 20:25:07 +0000 (20:25 +0000)]
builtins: fix guard __AEABI__ -> __ARM_EABI__

llvm-svn: 303207

7 years ago[libunwind] Fix executable stack directive on Linux.
Manoj Gupta [Tue, 16 May 2017 20:18:57 +0000 (20:18 +0000)]
[libunwind] Fix executable stack directive on Linux.

Summary:
Disable executable stack on Linux. Also remove redundant Android check
as it is covered by Android.

Reviewers: phosek, compnerd, rs, rmaprath, EricWF, krytarowski

Reviewed By: krytarowski

Subscribers: srhines, llvm-commits, krytarowski

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

llvm-svn: 303206

7 years ago[PPC] Lower load acquire/seq_cst trailing fence to cmp + bne + isync.
Tim Shen [Tue, 16 May 2017 20:18:06 +0000 (20:18 +0000)]
[PPC] Lower load acquire/seq_cst trailing fence to cmp + bne + isync.

Summary:
This fixes pr32392.

The lowering pipeline is:
llvm.ppc.cfence in IR -> PPC::CFENCE8 in isel -> Actual instructions in
expandPostRAPseudo.

The reason why expandPostRAPseudo is chosen is because previous passes
are likely eliminating instructions like cmpw 3, 3 (early CSE) and bne-
7, .+4 (some branch pass(s)).

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

llvm-svn: 303205

7 years agoAdd hasProfileSummary and has{Sample|Instrumentation}Profile methods
Easwaran Raman [Tue, 16 May 2017 20:14:39 +0000 (20:14 +0000)]
Add hasProfileSummary and has{Sample|Instrumentation}Profile methods

ProfileSummaryInfo already checks whether the module has sample profile
in determining profile counts. This will also be useful in inliner to
clean up threshold updates.

llvm-svn: 303204

7 years ago[InstCombine] auto-generate better checks; NFC
Sanjay Patel [Tue, 16 May 2017 20:09:32 +0000 (20:09 +0000)]
[InstCombine] auto-generate better checks; NFC

llvm-svn: 303203

7 years agoIn debug builds non-trivial amount of time is spent in InstCombine processing
Dmitry Mikulin [Tue, 16 May 2017 20:08:49 +0000 (20:08 +0000)]
In debug builds non-trivial amount of time is spent in InstCombine processing
@llvm.dbg.* calls in visitCallInst(). They can be safely ignored.

llvm-svn: 303202

7 years agoNewGVN: Only do something in verifyStoreExpressions if assertions are enabled, to...
Daniel Berlin [Tue, 16 May 2017 20:02:45 +0000 (20:02 +0000)]
NewGVN: Only do something in verifyStoreExpressions if assertions are enabled, to avoid unused code warnings.

llvm-svn: 303201

7 years agoNewGVN: Fix PR 33051 by making sure we remove old store expressions
Daniel Berlin [Tue, 16 May 2017 19:58:47 +0000 (19:58 +0000)]
NewGVN: Fix PR 33051 by making sure we remove old store expressions
from the ExpressionToClass mapping.

llvm-svn: 303200

7 years agoRevert "[X86] Replace slow LEA instructions in X86"
Reid Kleckner [Tue, 16 May 2017 19:55:03 +0000 (19:55 +0000)]
Revert "[X86] Replace slow LEA instructions in X86"

This reverts commit r303183, it broke various buildbots and introduced
sanitizer errors.

llvm-svn: 303199

7 years agoElide stores which are overwritten without being observed.
Nirav Dave [Tue, 16 May 2017 19:43:56 +0000 (19:43 +0000)]
Elide stores which are overwritten without being observed.

Summary:
In SelectionDAG, when a store is immediately chained to another store
to the same address, elide the first store as it has no observable
effects. This is causes small improvements dealing with intrinsics
lowered to stores.

Test notes:

* Many testcases overwrite store addresses multiple times and needed
  minor changes, mainly making stores volatile to prevent the
  optimization from optimizing the test away.

* Many X86 test cases optimized out instructions associated with
  associated with va_start.

* Note that test_splat in CodeGen/AArch64/misched-stp.ll no longer has
  dependencies to check and can probably be removed and potentially
  replaced with another test.

Reviewers: rnk, john.brawn

Subscribers: aemerson, rengolin, qcolombet, jyknight, nemanjai, nhaehnle, javed.absar, llvm-commits

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

llvm-svn: 303198

7 years agoShrinkWrap: Add skipFunction() call
Matthias Braun [Tue, 16 May 2017 18:43:30 +0000 (18:43 +0000)]
ShrinkWrap: Add skipFunction() call

ShrinkWrapping is a performance optimization that can safely be skipped,
so we can add `if (!skipFunction()) return;`

llvm-svn: 303197

7 years ago[MetadataLoader] Remove unused Vector. NFCI.
Davide Italiano [Tue, 16 May 2017 18:41:46 +0000 (18:41 +0000)]
[MetadataLoader] Remove unused Vector. NFCI.

llvm-svn: 303196

7 years agobuiltins: one more case of a missing header
Saleem Abdulrasool [Tue, 16 May 2017 18:19:44 +0000 (18:19 +0000)]
builtins: one more case of a missing header

llvm-svn: 303195

7 years ago[libcxxabi] Fix the test case committed in r303175.
Akira Hatanaka [Tue, 16 May 2017 18:18:03 +0000 (18:18 +0000)]
[libcxxabi] Fix the test case committed in r303175.

Free the __cxa_exception object allocated with __cxa_allocate_exception.

This is an attempt to fix this asan bot:

http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-asan/builds/560

llvm-svn: 303194

7 years agoRevert "[ARM] Mark LEApcrel instructions as isAsCheapAsAMove"
Renato Golin [Tue, 16 May 2017 17:59:07 +0000 (17:59 +0000)]
Revert "[ARM] Mark LEApcrel instructions as isAsCheapAsAMove"

Revert "[ARM] Mark LEApcrel as not having side effects"

This reverts commit r303054 and r303053, as they broke the ARM
self-hosting buildbots:

http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/1550

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/1349

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost/builds/1845

Offline investigation on course.

llvm-svn: 303193

7 years ago[index] Avoid another crash that happens when looking up a dependent name
Alex Lorenz [Tue, 16 May 2017 17:33:17 +0000 (17:33 +0000)]
[index] Avoid another crash that happens when looking up a dependent name
in a record that has a base without a definition

rdar://32224197

llvm-svn: 303192

7 years ago[clang-tidy] Speed up performance-unnecessary-value-param check
Alexander Kornienko [Tue, 16 May 2017 17:28:17 +0000 (17:28 +0000)]
[clang-tidy] Speed up performance-unnecessary-value-param check

Moved slower matchers closer to the end. The total speed up on a large file I
was interested in is not huge, just about 10%, since the check seems to be doing
a lot in the check() method.

llvm-svn: 303191

7 years agobuiltins: add missing includes
Saleem Abdulrasool [Tue, 16 May 2017 17:06:48 +0000 (17:06 +0000)]
builtins: add missing includes

This inclusion is needed to fix the ARM build.  The int_lib.h include is
slightly ugly, but allows us to use the `AEABI_RTABI` macro to decorate
the CC for the functions.

llvm-svn: 303190

7 years ago[ScopInfo] Remove unused MemoryAccess::BaseName. NFC.
Michael Kruse [Tue, 16 May 2017 16:52:24 +0000 (16:52 +0000)]
[ScopInfo] Remove unused MemoryAccess::BaseName. NFC.

llvm-svn: 303189

7 years agobuiltins: expand out the AEABI function stubs
Saleem Abdulrasool [Tue, 16 May 2017 16:41:37 +0000 (16:41 +0000)]
builtins: expand out the AEABI function stubs

These actually may change calling conventions.  We cannot simply provide
function aliases as the aliased function may have a different calling
convention.  Provide a forwarding function instead to permit the
compiler to synthesize the calling convention adjustment thunk.

Remove the `ARM_EABI_FNALIAS` macro as that is not safe to use.

Resolves PR33030!

llvm-svn: 303188

7 years ago[clang-tidy] Optimize readability-implicit-bool-cast, NFC
Alexander Kornienko [Tue, 16 May 2017 16:40:46 +0000 (16:40 +0000)]
[clang-tidy] Optimize readability-implicit-bool-cast, NFC

Rearrange matchers to put the most expensive ones closer to the end. Speed up
another 3-5x on some files.

llvm-svn: 303187

7 years ago[AMDGPU] Use GCNRPTracker dumper methods in scheduler
Stanislav Mekhanoshin [Tue, 16 May 2017 16:31:45 +0000 (16:31 +0000)]
[AMDGPU] Use GCNRPTracker dumper methods in scheduler

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

llvm-svn: 303186

7 years ago[InstCombine] add motivational comment for tests; NFC
Sanjay Patel [Tue, 16 May 2017 16:30:46 +0000 (16:30 +0000)]
[InstCombine] add motivational comment for tests; NFC

The referenced tests are derived from:
https://bugs.llvm.org/show_bug.cgi?id=32791
and:
https://reviews.llvm.org/D33172

The motivation for including negative tests may not be clear, so I'm adding an explanatory comment here.
In the post-commit thread for r303133:
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20170515/453793.html
...it was mentioned that we don't want to add redundant tests. This is a valid point. But in this case,
we have a patch under review (D33172) that demonstrates that no existing regression tests are affected by
a proposed code change, but these are. Therefore, I think these tests have value not visible in any
existing regression tests regardless of whether they show a transform.

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

llvm-svn: 303185

7 years ago[AMDGPU] Cache live-ins and register pressure in scheduler
Stanislav Mekhanoshin [Tue, 16 May 2017 16:11:26 +0000 (16:11 +0000)]
[AMDGPU] Cache live-ins and register pressure in scheduler

Using LIS can be quite expensive, so caching of calculated region
live-ins and pressure is implemented. It does two things:

1. Caches the info for the second stage when we schedule with
   decreased target occupancy.
2. Tracks the basic block from top to bottom thus eliminating the
   need to scan whole register file liveness at every region split
   in the middle of the block.

The scheduling is now done in 3 stages instead of two, with the first
one being really a no-op and only used to collect scheduling regions
as sent by the scheduler driver.

There is no functional change to the current behavior, only compilation
speed is affected. In general computeBlockPressure() could be simplified
if we switch to backward RP tracker, because scheduler sends regions
within a block starting from the last upward. We could use a natural
order of upward tracker to seamlessly change between regions of the same
block, since live reg set of a previous tracked region would become a
live-out of the next region. That however requires fixing upward tracker
to properly account defs and uses of the same instruction as both are
contributing to the current pressure. When we converge on the produced
pressure we should be able to switch between them back and forth. In
addition, backward tracker is less expensive as it uses LIS in recede
less often than forward uses it in advance.

At the moment the worst known case compilation time has improved from 26
minutes to 8.5.

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

llvm-svn: 303184

7 years ago[X86] Replace slow LEA instructions in X86
Lama Saba [Tue, 16 May 2017 16:01:36 +0000 (16:01 +0000)]
[X86] Replace slow LEA instructions in X86

  According to Intel's Optimization Reference Manual for SNB+:
  " For LEA instructions with three source operands and some specific situations, instruction latency has increased to 3 cycles, and must
    dispatch via port 1:
  - LEA that has all three source operands: base, index, and offset
  - LEA that uses base and index registers where the base is EBP, RBP,or R13
  - LEA that uses RIP relative addressing mode
  - LEA that uses 16-bit addressing mode "
  This patch currently handles the first 2 cases only.

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

llvm-svn: 303183

7 years agoRevert 303174, 303176, and 303178
Matthew Simpson [Tue, 16 May 2017 15:50:30 +0000 (15:50 +0000)]
Revert 303174, 303176, and 303178

These commits are breaking the bots. Reverting to investigate.

llvm-svn: 303182

7 years ago[DAG] Prune deleted nodes in TokenFactor
Nirav Dave [Tue, 16 May 2017 15:49:02 +0000 (15:49 +0000)]
[DAG] Prune deleted nodes in TokenFactor

Fix visitTokenFactor to correctly remove deleted nodes. NFC.

llvm-svn: 303181

7 years ago[clang-tidy] Optimize matchers in readability-implicit-bool-cast. NFC
Alexander Kornienko [Tue, 16 May 2017 15:44:42 +0000 (15:44 +0000)]
[clang-tidy] Optimize matchers in readability-implicit-bool-cast. NFC

Don't repeat `isInTemplateInstantiation()` and `hasAncestor()` unnecessarily.
This speeds up the check by a factor of up to 3 on some large files.

llvm-svn: 303180

7 years ago[AMDGPU] Turn register pressure estimation into forward tracker
Stanislav Mekhanoshin [Tue, 16 May 2017 15:43:52 +0000 (15:43 +0000)]
[AMDGPU] Turn register pressure estimation into forward tracker

This factors register pressure estimation mechanism from the
GCNSchedStrategy into the forward tracker to unify interface
with other strategies and expose it to other interested phases.

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

llvm-svn: 303179

7 years agoMake test target-specific
Matthew Simpson [Tue, 16 May 2017 15:33:22 +0000 (15:33 +0000)]
Make test target-specific

llvm-svn: 303178

7 years agoAdded missing includes in clangd to fix the build.
Ilya Biryukov [Tue, 16 May 2017 15:23:55 +0000 (15:23 +0000)]
Added missing includes in clangd to fix the build.

This commit should fix buildbot failures.

llvm-svn: 303177

7 years agoFix test case to unbreak bots
Matthew Simpson [Tue, 16 May 2017 15:20:27 +0000 (15:20 +0000)]
Fix test case to unbreak bots

llvm-svn: 303176

7 years ago[libcxxabi] Align unwindHeader on a double-word boundary.
Akira Hatanaka [Tue, 16 May 2017 15:19:08 +0000 (15:19 +0000)]
[libcxxabi] Align unwindHeader on a double-word boundary.

r276215 made a change to annotate _Unwind_Exception with attribute
"aligned" so that an exception object following field __cxa_exception
is sufficiently aligned. This fix hasn't been incorporated to unwind.h
on Darwin since it is an ABI breaking change.

Instead of annotating struct _Unwind_Exception with the attribute, this
commit annotates field unwindHeader of __cxa_exception. This ensures the
exception object is sufficiently aligned without breaking the ABI.

This recommits r302978 and r302981, which were reverted in r303016
because a libcxx test was failing on an AArch64 bot. I also modified the
libcxxabi test case to check the alignment of the pointer returned by
__cxa_allocate_exception rather than compiling the test with -O1 and
checking whether it segfaults.

rdar://problem/25364625

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

llvm-svn: 303175

7 years ago[LV] Avoid potentential division by zero when selecting IC
Matthew Simpson [Tue, 16 May 2017 14:43:55 +0000 (14:43 +0000)]
[LV] Avoid potentential division by zero when selecting IC

llvm-svn: 303174

7 years ago[clangd] Refactor ProtocolHandlers to decouple them from ClangdLSPServer
Ilya Biryukov [Tue, 16 May 2017 14:40:30 +0000 (14:40 +0000)]
[clangd] Refactor ProtocolHandlers to decouple them from ClangdLSPServer

Summary:
A refactoring to decouple ProtocolHandlers and Language Server input parsing
loop from the ClangdLSPServer.
The input parsing was extracted from `main` to a function(runLanguageServerLoop).
ProtocolHandlers now provide an interface to handle various LSP methods,
this interface is used by ClangdLSPServer.
Methods for code formatting were moved from ProtocolHandlers to ClangdServer.
ClangdLSPServer now provides a cleaner interface that only runs Language Server
input loop.

Reviewers: bkramer, krasimir

Reviewed By: krasimir

Subscribers: cfe-commits, klimek

Tags: #clang-tools-extra

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

llvm-svn: 303173

7 years ago[coroutines] Handle unwind edge splitting
Gor Nishanov [Tue, 16 May 2017 14:11:39 +0000 (14:11 +0000)]
[coroutines] Handle unwind edge splitting

Summary:
RewritePHIs algorithm used in building of CoroFrame inserts a placeholder
```
%placeholder = phi [%val]
```
on every edge leading to a block starting with PHI node with multiple incoming edges,
so that if one of the incoming values was spilled and need to be reloaded, we have a
place to insert a reload. We use SplitEdge helper function to split the incoming edge.

SplitEdge function does not deal with unwind edges comping into a block with an EHPad.

This patch adds an ehAwareSplitEdge function that can correctly split the unwind edge.

For landing pads, we clone the landing pad into every edge block and replace the original
landing pad with a PHI collection the values from all incoming landing pads.

For WinEH pads, we keep the original EHPad in place and insert cleanuppad/cleapret in the
edge blocks.

Reviewers: majnemer, rnk

Reviewed By: majnemer

Subscribers: EricWF, llvm-commits

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

llvm-svn: 303172

7 years ago[DWARF] - Add RelocAddrEntry for cleanup. NFCi.
George Rimar [Tue, 16 May 2017 14:05:45 +0000 (14:05 +0000)]
[DWARF] - Add RelocAddrEntry for cleanup. NFCi.

Was mentioned as possible cleanup during review of D33184.

llvm-svn: 303171

7 years ago[Sema] Avoid duplicate -Wunguarded-availability warnings in nested functions
Alex Lorenz [Tue, 16 May 2017 13:58:53 +0000 (13:58 +0000)]
[Sema] Avoid duplicate -Wunguarded-availability warnings in nested functions

rdar://31862310

llvm-svn: 303170

7 years ago[GlobalISel][X86] Split memop test file. NFC
Igor Breger [Tue, 16 May 2017 13:37:31 +0000 (13:37 +0000)]
[GlobalISel][X86] Split memop test file. NFC

llvm-svn: 303169

7 years agoFix an improperly placed curly bracket. NFC.
Chad Rosier [Tue, 16 May 2017 12:43:23 +0000 (12:43 +0000)]
Fix an improperly placed curly bracket. NFC.

llvm-svn: 303165

7 years ago[ELF] - Update for LLVM's r303163 change. NFCi.
George Rimar [Tue, 16 May 2017 12:34:51 +0000 (12:34 +0000)]
[ELF] - Update for LLVM's r303163 change. NFCi.

llvm-svn: 303164

7 years ago[DWARF] - Use DWARFAddressRange struct instead of uint64_t pair for DWARFAddressRange...
George Rimar [Tue, 16 May 2017 12:30:59 +0000 (12:30 +0000)]
[DWARF] - Use DWARFAddressRange struct instead of uint64_t pair for DWARFAddressRangesVector.

Recommit of r303159 "[DWARF] - Use DWARFAddressRange struct instead of uint64_t pair for DWARFAddressRangesVector"
All places were shitched to use DWARFAddressRange now.

Suggested during review of D33184.

llvm-svn: 303163

7 years agoRevert r303159 "[DWARF] - Use DWARFAddressRange struct instead of uint64_t pair for...
George Rimar [Tue, 16 May 2017 12:05:03 +0000 (12:05 +0000)]
Revert r303159 "[DWARF] - Use DWARFAddressRange struct instead of uint64_t pair for DWARFAddressRangesVector."

Something went wrong, it broke BB.
http://green.lab.llvm.org/green//job/clang-stage1-cmake-RA-incremental_build/38477/consoleFull#-200034420049ba4694-19c4-4d7e-bec5-911270d8a58c

llvm-svn: 303162

7 years agoSkip TestWatchedVarHitWhenInScope on android arm because it triggers a kernel bug
Pavel Labath [Tue, 16 May 2017 11:58:18 +0000 (11:58 +0000)]
Skip TestWatchedVarHitWhenInScope on android arm because it triggers a kernel bug

llvm-svn: 303160

7 years ago[DWARF] - Use DWARFAddressRange struct instead of uint64_t pair for DWARFAddressRange...
George Rimar [Tue, 16 May 2017 11:54:19 +0000 (11:54 +0000)]
[DWARF] - Use DWARFAddressRange struct instead of uint64_t pair for DWARFAddressRangesVector.

Suggested during review of D33184.

llvm-svn: 303159

7 years ago[StaticAnalyzer] Move inline counter increaser to inlineCall function
Peter Szecsi [Tue, 16 May 2017 11:54:00 +0000 (11:54 +0000)]
[StaticAnalyzer] Move inline counter increaser to inlineCall function

Even though the shouldInlineCall function returns true, it can happen that the
function is not going to be inlined (as it can be seen at line 913 and below).
Moved the bumpNumTimesInlined(D) (the counter increaser) call to the inlineCall
function where it logically belongs.

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

llvm-svn: 303158

7 years ago[clang-tidy] Add "emplace_back" detection in inefficient-vector-operation.
Haojian Wu [Tue, 16 May 2017 10:39:55 +0000 (10:39 +0000)]
[clang-tidy] Add "emplace_back" detection in inefficient-vector-operation.

Reviewers: alexfh, aaron.ballman

Reviewed By: alexfh

Subscribers: cfe-commits, Prazek, malcolm.parsons, xazax.hun

Tags: #clang-tools-extra

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

llvm-svn: 303157

7 years agoFix PR 10758: Infinite recursion when dealing with copy-initialization
Alex Lorenz [Tue, 16 May 2017 10:23:58 +0000 (10:23 +0000)]
Fix PR 10758: Infinite recursion when dealing with copy-initialization

This commit fixes a bug that's tracked by PR 10758 and duplicates like PR 30343.
The bug causes clang to crash with a stack overflow while recursing infinitely
trying to perform copy-initialization on a type without a copy constructor but
with a constructor that accepts another type that can be constructed using the
original type.

The commit fixes this bug by detecting the recursive behavior and failing
correctly with an appropriate error message. It also tries to provide a
meaningful diagnostic note about the constructor which leads to this behavior.

rdar://28483944

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

llvm-svn: 303156

7 years ago[ELF] - Detemplate elf::addSyntheticLocal(). NFC.
George Rimar [Tue, 16 May 2017 10:11:36 +0000 (10:11 +0000)]
[ELF] - Detemplate elf::addSyntheticLocal(). NFC.

llvm-svn: 303155

7 years agoFixing compilation failures on buildbots.
Ilya Biryukov [Tue, 16 May 2017 10:06:20 +0000 (10:06 +0000)]
Fixing compilation failures on buildbots.

llvm-svn: 303154

7 years ago[ELF] - Detemplate access to SymTab, DynSymTab, GnuHashTab. NFC.
George Rimar [Tue, 16 May 2017 10:04:42 +0000 (10:04 +0000)]
[ELF] - Detemplate access to SymTab, DynSymTab, GnuHashTab. NFC.

Follow up for r303150.

llvm-svn: 303153

7 years ago[LTO] Print time-passes information at conclusion of LTO codegen
James Henderson [Tue, 16 May 2017 09:43:21 +0000 (09:43 +0000)]
[LTO] Print time-passes information at conclusion of LTO codegen

The information collected when requested by -time-passes is only printed when
llvm_shutdown is called at the moment. This means that when linking against the LTO
library dynamically and using the C interface, it is not possible to see the timing
information, because llvm_shutdown cannot be called. This change modifies the LTO
code generation functions for both regular LTO and thin LTO to explicitly print and
reset the timing information.

I have tested that this works with our proprietary linker. However, as this relies
on a specific method of building and linking against the LTO library, I'm not sure
how or if this can be tested in the LLVM testsuite.

Reviewed by: mehdi_amini

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

llvm-svn: 303152

7 years agoRestored r303067 and fixed failing test.
Ilya Biryukov [Tue, 16 May 2017 09:38:59 +0000 (09:38 +0000)]
Restored r303067 and fixed failing test.

Summary:
This commit restores r303067(reverted by r303094) and fixes the 'formatting.test'
failure.
The failure is due to destructors of `ClangdLSPServer`'s fields(`FixItsMap` and
`FixItsMutex`) being called before destructor of `Server`. It led to the worker
thread calling `consumeDiagnostics` after `FixItsMutex` and `FixItsMap`
destructors were called.
Also, clangd is now run with '-run-synchronously' flag in 'formatting.test'.

Reviewers: bkramer, krasimir

Reviewed By: krasimir

Subscribers: mgorny, cfe-commits, klimek

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

llvm-svn: 303151

7 years ago[ELF] - Detemplate GnuHashTableSection and SymbolTableSection sections.
George Rimar [Tue, 16 May 2017 08:53:30 +0000 (08:53 +0000)]
[ELF] - Detemplate GnuHashTableSection and SymbolTableSection sections.

SymbolTableBaseSection was introduced.

Detemplation of SymbolTableSection should allow to detemplate more things.

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

llvm-svn: 303150

7 years ago[ELF] - Use llvm::to_integer() instead of StringRef::getAsInteger().
George Rimar [Tue, 16 May 2017 08:19:25 +0000 (08:19 +0000)]
[ELF] - Use llvm::to_integer() instead of StringRef::getAsInteger().

Switch to llvm::to_integer() everywhere in LLD instead of
StringRef::getAsInteger() because API of latter is confusing.
It returns true on error and false otherwise what makes reading
the code incomfortable.

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

llvm-svn: 303149

7 years ago[SCEV] Fix sorting order for AddRecExprs
Max Kazantsev [Tue, 16 May 2017 07:27:06 +0000 (07:27 +0000)]
[SCEV] Fix sorting order for AddRecExprs

The existing sorting order in defined CompareSCEVComplexity sorts AddRecExprs
by loop depth, but does not pay attention to dominance of loops. This can
lead us to the following buggy situation:

for (...) { // loop1
  op1 = {A,+,B}
}
for (...) { // loop2
  op2 = {A,+,B}
  S = add op1, op2
}

In this case there is no guarantee that in operand list of S the op2 comes
before op1 (loop depth is the same, so they will be sorted just
lexicographically), so we can incorrectly treat S as a recurrence of loop1,
which is wrong.

This patch changes the sorting logic so that it places the dominated recs
before the dominating recs. This ensures that when we pick the first recurrency
in the operands order, it will be the bottom-most in terms of domination tree.
The attached test set includes some tests that produce incorrect SCEV
estimations and crashes with oldlogic.

Reviewers: sanjoy, reames, apilipenko, anna

Reviewed By: sanjoy

Subscribers: llvm-commits, mzolotukhin

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

llvm-svn: 303148

7 years ago[CorrelatedValuePropagation] Don't use -> to call a static method of ConstantRange...
Craig Topper [Tue, 16 May 2017 07:05:38 +0000 (07:05 +0000)]
[CorrelatedValuePropagation] Don't use -> to call a static method of ConstantRange. NFC

llvm-svn: 303147

7 years ago[clang-tidy] modernize-use-emplace: Remove unnecessary make_tuple calls
Jakub Kuderski [Tue, 16 May 2017 06:32:38 +0000 (06:32 +0000)]
[clang-tidy] modernize-use-emplace: Remove unnecessary make_tuple calls

Summary:
This patch makes modernize-use-emplace remove unnecessary make_ calls from push_back calls and turn them into emplace_back -- the same way make_pair calls are handled.
Custom make_ calls can be removed for custom tuple-like types -- two new options that control that are `TupleTypes` and `TupleMakeFunctions`. By default, the check removes calls to `std::make_pair` and `std::make_tuple`.

Eq.

```
std::vector<std::tuple<int, char, bool>> v;
v.push_back(std::make_tuple(1, 'A', true)); // --> v.emplace_back(1, 'A', true);
```

Reviewers: alexfh, aaron.ballman, Prazek, hokein

Reviewed By: Prazek

Subscribers: JDevlieghere, xazax.hun, JonasToth, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 303145

7 years agoNewGVN: Use StoreExpression StoredValue instead of looking it up again, since it...
Daniel Berlin [Tue, 16 May 2017 06:06:15 +0000 (06:06 +0000)]
NewGVN: Use StoreExpression StoredValue instead of looking it up again, since it was already looked up when it was created

llvm-svn: 303144

7 years agoNewGVN: Formatting fixes
Daniel Berlin [Tue, 16 May 2017 06:06:12 +0000 (06:06 +0000)]
NewGVN: Formatting fixes

llvm-svn: 303143

7 years agoRevert "[NewGVN] Replace predicate info leftovers."
Davide Italiano [Tue, 16 May 2017 05:51:21 +0000 (05:51 +0000)]
Revert "[NewGVN] Replace predicate info leftovers."

It's breaking the bots.

llvm-svn: 303142

7 years ago[NewGVN] Replace predicate info leftovers.
Davide Italiano [Tue, 16 May 2017 05:23:23 +0000 (05:23 +0000)]
[NewGVN] Replace predicate info leftovers.

Fixes PR32945.

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

llvm-svn: 303141

7 years agoRevert "[clang-tidy] modernize-use-emplace: Remove unnecessary make_tuple calls"
Jakub Kuderski [Tue, 16 May 2017 05:07:40 +0000 (05:07 +0000)]
Revert "[clang-tidy] modernize-use-emplace: Remove unnecessary make_tuple calls"

This reverts commit r303139. The commit made docs build emit a warning.

llvm-svn: 303140

7 years ago[clang-tidy] modernize-use-emplace: Remove unnecessary make_tuple calls
Jakub Kuderski [Tue, 16 May 2017 04:25:42 +0000 (04:25 +0000)]
[clang-tidy] modernize-use-emplace: Remove unnecessary make_tuple calls

Summary:
This patch makes modernize-use-emplace remove unnecessary make_ calls from push_back calls and turn them into emplace_back -- the same way make_pair calls are handled.
Custom make_ calls can be removed for custom tuple-like types -- two new options that control that are `TupleTypes` and `TupleMakeFunctions`. By default, the check removes calls to `std::make_pair` and `std::make_tuple`.

Eq.

```
std::vector<std::tuple<int, char, bool>> v;
v.push_back(std::make_tuple(1, 'A', true)); // --> v.emplace_back(1, 'A', true);
```

Reviewers: alexfh, aaron.ballman, Prazek, hokein

Reviewed By: Prazek

Subscribers: JDevlieghere, xazax.hun, JonasToth, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 303139

7 years agobuiltins: use reserved spelling (NFC)
Saleem Abdulrasool [Tue, 16 May 2017 04:17:12 +0000 (04:17 +0000)]
builtins: use reserved spelling (NFC)

llvm-svn: 303138

7 years agoAMDGPUCodeGen: Fix warnings in r303111. [-Wunused-variable]
NAKAMURA Takumi [Tue, 16 May 2017 04:01:23 +0000 (04:01 +0000)]
AMDGPUCodeGen: Fix warnings in r303111. [-Wunused-variable]

llvm-svn: 303137

7 years ago[tsan] Update tsan test for r303084
Vitaly Buka [Tue, 16 May 2017 02:06:15 +0000 (02:06 +0000)]
[tsan] Update tsan test for r303084

Tail duplication changed number of pop instruction, but TSAN performance was not
affected.

llvm-svn: 303136

7 years agoMerge a test YAML file and a test file.
Rui Ueyama [Tue, 16 May 2017 01:16:20 +0000 (01:16 +0000)]
Merge a test YAML file and a test file.

llvm-svn: 303135

7 years agoIR: Give function GlobalValue::getRealLinkageName() a less misleading name: dropLLVMM...
Peter Collingbourne [Tue, 16 May 2017 00:39:01 +0000 (00:39 +0000)]
IR: Give function GlobalValue::getRealLinkageName() a less misleading name: dropLLVMManglingEscape().

This function gives the wrong answer on some non-ELF platforms in some
cases. The function that does the right thing lives in Mangler.h. To try to
discourage people from using this function, give it a different name.

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

llvm-svn: 303134

7 years ago[InstCombine] add tests for PR32791; NFC
Sanjay Patel [Mon, 15 May 2017 23:59:28 +0000 (23:59 +0000)]
[InstCombine] add tests for PR32791; NFC

llvm-svn: 303133

7 years ago[asan] make asan under sandboxes more robust
Kostya Serebryany [Mon, 15 May 2017 23:37:54 +0000 (23:37 +0000)]
[asan] make asan under sandboxes more robust

llvm-svn: 303132

7 years agoFix executable stack directive on Linux.
Manoj Gupta [Mon, 15 May 2017 23:13:54 +0000 (23:13 +0000)]
Fix executable stack directive on Linux.

Summary: Use __linux__  to check for Linux and bring back the check for __GNU__.

Reviewers: echristo, krytarowski, compnerd, rengolin

Reviewed By: krytarowski

Subscribers: phosek, llvm-commits, srhines

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

llvm-svn: 303131

7 years ago[ShrinkWrapping] Handle restores on no-return paths
Francis Visoiu Mistrih [Mon, 15 May 2017 23:13:35 +0000 (23:13 +0000)]
[ShrinkWrapping] Handle restores on no-return paths

Shrink-wrapping uses post-dominators to find a restore point that
post-dominates all the uses of CSR / stack.

The way dominator trees are modeled in LLVM today is that unreachable
blocks are not present in a generic dominator tree, so, an unreachable node is
dominated by anything: include/llvm/Support/GenericDomTree.h:467.

Since for post-dominators, a no-return block is considered
"unreachable", calling findNearestCommonDominator on an unreachable node
A and a non-unreachable node B, will return B, which can be false. If we
find such node, we bail out since there is no good restore point
available.

rdar://problem/30186931

llvm-svn: 303130

7 years ago[lsan] Report the missing linker only when the linker is actually missing.
Alex Shlyapnikov [Mon, 15 May 2017 23:11:01 +0000 (23:11 +0000)]
[lsan] Report the missing linker only when the linker is actually missing.

Reviewers: eugenis

Subscribers: llvm-commits

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

llvm-svn: 303129