platform/upstream/llvm.git
7 years agoFix CMake configuration error and add ABI lists for OS X.
Eric Fiselier [Fri, 14 Oct 2016 02:55:19 +0000 (02:55 +0000)]
Fix CMake configuration error and add ABI lists for OS X.

The primary reason for this patch is to add the OS X ABI lists for 3.9 and
ToT.

However while working on that I discovered that we incorrectly
exported the libc++abi symbols. Previously we had chosen the wrong CMake
configuration path and that caused us to re-export the c++abi binary instead
of using the symbol lists.

llvm-svn: 284188

7 years agoFix bogus assert breaking modules self-host.
Richard Smith [Fri, 14 Oct 2016 02:35:11 +0000 (02:35 +0000)]
Fix bogus assert breaking modules self-host.

llvm-svn: 284187

7 years agoAdd OS X abi list
Eric Fiselier [Fri, 14 Oct 2016 02:32:54 +0000 (02:32 +0000)]
Add OS X abi list

llvm-svn: 284186

7 years agoAdd ABI Changelog and current symbol list for Linux
Eric Fiselier [Fri, 14 Oct 2016 02:27:44 +0000 (02:27 +0000)]
Add ABI Changelog and current symbol list for Linux

llvm-svn: 284185

7 years agoUse SubstInitializer instead of SubstExpr when instantiating a default
Richard Smith [Fri, 14 Oct 2016 01:12:20 +0000 (01:12 +0000)]
Use SubstInitializer instead of SubstExpr when instantiating a default
argument, in order to correctly instantiate the initializer.

llvm-svn: 284184

7 years agoThis test passes on i386 now.
Jim Ingham [Fri, 14 Oct 2016 01:11:19 +0000 (01:11 +0000)]
This test passes on i386 now.

llvm-svn: 284183

7 years agoThis test is passing on i386 now.
Jim Ingham [Fri, 14 Oct 2016 01:03:03 +0000 (01:03 +0000)]
This test is passing on i386 now.

llvm-svn: 284182

7 years agoTimer: Fix doxygen comments, use member initializer; NFC
Matthias Braun [Fri, 14 Oct 2016 00:17:19 +0000 (00:17 +0000)]
Timer: Fix doxygen comments, use member initializer; NFC

llvm-svn: 284181

7 years agoAdd interface for querying physical hardware concurrency
Teresa Johnson [Fri, 14 Oct 2016 00:13:59 +0000 (00:13 +0000)]
Add interface for querying physical hardware concurrency

Summary:
This will be used by ThinLTO to set the amount of backend
parallelism, which performs better when restricted to the number
of physical cores (on X86 at least, where getHostNumPhysicalCores is
currently defined). If not available this falls back to
thread::hardware_concurrency.

Note I didn't add to the thread class since that is a typedef to
std::thread where available.

Reviewers: mehdi_amini

Subscribers: beanz, llvm-commits, mgorny

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

llvm-svn: 284180

7 years agoremove warnings from google-benchmarks in libcxx
Sebastian Pop [Fri, 14 Oct 2016 00:07:57 +0000 (00:07 +0000)]
remove warnings from google-benchmarks in libcxx

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

Patch written by Aditya Kumar.

llvm-svn: 284179

7 years ago[compiler-rt][XRay] Support tail call sleds
Dean Michael Berris [Thu, 13 Oct 2016 23:56:54 +0000 (23:56 +0000)]
[compiler-rt][XRay] Support tail call sleds

Summary:
This change depends on D23986 which adds tail call-specific sleds. For
now we treat them first as normal exits, and in the future leave room
for implementing this as a different kind of log entry.

The reason for deferring the change is so that we can keep the naive
logging implementation more accurate without additional complexity for
reading the log. The accuracy is gained in effectively interpreting call
stacks like:

  A()
    B()
      C()

Which when tail-call merged will end up not having any exit entries for
A() nor B(), but effectively in turn can be reasoned about as:

  A()
  B()
  C()

Although we lose the fact that A() had called B() then had called C()
with the naive approach, a later iteration that adds the explicit tail
call entries would be a change in the log format and thus necessitate a
version change for the header. We can do this later to have a chance at
releasing some tools (in D21987) that are able to handle the naive log
format, then support higher version numbers of the log format too.

Reviewers: echristo, kcc, rSerge, majnemer

Subscribers: mehdi_amini, llvm-commits, dberris

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

llvm-svn: 284178

7 years agoImprove comments.
Rui Ueyama [Thu, 13 Oct 2016 23:08:33 +0000 (23:08 +0000)]
Improve comments.

llvm-svn: 284177

7 years agoReinstate r281429, reverted in r281452, with a fix for its mishandling of
Richard Smith [Thu, 13 Oct 2016 23:04:14 +0000 (23:04 +0000)]
Reinstate r281429, reverted in r281452, with a fix for its mishandling of
compiles without -fmodules-local-submodule-visibility. Original commit message:

[modules] When merging one definition into another, propagate the list of
re-exporting modules from the discarded definition to the retained definition.

llvm-svn: 284176

7 years agoCodeGen: use MSVC division on windows itanium
Saleem Abdulrasool [Thu, 13 Oct 2016 23:00:11 +0000 (23:00 +0000)]
CodeGen: use MSVC division on windows itanium

Windows itanium is identical to MSVC when dealing with everything but C++.
Lower the math routines into msvcrt rather than compiler-rt.

llvm-svn: 284175

7 years agoDisable swiftcall test on windows: More brutal way to appease windows bots
Arnold Schwaighofer [Thu, 13 Oct 2016 22:47:03 +0000 (22:47 +0000)]
Disable swiftcall test on windows: More brutal way to appease windows bots

The backtrace on the bot does not give me any indication what is wrong.
The test case interestingly passes in stage2 of the build.
I don't have a way of debugging this.

Disable the test on windows and hope if there is truly a bug in the code that
was causing we will eventually run into this on other platforms.

llvm-svn: 284174

7 years agoCodeGen: adjust floating point operations in Windows itanium
Saleem Abdulrasool [Thu, 13 Oct 2016 22:38:15 +0000 (22:38 +0000)]
CodeGen: adjust floating point operations in Windows itanium

Windows itanium is equivalent to MSVC except in C++ mode.  Ensure that the
promote the 32-bit floating point operations to their 64-bit equivalences.

llvm-svn: 284173

7 years agoAdd 64-bit MS _Interlocked functions as builtins again
Albert Gutowski [Thu, 13 Oct 2016 22:35:07 +0000 (22:35 +0000)]
Add 64-bit MS _Interlocked functions as builtins again

Summary: Previously global 64-bit versions of _Interlocked functions broke buildbots on i386, so now I'm adding them as builtins for x86-64 and ARM only (should they be also on AArch64? I had problems with testing it for AArch64, so I left it)

Reviewers: hans, majnemer, mstorsjo, rnk

Subscribers: cfe-commits, aemerson

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

llvm-svn: 284172

7 years agoMake lsan complain loudly when running under ptrace
Kostya Serebryany [Thu, 13 Oct 2016 22:34:13 +0000 (22:34 +0000)]
Make lsan complain loudly when running under ptrace

Summary:
LeakSanitizer does not work with ptrace but currently it
will print warnings (only under verbosity=1) and then proceed
to print tons of false reports.
This patch makes lsan fail hard under ptrace with a verbose message.

https://github.com/google/sanitizers/issues/728

Reviewers: eugenis, vitalybuka, aizatsky

Subscribers: kubabrecka, llvm-commits

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

llvm-svn: 284171

7 years ago[DAG] hoist DL(N) and fix formatting; NFC
Sanjay Patel [Thu, 13 Oct 2016 22:27:10 +0000 (22:27 +0000)]
[DAG] hoist DL(N) and fix formatting; NFC

llvm-svn: 284170

7 years ago[libFuzzer] more detailed message for disabled leak detection
Kostya Serebryany [Thu, 13 Oct 2016 22:24:10 +0000 (22:24 +0000)]
[libFuzzer] more detailed message for disabled leak detection

llvm-svn: 284169

7 years agoELF: Override DSO definitions when creating __start_* and __stop_* symbols.
Peter Collingbourne [Thu, 13 Oct 2016 22:20:18 +0000 (22:20 +0000)]
ELF: Override DSO definitions when creating __start_* and __stop_* symbols.

Previously we would fail to synthesise a __start_ or __stop_ symbol if
there existed a definition in a DSO. Instead, we would try to link against
the DSO definition. This became possible after D23552 when linking against
lld-produced DSOs but could in principle also occur when linking against
DSOs produced by other linkers.

Not only does it seem more likely that a user would expect the resolved
definition to be local to the executable, but if a __start_ or __stop_
symbol was synthesised by the linker, it is effectively impossible to link
against correctly from a non-PIC executable in a read-only section. Neither
a PLT nor a copy relocation would give us the right semantics here. The only
way the link could succeed is if the executable provided its own synthetic
definition of the symbol.

The fix is to also synthesise the definition if the only definition comes
from a DSO. Since this is what the addOptionalSynthetic function does,
switch to using that function.

Fixes PR30680.

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

llvm-svn: 284168

7 years agofix _BitScan intrinsics missing header warnings; fix some line endings
Albert Gutowski [Thu, 13 Oct 2016 21:55:16 +0000 (21:55 +0000)]
fix _BitScan intrinsics missing header warnings; fix some line endings

llvm-svn: 284167

7 years ago[analyzer] Remove superquadratic behaviour from DataflowWorklist
Alexander Shaposhnikov [Thu, 13 Oct 2016 21:31:46 +0000 (21:31 +0000)]
[analyzer] Remove superquadratic behaviour from DataflowWorklist

The class DataflowWorklist internally maintains a sorted list of pointers to CFGBlock
and the method enqueuePredecessors has to call sortWorklist to maintain the invariant.
The implementation based on vector + sort works well for small sizes
but gets infeasible for relatively large sizes. In particular the issue takes place
for some cryptographic libraries which use code generation.
The diff replaces vector + sort with priority queue.
For one of the implementations of AES this patch reduces
the time for analysis from 204 seconds to 8 seconds.

Test plan: make -j8 check-clang

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

llvm-svn: 284166

7 years agoUpdate the status of three papers that do not require library changes
Marshall Clow [Thu, 13 Oct 2016 21:15:09 +0000 (21:15 +0000)]
Update the status of three papers that do not require library changes

llvm-svn: 284165

7 years agoImplement http://wg21.link/p0302r1: Removing Allocator Support in std::function....
Marshall Clow [Thu, 13 Oct 2016 21:06:03 +0000 (21:06 +0000)]
Implement wg21.link/p0302r1: Removing Allocator Support in std::function. These functions never worked, and as far as I know, no one ever called them.

llvm-svn: 284164

7 years agoLegalizeDAG: Implement PROMOTE for ISD::BITREVERSE
Tom Stellard [Thu, 13 Oct 2016 21:03:49 +0000 (21:03 +0000)]
LegalizeDAG: Implement PROMOTE for ISD::BITREVERSE

Summary:
This operation is promoted the same way was ISD::BSWAP.  This will
prevent a regression in test/Target/AMDGOU/bitreverse.ll when i16
support is implemented.

Reviewers: bogner, hfinkel

Subscribers: hfinkel, wdng, llvm-commits

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

llvm-svn: 284163

7 years agoAdd required targets to tests to (hopefully) appease bots
Arnold Schwaighofer [Thu, 13 Oct 2016 20:59:23 +0000 (20:59 +0000)]
Add required targets to tests to (hopefully) appease bots

llvm-svn: 284162

7 years ago[safestack] Reapply r283248 after moving X86-targeted SafeStack tests into
David L Kreitzer [Thu, 13 Oct 2016 20:57:51 +0000 (20:57 +0000)]
[safestack] Reapply r283248 after moving X86-targeted SafeStack tests into
the X86 subdirectory. Original commit message:

Requires a valid TargetMachine to be passed to the SafeStack pass.

Patch by Michael LeMay

Differential revision: http://reviews.llvm.org/D24896

llvm-svn: 284161

7 years agoNew llc option pie-copy-relocations to optimize access to extern globals.
Sriraman Tallam [Thu, 13 Oct 2016 20:54:39 +0000 (20:54 +0000)]
New llc option pie-copy-relocations to optimize access to extern globals.

This option indicates copy relocations support is available from the linker
when building as PIE and allows accesses to extern globals to avoid the GOT.

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

llvm-svn: 284160

7 years agoAdd and use isDiscardableGVALinkage function.
Justin Lebar [Thu, 13 Oct 2016 20:52:17 +0000 (20:52 +0000)]
Add and use isDiscardableGVALinkage function.

Reviewers: rnk

Subscribers: cfe-commits

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

llvm-svn: 284159

7 years ago[CUDA] Emit deferred diagnostics during Sema rather than during codegen.
Justin Lebar [Thu, 13 Oct 2016 20:52:12 +0000 (20:52 +0000)]
[CUDA] Emit deferred diagnostics during Sema rather than during codegen.

Summary:
Emitting deferred diagnostics during codegen was a hack.  It did work,
but usability was poor, both for us as compiler devs and for users.  We
don't codegen if there are any sema errors, so for users this meant that
they wouldn't see deferred errors if there were any non-deferred errors.
For devs, this meant that we had to carefully split up our tests so that
when we tested deferred errors, we didn't emit any non-deferred errors.

This change moves checking for deferred errors into Sema.  See the big
comment in SemaCUDA.cpp for an overview of the idea.

This checking adds overhead to compilation, because we have to maintain
a partial call graph.  As a result, this change makes deferred errors a
CUDA-only concept (whereas before they were a general concept).  If
anyone else wants to use this framework for something other than CUDA,
we can generalize at that time.

This patch makes the minimal set of test changes -- after this lands,
I'll go back through and do a cleanup of the tests that we no longer
have to split up.

Reviewers: rnk

Subscribers: cfe-commits, rsmith, tra

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

llvm-svn: 284158

7 years agoRevert "In visitSTORE, always use FindBetterChain, rather than only when UseAA is...
Nirav Dave [Thu, 13 Oct 2016 20:23:25 +0000 (20:23 +0000)]
Revert "In visitSTORE, always use FindBetterChain, rather than only when UseAA is enabled."

This reverts commit r284151 which appears to be triggering a LTO
failures on Hexagon

llvm-svn: 284157

7 years agotest: attempt to repair SCEI buildbots
Saleem Abdulrasool [Thu, 13 Oct 2016 20:10:22 +0000 (20:10 +0000)]
test: attempt to repair SCEI buildbots

The tests target ARM, ensure that the ARM target is registered.

llvm-svn: 284156

7 years ago[clang-move] error out when fail to create new files.
Eric Liu [Thu, 13 Oct 2016 19:49:19 +0000 (19:49 +0000)]
[clang-move] error out when fail to create new files.

llvm-svn: 284155

7 years agoCodeGen: ensure that the runtime calling convention matches
Saleem Abdulrasool [Thu, 13 Oct 2016 19:45:08 +0000 (19:45 +0000)]
CodeGen: ensure that the runtime calling convention matches

Incorrect specification of the calling convention results in UB which can cause
the code path to be eliminated.  Simplify the existing code by using the
RuntimeCall constructor in `CodeGenFunction`.

llvm-svn: 284154

7 years ago[RAGreedy] Empty live-ranges always succeed in last chance recoloring.
Quentin Colombet [Thu, 13 Oct 2016 19:27:48 +0000 (19:27 +0000)]
[RAGreedy] Empty live-ranges always succeed in last chance recoloring.

Relax the constraint for empty live-ranges while doing last chance
recoloring. Indeed, those live-ranges do not need an actual color to be
fond for the recoloring to work.
Empty live-range may happen as a result of splitting/spilling.

Unfortunately no test case for in-tree targets.

llvm-svn: 284152

7 years agoIn visitSTORE, always use FindBetterChain, rather than only when UseAA is enabled.
Nirav Dave [Thu, 13 Oct 2016 19:20:16 +0000 (19:20 +0000)]
In visitSTORE, always use FindBetterChain, rather than only when UseAA is enabled.

   Retrying after upstream changes.

   Simplify Consecutive Merge Store Candidate Search

   Now that address aliasing is much less conservative, push through
   simplified store merging search which only checks for parallel stores
   through the chain subgraph. This is cleaner as the separation of
   non-interfering loads/stores from the store-merging logic.

   Whem merging stores, search up the chain through a single load, and
   finds all possible stores by looking down from through a load and a
   TokenFactor to all stores visited. This improves the quality of the
   output SelectionDAG and generally the output CodeGen (with some
   exceptions).

   Additional Minor Changes:

       1. Finishes removing unused AliasLoad code
       2. Unifies the the chain aggregation in the merged stores across
       code paths
       3. Re-add the Store node to the worklist after calling
       SimplifyDemandedBits.
       4. Increase GatherAllAliasesMaxDepth from 6 to 18. That number is
       arbitrary, but seemed sufficient to not cause regressions in
       tests.

   This finishes the change Matt Arsenault started in r246307 and
   jyknight's original patch.

   Many tests required some changes as memory operations are now
   reorderable. Some tests relying on the order were changed to use
   volatile memory operations

   Noteworthy tests:

    CodeGen/AArch64/argument-blocks.ll -
      It's not entirely clear what the test_varargs_stackalign test is
      supposed to be asserting, but the new code looks right.

    CodeGen/AArch64/arm64-memset-inline.lli -
    CodeGen/AArch64/arm64-stur.ll -
    CodeGen/ARM/memset-inline.ll -

      The backend now generates *worse* code due to store merging
      succeeding, as we do do a 16-byte constant-zero store efficiently.

    CodeGen/AArch64/merge-store.ll -
      Improved, but there still seems to be an extraneous vector insert
      from an element to itself?

    CodeGen/PowerPC/ppc64-align-long-double.ll -
      Worse code emitted in this case, due to the improved store->load
      forwarding.

    CodeGen/X86/dag-merge-fast-accesses.ll -
    CodeGen/X86/MergeConsecutiveStores.ll -
    CodeGen/X86/stores-merging.ll -
    CodeGen/Mips/load-store-left-right.ll -
      Restored correct merging of non-aligned stores

    CodeGen/AMDGPU/promote-alloca-stored-pointer-value.ll -
      Improved. Correctly merges buffer_store_dword calls

    CodeGen/AMDGPU/si-triv-disjoint-mem-access.ll -
      Improved. Sidesteps loading a stored value and
      merges two stores

    CodeGen/X86/pr18023.ll -
      This test has been removed, as it was asserting incorrect
      behavior. Non-volatile stores *CAN* be moved past volatile loads,
      and now are.

    CodeGen/X86/vector-idiv.ll -
    CodeGen/X86/vector-lzcnt-128.ll -
      It's basically impossible to tell what these tests are actually
      testing. But, looks like the code got better due to the memory
      operations being recognized as non-aliasing.

    CodeGen/X86/win32-eh.ll -
      Both loads of the securitycookie are now merged.

    CodeGen/AMDGPU/vgpr-spill-emergency-stack-slot-compute.ll -
      This test appears to work but no longer exhibits the spill behavior.

Reviewers: arsenm, hfinkel, tstellarAMD, jyknight, nhaehnle

Subscribers: wdng, nhaehnle, nemanjai, arsenm, weimingz, niravd, RKSimon, aemerson, qcolombet, dsanders, resistor, tstellarAMD, t.p.northover, spatel

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

llvm-svn: 284151

7 years agoSwift Calling Convention: Fix out of bounds access
Arnold Schwaighofer [Thu, 13 Oct 2016 19:19:37 +0000 (19:19 +0000)]
Swift Calling Convention: Fix out of bounds access

Use iterator instead of address of element in vector

It is not valid to access one after the last element.

rdar://28759508

llvm-svn: 284150

7 years ago[libFuzzer] add -trace_malloc= flag
Kostya Serebryany [Thu, 13 Oct 2016 19:06:46 +0000 (19:06 +0000)]
[libFuzzer] add -trace_malloc= flag

llvm-svn: 284149

7 years agoPrint stack trace for clang-move tool.
Eric Liu [Thu, 13 Oct 2016 19:04:19 +0000 (19:04 +0000)]
Print stack trace for clang-move tool.

llvm-svn: 284148

7 years agoPrint stack trace for clang-change-namespace tool.
Eric Liu [Thu, 13 Oct 2016 18:56:14 +0000 (18:56 +0000)]
Print stack trace for clang-change-namespace tool.

llvm-svn: 284147

7 years ago[AArch64][RegisterBankInfo] Switch to fully static opds mapping for G_BITCAST.
Quentin Colombet [Thu, 13 Oct 2016 18:46:38 +0000 (18:46 +0000)]
[AArch64][RegisterBankInfo] Switch to fully static opds mapping for G_BITCAST.

NFC.

llvm-svn: 284146

7 years ago[CUDA] Allow static variables in __host__ __device__ functions, so long as they're...
Justin Lebar [Thu, 13 Oct 2016 18:45:17 +0000 (18:45 +0000)]
[CUDA] Allow static variables in __host__ __device__ functions, so long as they're never codegen'ed for device.

Reviewers: tra, rnk

Subscribers: cfe-commits

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

llvm-svn: 284145

7 years ago[CUDA] Disallow __shared__ variables in host functions.
Justin Lebar [Thu, 13 Oct 2016 18:45:13 +0000 (18:45 +0000)]
[CUDA] Disallow __shared__ variables in host functions.

Reviewers: tra, rnk

Subscribers: cfe-commits

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

llvm-svn: 284144

7 years ago[CUDA] Add Sema::CUDADiagBuilder and Sema::CUDADiagIf{Device,Host}Code().
Justin Lebar [Thu, 13 Oct 2016 18:45:08 +0000 (18:45 +0000)]
[CUDA] Add Sema::CUDADiagBuilder and Sema::CUDADiagIf{Device,Host}Code().

Summary:
Together these let you easily create diagnostics that

 - are never emitted for host code
 - are always emitted for __device__ and __global__ functions, and
 - are emitted for __host__ __device__ functions iff these functions are
   codegen'ed.

At the moment there are only three diagnostics that need this treatment,
but I have more to add, and it's not sustainable to write code for emitting
every such diagnostic twice, and from a special wrapper in SemaCUDA.cpp.

While we're at it, don't emit the function name in
err_cuda_device_exceptions: It's not necessary to print it, and making
this work in the new framework in the face of a null value for
dyn_cast<FunctionDecl>(CurContext) isn't worth the effort.

Reviewers: rnk

Subscribers: cfe-commits, tra

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

llvm-svn: 284143

7 years agoModule: emit initializers for C/ObjC after r276159.
Manman Ren [Thu, 13 Oct 2016 18:42:14 +0000 (18:42 +0000)]
Module: emit initializers for C/ObjC after r276159.

In r276159, we started to defer emitting initializers for VarDecls, but
forgot to add the initializers for non-C++ language.

rdar://28740482

llvm-svn: 284142

7 years ago[libcxxabi] Fix gcc build after r284128
Asiri Rathnayake [Thu, 13 Oct 2016 18:40:57 +0000 (18:40 +0000)]
[libcxxabi] Fix gcc build after r284128

NFC.

llvm-svn: 284141

7 years agoPass -ffunction-sections/-fdata-sections along to gold-plugin
Teresa Johnson [Thu, 13 Oct 2016 18:05:53 +0000 (18:05 +0000)]
Pass -ffunction-sections/-fdata-sections along to gold-plugin

Summary:
These options need to be passed to the plugin in order to have
an effect on LTO/ThinLTO compiles.

Reviewers: mehdi_amini, pcc

Subscribers: jfb, dschuff, mehdi_amini, cfe-commits

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

llvm-svn: 284140

7 years ago[safestack] Move X86-targeted tests into the X86 subdirectory.
David L Kreitzer [Thu, 13 Oct 2016 17:51:59 +0000 (17:51 +0000)]
[safestack] Move X86-targeted tests into the X86 subdirectory.

Patch by Michael LeMay

Differential revision: http://reviews.llvm.org/D25340

llvm-svn: 284139

7 years agoAdd interface to compute number of physical cores on host system
Teresa Johnson [Thu, 13 Oct 2016 17:43:20 +0000 (17:43 +0000)]
Add interface to compute number of physical cores on host system

Summary:
For now I have only added support for x86_64 Linux, but other systems
can be added incrementally.

This is to be used for setting the default parallelism for ThinLTO
backends (instead of thread::hardware_concurrency which includes
hyperthreading and is too aggressive). I'll send this as a follow-on
patch, and it will fall back to hardware_concurrency when the new
getHostNumPhysicalCores returns -1 (when not supported for a given
host system).

I also added an interface to MemoryBuffer to force reading a file
as a stream - this is required for /proc/cpuinfo which is a special
file that looks like a normal file but appears to have 0 size.
The existing readers of this file in Host.cpp are reading the first
1024 or so bytes from it, because the necessary info is near the top.
But for the new functionality we need to be able to read the entire
file. I can go back and change the other readers to use the new
getFileAsStream as a follow-on patch since it seems much more robust.

Added a unittest.

Reviewers: mehdi_amini

Subscribers: beanz, mgorny, llvm-commits, modocache

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

llvm-svn: 284138

7 years ago[ThinLTO] Update doc to include lld (now supported).
Davide Italiano [Thu, 13 Oct 2016 17:42:38 +0000 (17:42 +0000)]
[ThinLTO] Update doc to include lld (now supported).

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

llvm-svn: 284137

7 years agoTruncate long names in type records
Reid Kleckner [Thu, 13 Oct 2016 17:33:22 +0000 (17:33 +0000)]
Truncate long names in type records

In the MS ABI, the frontend is supposed to MD5 such pathologically long
names. LLVM should still defend itself from long names, though.

Fixes part of PR29098.

llvm-svn: 284136

7 years ago[unittests] Remove a redundant test fixture (NFC)
Vedant Kumar [Thu, 13 Oct 2016 17:22:44 +0000 (17:22 +0000)]
[unittests] Remove a redundant test fixture (NFC)

llvm-svn: 284135

7 years ago[X86][AVX512] Fix sext v32i1 -> v32i8 lowering.
Igor Breger [Thu, 13 Oct 2016 17:20:38 +0000 (17:20 +0000)]
[X86][AVX512] Fix sext v32i1 -> v32i8 lowering.
Fix PR30600.

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

llvm-svn: 284134

7 years agoAdd more 64bit swiftcall convention tests
Arnold Schwaighofer [Thu, 13 Oct 2016 17:17:36 +0000 (17:17 +0000)]
Add more 64bit swiftcall convention tests

llvm-svn: 284133

7 years ago[libFuzzer] reapply r283946: refactoring to speed things up, NFC. Now with a fix...
Kostya Serebryany [Thu, 13 Oct 2016 16:19:09 +0000 (16:19 +0000)]
[libFuzzer] reapply r283946: refactoring to speed things up, NFC. Now with a fix for gcc build

llvm-svn: 284132

7 years agoImplement MS _ReturnAddress and _AddressOfReturnAddress intrinsics
Albert Gutowski [Thu, 13 Oct 2016 16:03:42 +0000 (16:03 +0000)]
Implement MS _ReturnAddress and _AddressOfReturnAddress intrinsics

Reviewers: rnk, thakis, majnemer, hans

Subscribers: cfe-commits

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

llvm-svn: 284131

7 years agoFix for PR30687. Avoid dereferencing MBB.end().
Reid Kleckner [Thu, 13 Oct 2016 15:48:48 +0000 (15:48 +0000)]
Fix for PR30687. Avoid dereferencing MBB.end().

We don't need to return a MachineInstr* from these stack probe insertion
calls anyway. If we ever need to add it back, we can return an iterator
instead.

Based on a patch by David Kreitzer

This bug is a consequence of

r279314 | dexonsmith | 2016-08-19 13:40:12 -0700 (Fri, 19 Aug 2016) | 110 lines

We hit the "Assertion `!NodePtr->isKnownSentinel()' failed" assertion,
but only when inserting a stack probe call at the end of an MBB, which
isn't necessarily a common situation.

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

llvm-svn: 284130

7 years agoDo not delete leading ../ in remove_dots.
Eric Liu [Thu, 13 Oct 2016 15:07:14 +0000 (15:07 +0000)]
Do not delete leading ../ in remove_dots.

Reviewers: bkramer

Subscribers: llvm-commits

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

llvm-svn: 284129

7 years ago[libcxxabi] Refactor pthread usage into a separate API
Asiri Rathnayake [Thu, 13 Oct 2016 15:05:19 +0000 (15:05 +0000)]
[libcxxabi] Refactor pthread usage into a separate API

This patch refactors all pthread uses of libc++abi into a separate API. This
is the first step towards supporting an externlly-threaded libc++abi library.

I've followed the conventions already used in the libc++ library for the same
purpose.

Patch from: Saleem Abdulrasool and Asiri Rathnayake

Reviewed by: compnerd, EricWF

Differential revisions:
  https://reviews.llvm.org/D18482 (original)
  https://reviews.llvm.org/D24864 (final)

llvm-svn: 284128

7 years ago[ARM]: Assign cost of scaling used in addressing mode for ARM cores
Javed Absar [Thu, 13 Oct 2016 14:57:43 +0000 (14:57 +0000)]
[ARM]: Assign cost of scaling used in addressing mode for ARM cores

This patch assigns cost of the scaling used in addressing.
On many ARM cores, a negated register offset takes longer than a
non-negated register offset, in a register-offset addressing mode.

For instance:

LDR R0, [R1, R2 LSL #2]
LDR R0, [R1, -R2 LSL #2]

Above, (1) takes less cycles than (2).

By assigning appropriate scaling factor cost, we enable the LLVM
to make the right trade-offs in the optimization and code-selection phase.

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

Reviewers: jmolloy, rengolin
llvm-svn: 284127

7 years ago[LV] Account for predicated stores in instruction costs
Matthew Simpson [Thu, 13 Oct 2016 14:54:31 +0000 (14:54 +0000)]
[LV] Account for predicated stores in instruction costs

This patch ensures that we scale the estimated cost of predicated stores by
block probability. This is a follow-on patch for r284123.

llvm-svn: 284126

7 years ago[libunwind] Add missing <stdint.h> include. NFC.
Asiri Rathnayake [Thu, 13 Oct 2016 14:32:24 +0000 (14:32 +0000)]
[libunwind] Add missing <stdint.h> include. NFC.

This missing include seems to cause compilation failures on older MacOS
versions (< 10.9). This is because r270692 has introduced uint64_t into
config.h without including this header.

Patch from: Jeremy Huddleston Sequoia (jeremyhu@apple.com)

llvm-svn: 284125

7 years ago[x86] add negate-i1 run for 32-bit target
Sanjay Patel [Thu, 13 Oct 2016 14:27:08 +0000 (14:27 +0000)]
[x86] add negate-i1 run for 32-bit target

llvm-svn: 284124

7 years ago[LV] Avoid rounding errors for predicated instruction costs
Matthew Simpson [Thu, 13 Oct 2016 14:19:48 +0000 (14:19 +0000)]
[LV] Avoid rounding errors for predicated instruction costs

This patch modifies the cost calculation of predicated instructions (div and
rem) to avoid the accumulation of rounding errors due to multiple truncating
integer divisions. The calculation for predicated stores will be addressed in a
follow-on patch since we currently don't scale the cost of predicated stores by
block probability.

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

llvm-svn: 284123

7 years ago[DAGCombiner] Add vector support to (mul (shl X, Y), Z) -> (shl (mul X, Z), Y) style...
Simon Pilgrim [Thu, 13 Oct 2016 14:04:35 +0000 (14:04 +0000)]
[DAGCombiner] Add vector support to (mul (shl X, Y), Z) -> (shl (mul X, Z), Y) style combines

llvm-svn: 284122

7 years agoGuard flag –fdenormal-fp-math with –fno-fast-math.
Sjoerd Meijer [Thu, 13 Oct 2016 13:22:01 +0000 (13:22 +0000)]
Guard flag –fdenormal-fp-math with –fno-fast-math.
This allows disabling the FP options with just one flag (-fno-fast-math).

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

llvm-svn: 284121

7 years agoAdd missing include in test; NFC. Thanks to Jonathan Wakely for the report.
Marshall Clow [Thu, 13 Oct 2016 13:21:38 +0000 (13:21 +0000)]
Add missing include in test; NFC. Thanks to Jonathan Wakely for the report.

llvm-svn: 284120

7 years agoAMDGPU: Assume spilling will occur at -O0
Matt Arsenault [Thu, 13 Oct 2016 13:10:00 +0000 (13:10 +0000)]
AMDGPU: Assume spilling will occur at -O0

Because everything live is spilled at the end of a
block by fast regalloc, assume this will happen and
avoid the copies of the resource descriptor.

llvm-svn: 284119

7 years agoCopy+pasts typo in comment describing combine test
Simon Pilgrim [Thu, 13 Oct 2016 12:54:32 +0000 (12:54 +0000)]
Copy+pasts typo in comment describing combine test

Repeated the "fold (mul x, 0) -> 0" instead of "fold (mul x, 1) -> x"

llvm-svn: 284118

7 years ago[DAGCombiner] Add vector support to C2-(A+C1) -> (C2-C1)-A folding
Simon Pilgrim [Thu, 13 Oct 2016 12:49:31 +0000 (12:49 +0000)]
[DAGCombiner] Add vector support to C2-(A+C1) -> (C2-C1)-A folding

llvm-svn: 284117

7 years agoAMDGPU: Fix truncate to bool warnings
Matt Arsenault [Thu, 13 Oct 2016 12:45:16 +0000 (12:45 +0000)]
AMDGPU: Fix truncate to bool warnings

llvm-svn: 284116

7 years ago[mips] Add IAS support for dvp, evp
Simon Dardis [Thu, 13 Oct 2016 12:12:56 +0000 (12:12 +0000)]
[mips] Add IAS support for dvp, evp

These instructions were only defined for microMIPSR6 previously. Add
definitions for MIPSR6, correct definitions for microMIPSR6, flag these
instructions as having unmodelled side effects (they disable/enable
virtual processors) and add missing disassember tests for microMIPSR6.

Reviewers: vkalintiris

Differential Review: https://reviews.llvm.org/D24291

llvm-svn: 284115

7 years ago[lldb] Improve identification of Linux core dumps. Fix for bug #30485.
Richard Chamberlain [Thu, 13 Oct 2016 12:11:00 +0000 (12:11 +0000)]
[lldb] Improve identification of Linux core dumps. Fix for bug #30485.

Summary:
ObjectFileELF::RefineModuleDetailsFromNote() identifies Linux core dumps by searching for
 library paths starting with /lib/x86_64-linux-gnu or /lib/i386-linux-gnu. This change widens the
test to allow for linux installations which have addition directories in the path.

Reviewers: ted, hhellyer, clayborg

Subscribers: lldb-commits

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

llvm-svn: 284114

7 years ago[DAGCombiner] Add vector support to (sub -1, x) -> (xor x, -1) canonicalization
Simon Pilgrim [Thu, 13 Oct 2016 12:05:20 +0000 (12:05 +0000)]
[DAGCombiner] Add vector support to (sub -1, x) -> (xor x, -1) canonicalization

Improves commutation potential

llvm-svn: 284113

7 years ago[analyzer] Link libStaticAnalyzerCheckers to libASTMatchers.
Artem Dergachev [Thu, 13 Oct 2016 11:41:12 +0000 (11:41 +0000)]
[analyzer] Link libStaticAnalyzerCheckers to libASTMatchers.

AST matchers are useful for the analyzer's checkers.
More patches on particular checkers shall follow.

This is the first time clang binary gets linked to ASTMatchers.
The binary size increase for the clang executable would be
+0.5% in release mode, +2% in debug mode.

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

llvm-svn: 284112

7 years ago[clang-move] Better support enclosing class.
Haojian Wu [Thu, 13 Oct 2016 10:31:00 +0000 (10:31 +0000)]
[clang-move] Better support enclosing class.

Summary:
* When moving an outermost enclosing class, all its nested classes should also
  be moved together.
* Add a test for not moving nested class.

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 284111

7 years agoFix for PR30639: CGDebugInfo Null dereference with OpenMP array
Alexey Bataev [Thu, 13 Oct 2016 09:52:46 +0000 (09:52 +0000)]
Fix for PR30639: CGDebugInfo Null dereference with OpenMP array
access, by Erich Keane

OpenMP creates a variable array type with a a null size-expr. The Debug
generation failed to due to this. This patch corrects the openmp
implementation, updates the tests, and adds a new one for this
condition.

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

llvm-svn: 284110

7 years agoRecommit r283538 "[clang-move] Support moving multiple classes in one run."
Haojian Wu [Thu, 13 Oct 2016 08:48:42 +0000 (08:48 +0000)]
Recommit r283538 "[clang-move] Support moving multiple classes in one run."

llvm-svn: 284109

7 years ago[X86] Basic additions to support RegCall Calling Convention.
Oren Ben Simhon [Thu, 13 Oct 2016 07:53:43 +0000 (07:53 +0000)]
[X86] Basic additions to support RegCall Calling Convention.

The Register Calling Convention (RegCall) was introduced by Intel to optimize parameter transfer on function call.
This calling convention ensures that as many values as possible are passed or returned in registers.
This commit presents the basic additions to LLVM CodeGen in order to support RegCall in X86.

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

llvm-svn: 284108

7 years agoSilence unused warning in non-assert builds.
Daniel Jasper [Thu, 13 Oct 2016 06:39:44 +0000 (06:39 +0000)]
Silence unused warning in non-assert builds.

llvm-svn: 284107

7 years ago[AVX-512] Fix v16i32 zero extending shuffle test case so it's really zero extend.
Craig Topper [Thu, 13 Oct 2016 05:41:01 +0000 (05:41 +0000)]
[AVX-512] Fix v16i32 zero extending shuffle test case so it's really zero extend.

llvm-svn: 284106

7 years ago[AVX-512] Teach shuffle lowering to recognize 512-bit zero extends.
Craig Topper [Thu, 13 Oct 2016 05:29:41 +0000 (05:29 +0000)]
[AVX-512] Teach shuffle lowering to recognize 512-bit zero extends.

llvm-svn: 284105

7 years ago[AVX-512] Add tests for basic 512-bit zero extending shuffle patterns. Code will...
Craig Topper [Thu, 13 Oct 2016 05:29:37 +0000 (05:29 +0000)]
[AVX-512] Add tests for basic 512-bit zero extending shuffle patterns. Code will be improved in a future commit.

llvm-svn: 284104

7 years agoRemove a FIXME that I forgot about. NFC.
Diana Picus [Thu, 13 Oct 2016 05:28:55 +0000 (05:28 +0000)]
Remove a FIXME that I forgot about. NFC.

Sorry about the noise.

llvm-svn: 284103

7 years ago[X86] Simplify the lowering code for extracting and inserting subvectors.
Craig Topper [Thu, 13 Oct 2016 04:14:47 +0000 (04:14 +0000)]
[X86] Simplify the lowering code for extracting and inserting subvectors.

We don't need to check if AVX is enabled. It's implied by the operation action being set to Custom.
We don't need to check both the input and output type widths. We only need to check the type that's being inserted or extracted. The other type is known to be a legal type and we can assume its a different width.

llvm-svn: 284102

7 years agoRevert r282345 - Use __attribute__((internal_linkage)) when available.
Eric Fiselier [Thu, 13 Oct 2016 04:07:58 +0000 (04:07 +0000)]
Revert r282345 - Use __attribute__((internal_linkage)) when available.

llvm-svn: 284101

7 years agoFix Python binding generation build step on Windows
Vadim Macagon [Thu, 13 Oct 2016 04:07:22 +0000 (04:07 +0000)]
Fix Python binding generation build step on Windows

Summary:
If Python is installed to a location that contains spaces
(e.g. "C:\Program Files\Python3") then the build fails while attempting
to run the modify-python-lldb.py script because the path to the Python
executable is not double-quoted before being passed to the shell. The
fix consists of letting Python handle the formatting of the command
line, since subprocess.Popen() is perfectly capable of handling paths
containing spaces if it's given the command and arguments as a list
instead of a single pre-formatted string.

Reviewers: zturner, clayborg

Subscribers: lldb-commits

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

llvm-svn: 284100

7 years agoMemory-SSA: strengthen defClobbersUseOrDef interface
Sebastian Pop [Thu, 13 Oct 2016 03:23:33 +0000 (03:23 +0000)]
Memory-SSA: strengthen defClobbersUseOrDef interface

As Danny pointed out, defClobbersUseOrDef should use MemoryLocOrCall to make
sure fences are properly handled.

llvm-svn: 284099

7 years agocommit back "GVN-hoist: fix store past load dependence analysis (PR30216, PR30499)"
Sebastian Pop [Thu, 13 Oct 2016 01:39:10 +0000 (01:39 +0000)]
commit back "GVN-hoist: fix store past load dependence analysis (PR30216, PR30499)"

This is with an extra change to avoid calling MemoryLocation::get() on a call instruction.

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

llvm-svn: 284098

7 years ago[AArch64][RegisterBankInfo] Provide alternative mappings for 64-bit load
Quentin Colombet [Thu, 13 Oct 2016 01:01:23 +0000 (01:01 +0000)]
[AArch64][RegisterBankInfo] Provide alternative mappings for 64-bit load

This allows RegBankSelect in greedy mode to get rid some of the cross
register bank copies when loads are involved in the chain of
computation.

llvm-svn: 284097

7 years agoCorrect PrivateLinkage for COFF
Reid Kleckner [Thu, 13 Oct 2016 00:55:24 +0000 (00:55 +0000)]
Correct PrivateLinkage for COFF

- Use storage class C_STAT for 'PrivateLinkage' The storage class for
  PrivateLinkage should equal to the Internal Linkage.

- Set 'PrivateGlobalPrefix' from "L" to ".L" for MM_WinCOFF (includes
  x86_64) MM_WinCOFF has empty GlobalPrefix '\0' so PrivateGlobalPrefix
  "L" may conflict to the normal symbol name starting with 'L'.

Based on a patch by Han Sangjin! Manually updated test cases.

llvm-svn: 284096

7 years agoAdd "opt" to the list of test dependencies.
Peter Collingbourne [Thu, 13 Oct 2016 00:49:21 +0000 (00:49 +0000)]
Add "opt" to the list of test dependencies.

We've started using it in the ThinLTO tests.

Also remove a repeated dependency on llvm-nm.

llvm-svn: 284095

7 years ago[AArch64][RegisterBankInfo] Provide alternative mappings for G_BITCASTs.
Quentin Colombet [Thu, 13 Oct 2016 00:34:48 +0000 (00:34 +0000)]
[AArch64][RegisterBankInfo] Provide alternative mappings for G_BITCASTs.

Thanks to this patch, RegBankSelect is able to get rid of some register
bank copies as demonstrated in the test case.

llvm-svn: 284094

7 years agoRevert "GVN-hoist: fix store past load dependence analysis (PR30216, PR30499)"
Reid Kleckner [Thu, 13 Oct 2016 00:18:26 +0000 (00:18 +0000)]
Revert "GVN-hoist: fix store past load dependence analysis (PR30216, PR30499)"

This CL didn't actually address the test case in PR30499, and clang
still crashes.

Also revert dependent change "Memory-SSA cleanup of clobbers interface, NFC"

Reverts r283965 and r283967.

llvm-svn: 284093

7 years agoMove a utility function to Strings.cpp.
Rui Ueyama [Thu, 13 Oct 2016 00:13:15 +0000 (00:13 +0000)]
Move a utility function to Strings.cpp.

So that we can use the function from anywhere.

llvm-svn: 284092

7 years ago[AArch64][RegisterBankInfo] Describe cross regbank copies statically.
Quentin Colombet [Thu, 13 Oct 2016 00:12:06 +0000 (00:12 +0000)]
[AArch64][RegisterBankInfo] Describe cross regbank copies statically.

NFC.

llvm-svn: 284091

7 years ago[AArch64][RegisterBankInfo] Use static mapping for same bank G_BITCAST.
Quentin Colombet [Thu, 13 Oct 2016 00:12:04 +0000 (00:12 +0000)]
[AArch64][RegisterBankInfo] Use static mapping for same bank G_BITCAST.

NFC.

llvm-svn: 284090

7 years ago[AArch64][MachineLegalizer] Mark more G_BITCAST as legal.
Quentin Colombet [Thu, 13 Oct 2016 00:12:01 +0000 (00:12 +0000)]
[AArch64][MachineLegalizer] Mark more G_BITCAST as legal.

Basically any vector types that fits in a 32-bit register is also valid
as far as copies are concerned.

llvm-svn: 284089

7 years ago[AArch64][RegisterBankInfo] Bump the cost of vector loads.
Quentin Colombet [Thu, 13 Oct 2016 00:11:59 +0000 (00:11 +0000)]
[AArch64][RegisterBankInfo] Bump the cost of vector loads.

This does not change anything yet, because we do not offer any
alternative mapping.

llvm-svn: 284088