platform/upstream/llvm.git
6 years agoDon't ignore addend in getOffset.
Rafael Espindola [Wed, 4 Apr 2018 19:13:30 +0000 (19:13 +0000)]
Don't ignore addend in getOffset.

We were ignoring the addend if the piece was dead. I don't expect this
to make a difference in any real world situations, but it is simpler
anyway.

llvm-svn: 329219

6 years ago[Analysis] Support aligned new/delete functions.
Eric Fiselier [Wed, 4 Apr 2018 19:01:51 +0000 (19:01 +0000)]
[Analysis] Support aligned new/delete functions.

Summary:
Clang's __builtin_operator_new/delete was recently taught about the aligned allocation overloads (r328134). This patch makes LLVM aware of them as well.
This allows the compiler to perform certain optimizations including eliding new/delete calls.

Reviewers: rsmith, majnemer, dblaikie, vsk, bkramer

Reviewed By: bkramer

Subscribers: ckennelly, llvm-commits

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

llvm-svn: 329218

6 years agoRevert "[Analysis] Support aligned new/delete functions."
Eric Fiselier [Wed, 4 Apr 2018 18:23:00 +0000 (18:23 +0000)]
Revert "[Analysis] Support aligned new/delete functions."

This reverts commit bee3bbd9bdd3ab3364b8fb0cdb6326bc1ae740e0.

llvm-svn: 329217

6 years ago[AArch64] Change std::sort to llvm::sort in response to r327219
Mandeep Singh Grang [Wed, 4 Apr 2018 18:20:28 +0000 (18:20 +0000)]
[AArch64] Change std::sort to llvm::sort in response to r327219

Summary:
r327219 added wrappers to std::sort which randomly shuffle the container before sorting.
This will help in uncovering non-determinism caused due to undefined sorting
order of objects having the same key.

To make use of that infrastructure we need to invoke llvm::sort instead of std::sort.

Note: This patch is one of a series of patches to replace *all* std::sort to llvm::sort. Refer the comments section in D44363 for a list of all the required patches.

Reviewers: t.p.northover, jmolloy, RKSimon, rengolin

Reviewed By: rengolin

Subscribers: dexonsmith, rengolin, javed.absar, kristof.beyls, llvm-commits

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

llvm-svn: 329216

6 years ago[Analysis] Support aligned new/delete functions.
Eric Fiselier [Wed, 4 Apr 2018 18:12:01 +0000 (18:12 +0000)]
[Analysis] Support aligned new/delete functions.

Summary:
Clang's __builtin_operator_new/delete was recently taught about the aligned allocation overloads (r328134). This patch makes LLVM aware of them as well.
This allows the compiler to perform certain optimizations including eliding new/delete calls.

Reviewers: rsmith, majnemer, dblaikie, vsk, bkramer

Reviewed By: bkramer

Subscribers: ckennelly, llvm-commits

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

llvm-svn: 329215

6 years ago[Polly][IslAst] Fix minimal dependence distance.
Huihui Zhang [Wed, 4 Apr 2018 18:08:13 +0000 (18:08 +0000)]
[Polly][IslAst] Fix minimal dependence distance.

Summary:
When checking the parallelism of a scheduling dimension, we first check if excluding reduction dependences the loop is parallel or not.
If the loop is not parallel, then we need to return the minimal dependence distance of all data dependences, including the previously subtracted reduction dependences.

Reviewers: grosser, Meinersbur, efriedma, eli.friedman, jdoerfert, bollu

Reviewed By: Meinersbur

Subscribers: llvm-commits, pollydev

Tags: #polly

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

llvm-svn: 329214

6 years ago[MachineOutliner] Fix typo; NFC
Jessica Paquette [Wed, 4 Apr 2018 18:07:07 +0000 (18:07 +0000)]
[MachineOutliner] Fix typo; NFC

There was a typo in an unreachable statement in one of the outliner target
hooks.

llvm-svn: 329213

6 years ago[CMake] Support for monorepo layout
Petr Hosek [Wed, 4 Apr 2018 17:57:15 +0000 (17:57 +0000)]
[CMake] Support for monorepo layout

Support finding libcxx sources in monorepo style layout.

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

llvm-svn: 329212

6 years ago[X86] Separate BSWAP32r and BSWAP64r scheduling data in SandyBridge/Haswell/Broadwell...
Craig Topper [Wed, 4 Apr 2018 17:54:19 +0000 (17:54 +0000)]
[X86] Separate BSWAP32r and BSWAP64r scheduling data in SandyBridge/Haswell/Broadwell/Skylake scheduler models.

The BSWAP64r version is 2 uops and BSWAP32r is only 1 uop. The regular expressions also looked for a non-existant BSWAP16r.

llvm-svn: 329211

6 years agoAdd simple runtime tests for shadowcallstack
Vlad Tsyrklevich [Wed, 4 Apr 2018 17:53:33 +0000 (17:53 +0000)]
Add simple runtime tests for shadowcallstack

Summary:
ShadowCallStack does not yet have a runtime provided by compiler-rt, but
this change includes simple tests that make use of a very minimal
runtime in test/shadowcallstack/minimal_runtime.h

Reviewers: pcc, kcc, delcypher, eugenis, filcab

Reviewed By: pcc

Subscribers: kubamracek, mgorny, delcypher, llvm-commits, #sanitizers, kcc

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

llvm-svn: 329210

6 years agoFix a compilation failure with non MSVC compilers.
Zachary Turner [Wed, 4 Apr 2018 17:41:05 +0000 (17:41 +0000)]
Fix a compilation failure with non MSVC compilers.

llvm-svn: 329209

6 years ago[CMake] Support for monorepo layout
Petr Hosek [Wed, 4 Apr 2018 17:40:59 +0000 (17:40 +0000)]
[CMake] Support for monorepo layout

Support finding libcxx and libunwind sources in monorepo style layout.

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

llvm-svn: 329208

6 years ago[llvm-pdbutil] Add the ability to explain binary files.
Zachary Turner [Wed, 4 Apr 2018 17:29:09 +0000 (17:29 +0000)]
[llvm-pdbutil] Add the ability to explain binary files.

Using this, you can use llvm-pdbutil to export the contents of a
stream to a binary file, then run explain on the binary file so
that it treats the offset as an offset into the stream instead
of an offset into a file.  This makes it easy to compare the
contents of the same stream from two different files.

llvm-svn: 329207

6 years ago[Power9]Legalize and emit code for quad-precision fma instructions
Lei Huang [Wed, 4 Apr 2018 16:43:50 +0000 (16:43 +0000)]
[Power9]Legalize and emit code for quad-precision fma instructions

Legalize and emit code for the following quad-precision fma:

  * xsmaddqp
  * xsnmaddqp
  * xsmsubqp
  * xsnmsubqp

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

llvm-svn: 329206

6 years ago[CMake] Support statically linked libc++abi and libunwind
Petr Hosek [Wed, 4 Apr 2018 16:27:33 +0000 (16:27 +0000)]
[CMake] Support statically linked libc++abi and libunwind

This expands the CMake check to handle both statically and dynamically
linked version of libc++abi and libunwind and matches the implemnetation
used elsewhere in LLVM.

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

llvm-svn: 329205

6 years ago[sanitizer] Split stacktrace/symbolizer: Windows unwind
Kostya Kortchinsky [Wed, 4 Apr 2018 15:23:30 +0000 (15:23 +0000)]
[sanitizer] Split stacktrace/symbolizer: Windows unwind

Summary:
The purpose of this set of changes is to separate stackframe/symbolizer support into their own RT within sanitizer_common.
Sanitizers with no use for those could then be built without the extraneous dependencies pulled in by the default visibility interface functions.
I am aiming to do small changes for specific platforms.

In this one, we split the unwind functions from sanitizer_win.cc into their own sanitizer_unwind_win.cc.

Reviewers: alekseyshl, rnk

Reviewed By: alekseyshl, rnk

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

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

llvm-svn: 329204

6 years ago[ELF] - X86_64: Use white list for relocations checked by isPicRel.
George Rimar [Wed, 4 Apr 2018 15:21:21 +0000 (15:21 +0000)]
[ELF] - X86_64: Use white list for relocations checked by isPicRel.

isPicRel is used to check if we want to create the dynamic relocations.
Not all of the dynamic relocations we create are passing through this
check, but those that are, probably better be whitelisted.

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

llvm-svn: 329203

6 years agoFix build breakage from r329201
Pavel Labath [Wed, 4 Apr 2018 14:54:08 +0000 (14:54 +0000)]
Fix build breakage from r329201

Some compilers do not like having an enum type and a variable with the
same name (AccelTableKind). I rename the variable to TheAccelTableKind.

Suggestions for a better name welcome.

llvm-svn: 329202

6 years agoRe-commit r329179 after fixing build&test issues
Pavel Labath [Wed, 4 Apr 2018 14:42:14 +0000 (14:42 +0000)]
Re-commit r329179 after fixing build&test issues

- MSVC was not OK with a static_assert referencing a non-static member
  variable, even though it was just in a sizeof(expression). I move the
  assert into the emit function, where it is probably more useful.
- Tests were failing in builds which did not have the X86 target
  configured. Since this functionality is not target-specific, I have
  removed the target specifiers from the .ll files.

llvm-svn: 329201

6 years ago[llvm-exegesis] Temporarily disable a few tests.
Clement Courbet [Wed, 4 Apr 2018 14:32:09 +0000 (14:32 +0000)]
[llvm-exegesis] Temporarily disable a few tests.

These are failing on clang-ppc64le-linux-lnt, though the subdirectory is
not even supposed to be built in CMakeLists. Disable the tests until we
understand what's going on.

llvm-svn: 329200

6 years ago[libcxx][test] Fix fs::proximate tests on platforms where /net exists.
Jan Korous [Wed, 4 Apr 2018 14:23:51 +0000 (14:23 +0000)]
[libcxx][test] Fix fs::proximate tests on platforms where /net exists.

Following Eric's patch.

llvm-svn: 329199

6 years ago[InstCombine] [NFC] Add tests for getting rid of select of bittest (PR36950 / PR17564)
Roman Lebedev [Wed, 4 Apr 2018 14:10:13 +0000 (14:10 +0000)]
[InstCombine] [NFC] Add tests for getting rid of select of bittest (PR36950 / PR17564)

Summary: See [[ https://bugs.llvm.org/show_bug.cgi?id=36950 | PR36950 ]], [[ https://bugs.llvm.org/show_bug.cgi?id=17564 | PR17564 ]], D45065, D45108

Reviewers: spatel, craig.topper

Reviewed By: spatel

Subscribers: llvm-commits

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

llvm-svn: 329198

6 years ago[AMDGPU][MC] Enabled instruction TBUFFER_LOAD_FORMAT_XYZ for SI/CI
Dmitry Preobrazhensky [Wed, 4 Apr 2018 13:54:55 +0000 (13:54 +0000)]
[AMDGPU][MC] Enabled instruction TBUFFER_LOAD_FORMAT_XYZ for SI/CI

See bug 36958: https://bugs.llvm.org/show_bug.cgi?id=36958

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

Reviewers: artem.tamazov, arsenm, timcorringham
llvm-svn: 329197

6 years ago[SLPVectorizer][X86] Regenerate some tests. NFCI
Simon Pilgrim [Wed, 4 Apr 2018 13:53:51 +0000 (13:53 +0000)]
[SLPVectorizer][X86] Regenerate some tests. NFCI

llvm-svn: 329196

6 years ago[llvm-exegesis] Temporarily disable some tests.
Clement Courbet [Wed, 4 Apr 2018 13:33:21 +0000 (13:33 +0000)]
[llvm-exegesis] Temporarily disable some tests.

The tests fail on clang-x86-windows-msvc2015:
unknown file: error: SEH exception with code 0x3221225477 thrown in the test body.

llvm-svn: 329195

6 years ago[libcxx][test] Improve assert message
Jan Korous [Wed, 4 Apr 2018 13:31:39 +0000 (13:31 +0000)]
[libcxx][test] Improve assert message

llvm-svn: 329194

6 years ago[llvm-exegesis] Only run unit tests on x86_64 hosts.
Clement Courbet [Wed, 4 Apr 2018 13:30:23 +0000 (13:30 +0000)]
[llvm-exegesis] Only run unit tests on x86_64 hosts.

llvm-svn: 329193

6 years ago[X86][Btver2] Strip unnecessary check prefixes from resources tests
Simon Pilgrim [Wed, 4 Apr 2018 13:25:45 +0000 (13:25 +0000)]
[X86][Btver2] Strip unnecessary check prefixes from resources tests

llvm-svn: 329192

6 years agoRemove llvm-build's --write-make-fragment which looks like a remnant from the autocon...
Nico Weber [Wed, 4 Apr 2018 13:23:24 +0000 (13:23 +0000)]
Remove llvm-build's --write-make-fragment which looks like a remnant from the autoconf build.

llvm-svn: 329191

6 years agoRevert r329179 (and follow-up unsuccessful fix attempts 329184, 329186); it doesn...
Nico Weber [Wed, 4 Apr 2018 13:06:22 +0000 (13:06 +0000)]
Revert r329179 (and follow-up unsuccessful fix attempts 329184, 329186); it doesn't build.

llvm-svn: 329190

6 years ago[XRay][compiler-rt] Build XRay runtime for OpenBSD
Dean Michael Berris [Wed, 4 Apr 2018 13:04:15 +0000 (13:04 +0000)]
[XRay][compiler-rt] Build XRay runtime for OpenBSD

Summary:
This is D45125; the patch enables the build of XRay on OpenBSD. We also
introduce some OpenBSD specific changes to the runtime implementation,
involving how we get the TSC rate through the syscall interface specific
to OpenBSD.

Reviewers: dberris

Authored by: devnexen

Subscribers: dberris, mgorny, krytarowski, llvm-commits

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

llvm-svn: 329189

6 years agoAdd AMDPAL Code Conventions section to AMD docs
Tim Corringham [Wed, 4 Apr 2018 13:02:09 +0000 (13:02 +0000)]
Add AMDPAL Code Conventions section to AMD docs

Summary:
This is a first version of the AMDPAL code conventions.
Further updates will undoubtably be required to fully
document AMDPAL.

Subscribers: nhaehnle, llvm-commits

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

llvm-svn: 329188

6 years ago[AMDGPU][MC] Added support of 3-element addresses for MIMG instructions
Dmitry Preobrazhensky [Wed, 4 Apr 2018 13:01:17 +0000 (13:01 +0000)]
[AMDGPU][MC] Added support of 3-element addresses for MIMG instructions

See bug 35999: https://bugs.llvm.org/show_bug.cgi?id=35999

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

Reviewers: artem.tamazov, arsenm, timcorringham
llvm-svn: 329187

6 years agoAttempt to fix bots more after r329179.
Nico Weber [Wed, 4 Apr 2018 12:58:49 +0000 (12:58 +0000)]
Attempt to fix bots more after r329179.

llvm-svn: 329186

6 years ago[llvm-exegesis] Add missing link libraries.
Clement Courbet [Wed, 4 Apr 2018 12:58:41 +0000 (12:58 +0000)]
[llvm-exegesis] Add missing link libraries.

llvm-svn: 329185

6 years agoAttempt to fix bots after r329179.
Nico Weber [Wed, 4 Apr 2018 12:54:34 +0000 (12:54 +0000)]
Attempt to fix bots after r329179.

llvm-svn: 329184

6 years ago[XRay][clang] Allow clang to build XRay instrumented binaries in OpenBSD
Dean Michael Berris [Wed, 4 Apr 2018 12:47:49 +0000 (12:47 +0000)]
[XRay][clang] Allow clang to build XRay instrumented binaries in OpenBSD

Summary:
This patch was originally reviewed in D45126. It enables clang to add
the XRay runtime and the link-time dependencies for XRay instrumentation
in OpenBSD.

Landing for devnexen.

Reviewers: brad, dberris

Subscribers: dberris, krytarowski, cfe-commits

Author: devnexen

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

llvm-svn: 329183

6 years ago[clang-tidy] Rename -warnings-as-errors tests. NFC.
Alexander Kornienko [Wed, 4 Apr 2018 12:40:00 +0000 (12:40 +0000)]
[clang-tidy] Rename -warnings-as-errors tests. NFC.

The tests will be more discoverable with proper names.

llvm-svn: 329182

6 years agoSort targetgen calls in lib/Target/*/CMakeLists.
Nico Weber [Wed, 4 Apr 2018 12:37:44 +0000 (12:37 +0000)]
Sort targetgen calls in lib/Target/*/CMakeLists.

Makes it easier to see mistakes such as the one fixed in r329178 and makes
the different target CMakeLists more consistent.

Also remove some stale-looking comments from the Nios2 target cmakefile.

No intended behavior change.

llvm-svn: 329181

6 years ago[ELF] - Use early return. NFC.
George Rimar [Wed, 4 Apr 2018 12:36:21 +0000 (12:36 +0000)]
[ELF] - Use early return. NFC.

llvm-svn: 329180

6 years ago[CodeGen] Generate DWARF v5 Accelerator Tables
Pavel Labath [Wed, 4 Apr 2018 12:28:20 +0000 (12:28 +0000)]
[CodeGen] Generate DWARF v5 Accelerator Tables

Summary:
This patch adds a DwarfAccelTableEmitter class, which generates an
accelerator table, as specified in DWARF v5 standard. At the moment it
only generates a DIE offset column and (if we are indexing more than one
compile unit) a CU column.

Indexing type units is not currently supported, as we don't even have
the ability to generate DWARF v5-compatible compile units.

The implementation is not data-source agnostic like the one generating
apple tables. This was not necessary as we currently only have one user
of this code, and without a second user it was not obvious to me how to
best abstract this. (The difference between these tables and the apple
ones is that they need a lot more metadata about the debug info they are
indexing).

The generation is triggered by the --accel-tables argument, which
supersedes the --dwarf-accel-tables arg -- the latter was a simple
on-off switch, but not we can choose between two kinds of accelerator
tables we can generate.

This is tested by parsing the generated tables with llvm-dwarfdump and
the DWARFVerifier, and I've also checked that GNU readelf is able to
make sense of the tables.

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

llvm-svn: 329179

6 years agoRemove duplicate tablegen lines from AVR target.
Nico Weber [Wed, 4 Apr 2018 12:27:43 +0000 (12:27 +0000)]
Remove duplicate tablegen lines from AVR target.

They were added in r285274, in what looks like a merge mishap.
AVRGenMCCodeEmitter.inc is the only non-dupe tablegen invocation added in that
revision.

Also sort the tablegen lines to make this easier to spot in the future.

llvm-svn: 329178

6 years ago[llvm-exegesis] Do not initialize FileDescriptor when libpfm is not
Clement Courbet [Wed, 4 Apr 2018 12:12:38 +0000 (12:12 +0000)]
[llvm-exegesis] Do not initialize FileDescriptor when libpfm is not
available.

llvm-svn: 329177

6 years ago[llvm-exegesis] Fix compilation on lld-x86_64-darwin13
Clement Courbet [Wed, 4 Apr 2018 12:01:46 +0000 (12:01 +0000)]
[llvm-exegesis] Fix compilation on lld-x86_64-darwin13

YAMLTraits does not know how to serialize `size_t` portably. Use `int`
instead.

llvm-svn: 329176

6 years ago[llvm-exegesis][NFC] Fix compilation warning.
Clement Courbet [Wed, 4 Apr 2018 12:01:43 +0000 (12:01 +0000)]
[llvm-exegesis][NFC] Fix compilation warning.

llvm-svn: 329175

6 years ago[llvm-exegesis][NFC] Fix a few warnings.
Clement Courbet [Wed, 4 Apr 2018 12:01:38 +0000 (12:01 +0000)]
[llvm-exegesis][NFC] Fix a few warnings.

llvm-svn: 329174

6 years ago[Tablegen] Slightly refactor method SubtargetEmitter::EmitExtraProcessorInfo.
Andrea Di Biagio [Wed, 4 Apr 2018 11:53:13 +0000 (11:53 +0000)]
[Tablegen] Slightly refactor method SubtargetEmitter::EmitExtraProcessorInfo.

This patch moves most of the logic from EmitExtraProcessorInfo to a couple of
helper functions. No functional change intended.

llvm-svn: 329173

6 years ago[llvm-exegesis] Fix build when libpfm is not available.
Clement Courbet [Wed, 4 Apr 2018 11:48:15 +0000 (11:48 +0000)]
[llvm-exegesis] Fix build when libpfm is not available.

llvm-svn: 329172

6 years ago[llvm-exegesis] Fix compilation on some clang versions.
Clement Courbet [Wed, 4 Apr 2018 11:45:53 +0000 (11:45 +0000)]
[llvm-exegesis] Fix compilation on some clang versions.

default initialization of an object of const type 'const llvm::DebugLoc' requires a user-provided default constructor.

llvm-svn: 329171

6 years agoMake helpers static. NFC.
Benjamin Kramer [Wed, 4 Apr 2018 11:45:11 +0000 (11:45 +0000)]
Make helpers static. NFC.

llvm-svn: 329170

6 years agoRe-land r329156 "Add llvm-exegesis tool."
Clement Courbet [Wed, 4 Apr 2018 11:37:06 +0000 (11:37 +0000)]
Re-land r329156 "Add llvm-exegesis tool."

Fixed to depend on and initialize the native target instead of X86.

llvm-svn: 329169

6 years ago[X86][CostModel] Use generic SSE levels instead of particular CPUs for shuffle costs
Simon Pilgrim [Wed, 4 Apr 2018 11:14:12 +0000 (11:14 +0000)]
[X86][CostModel] Use generic SSE levels instead of particular CPUs for shuffle costs

llvm-svn: 329168

6 years ago[libcxx][cmake] Remove libatomic temporarily from CMAKE_REQUIRED_LIBRARIES when confi...
Simon Dardis [Wed, 4 Apr 2018 11:05:03 +0000 (11:05 +0000)]
[libcxx][cmake] Remove libatomic temporarily from CMAKE_REQUIRED_LIBRARIES when configuring

When libcxx is built in tree for a host which requires libatomic, LLVM's
configuration steps will determine it is required and add it to
CMAKE_REQUIRED_LIBRARIES. When libcxx is later configured, it tests if it
has C++ atomics without libatomic. The test erroneously passes as libatomic
is already part of the set of required libraries.

In turn, a number of the atomic tests will fail as they require libatomic
but the test suite is configured not to use libatomic.

Address this by always dropping libatomic from the set of required libraries
before determining if LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB is true,
then restoring the set of required libraries.

Reviewers: EricWF

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

llvm-svn: 329167

6 years agoAMDGPU: Dimension-aware image intrinsics
Nicolai Haehnle [Wed, 4 Apr 2018 10:58:54 +0000 (10:58 +0000)]
AMDGPU: Dimension-aware image intrinsics

Summary:
These new image intrinsics contain the texture type as part of
their name and have each component of the address/coordinate as
individual parameters.

This is a preparatory step for implementing the A16 feature, where
coordinates are passed as half-floats or -ints, but the Z compare
value and texel offsets are still full dwords, making it difficult
or impossible to distinguish between A16 on or off in the old-style
intrinsics.

Additionally, these intrinsics pass the 'texfailpolicy' and
'cachectrl' as i32 bit fields to reduce operand clutter and allow
for future extensibility.

v2:
- gather4 supports 2darray images
- fix a bug with 1D images on SI

Change-Id: I099f309e0a394082a5901ea196c3967afb867f04

Reviewers: arsenm, rampitec, b-sumner

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

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

llvm-svn: 329166

6 years agoStructurizeCFG: Test for branch divergence correctly
Nicolai Haehnle [Wed, 4 Apr 2018 10:58:15 +0000 (10:58 +0000)]
StructurizeCFG: Test for branch divergence correctly

Fixes cases like the new test @nonuniform. In that test, %cc itself
is a uniform value; however, when reading it after the end of the loop in
basic block %if, its value is effectively non-uniform, so the branch is
non-uniform.

This problem was encountered in
https://bugs.freedesktop.org/show_bug.cgi?id=103743; however, this change
in itself is not sufficient to fix that bug, as there is another issue
in the AMDGPU backend.

As discovered after committing an earlier version of this change, this
exposes a subtle interaction between this pass and DivergenceAnalysis:
since we remove and re-create branch instructions, we can no longer rely
on DivergenceAnalysis for branches in subregions that were already
processed by the pass.

Explicitly remove branch instructions from DivergenceAnalysis to
avoid dangling pointers as a matter of defensive programming, and
change how we detect non-uniform subregions.

Change-Id: I32bbffece4a32f686fab54964dae1a5dd72949d4

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

llvm-svn: 329165

6 years agoAMDGPU: Fix copying i1 value out of loop with non-uniform exit
Nicolai Haehnle [Wed, 4 Apr 2018 10:57:58 +0000 (10:57 +0000)]
AMDGPU: Fix copying i1 value out of loop with non-uniform exit

Summary:
When an i1-value is defined inside of a loop and used outside of it, we
cannot simply use the SGPR bitmask from the loop's last iteration.

There are also useful and correct cases of an i1-value being copied between
basic blocks, e.g. when a condition is computed outside of a loop and used
inside it. The concept of dominators is not sufficient to capture what is
going on, so I propose the notion of "lane-dominators".

Fixes a bug encountered in Nier: Automata.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103743
Change-Id: If37b969ddc71d823ab3004aeafb9ea050e45bd9a

Reviewers: arsenm, rampitec

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

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

llvm-svn: 329164

6 years ago[AArch64] Add patterns matching (fabs (fsub x y)) to (fabd x y)
John Brawn [Wed, 4 Apr 2018 10:12:53 +0000 (10:12 +0000)]
[AArch64] Add patterns matching (fabs (fsub x y)) to (fabd x y)

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

llvm-svn: 329163

6 years ago[ELF] - Cleanup. NFCI.
George Rimar [Wed, 4 Apr 2018 09:39:05 +0000 (09:39 +0000)]
[ELF] - Cleanup. NFCI.

Rename field, added comments.

This is splitted from the D44894.
Requested to be committed as independent cleanup.

llvm-svn: 329162

6 years agoAs we don't use minor version anymore, let's remove it from the release notes too
Sylvestre Ledru [Wed, 4 Apr 2018 09:38:22 +0000 (09:38 +0000)]
As we don't use minor version anymore, let's remove it from the release notes too

llvm-svn: 329161

6 years ago[DAGCombine] Improve ReduceLoadWidth for SRL
Sam Parker [Wed, 4 Apr 2018 09:26:56 +0000 (09:26 +0000)]
[DAGCombine] Improve ReduceLoadWidth for SRL

Recommitting rL321259. Previosuly this caused an issue with PPCBE but
I didn't receieve a reproducer and didn't have the time to follow up.
If the issue appears again, please provide a reproducer so I can fix
it.

Original commit message:

If the SRL node is only used by an AND, we may be able to set the
ExtVT to the width of the mask, making the AND redundant. To support
this, another check has been added in isLegalNarrowLoad which queries
whether the load is valid.

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

llvm-svn: 329160

6 years ago[ELF] - Rename checkSectionOverlap() to checkSections(). NFC.
George Rimar [Wed, 4 Apr 2018 09:24:31 +0000 (09:24 +0000)]
[ELF] - Rename checkSectionOverlap() to checkSections(). NFC.

Renaming was requested in post commit review for D43820.

llvm-svn: 329159

6 years ago[ARM] Do not convert some vmov instructions
Mikhail Maltsev [Wed, 4 Apr 2018 08:54:19 +0000 (08:54 +0000)]
[ARM] Do not convert some vmov instructions

Summary:
Patch https://reviews.llvm.org/D44467 implements conversion of invalid
vmov instructions into valid ones. It turned out that some valid
instructions also get converted, for example

  vmov.i64 d2, #0xff00ff00ff00ff00 ->
  vmov.i16 d2, #0xff00

Such behavior is incorrect because according to the ARM ARM section
F2.7.7 Modified immediate constants in T32 and A32 Advanced SIMD
instructions, "On assembly, the data type must be matched in the table
if possible."

This patch fixes the isNEONmovReplicate check so that the above
instruction is not modified any more.

Reviewers: rengolin, olista01

Reviewed By: rengolin

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

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

llvm-svn: 329158

6 years agoRevert r329156 "Add llvm-exegesis tool."
Clement Courbet [Wed, 4 Apr 2018 08:22:54 +0000 (08:22 +0000)]
Revert r329156 "Add llvm-exegesis tool."

Breaks a bunch of bots.

llvm-svn: 329157

6 years agoAdd llvm-exegesis tool.
Clement Courbet [Wed, 4 Apr 2018 08:13:32 +0000 (08:13 +0000)]
Add llvm-exegesis tool.

Summary:
[llvm-exegesis][RFC] Automatic Measurement of Instruction Latency/Uops

This is the code corresponding to the RFC "llvm-exegesis Automatic Measurement of Instruction Latency/Uops".

The RFC is available on the LLVM mailing lists as well as the following document
for easier reading:
https://docs.google.com/document/d/1QidaJMJUyQdRrFKD66vE1_N55whe0coQ3h1GpFzz27M/edit?usp=sharing

Subscribers: mgorny, gchatelet, orwant, llvm-commits

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

llvm-svn: 329156

6 years ago[ELF] - Revert r329060 "Simplify createFiles. NFCI."
George Rimar [Wed, 4 Apr 2018 08:13:28 +0000 (08:13 +0000)]
[ELF] - Revert r329060 "Simplify createFiles. NFCI."

Was requested during post commit review.

llvm-svn: 329155

6 years ago[X86] Use the same predicate for the load for PMOVSXBQ and PMOVZXBQ.
Craig Topper [Wed, 4 Apr 2018 07:00:24 +0000 (07:00 +0000)]
[X86] Use the same predicate for the load for PMOVSXBQ and PMOVZXBQ.

These both use a 16-bit load, but one used loadi16_anyext and the other used extloadi32i16. The only difference between them is that loadi16_anyext checked that the load was at least 2 byte aligned and non-volatile. But the alignment doesn't matter here. Just use extloadi32i16 for both.

llvm-svn: 329154

6 years ago[X86] Use loadi16/loadi32 predicates in multiply patterns
Craig Topper [Wed, 4 Apr 2018 07:00:19 +0000 (07:00 +0000)]
[X86] Use loadi16/loadi32 predicates in multiply patterns

llvm-svn: 329153

6 years ago[X86] Remove more dead code left over from the handling of i8/i16 UMUL_LOHI/SMUL_LOHI...
Craig Topper [Wed, 4 Apr 2018 07:00:16 +0000 (07:00 +0000)]
[X86] Remove more dead code left over from the handling of i8/i16 UMUL_LOHI/SMUL_LOHI that is no longer needed. NFC

llvm-svn: 329152

6 years agoFix typo in ASTStructuralEquivalence.cpp for UnaryTransform types.
Eric Fiselier [Wed, 4 Apr 2018 06:31:21 +0000 (06:31 +0000)]
Fix typo in ASTStructuralEquivalence.cpp for UnaryTransform types.

Previously UnaryTransformType nodes were comparing the same node
for structural equivalence. This was due to a typo where T1 was
on both sides of the comparison. This patch corrects that typo.

Unfortunately I couldn't find a way to test this change. It seems
that currently UnaryTransform nodes are never actually checked
for equivalence, only their canonical types are.

None the less, this correction seemed appropriate.

llvm-svn: 329151

6 years ago[SCEV] Prove implications for SCEVUnknown Phis
Max Kazantsev [Wed, 4 Apr 2018 05:46:47 +0000 (05:46 +0000)]
[SCEV] Prove implications for SCEVUnknown Phis

This patch teaches SCEV how to prove implications for SCEVUnknown nodes that are Phis.
If we need to prove `Pred` for `LHS, RHS`, and `LHS` is a Phi with possible incoming values
`L1, L2, ..., LN`, then if we prove `Pred` for `(L1, RHS), (L2, RHS), ..., (LN, RHS)` then we can also
prove it for `(LHS, RHS)`. If both `LHS` and `RHS` are Phis from the same block, it is sufficient
to prove the predicate for values that come from the same predecessor block.

The typical case that it handles is that we sometimes need to prove that `Phi(Len, Len - 1) >= 0`
given that `Len > 0`. The new logic was added to `isImpliedViaOperations` and only uses it and
non-recursive reasoning to prove the facts we need, so it should not hurt compile time a lot.

Differential Revision: https://reviews.llvm.org/D44001
Reviewed By: anna

llvm-svn: 329150

6 years agoFix undefined macro issue in locale tests; Try 2
Eric Fiselier [Wed, 4 Apr 2018 04:48:26 +0000 (04:48 +0000)]
Fix undefined macro issue in locale tests; Try 2

llvm-svn: 329149

6 years agoFix undefined macro issue in locale tests
Eric Fiselier [Wed, 4 Apr 2018 04:39:38 +0000 (04:39 +0000)]
Fix undefined macro issue in locale tests

llvm-svn: 329148

6 years ago[X86] Remove dead code for handling i8/i16 UMUL_LOHI/SMUL_LOHI from X86ISelDAGToDAG...
Craig Topper [Wed, 4 Apr 2018 04:38:55 +0000 (04:38 +0000)]
[X86] Remove dead code for handling i8/i16 UMUL_LOHI/SMUL_LOHI from X86ISelDAGToDAG.cpp. NFC

These are promoted to i16/i32 multiplies by a DAG combine.

llvm-svn: 329147

6 years ago[X86] Remove some code that was only needed when i1 was a legal type. NFC
Craig Topper [Wed, 4 Apr 2018 04:38:54 +0000 (04:38 +0000)]
[X86] Remove some code that was only needed when i1 was a legal type. NFC

llvm-svn: 329146

6 years agoUpdate Clang version on Appveyor bots
Eric Fiselier [Wed, 4 Apr 2018 04:33:09 +0000 (04:33 +0000)]
Update Clang version on Appveyor bots

llvm-svn: 329145

6 years agoTouch up tests for new <version> header; fix module.modulemap.
Eric Fiselier [Wed, 4 Apr 2018 04:21:54 +0000 (04:21 +0000)]
Touch up tests for new <version> header; fix module.modulemap.

This patch does some housekeeping for the new <version> header.
It adds it to the module.modulemap, and the double_include.sh.cpp test.

Additionally it corrects the // UNSUPPORTED options for the libc++
specific test. The header needs to compile under C++03 to support
modules, and it should compile under all available compilers.

llvm-svn: 329144

6 years agoFix locale test data for GLIBC 2.27 and newer.
Eric Fiselier [Wed, 4 Apr 2018 04:00:14 +0000 (04:00 +0000)]
Fix locale test data for GLIBC 2.27 and newer.

GLIBC 2.27 changed the locale data for fr_FR and ru_RU. In particular
they change the decimal and thousands separators used. This patch
makes the locale tests tolerate the updated locales.

llvm-svn: 329143

6 years ago[SimplifyCFG] Teach merge conditional stores to handle cases where the PostBB has...
Craig Topper [Wed, 4 Apr 2018 03:47:17 +0000 (03:47 +0000)]
[SimplifyCFG] Teach merge conditional stores to handle cases where the PostBB has more than 2 predecessors by inserting a new block for the store.

Summary:
Currently merge conditional stores can't handle cases where PostBB (the block we need to move the store to) has more than 2 predecessors.

This patch removes that restriction by creating a new block with only the 2 predecessors we care about and an unconditional branch to the original block. This provides a place to put the store.

Reviewers: efriedma, jmolloy, ABataev

Reviewed By: efriedma

Subscribers: llvm-commits

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

llvm-svn: 329142

6 years agoSplit test/Driver/darwin-sdkroot.c into two tests
Alex Lorenz [Wed, 4 Apr 2018 02:11:20 +0000 (02:11 +0000)]
Split test/Driver/darwin-sdkroot.c into two tests

The test additions in r329110 are Darwin-specific, as they rely
on a code path that is reachabled when driver is invoked without
-target. Instead of making the old test checks Darwin-specific too,
let's simply split it into two files to ensure that the old
checks are still platform-agnostic. Thanks Chandler for
suggesting this!

llvm-svn: 329141

6 years agoFix bad #include path in r329139
Vlad Tsyrklevich [Wed, 4 Apr 2018 01:34:42 +0000 (01:34 +0000)]
Fix bad #include path in r329139

llvm-svn: 329140

6 years agoAdd the ShadowCallStack pass
Vlad Tsyrklevich [Wed, 4 Apr 2018 01:21:16 +0000 (01:21 +0000)]
Add the ShadowCallStack pass

Summary:
The ShadowCallStack pass instruments functions marked with the
shadowcallstack attribute. The instrumented prolog saves the return
address to [gs:offset] where offset is stored and updated in [gs:0].
The instrumented epilog loads/updates the return address from [gs:0]
and checks that it matches the return address on the stack before
returning.

Reviewers: pcc, vitalybuka

Reviewed By: pcc

Subscribers: cryptoad, eugenis, craig.topper, mgorny, llvm-commits, kcc

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

llvm-svn: 329139

6 years agoMinor no-op cmake file style fix.
Nico Weber [Wed, 4 Apr 2018 00:50:22 +0000 (00:50 +0000)]
Minor no-op cmake file style fix.

llvm-svn: 329137

6 years agoReapply r329133 with fix.
Lang Hames [Wed, 4 Apr 2018 00:34:54 +0000 (00:34 +0000)]
Reapply r329133 with fix.

llvm-svn: 329136

6 years agoRevert r329133 "[RuntimeDyld][AArch64] Add some error pluming / generation..."
Lang Hames [Wed, 4 Apr 2018 00:12:12 +0000 (00:12 +0000)]
Revert r329133 "[RuntimeDyld][AArch64] Add some error pluming / generation..."

This broke a number of buildbots. Looking in to it now...

llvm-svn: 329135

6 years ago[MachineOutliner] Test for X86FI->getUsesRedZone() as well as Attribute::NoRedZone
Jessica Paquette [Tue, 3 Apr 2018 23:32:41 +0000 (23:32 +0000)]
[MachineOutliner] Test for X86FI->getUsesRedZone() as well as Attribute::NoRedZone

This commit is similar to r329120, but uses the existing getUsesRedZone() function
in X86MachineFunctionInfo. This teaches the outliner to look at whether or not a
function *truly* uses a redzone instead of just the noredzone attribute on a
function.

Thus, after this commit, it's possible to outline from x86 without using
-mno-red-zone and still get outlining results.

This also adds a new test for the new redzone behaviour.

llvm-svn: 329134

6 years ago[RuntimeDyld][AArch64] Add some error pluming / generation to catch unhandled
Lang Hames [Tue, 3 Apr 2018 23:19:20 +0000 (23:19 +0000)]
[RuntimeDyld][AArch64] Add some error pluming / generation to catch unhandled
relocation types on AArch64.

llvm-svn: 329133

6 years agoFix manifestinput-error.test on Windows 10.
Rui Ueyama [Tue, 3 Apr 2018 23:12:28 +0000 (23:12 +0000)]
Fix manifestinput-error.test on Windows 10.

Patch by Alexandre Ganea.

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

llvm-svn: 329132

6 years ago[AMDGPU] performMinMaxCombine should not optimize patterns of vectors to min3/max3.
Farhana Aleen [Tue, 3 Apr 2018 23:00:30 +0000 (23:00 +0000)]
[AMDGPU] performMinMaxCombine should not optimize patterns of vectors to min3/max3.

Summary: There are no packed instructions for min3 or max3. So, performMinMaxCombine should not optimize vectors of f16 to min3/max3.

Author: FarhanaAleen

Reviewed By: arsenm

Subscribers: llvm-commits, AMDGPU

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

llvm-svn: 329131

6 years ago[AArch64] Adjust the cost model for Exynos M3
Evandro Menezes [Tue, 3 Apr 2018 22:57:17 +0000 (22:57 +0000)]
[AArch64] Adjust the cost model for Exynos M3

Fix typo and simplify matching expression.

llvm-svn: 329130

6 years ago[Hexagon] peel loops with runtime small trip counts
Ikhlas Ajbar [Tue, 3 Apr 2018 22:55:09 +0000 (22:55 +0000)]
[Hexagon] peel loops with runtime small trip counts

Move the check canPeel() to Hexagon Target before setting PeelCount.

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

llvm-svn: 329129

6 years ago[ObjC] Use the name specified by objc_runtime_name instead of the class
Akira Hatanaka [Tue, 3 Apr 2018 22:50:16 +0000 (22:50 +0000)]
[ObjC] Use the name specified by objc_runtime_name instead of the class
identifier.

This patch fixes a few places in CGObjCMac.cpp where the class
identifier was used instead of the name specified by objc_runtime_name.

rdar://problem/37910822

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

llvm-svn: 329128

6 years ago[CUDA] Check initializers of instantiated template variables.
Artem Belevich [Tue, 3 Apr 2018 22:41:06 +0000 (22:41 +0000)]
[CUDA] Check initializers of instantiated template variables.

We were already performing checks on non-template variables,
but the checks on templated ones were missing.

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

llvm-svn: 329127

6 years agoReturn early. NFC.
Rui Ueyama [Tue, 3 Apr 2018 22:39:12 +0000 (22:39 +0000)]
Return early. NFC.

llvm-svn: 329126

6 years agoMerge two `if`s and add a few blank lines. NFC.
Rui Ueyama [Tue, 3 Apr 2018 22:39:04 +0000 (22:39 +0000)]
Merge two `if`s and add a few blank lines. NFC.

llvm-svn: 329125

6 years agoInline a small test file.
Rui Ueyama [Tue, 3 Apr 2018 22:38:56 +0000 (22:38 +0000)]
Inline a small test file.

llvm-svn: 329124

6 years ago'cat' command for internal shell - Support Python 3
Reid Kleckner [Tue, 3 Apr 2018 22:38:25 +0000 (22:38 +0000)]
'cat' command for internal shell - Support Python 3

LLVM Bug Id : 36449

Revision 328563 caused tests to fail under python 3.

This patch modified cat.py file to support both python 2 and 3.
This patch also fixes CRLF issues on Windows.

Patch by Chamal de Silva

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

llvm-svn: 329123

6 years agoAdd the -fsanitize=shadow-call-stack flag
Vlad Tsyrklevich [Tue, 3 Apr 2018 22:33:53 +0000 (22:33 +0000)]
Add the -fsanitize=shadow-call-stack flag

Summary:
Add support for the -fsanitize=shadow-call-stack flag which causes clang
to add ShadowCallStack attribute to functions compiled with that flag
enabled.

Reviewers: pcc, kcc

Reviewed By: pcc, kcc

Subscribers: cryptoad, cfe-commits, kcc

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

llvm-svn: 329122

6 years ago[InstCombine] allow more fmul folds with 'reassoc'
Sanjay Patel [Tue, 3 Apr 2018 22:19:19 +0000 (22:19 +0000)]
[InstCombine] allow more fmul folds with 'reassoc'

The tests marked with 'FIXME' require loosening the check
in SimplifyAssociativeOrCommutative() to optimize completely;
that's still checking isFast() in Instruction::isAssociative().

llvm-svn: 329121

6 years ago[MachineOutliner] Keep track of fns that use a redzone in AArch64FunctionInfo
Jessica Paquette [Tue, 3 Apr 2018 21:56:10 +0000 (21:56 +0000)]
[MachineOutliner] Keep track of fns that use a redzone in AArch64FunctionInfo

This patch adds a hasRedZone() function to AArch64MachineFunctionInfo. It
returns true if the function is known to use a redzone, false if it is known
to not use a redzone, and no value otherwise.

This removes the requirement to pass -mno-red-zone when outlining for AArch64.

https://reviews.llvm.org/D45189

llvm-svn: 329120

6 years agoRevert "MSG"
Farhana Aleen [Tue, 3 Apr 2018 21:51:45 +0000 (21:51 +0000)]
Revert "MSG"

This reverts commit 9a0ce889d1c39c74d69ecad5ce9c875155ae55de.

This was committed by mistake.

llvm-svn: 329119