platform/upstream/llvm.git
7 years agoImplement mem_fence on ptx
Jeroen Ketema [Mon, 9 Oct 2017 19:43:04 +0000 (19:43 +0000)]
Implement mem_fence on ptx

PTX does not differentiate between read and write fences. Hence, these a
lowered to a mem_fence call. The mem_fence function compiles to the
“member.cta” instruction, which commits all outstanding reads and writes
of a thread such that these become visible to all other threads in the same
CTA (i.e., work-group). The instruction does not differentiate between
global and local memory. Hence, the flags parameter is ignored, except
for deciding whether a “member.cta” instruction should be issued at all.

Reviewed-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 315235

7 years ago[libc++] Support Microsoft ABI without vcruntime headers
Shoaib Meenai [Mon, 9 Oct 2017 19:25:17 +0000 (19:25 +0000)]
[libc++] Support Microsoft ABI without vcruntime headers

The vcruntime headers are hairy and clash with both libc++ headers
themselves and other libraries. libc++ normally deals with the clashes
by deferring to the vcruntime headers and silencing its own definitions,
but for clients which don't want to depend on vcruntime headers, it's
desirable to support the opposite, i.e. have libc++ provide its own
definitions.

Certain operator new/delete replacement scenarios are not currently
supported in this mode, which requires some tests to be marked XFAIL.
The added documentation has more details.

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

llvm-svn: 315234

7 years ago[SLP] Add test for reversed load, NFC.
Alexey Bataev [Mon, 9 Oct 2017 19:08:15 +0000 (19:08 +0000)]
[SLP] Add test for reversed load, NFC.

llvm-svn: 315232

7 years agoTesting commit access.
Hamza Sood [Mon, 9 Oct 2017 19:07:09 +0000 (19:07 +0000)]
Testing commit access.

llvm-svn: 315231

7 years agoFix some C++ value / reference semantics issues.
Zachary Turner [Mon, 9 Oct 2017 18:50:29 +0000 (18:50 +0000)]
Fix some C++ value / reference semantics issues.

Some functions were taking Twine's not by const&, these are all
fixed to take by const&.  We also had a case where some functions
were overloaded to accept by const& and &&.  Now there is only
one version which accepts by value and move's the value.

llvm-svn: 315229

7 years agoMake ptx barrier work irrespective of the cl_mem_fence_flags
Jeroen Ketema [Mon, 9 Oct 2017 18:36:48 +0000 (18:36 +0000)]
Make ptx barrier work irrespective of the cl_mem_fence_flags

This generates a "bar.sync 0” instruction, which not only causes the
threads to wait, but does acts as a memory fence, as required by
OpenCL. The fence does not differentiate between local and global
memory. Unfortunately, there is no similar instruction which does
not include a memory fence. Hence, we cannot optimize the case
where neither CLK_LOCAL_MEM_FENCE nor CLK_GLOBAL_MEM_FENCE is
passed.

llvm-svn: 315228

7 years ago[sanitizer] Don't intercept signal and sigaction on Fuchsia
Petr Hosek [Mon, 9 Oct 2017 18:29:52 +0000 (18:29 +0000)]
[sanitizer] Don't intercept signal and sigaction on Fuchsia

Fuchsia doesn't support signals, so don't use interceptors for signal or
sigaction.

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

llvm-svn: 315227

7 years ago[globalisel] Add support for ValueType operands in patterns.
Daniel Sanders [Mon, 9 Oct 2017 18:14:53 +0000 (18:14 +0000)]
[globalisel] Add support for ValueType operands in patterns.

It's rare but there are a small number of patterns like this:
    (set i64:$dst, (add i64:$src1, i64:$src2))
These should be equivalent to register classes except they shouldn't check for
a specific register bank.

This doesn't occur in AArch64/ARM/X86 but does occasionally come up in other
in-tree targets such as BPF.

llvm-svn: 315226

7 years ago[MC] Use a unique_ptr<MCAssembler> for MCObjectStreamer's Assembler member.
Lang Hames [Mon, 9 Oct 2017 18:11:04 +0000 (18:11 +0000)]
[MC] Use a unique_ptr<MCAssembler> for MCObjectStreamer's Assembler member.

Removes manual new/delete.

llvm-svn: 315225

7 years ago[InstCombine] fix formatting; NFC
Sanjay Patel [Mon, 9 Oct 2017 17:54:46 +0000 (17:54 +0000)]
[InstCombine] fix formatting; NFC

llvm-svn: 315223

7 years agoFix after r315079
Adrian McCarthy [Mon, 9 Oct 2017 17:50:01 +0000 (17:50 +0000)]
Fix after r315079

Microsoft's debug implementation of std::copy checks if the destination is an
array and then does some bounds checking.  This was causing an assertion
failure in fs::rename_internal which copies to a buffer of the appropriate
size but that's type-punned to an array of length 1 for API compatibility
reasons.

Fix is to make make the destination a pointer rather than an array.

llvm-svn: 315222

7 years agoUpdate ABISysV_arm64::RegisterIsVolatile to accept registers prefixed with r
Stephane Sezer [Mon, 9 Oct 2017 17:49:32 +0000 (17:49 +0000)]
Update ABISysV_arm64::RegisterIsVolatile to accept registers prefixed with r

Summary:
While the specification says that the 64bit registers are prefixed with
`x`, it seems that many people still use `r`. Until recently, we had been using
the `r` prefix instead of the `x` prefix in ds2. This caused lldb to fail during
unwinding. I think it's reasonable to check for a register prefixed with `r`,
since some people still choose to use `r`.

Reviewers: sas, fjricci, clayborg

Reviewed By: sas, clayborg

Subscribers: aemerson, javed.absar, kristof.beyls

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

Change by Alex Langford <apl@fb.com>

llvm-svn: 315221

7 years ago[ubsan] Disable one test on Android.
Evgeniy Stepanov [Mon, 9 Oct 2017 17:45:03 +0000 (17:45 +0000)]
[ubsan] Disable one test on Android.

llvm-svn: 315220

7 years agoAMDGPU: Fix missing declaration for __builtin_amdgcn_dispatch_ptr
Matt Arsenault [Mon, 9 Oct 2017 17:44:18 +0000 (17:44 +0000)]
AMDGPU: Fix missing declaration for __builtin_amdgcn_dispatch_ptr

llvm-svn: 315219

7 years ago[dsymutil] Emit valid debug locations when no symbol flags are set
Francis Ricci [Mon, 9 Oct 2017 17:27:47 +0000 (17:27 +0000)]
[dsymutil] Emit valid debug locations when no symbol flags are set

Summary:
swiftc emits symbols without flags set, which led dsymutil to ignore
them when searching for global symbols, causing dwarf location data
to be omitted. Xcode's dsymutil handles this case correctly, and emits
valid location data. Add this functionality to llvm-dsymutil by
allowing parsing of symbols with no flags set.

Reviewers: aprantl, friss, JDevlieghere

Subscribers: llvm-commits

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

llvm-svn: 315218

7 years ago[SLP] Test for wrongly vectorized set of extractelements, NFC.
Alexey Bataev [Mon, 9 Oct 2017 17:14:03 +0000 (17:14 +0000)]
[SLP] Test for wrongly vectorized set of extractelements, NFC.

llvm-svn: 315217

7 years agoLimit CFI blacklist entries to specific CFI mode
Vlad Tsyrklevich [Mon, 9 Oct 2017 17:11:44 +0000 (17:11 +0000)]
Limit CFI blacklist entries to specific CFI mode

Summary:
Since D37924 and D37925 were merged, it's now possible to specify
individual sanitizers or CFI modes in sanitizer blacklists. Update the
CFI blacklist entries to only apply to cfi-unrelated-cast checks.

Reviewers: eugenis, pcc

Reviewed By: eugenis

Subscribers: kcc

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

llvm-svn: 315216

7 years agoMake the cfi target available on more platforms.
Peter Collingbourne [Mon, 9 Oct 2017 17:07:47 +0000 (17:07 +0000)]
Make the cfi target available on more platforms.

On non-Linux targets it just installs the blacklist.

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

llvm-svn: 315215

7 years ago[clangd] Added a command-line arg to mirror clangd input into a file.
Ilya Biryukov [Mon, 9 Oct 2017 16:58:16 +0000 (16:58 +0000)]
[clangd] Added a command-line arg to mirror clangd input into a file.

Summary: The arg is useful for debugging and creating test cases.

Reviewers: bkramer, krasimir

Reviewed By: bkramer

Subscribers: klimek, cfe-commits

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

llvm-svn: 315214

7 years ago[clangd] Added a test for r315212.
Ilya Biryukov [Mon, 9 Oct 2017 16:53:00 +0000 (16:53 +0000)]
[clangd] Added a test for r315212.

llvm-svn: 315213

7 years agoSet PreprocessorOpts.GeneratePreamble=true in PrecompiledPreamble.
Ilya Biryukov [Mon, 9 Oct 2017 16:52:12 +0000 (16:52 +0000)]
Set PreprocessorOpts.GeneratePreamble=true in PrecompiledPreamble.

Summary:
It was previsouly set only in ASTUnit, but it should be set for all client of
PrecompiledPreamble.

Reviewers: erikjv, bkramer, klimek

Reviewed By: bkramer

Subscribers: cfe-commits

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

llvm-svn: 315212

7 years ago[clangd] Added move-only function helpers.
Ilya Biryukov [Mon, 9 Oct 2017 16:26:26 +0000 (16:26 +0000)]
[clangd] Added move-only function helpers.

Summary:
They are now used in ClangdScheduler instead of deferred std::async
computations.
The results of `std::async` are much less effective and do not provide
a good abstraction for similar purposes, i.e. for storing additional callbacks
to clangd async tasks. The actual callback API will follow a bit later.

Reviewers: klimek, bkramer, sammccall, krasimir

Reviewed By: sammccall

Subscribers: cfe-commits

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

llvm-svn: 315210

7 years ago[TableGen] remove make_range where not necessary
Javed Absar [Mon, 9 Oct 2017 16:21:25 +0000 (16:21 +0000)]
[TableGen] remove make_range where not necessary

llvm-svn: 315209

7 years ago[llvm-rc] Have the tokenizer discard single & block comments.
Zachary Turner [Mon, 9 Oct 2017 15:46:13 +0000 (15:46 +0000)]
[llvm-rc] Have the tokenizer discard single & block comments.

This allows rc files to have comments.  Eventually we should
just use clang's c preprocessor, but that's a bit larger
effort for minimal gain, and this is straightforward.

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

llvm-svn: 315207

7 years ago[DAG] combine assertsexts around a trunc
Sanjay Patel [Mon, 9 Oct 2017 15:22:20 +0000 (15:22 +0000)]
[DAG] combine assertsexts around a trunc

This was a suggested follow-up to:
D37017 / https://reviews.llvm.org/rL313577

llvm-svn: 315206

7 years ago[AArch64] Improve codegen for inverted overflow checking intrinsics
Amara Emerson [Mon, 9 Oct 2017 15:15:09 +0000 (15:15 +0000)]
[AArch64] Improve codegen for inverted overflow checking intrinsics

E.g. if we have a (xor(overflow-bit), 1) where overflow-bit comes from an
intrinsic like llvm.sadd.with.overflow then we can kill the xor and use the
inverted condition code for the CSEL.

rdar://28495949

Reviewed By: kristof.beyls

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

llvm-svn: 315205

7 years ago[x86] regenerate test checks; NFC
Sanjay Patel [Mon, 9 Oct 2017 15:01:58 +0000 (15:01 +0000)]
[x86] regenerate test checks; NFC

llvm-svn: 315204

7 years ago[AArch64] fix typos in test assertions
Sanjay Patel [Mon, 9 Oct 2017 01:29:54 +0000 (01:29 +0000)]
[AArch64] fix typos in test assertions

llvm-svn: 315203

7 years ago[X86] Remove a setLoadExtAction from the AVX512 section that uses an AVX512BW type...
Craig Topper [Mon, 9 Oct 2017 01:05:16 +0000 (01:05 +0000)]
[X86] Remove a setLoadExtAction from the AVX512 section that uses an AVX512BW type and is alraedy present in the AVX512BW section.

llvm-svn: 315202

7 years ago[X86] Enable extended comparison predicate support for SETUEQ/SETONE when targeting...
Craig Topper [Mon, 9 Oct 2017 01:05:15 +0000 (01:05 +0000)]
[X86] Enable extended comparison predicate support for SETUEQ/SETONE when targeting AVX instructions.

We believe that despite AMD's documentation, that they really do support all 32 comparision predicates under AVX.

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

llvm-svn: 315201

7 years ago[DWARFDIE] Rewrite `operator !=` using `operator ==`. NFCI.
Davide Italiano [Mon, 9 Oct 2017 00:18:45 +0000 (00:18 +0000)]
[DWARFDIE] Rewrite `operator !=` using `operator ==`. NFCI.

llvm-svn: 315200

7 years ago[SymbolFile/DWARF] Simplify two functions. NFCI.
Davide Italiano [Mon, 9 Oct 2017 00:11:49 +0000 (00:11 +0000)]
[SymbolFile/DWARF] Simplify two functions. NFCI.

llvm-svn: 315199

7 years agoCertain versions of clang require an explicit initialization for literal const members.
Benjamin Kramer [Sun, 8 Oct 2017 21:28:47 +0000 (21:28 +0000)]
Certain versions of clang require an explicit initialization for literal const members.

include/clang/Lex/PreprocessorLexer.h:79:3: error: constructor for
'clang::PreprocessorLexer' must explicitly initialize the const member
'FID'

llvm-svn: 315197

7 years agoRemove unused variables. No functionality change.
Benjamin Kramer [Sun, 8 Oct 2017 21:23:02 +0000 (21:23 +0000)]
Remove unused variables. No functionality change.

llvm-svn: 315196

7 years ago[X86][SSE] Don't call combineTo inside combineX86ShufflesRecursively. NFCI.
Simon Pilgrim [Sun, 8 Oct 2017 20:58:14 +0000 (20:58 +0000)]
[X86][SSE] Don't call combineTo inside combineX86ShufflesRecursively. NFCI.

Return the combined shuffle from combineX86ShufflesRecursively and perform the combineTo in the caller.

Makes it easier for future patches to use this in functions that aren't actually shuffles themselves.

llvm-svn: 315195

7 years agoMake SourceLocation, QualType and friends have constexpr constructors.
Benjamin Kramer [Sun, 8 Oct 2017 20:53:36 +0000 (20:53 +0000)]
Make SourceLocation, QualType and friends have constexpr constructors.

No functionality change intended.

llvm-svn: 315194

7 years agotravis: Make sure we report failure even if only earlier checked files fail
Jan Vesely [Sun, 8 Oct 2017 20:07:58 +0000 (20:07 +0000)]
travis: Make sure we report failure even if only earlier checked files fail

for loop would only report status of the last command
v2: return '1'
    call test instead of '['

Reviewer: Jeroen Ketema
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 315193

7 years agocheck_external_calls.sh: Print number of calls in tested file.
Jan Vesely [Sun, 8 Oct 2017 20:07:56 +0000 (20:07 +0000)]
check_external_calls.sh: Print number of calls in tested file.

Reviewer: Jeroen Ketema
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 315192

7 years agoptx: Use __clc_nextafter to implement nextafter
Jan Vesely [Sun, 8 Oct 2017 19:34:00 +0000 (19:34 +0000)]
ptx: Use __clc_nextafter to implement nextafter

using clang builtin results in external library call

Reviewer: Jeroen Ketema
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 315191

7 years agoDo not include clc_nextafter header globally
Jan Vesely [Sun, 8 Oct 2017 19:33:58 +0000 (19:33 +0000)]
Do not include clc_nextafter header globally

Drop unused clc/math/clc_nextafter.h header

Reviewer: Jeroen Ketema
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 315190

7 years agomath/nextafter: Use custom declaration inc file
Jan Vesely [Sun, 8 Oct 2017 19:33:55 +0000 (19:33 +0000)]
math/nextafter: Use custom declaration inc file

Reviewer: Jeroen Ketema
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 315189

7 years agomath/binary_decl.inc: Do not declare mixed float/double functions
Jan Vesely [Sun, 8 Oct 2017 19:33:53 +0000 (19:33 +0000)]
math/binary_decl.inc: Do not declare mixed float/double functions

fmin/fmax only need vector/scalar mix

Reviewer: Jeroen Ketema
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 315188

7 years agoTidyup with clang-format. NFCI.
Simon Pilgrim [Sun, 8 Oct 2017 19:24:30 +0000 (19:24 +0000)]
Tidyup with clang-format. NFCI.

llvm-svn: 315187

7 years ago[X86][SSE] Add test case for PR27708
Simon Pilgrim [Sun, 8 Oct 2017 19:18:10 +0000 (19:18 +0000)]
[X86][SSE] Add test case for PR27708

llvm-svn: 315186

7 years agoRemove unused variables. No functionality change.
Benjamin Kramer [Sun, 8 Oct 2017 19:11:02 +0000 (19:11 +0000)]
Remove unused variables. No functionality change.

llvm-svn: 315185

7 years ago[X86] Regenerate fast-isel-select-pseudo-cmov.ll to prepare for D38609.
Craig Topper [Sun, 8 Oct 2017 17:54:50 +0000 (17:54 +0000)]
[X86] Regenerate fast-isel-select-pseudo-cmov.ll to prepare for D38609.

llvm-svn: 315184

7 years ago[TableGen] Simplify, add range_loop in CodeGenSchedule
Javed Absar [Sun, 8 Oct 2017 17:23:30 +0000 (17:23 +0000)]
[TableGen] Simplify, add range_loop in CodeGenSchedule

llvm-svn: 315183

7 years ago[X86] getTargetConstantBitsFromNode - add support for decoding scalar constants
Simon Pilgrim [Sun, 8 Oct 2017 17:21:18 +0000 (17:21 +0000)]
[X86] getTargetConstantBitsFromNode - add support for decoding scalar constants

llvm-svn: 315182

7 years ago[X86] Prefer MOVSS/SD over BLENDI during legalization. Remove BLENDI versions of...
Craig Topper [Sun, 8 Oct 2017 16:57:23 +0000 (16:57 +0000)]
[X86] Prefer MOVSS/SD over BLENDI during legalization. Remove BLENDI versions of scalar arithmetic patterns

Summary:
We currently disable some converting of shuffles to MOVSS/MOVSD during legalization if SSE41 is enabled. But later during shuffle combining we go back to prefering MOVSS/MOVSD.

Additionally we have patterns that look for BLENDIs to detect scalar arithmetic operations. I believe due to the combining using MOVSS/MOVSD these are unnecessary.

Interestingly, we still codegen blend instructions even though lowering/isel emit movss/movsd instructions. Turns out machine CSE commutes them to blend, and then commuting those blends back into blends that are equivalent to the original movss/movsd.

This patch fixes the inconsistency in legalization to prefer MOVSS/MOVSD. The one test change was caused by this change. The problem is that we have integer types and are mostly selecting integer instructions except for the shufps. This shufps forced the execution domain, but the vpblendw couldn't have its domain changed with a naive instruction swap. We could fix this by special casing VPBLENDW based on the immediate to widen the element type.

The rest of the patch is removing all the excess scalar patterns.

Long term we should probably add isel patterns to make MOVSS/MOVSD emit blends directly instead of relying on the double commute. We may also want to consider emitting movss/movsd for optsize. I also wonder if we should still use the VEX encoded blendi instructions even with AVX512. Blends have better throughput, and that may outweigh the register constraint.

Reviewers: RKSimon, zvi

Reviewed By: RKSimon

Subscribers: llvm-commits

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

llvm-svn: 315181

7 years agoMake more constructors constexpr or use =default.
Benjamin Kramer [Sun, 8 Oct 2017 15:59:35 +0000 (15:59 +0000)]
Make more constructors constexpr or use =default.

This lets the compiler reason about the type more easily. No
functionality change intended.

llvm-svn: 315180

7 years ago[AArch64][GlobalISel] Add a test case for G_PHI of p0 instruction selection.
Amara Emerson [Sun, 8 Oct 2017 15:29:35 +0000 (15:29 +0000)]
[AArch64][GlobalISel] Add a test case for G_PHI of p0 instruction selection.

llvm-svn: 315179

7 years ago[AArch64][GlobalISel] Add a test case for G_PHI of p0 regbank selection.
Amara Emerson [Sun, 8 Oct 2017 15:29:31 +0000 (15:29 +0000)]
[AArch64][GlobalISel] Add a test case for G_PHI of p0 regbank selection.

llvm-svn: 315178

7 years ago[AArch64][GlobalISel] Make G_PHI of p0 types legal.
Amara Emerson [Sun, 8 Oct 2017 15:29:11 +0000 (15:29 +0000)]
[AArch64][GlobalISel] Make G_PHI of p0 types legal.

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

llvm-svn: 315177

7 years ago[X86][XOP] Add XOP oddshuffles tests
Simon Pilgrim [Sun, 8 Oct 2017 12:58:15 +0000 (12:58 +0000)]
[X86][XOP] Add XOP oddshuffles tests

XOP codegen is often different to generic AVX - thank you vpperm!

llvm-svn: 315176

7 years ago[X86][SKX] Adding the scheduling information for the SKX target.
Gadi Haber [Sun, 8 Oct 2017 12:52:54 +0000 (12:52 +0000)]
[X86][SKX] Adding the scheduling information for the SKX target.

Adding the scheduling information for the SkylakeServer (SKX) target.

This patch adds the instruction scheduling information for the SkylakeServer (SKX) architecture target by adding the file X86SchedSkylakeServer.td located under the X86 Target.
We used the scheduling information retrieved from the Skylake architects in order to create the file.
The scheduling information includes latency, number of micro-Ops and used ports by each SKL instruction.

The patch continues the scheduling replacement and insertion effort started with the SNB target in r310792, the HSW target in r311879 and the SkylakeClient (SKL) target in rL313613.

Please expect some performance fluctuations due to code alignment effects.

Reviewers: zvi, RKSimon, craig.topper, chandlerc, aymanmu
Differential Revision: https://reviews.llvm.org/D38443

Change-Id: I5c228fcc09e9e5a99b6116e62b356c4f9b971185
llvm-svn: 315175

7 years ago[X86] Add missing entries in 'MemoryFoldTable2Addr' to get complete form of the table.
Ayman Musa [Sun, 8 Oct 2017 09:46:50 +0000 (09:46 +0000)]
[X86] Add missing entries in 'MemoryFoldTable2Addr' to get complete form of the table.

Get the folding table 'MemoryFoldTable2Addr' to a complete state as part of the process explained in https://reviews.llvm.org/D38028

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

llvm-svn: 315174

7 years ago[X86][TableGen] Recommitting the X86 memory folding tables TableGen backend while...
Ayman Musa [Sun, 8 Oct 2017 09:20:32 +0000 (09:20 +0000)]
[X86][TableGen] Recommitting the X86 memory folding tables TableGen backend while disabling it by default.

After the original commit ([[ https://reviews.llvm.org/rL304088 | rL304088 ]]) was reverted, a discussion in llvm-dev was opened on 'how to accomplish this task'.
In the discussion we concluded that the best way to achieve our goal (which is to automate the folding tables and remove the manually maintained tables) is:

 # Commit the tablegen backend disabled by default.

 # Proceed with an incremental updating of the manual tables - while checking the validity of each added entry.

 # Repeat previous step until we reach a state where the generated and the manual tables are identical. Then we can safely remove the manual tables and include the generated tables instead.

 # Schedule periodical (1 week/2 weeks/1 month) runs of the pass:

   - if changes appear (new entries):
      - make sure the entries are legal
      - If they are not, mark them as illegal to folding
   - Commit the changes (if there are any).

CMake flag added for this purpose is "X86_GEN_FOLD_TABLES". Building with this flags will run the pass and emit the X86GenFoldTables.inc file under build/lib/Target/X86/ directory which is a good reference for any developer who wants to take part in the effort of completing the current folding tables.

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

llvm-svn: 315173

7 years ago[X86] Stop LowerSIGN_EXTEND_AVX512 from creating v8i16/v16i16/v16i8 vselects with...
Craig Topper [Sun, 8 Oct 2017 08:50:59 +0000 (08:50 +0000)]
[X86] Stop LowerSIGN_EXTEND_AVX512 from creating v8i16/v16i16/v16i8 vselects with a v8i1/v16i1 condition when BWI is not available.

Some of the tests in vector-shuffle-v1.ll would get into an infinite loop without this.

llvm-svn: 315172

7 years ago[X86] Add new attribute to X86 instructions to enable marking them as "not memory...
Ayman Musa [Sun, 8 Oct 2017 08:32:56 +0000 (08:32 +0000)]
[X86] Add new attribute to X86 instructions to enable marking them as "not memory foldable"

This attribute will be used in a tablegen backend that generated the X86 memory folding tables which will be added in a future pass.
Instructions with this attribute unset will be excluded from the full set of X86 instructions available for the pass.

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

llvm-svn: 315171

7 years agoldexp: Fix double precision function return type
Jan Vesely [Sun, 8 Oct 2017 06:56:14 +0000 (06:56 +0000)]
ldexp: Fix double precision function return type

Fixes ~1200 external calls from nvtpx library.

Reviewer: Jeroen Ketema
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 315170

7 years agoRename ignoreInterpSection -> needsInterpSection.
Rui Ueyama [Sun, 8 Oct 2017 03:52:15 +0000 (03:52 +0000)]
Rename ignoreInterpSection -> needsInterpSection.

This should improve consistency. Also added comment.

llvm-svn: 315169

7 years agoUse llvm::Optional instead of UINT_MAX to represent a null value.
Rui Ueyama [Sun, 8 Oct 2017 03:45:49 +0000 (03:45 +0000)]
Use llvm::Optional instead of UINT_MAX to represent a null value.

llvm-svn: 315168

7 years agoMake a helper function a non-member function. NFC.
Rui Ueyama [Sun, 8 Oct 2017 02:54:42 +0000 (02:54 +0000)]
Make a helper function a non-member function. NFC.

llvm-svn: 315167

7 years agoUse llvm::Optional instead of a magic number -1 to represent "no result".
Rui Ueyama [Sun, 8 Oct 2017 02:44:08 +0000 (02:44 +0000)]
Use llvm::Optional instead of a magic number -1 to represent "no result".

llvm-svn: 315166

7 years agoMake ScriptParser::checkSection a non-member function.
Rui Ueyama [Sun, 8 Oct 2017 02:27:02 +0000 (02:27 +0000)]
Make ScriptParser::checkSection a non-member function.

This patch also make its return type to `void` because
it always returns a given value as-is.

llvm-svn: 315165

7 years agoRemove a trivial function.
Rui Ueyama [Sun, 8 Oct 2017 02:06:03 +0000 (02:06 +0000)]
Remove a trivial function.

llvm-svn: 315164

7 years agoAdd comment.
Rui Ueyama [Sun, 8 Oct 2017 01:55:29 +0000 (01:55 +0000)]
Add comment.

llvm-svn: 315163

7 years ago[X86] Simplify some code in getInsertVINSERTImmediate and getExtractVEXTRACTImmediate...
Craig Topper [Sun, 8 Oct 2017 01:33:42 +0000 (01:33 +0000)]
[X86] Simplify some code in getInsertVINSERTImmediate and getExtractVEXTRACTImmediate. NFC

Replace one of the divides with a multiply.

llvm-svn: 315162

7 years ago[X86] If we see an insert of a bitcast into zero vector, canonicalize it to move...
Craig Topper [Sun, 8 Oct 2017 01:33:41 +0000 (01:33 +0000)]
[X86] If we see an insert of a bitcast into zero vector, canonicalize it to move the bitcast to the other side of the insert.

This improves detection of zeroing of upper bits during isel.

llvm-svn: 315161

7 years ago[X86] Remove ISD::INSERT_SUBVECTOR handling from combineBitcastForMaskedOp. Add isel...
Craig Topper [Sun, 8 Oct 2017 01:33:40 +0000 (01:33 +0000)]
[X86] Remove ISD::INSERT_SUBVECTOR handling from combineBitcastForMaskedOp. Add isel patterns to make up for it.

This will allow for some flexibility in canonicalizing bitcasts around insert_subvector.

llvm-svn: 315160

7 years ago[X86] Use getConstantOperandVal to simplify some code. NFC
Craig Topper [Sun, 8 Oct 2017 01:33:38 +0000 (01:33 +0000)]
[X86] Use getConstantOperandVal to simplify some code. NFC

llvm-svn: 315159

7 years agoRemove redundant initialization code.
Rui Ueyama [Sun, 8 Oct 2017 00:45:34 +0000 (00:45 +0000)]
Remove redundant initialization code.

llvm-svn: 315158

7 years agocmake: Fix one more usage of append()
Vedant Kumar [Sat, 7 Oct 2017 20:20:42 +0000 (20:20 +0000)]
cmake: Fix one more usage of append()

append() isn't available with some cmake versions, so I need to use a
different construct. I missed this case in r315144.

http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA/39355

llvm-svn: 315157

7 years ago[X86][SSE] Match bitcasted BUILD_VECTOR of constants for v2i64 shifts on 64-bit targe...
Simon Pilgrim [Sat, 7 Oct 2017 17:57:22 +0000 (17:57 +0000)]
[X86][SSE] Match bitcasted BUILD_VECTOR of constants for v2i64 shifts on 64-bit targets (PR34855)

Extension to rL315155, generate constant shifts on 64-bits as well as 32-bits.

llvm-svn: 315156

7 years ago[X86][SSE] Match bitcasted v4i32 BUILD_VECTORS for v2i64 shifts on 64-bit targets...
Simon Pilgrim [Sat, 7 Oct 2017 17:42:17 +0000 (17:42 +0000)]
[X86][SSE] Match bitcasted v4i32 BUILD_VECTORS for v2i64 shifts on 64-bit targets (PR34855)

We were already doing this for 32-bit targets, but we can generate these on 64-bits as well.

llvm-svn: 315155

7 years ago[SelectionDAG} Use KnownBits::isUnknown and hasConflict. NFC
Craig Topper [Sat, 7 Oct 2017 17:07:48 +0000 (17:07 +0000)]
[SelectionDAG} Use KnownBits::isUnknown and hasConflict. NFC

llvm-svn: 315154

7 years ago[X86] Add X86ISD::CMOV to computeKnownBitsForTargetNode and ComputeNumSignBitsForTarg...
Craig Topper [Sat, 7 Oct 2017 16:51:19 +0000 (16:51 +0000)]
[X86] Add X86ISD::CMOV to computeKnownBitsForTargetNode and ComputeNumSignBitsForTargetNode.

Summary: Implementations based on ISD::SELECT.

Reviewers: RKSimon, spatel

Reviewed By: RKSimon

Subscribers: llvm-commits

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

llvm-svn: 315153

7 years ago[InstSimplify] add tests to show we can do better at folding poison; NFC
Sanjay Patel [Sat, 7 Oct 2017 15:39:06 +0000 (15:39 +0000)]
[InstSimplify] add tests to show we can do better at folding poison; NFC

llvm-svn: 315152

7 years ago[TableGen] Avoid repeated find calls in CodeGenDAGPatterns getters. NFCI.
Simon Pilgrim [Sat, 7 Oct 2017 14:34:24 +0000 (14:34 +0000)]
[TableGen] Avoid repeated find calls in CodeGenDAGPatterns getters. NFCI.

The assertion tests were using count() instead of testing the find result, resulting in double the number of searches in debug/assert builds.

Instead, call find once (like the release builds do) and assert the result against end().

llvm-svn: 315151

7 years ago[X86][SSE] Improve shuffling combining with horizontal operations
Simon Pilgrim [Sat, 7 Oct 2017 12:42:23 +0000 (12:42 +0000)]
[X86][SSE] Improve shuffling combining with horizontal operations

Recognise cases when we can merge the shuffles with their horizontal (HADD/HSUB/PACK) instruction inputs.

Replaces an older implementation which performed some of this during lowering, expanding an existing target shuffle combine stage instead.

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

llvm-svn: 315150

7 years agoFix signed/unsigned warning
Simon Pilgrim [Sat, 7 Oct 2017 12:24:10 +0000 (12:24 +0000)]
Fix signed/unsigned warning

llvm-svn: 315149

7 years ago[TableGen] Avoid unnecessary std::string creations
Simon Pilgrim [Sat, 7 Oct 2017 12:08:43 +0000 (12:08 +0000)]
[TableGen] Avoid unnecessary std::string creations

Avoid unnecessary std::string creations in the TreePredicateFn getters and in CodeGenDAGPatterns::getSDNodeNamed

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

llvm-svn: 315148

7 years agoDelete empy directory
Jeroen Ketema [Sat, 7 Oct 2017 09:10:44 +0000 (09:10 +0000)]
Delete empy directory

llvm-svn: 315147

7 years ago[X86] Update an outdated comment about SjLj
Martin Storsjo [Sat, 7 Oct 2017 06:00:32 +0000 (06:00 +0000)]
[X86] Update an outdated comment about SjLj

The SjLj intrinsics in the X86 backend are intended for use with
SjLj exception handling as well, since SVN r271244.

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

llvm-svn: 315146

7 years ago[X86] Correct result type for the flag result of RDSEED and RDRAND nodes. Correct...
Craig Topper [Sat, 7 Oct 2017 05:11:59 +0000 (05:11 +0000)]
[X86] Correct result type for the flag result of RDSEED and RDRAND nodes. Correct the CC type for the CMOV used with RDSEED/RDRAND.

The flag result was MVT::Glue, but should be MVT::i32. The CC type was MVT::i8, but should be MVT::i32.

llvm-svn: 315145

7 years agoUse list(APPEND) instead of append()
Vedant Kumar [Sat, 7 Oct 2017 03:44:46 +0000 (03:44 +0000)]
Use list(APPEND) instead of append()

append() seems to be available with the version of cmake I'm using, but
not on the bots:

http://green.lab.llvm.org/green//job/clang-stage1-configure-RA/39354

llvm-svn: 315144

7 years ago[ubsan] Add a static runtime on Darwin
Vedant Kumar [Sat, 7 Oct 2017 01:46:36 +0000 (01:46 +0000)]
[ubsan] Add a static runtime on Darwin

As a follow-up to r315142, this makes it possible to use ubsan with a
static runtime on Darwin. I've also added a new StandaloneStatic testing
configuration so the new setup can be tested.

llvm-svn: 315143

7 years ago[Driver] Fix -static-libsan / -shared-libsan on Darwin
Vedant Kumar [Sat, 7 Oct 2017 01:42:09 +0000 (01:42 +0000)]
[Driver] Fix -static-libsan / -shared-libsan on Darwin

Don't ignore these flags on Darwin. The old behavior of using the
dynamic runtime when neither flag is passed is preserved.

llvm-svn: 315142

7 years agoInline small function. NFC.
Rafael Espindola [Sat, 7 Oct 2017 01:08:28 +0000 (01:08 +0000)]
Inline small function. NFC.

llvm-svn: 315141

7 years agoRemove OutputSection::updateAlignment.
Rui Ueyama [Sat, 7 Oct 2017 00:58:34 +0000 (00:58 +0000)]
Remove OutputSection::updateAlignment.

I feel it is easier to understand without this function.

llvm-svn: 315140

7 years agoClarify code by adding a comment.
Rui Ueyama [Sat, 7 Oct 2017 00:58:19 +0000 (00:58 +0000)]
Clarify code by adding a comment.

llvm-svn: 315139

7 years agoMerge addInputSec with OutputSection::addSection.
Rui Ueyama [Sat, 7 Oct 2017 00:43:31 +0000 (00:43 +0000)]
Merge addInputSec with OutputSection::addSection.

Previously, when we added an input section to an output section, we
called `OutputSectionFactory::addInputSec`. This isn't a good design
because, a factory class is intended to create a new object and
return it, but in this use case, it will never create a new object.
This patch fixes the design flaw.

llvm-svn: 315138

7 years agoReturn early. NFC.
Rui Ueyama [Sat, 7 Oct 2017 00:22:59 +0000 (00:22 +0000)]
Return early. NFC.

llvm-svn: 315137

7 years ago[MachineOutliner] Disable outlining from LinkOnceODRs by default
Jessica Paquette [Sat, 7 Oct 2017 00:16:34 +0000 (00:16 +0000)]
[MachineOutliner] Disable outlining from LinkOnceODRs by default

Say you have two identical linkonceodr functions, one in M1 and one in M2.
Say that the outliner outlines A,B,C from one function, and D,E,F from another
function (where letters are instructions). Now those functions are not
identical, and cannot be deduped. Locally to M1 and M2, these outlining
choices would be good-- to the whole program, however, this might not be true!

To mitigate this, this commit makes it so that the outliner sees linkonceodr
functions as unsafe to outline from. It also adds a flag,
-enable-linkonceodr-outlining, which allows the user to specify that they
want to outline from such functions when they know what they're doing.

Changing this handles most code size regressions in the test suite caused by
competing with linker dedupe. It also doesn't have a huge impact on the code
size improvements from the outliner. There are 6 tests that regress > 5% from
outlining WITH linkonceodrs to outlining WITHOUT linkonceodrs. Overall, most
tests either improve or are not impacted.

Not outlined vs outlined without linkonceodrs:
https://hastebin.com/raw/qeguxavuda

Not outlined vs outlined with linkonceodrs:
https://hastebin.com/raw/edepoqoqic

Outlined with linkonceodrs vs outlined without linkonceodrs:
https://hastebin.com/raw/awiqifiheb

Numbers generated using compare.py with -m size.__text. Tests run for AArch64
with -Oz -mllvm -enable-machine-outliner -mno-red-zone.

llvm-svn: 315136

7 years agoRemove the input file specification from the
Jason Molenda [Sat, 7 Oct 2017 00:13:10 +0000 (00:13 +0000)]
Remove the input file specification from the
"Prepare Swig Bindings" shell script phase; it
wasn't the actual input file and could lead
to incorrect dependency analysis by the build
system.
<rdar://problem/34751196>

llvm-svn: 315135

7 years agoRemove unused parameters.
Rui Ueyama [Sat, 7 Oct 2017 00:08:30 +0000 (00:08 +0000)]
Remove unused parameters.

llvm-svn: 315133

7 years ago[asan] Disable wcslen test on 32-bit Android.
Evgeniy Stepanov [Sat, 7 Oct 2017 00:04:24 +0000 (00:04 +0000)]
[asan] Disable wcslen test on 32-bit Android.

llvm-svn: 315132

7 years agoUse error() instead of warn() to report undefined symbols.
Rui Ueyama [Fri, 6 Oct 2017 23:43:54 +0000 (23:43 +0000)]
Use error() instead of warn() to report undefined symbols.

I believe the reason why we used warn() instead of error() to report
undefined symbols is because the older implementation of error() exitted
immediately. Here, we want to find as many undefined symbols as we can,
so I chose to use warn() instead of error().

Now error() does not exit immediately, so it doesn't make sense to keep
them as warnings.

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

llvm-svn: 315131

7 years ago[InstCombine] use correct type when propagating constant condition in simplifyDivRemO...
Sanjay Patel [Fri, 6 Oct 2017 23:43:06 +0000 (23:43 +0000)]
[InstCombine] use correct type when propagating constant condition in simplifyDivRemOfSelectWithZeroOp (PR34856)

llvm-svn: 315130

7 years agoDo not mutate Script->Opt.Commands from a leaf helper function.
Rui Ueyama [Fri, 6 Oct 2017 23:34:43 +0000 (23:34 +0000)]
Do not mutate Script->Opt.Commands from a leaf helper function.

Factory::addInputSec added an output section to Script->Opt.Commands,
but that is too subtle. This patch makes it explicit so that it is easy
to see when a new element is added to Script->Opt.Commands.

llvm-svn: 315129