platform/upstream/llvm.git
7 years agoAMDGPU: Fix use-after-frees
Nicolai Haehnle [Fri, 14 Oct 2016 09:03:04 +0000 (09:03 +0000)]
AMDGPU: Fix use-after-frees

Reviewers: arsenm, tstellarAMD

Subscribers: kzhuravl, wdng, yaxunl, tony-tye, llvm-commits

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

llvm-svn: 284215

7 years agoXFAIL aligned allocation tests for older Clang versions
Eric Fiselier [Fri, 14 Oct 2016 08:47:09 +0000 (08:47 +0000)]
XFAIL aligned allocation tests for older Clang versions

llvm-svn: 284214

7 years ago[x86][ms-inline-asm] use of "jmp short" in asm is not supported
Michael Zuckerman [Fri, 14 Oct 2016 08:13:27 +0000 (08:13 +0000)]
[x86][ms-inline-asm] use of "jmp short" in asm is not supported

Test linked to: https://reviews.llvm.org/D24957

Committing in the name of Ziv Izhar: After check-all and LGTM .

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

llvm-svn: 284213

7 years ago[clang-tidy] Fix readability-braces-around-statements false positive
Marek Kurdej [Fri, 14 Oct 2016 08:10:08 +0000 (08:10 +0000)]
[clang-tidy] Fix readability-braces-around-statements false positive

Summary:
This fixes a false-positive e.g. when string literals are returned from if statement.

This patch includes as well a small fix to includes and renames of the test suite that collided with the name of the check.

Reviewers: alexfh, hokein

Subscribers: hokein

Tags: #clang-tools-extra

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

llvm-svn: 284212

7 years ago[x86][ms-inline-asm] use of "jmp short" in asm is not supported
Michael Zuckerman [Fri, 14 Oct 2016 08:09:40 +0000 (08:09 +0000)]
[x86][ms-inline-asm] use of "jmp short" in asm is not supported

Committing in the name of Ziv Izhar: After check-all and LGTM .

The following patch is for compatability with Microsoft.
Microsoft ignores the keyword "short" when used after a jmp, for example:
__asm {
      jmp short label
      label:
      }

A test for that patch will be added in another patch, since it's located in clang's codegen tests. Link will be added shortly.
link to test: https://reviews.llvm.org/D24958

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

llvm-svn: 284211

7 years agoXFAIL aligned allocation test failures with UBSAN
Eric Fiselier [Fri, 14 Oct 2016 07:49:15 +0000 (07:49 +0000)]
XFAIL  aligned allocation test failures with UBSAN

llvm-svn: 284210

7 years agoAdd void_t and invoke feature test macros
Eric Fiselier [Fri, 14 Oct 2016 07:19:52 +0000 (07:19 +0000)]
Add void_t and invoke feature test macros

llvm-svn: 284209

7 years agoUpdate OS X ABI list
Eric Fiselier [Fri, 14 Oct 2016 06:49:30 +0000 (06:49 +0000)]
Update OS X ABI list

llvm-svn: 284208

7 years agoCorrect ABI changelog revision number
Eric Fiselier [Fri, 14 Oct 2016 06:47:37 +0000 (06:47 +0000)]
Correct ABI changelog revision number

llvm-svn: 284207

7 years agoImplement P0035R4 -- Add C++17 aligned allocation functions
Eric Fiselier [Fri, 14 Oct 2016 06:46:30 +0000 (06:46 +0000)]
Implement P0035R4 -- Add C++17 aligned allocation functions

Summary:
This patch implements the library side of P0035R4. The implementation is thanks to @rsmith.

In addition to the C++17 implementation, the library implementation can be explicitly turned on using `-faligned-allocation` in all dialects.

Reviewers: mclow.lists, rsmith

Subscribers: rsmith, cfe-commits

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

llvm-svn: 284206

7 years agoCleanup LIT testing doc
Eric Fiselier [Fri, 14 Oct 2016 06:15:27 +0000 (06:15 +0000)]
Cleanup LIT testing doc

llvm-svn: 284205

7 years ago[DAGCombiner] Teach createBuildVecShuffle to handle cases where input vectors are...
Craig Topper [Fri, 14 Oct 2016 06:00:42 +0000 (06:00 +0000)]
[DAGCombiner] Teach createBuildVecShuffle to handle cases where input vectors are less than half of the output vector size.

This will be needed by a future commit to support sign/zero extending from v8i8 to v8i64 which requires a sign/zero_extend_vector_inreg to be created which requires v8i8 to be concatenated upto v64i8 and goes through this code.

llvm-svn: 284204

7 years agoIn preparation for removing getNameWithPrefix off of TargetMachine,
Eric Christopher [Fri, 14 Oct 2016 05:47:41 +0000 (05:47 +0000)]
In preparation for removing getNameWithPrefix off of TargetMachine,
sink the current behavior into the callers and sink
TargetMachine::getNameWithPrefix into TargetMachine::getSymbol.

llvm-svn: 284203

7 years agoTidy the calls to getCurrentSection().first -> getCurrentSectionOnly to help
Eric Christopher [Fri, 14 Oct 2016 05:47:37 +0000 (05:47 +0000)]
Tidy the calls to getCurrentSection().first -> getCurrentSectionOnly to help
readability a bit.

llvm-svn: 284202

7 years agoTidy up example of getting the pointer size.
Eric Christopher [Fri, 14 Oct 2016 05:45:46 +0000 (05:45 +0000)]
Tidy up example of getting the pointer size.

llvm-svn: 284201

7 years agoRemove two ABI symbols added after the 3.9 release
Eric Fiselier [Fri, 14 Oct 2016 05:29:46 +0000 (05:29 +0000)]
Remove two ABI symbols added after the 3.9 release

llvm-svn: 284200

7 years agoAdd ABI changelog entry for <any>
Eric Fiselier [Fri, 14 Oct 2016 05:10:06 +0000 (05:10 +0000)]
Add ABI changelog entry for <any>

llvm-svn: 284199

7 years agoSort ABI lists by name so that changes don't generate big diffs
Eric Fiselier [Fri, 14 Oct 2016 05:04:00 +0000 (05:04 +0000)]
Sort ABI lists by name so that changes don't generate big diffs

llvm-svn: 284198

7 years ago[ELF/AMDGPU]: Add support for new relocations
Konstantin Zhuravlyov [Fri, 14 Oct 2016 04:51:43 +0000 (04:51 +0000)]
[ELF/AMDGPU]: Add support for new relocations

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

llvm-svn: 284197

7 years ago[AMDGPU] Emit 32-bit lo/hi got and pc relative variant kinds for external and global...
Konstantin Zhuravlyov [Fri, 14 Oct 2016 04:37:34 +0000 (04:37 +0000)]
[AMDGPU] Emit 32-bit lo/hi got and pc relative variant kinds for external and global address space variables

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

llvm-svn: 284196

7 years ago[AMDGPU] Add 32-bit lo/hi got and pc relative variant kinds and emit appropriate...
Konstantin Zhuravlyov [Fri, 14 Oct 2016 04:21:32 +0000 (04:21 +0000)]
[AMDGPU] Add 32-bit lo/hi got and pc relative variant kinds and emit appropriate relocations

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

llvm-svn: 284195

7 years agoRevert r284193 - it is not correct on OS X
Eric Fiselier [Fri, 14 Oct 2016 04:21:24 +0000 (04:21 +0000)]
Revert r284193 - it is not correct on OS X

llvm-svn: 284194

7 years agoRe-export two previously exported std::string functions.
Eric Fiselier [Fri, 14 Oct 2016 04:14:24 +0000 (04:14 +0000)]
Re-export two previously exported std::string functions.

These functions were removed from the dylib sometime between the 3.9 release
and now. This patch manually exports them to re-gain ABI compatibility.

llvm-svn: 284193

7 years agoAdd ABI list for 3.9 linux
Eric Fiselier [Fri, 14 Oct 2016 04:06:19 +0000 (04:06 +0000)]
Add ABI list for 3.9 linux

llvm-svn: 284192

7 years ago[Support/ELF/AMDGPU] Add 32-bit lo/hi got and pc relative relocations
Konstantin Zhuravlyov [Fri, 14 Oct 2016 04:03:49 +0000 (04:03 +0000)]
[Support/ELF/AMDGPU] Add 32-bit lo/hi got and pc relative relocations

Added relocation names:
  - R_AMDGPU_GOTPCREL32_LO
  - R_AMDGPU_GOTPCREL32_HI
  - R_AMDGPU_REL32_LO
  - R_AMDGPU_REL32_HI

AMDGPU isa only supports 32-bit immediates. In order to access 64-bit address we need to generate 32-bit lo/hi relocations, and do the right math (separate patch). Currently we only generate one 32 bit relocation for lower bits for each access, losing higher bits. Hence we need relocations listed above.

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

llvm-svn: 284191

7 years agoAdd `llvm::` in clEnumVal macro (NFC)
Mehdi Amini [Fri, 14 Oct 2016 03:54:46 +0000 (03:54 +0000)]
Add `llvm::` in clEnumVal macro (NFC)

This allows to use llvm:cl::opt without `using namespace llvm;`

llvm-svn: 284190

7 years agoAdd 3.9 symbol list for OS X
Eric Fiselier [Fri, 14 Oct 2016 02:55:43 +0000 (02:55 +0000)]
Add 3.9 symbol list for OS X

llvm-svn: 284189

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