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

7 years ago[libFuzzer] fix tests on Windows
Kostya Serebryany [Mon, 15 May 2017 22:55:00 +0000 (22:55 +0000)]
[libFuzzer] fix tests on Windows

llvm-svn: 303128

7 years ago[InstSimplify] add tests for unnecessary mask of shifted values; NFC
Sanjay Patel [Mon, 15 May 2017 22:54:37 +0000 (22:54 +0000)]
[InstSimplify] add tests for unnecessary mask of shifted values; NFC

llvm-svn: 303127

7 years agoFix memory leak
Xinliang David Li [Mon, 15 May 2017 22:43:52 +0000 (22:43 +0000)]
Fix memory leak

llvm-svn: 303126

7 years ago[libFuzzer] improve the afl driver and it's tests. Make it possible to run individual...
Kostya Serebryany [Mon, 15 May 2017 22:38:29 +0000 (22:38 +0000)]
[libFuzzer] improve the afl driver and it's tests. Make it possible to run individual inputs with afl driver

llvm-svn: 303125

7 years agoFix git command line in the Getting Started guide.
Rui Ueyama [Mon, 15 May 2017 22:32:34 +0000 (22:32 +0000)]
Fix git command line in the Getting Started guide.

By default, git creates "llvm-project-20170507" directory,
but we want to create "llvm-project" directory.

llvm-svn: 303124

7 years agoAdd "REQUIRES:" to the last few tests that use target specific intrinsics
Justin Bogner [Mon, 15 May 2017 22:15:22 +0000 (22:15 +0000)]
Add "REQUIRES:" to the last few tests that use target specific intrinsics

llvm-svn: 303123

7 years ago[AMDGPU] Kill now unused phiInfoElementGetDebugLoc(). NFCI.
Davide Italiano [Mon, 15 May 2017 22:10:15 +0000 (22:10 +0000)]
[AMDGPU] Kill now unused phiInfoElementGetDebugLoc(). NFCI.

llvm-svn: 303122

7 years ago[Sema] Use CK_NoOp instead CK_Invalid in tryGCCVectorConvertAndSplat
Vitaly Buka [Mon, 15 May 2017 22:04:03 +0000 (22:04 +0000)]
[Sema] Use CK_NoOp instead CK_Invalid in tryGCCVectorConvertAndSplat

This fix UBSAN bots after r302935. Storing non-defined values in enum is
undefined behavior.

Other places, where "if (ScalarCast != CK_Invalid)" is used, never get to the
"if" with CK_Invalid. tryGCCVectorConvertAndSplat can get to the "if" with
CK_Invalid and it looks like expected case. So we have to use something other
than CK_Invalid, e.g. CK_NoOp.

llvm-svn: 303121

7 years ago[APInt] Simplify a for loop initialization based on the fact that 'n' is known to...
Craig Topper [Mon, 15 May 2017 22:01:03 +0000 (22:01 +0000)]
[APInt] Simplify a for loop initialization based on the fact that 'n' is known to be 1 by an earlier 'if'.

llvm-svn: 303120

7 years ago[IR] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC).
Eugene Zelenko [Mon, 15 May 2017 21:57:41 +0000 (21:57 +0000)]
[IR] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC).

llvm-svn: 303119

7 years agoAArch64: use linker-private symbols for globals in MachO.
Tim Northover [Mon, 15 May 2017 21:51:38 +0000 (21:51 +0000)]
AArch64: use linker-private symbols for globals in MachO.

We don't use section-relative relocations on AArch64, so all symbols must be at
least visible to the linker (i.e. properly global or l_whatever, but not
L_whatever).

llvm-svn: 303118

7 years agoPR32288: Describe a bool parameter's DWARF location with a simple register
David Blaikie [Mon, 15 May 2017 21:34:01 +0000 (21:34 +0000)]
PR32288: Describe a bool parameter's DWARF location with a simple register

There's no need (& a bit incorrect) to mask off the high bits of the
register reference when describing a simple bool value.

Reviewers: aprantl

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

llvm-svn: 303117

7 years ago[SLP] Enable 64-bit wide vectorization on AArch64
Adam Nemet [Mon, 15 May 2017 21:15:01 +0000 (21:15 +0000)]
[SLP] Enable 64-bit wide vectorization on AArch64

ARM Neon has native support for half-sized vector registers (64 bits).  This
is beneficial for example for 2D and 3D graphics.  This patch adds the option
to lower MinVecRegSize from 128 via a TTI in the SLP Vectorizer.

*** Performance Analysis

This change was motivated by some internal benchmarks but it is also
beneficial on SPEC and the LLVM testsuite.

The results are with -O3 and PGO.  A negative percentage is an improvement.
The testsuite was run with a sample size of 4.

** SPEC

* CFP2006/482.sphinx3  -3.34%

A pretty hot loop is SLP vectorized resulting in nice instruction reduction.
This used to be a +22% regression before rL299482.

* CFP2000/177.mesa     -3.34%
* CINT2000/256.bzip2   +6.97%

My current plan is to extend the fix in rL299482 to i16 which brings the
regression down to +2.5%.  There are also other problems with the codegen in
this loop so there is further room for improvement.

** LLVM testsuite

* SingleSource/Benchmarks/Misc/ReedSolomon               -10.75%

There are multiple small SLP vectorizations outside the hot code.  It's a bit
surprising that it adds up to 10%.  Some of this may be code-layout noise.

* MultiSource/Benchmarks/VersaBench/beamformer/beamformer -8.40%

The opt-viewer screenshot can be seen at F3218284.  We start at a colder store
but the tree leads us into the hottest loop.

* MultiSource/Applications/lambda-0.1.3/lambda            -2.68%
* MultiSource/Benchmarks/Bullet/bullet                    -2.18%

This is using 3D vectors.

* SingleSource/Benchmarks/Shootout-C++/Shootout-C++-lists +6.67%

Noise, binary is unchanged.

* MultiSource/Benchmarks/Ptrdist/anagram/anagram          +4.90%

There is an additional SLP in the cold code.  The test runs for ~1sec and
prints out over 2000 lines. This is most likely noise.

* MultiSource/Applications/aha/aha                        +1.63%
* MultiSource/Applications/JM/lencod/lencod               +1.41%
* SingleSource/Benchmarks/Misc/richards_benchmark         +1.15%

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

llvm-svn: 303116

7 years agoRevert r302678 "[AArch64] Enable use of reduction intrinsics."
Hans Wennborg [Mon, 15 May 2017 20:59:32 +0000 (20:59 +0000)]
Revert r302678 "[AArch64] Enable use of reduction intrinsics."

This caused PR33053.

Original commit message:

> The new experimental reduction intrinsics can now be used, so I'm enabling this
> for AArch64. We will need this for SVE anyway, so it makes sense to do this for
> NEON reductions as well.
>
> The existing code to match shufflevector patterns are replaced with a direct
> lowering of the reductions to AArch64-specific nodes. Tests updated with the
> new, simpler, representation.
>
> Differential Revision: https://reviews.llvm.org/D32247

llvm-svn: 303115

7 years ago[asan] One more test for -fsanitize-address-globals-dead-stripping.
Evgeniy Stepanov [Mon, 15 May 2017 20:43:48 +0000 (20:43 +0000)]
[asan] One more test for -fsanitize-address-globals-dead-stripping.

llvm-svn: 303114

7 years ago[asan] Better workaround for gold PR19002.
Evgeniy Stepanov [Mon, 15 May 2017 20:43:42 +0000 (20:43 +0000)]
[asan] Better workaround for gold PR19002.

See the comment for more details. Test in a follow-up CFE commit.

llvm-svn: 303113

7 years ago[builtins] Fix a check from __GNU__ to __GNUC__ for disabling executable stack.
Manoj Gupta [Mon, 15 May 2017 20:41:17 +0000 (20:41 +0000)]
[builtins] Fix a check from __GNU__ to __GNUC__ for disabling executable stack.

Summary:
Neither GCC nor Clang define __GNU__. Instead use __GNUC__ for the check.

Reviewers: echristo, rengolin, compnerd

Subscribers: srhines, krytarowski, llvm-commits

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

llvm-svn: 303112

7 years agoRe-submit AMDGPUMachineCFGStructurizer.
Jan Sjodin [Mon, 15 May 2017 20:18:37 +0000 (20:18 +0000)]
Re-submit AMDGPUMachineCFGStructurizer.

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

llvm-svn: 303111

7 years ago[TypeSystem] Fix inspection of Objective-C object types
Sean Callanan [Mon, 15 May 2017 19:55:20 +0000 (19:55 +0000)]
[TypeSystem] Fix inspection of Objective-C object types

ptr_refs exposed a problem in ClangASTContext's implementation: it
uses an accessor to downcast a QualType to an
ObjCObjectPointerType, but the accessor is not fully general.
getAs() is the safer way to go.

I've added a test case that uses ptr_refs in a way that would
crash before the fix.

<rdar://problem/31363513>

llvm-svn: 303110

7 years agoAArch64: diagnose unrecognized features in .cpu directive.
Tim Northover [Mon, 15 May 2017 19:42:15 +0000 (19:42 +0000)]
AArch64: diagnose unrecognized features in .cpu directive.

We were silently ignoring any features we couldn't match up, which led to
errors in an inline asm block missing the conventional "\n\t".

llvm-svn: 303108

7 years ago[NewGVN] Remove unused setDefiningExpr(). NFCI.
Davide Italiano [Mon, 15 May 2017 19:35:40 +0000 (19:35 +0000)]
[NewGVN] Remove unused setDefiningExpr(). NFCI.

llvm-svn: 303107

7 years agoclang-format: [JS] for async loops.
Martin Probst [Mon, 15 May 2017 19:33:20 +0000 (19:33 +0000)]
clang-format: [JS] for async loops.

Summary:
JavaScript supports asynchronous loop iteration in async functions:

    for async (const x of y) ...

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 303106

7 years ago[InstCombine] restrict icmp fold with 2 sdiv exact operands (PR32949)
Sanjay Patel [Mon, 15 May 2017 19:27:53 +0000 (19:27 +0000)]
[InstCombine] restrict icmp fold with 2 sdiv exact operands (PR32949)

This is the InstCombine counterpart to D32954.
I added some comments about the code duplication in:
rL302436

Alive-based verification:
http://rise4fun.com/Alive/dPw

This is a 2nd fix for the problem reported in:
https://bugs.llvm.org/show_bug.cgi?id=32949

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

llvm-svn: 303105

7 years ago[InstSimplify] restrict icmp fold with 2 sdiv exact operands (PR32949)
Sanjay Patel [Mon, 15 May 2017 19:16:49 +0000 (19:16 +0000)]
[InstSimplify] restrict icmp fold with 2 sdiv exact operands (PR32949)

These folds were introduced with https://reviews.llvm.org/rL127064 as part of solving:
https://bugs.llvm.org/show_bug.cgi?id=9343

As shown here:
http://rise4fun.com/Alive/C8
...however, the sdiv exact case needs a stronger predicate.

I opted for duplicated code instead of adding another fallthrough because I think that's
easier to read (and edit in case we need/want to restrict/loosen the predicates any more).

This should fix:
https://bugs.llvm.org/show_bug.cgi?id=32949
https://bugs.llvm.org/show_bug.cgi?id=32948

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

llvm-svn: 303104

7 years agobuiltins: fix filtering aliased targets
Saleem Abdulrasool [Mon, 15 May 2017 19:09:13 +0000 (19:09 +0000)]
builtins: fix filtering aliased targets

Some build targets (e.g. i686) have aliased names (e.g. i386).  We would
get multiple definitions previously and have the linker arbitrarily
select a definition on those aliased targets.  Make this more
deterministic by checking those aliases.

llvm-svn: 303103

7 years agoThe patch adds CTLZ idiom recognition.
Evgeny Stupachenko [Mon, 15 May 2017 19:08:56 +0000 (19:08 +0000)]
The patch adds CTLZ idiom recognition.

Summary:

The following loops should be recognized:
i = 0;
while (n) {
  n = n >> 1;
  i++;
  body();
}
use(i);

And replaced with builtin_ctlz(n) if body() is empty or
for CPUs that have CTLZ instruction converted to countable:

for (j = 0; j < builtin_ctlz(n); j++) {
  n = n >> 1;
  i++;
  body();
}
use(builtin_ctlz(n));

Reviewers: rengolin, joerg

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

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

7 years agoFix for KMP_AFFINITY=respect with multiple processor groups
Jonathan Peyton [Mon, 15 May 2017 19:05:59 +0000 (19:05 +0000)]
Fix for KMP_AFFINITY=respect with multiple processor groups

An assert() was being tripped when KMP_AFFINITY=respect + Multiple Processor
Groups. Let __kmp_affinity_create_proc_group_map() function be able to create
address2os object which contains a single group by deleting restriction that
process affinity mask must span multiple groups.

llvm-svn: 303101

7 years ago[NewGVN] Fix verification of MemoryPhis in verifyMemoryCongruency().
Davide Italiano [Mon, 15 May 2017 18:50:53 +0000 (18:50 +0000)]
[NewGVN] Fix verification of MemoryPhis in verifyMemoryCongruency().

verifyMemoryCongruency() filters out trivially dead MemoryDef(s),
as we find them immediately dead, before moving from TOP to a new
congruence class.
This fixes the same problem for PHI(s) skipping MemoryPhis if all
the operands are dead.

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

llvm-svn: 303100