platform/upstream/llvm.git
5 years ago[GVN] Don't use the eliminated load as an available value in phi construction
John Brawn [Mon, 23 Jul 2018 12:14:45 +0000 (12:14 +0000)]
[GVN] Don't use the eliminated load as an available value in phi construction

In ConstructSSAForLoadSet if an available value is actually the load that we're
doing SSA construction to eliminate, then we can omit it as SSAUpdate will add
in the value for the phi that will be replacing it anyway. This can result in
simpler IR which can allow further optimisation.

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

llvm-svn: 337686

5 years agoCleanup unnecessary conversions in filesystem.
Eric Fiselier [Mon, 23 Jul 2018 11:55:13 +0000 (11:55 +0000)]
Cleanup unnecessary conversions in filesystem.

llvm-svn: 337685

5 years agoCleanup name qualification in the filesystem internals.
Eric Fiselier [Mon, 23 Jul 2018 11:46:47 +0000 (11:46 +0000)]
Cleanup name qualification in the filesystem internals.

In most cases there is no reason why the filesystem internals
use the qualifier std:: or _VSTD::. This patch removes the unneeded
qualifiers, making the sources files more consistent

llvm-svn: 337684

5 years ago[ELF] Fix handling of FDE negative relative PC addr
Andrew Ng [Mon, 23 Jul 2018 11:29:46 +0000 (11:29 +0000)]
[ELF] Fix handling of FDE negative relative PC addr

Signed values for the FDE PC addr were not correctly handled in
readFdeAddr(). If the value is negative and the type of the value is
smaller than 64 bits, the FDE PC addr overflow error would be
incorrectly triggered.

Fixed readFdeAddr() to properly handle signed values by sign extending
where appropriate.

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

llvm-svn: 337683

5 years ago[Tooling] Use UniqueStringSaver. NFC
Sam McCall [Mon, 23 Jul 2018 11:25:25 +0000 (11:25 +0000)]
[Tooling] Use UniqueStringSaver. NFC

llvm-svn: 337682

6 years ago[clangd] Penalize non-instance members when accessed via class instances.
Eric Liu [Mon, 23 Jul 2018 10:56:37 +0000 (10:56 +0000)]
[clangd] Penalize non-instance members when accessed via class instances.

Summary:
The following are metrics for explicit member access completions. There is no
noticeable impact on other completion types.

Before:
EXPLICIT_MEMBER_ACCESS
  Total measurements: 24382
  All measurements: MRR: 62.27 Top10: 80.21% Top-100: 94.48%
  Full identifiers: MRR: 98.81 Top10: 99.89% Top-100: 99.95%
  0-5 filter len:
MRR:  13.25 46.31 62.47 67.77 70.40 81.91
Top-10:  29% 74% 84% 91% 91% 97%
Top-100:  67% 99% 99% 99% 99% 100%

After:
EXPLICIT_MEMBER_ACCESS
  Total measurements: 24382
  All measurements: MRR: 63.18 Top10: 80.58% Top-100: 95.07%
  Full identifiers: MRR: 98.79 Top10: 99.89% Top-100: 99.95%
  0-5 filter len:
MRR:  13.84 48.39 63.55 68.83 71.28 82.64
Top-10:  30% 75% 84% 91% 91% 97%
Top-100:  70% 99% 99% 99% 99% 100%

* Top-N: wanted result is found in the first N completion results.
* MRR: Mean reciprocal rank.

Remark: the change seems to have minor positive impact. Although the improvement
is relatively small, down-ranking non-instance members in instance member access
should reduce noise in the completion results.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

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

llvm-svn: 337681

6 years ago[MemorySSAUpdater] Update Phi operands after trivial Phi elimination
Alexandros Lamprineas [Mon, 23 Jul 2018 10:56:30 +0000 (10:56 +0000)]
[MemorySSAUpdater] Update Phi operands after trivial Phi elimination

Bug fix for PR37445. The underlying problem and its fix are similar to PR37808.
The bug lies in MemorySSAUpdater::getPreviousDefRecursive(), where PhiOps is
computed before the call to tryRemoveTrivialPhi() and it ends up being out of
date, pointing to stale data. We have now turned each of the PhiOps into a
TrackingVH<MemoryAccess>.

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

llvm-svn: 337680

6 years agoFix for last commit: adding new test file forgotten.
Adam Balogh [Mon, 23 Jul 2018 10:53:02 +0000 (10:53 +0000)]
Fix for last commit: adding new test file forgotten.

llvm-svn: 337679

6 years ago[Analyzer] Quick Fix for exponential execution time when simpilifying complex additiv...
Adam Balogh [Mon, 23 Jul 2018 10:50:20 +0000 (10:50 +0000)]
[Analyzer] Quick Fix for exponential execution time when simpilifying complex additive expressions

Patch https://reviews.llvm.org/rC329780 not only rearranges comparisons but
also binary expressions. This latter behavior is not protected by the analyzer
option. Hower, since no complexity threshold is enforced to the symbols this
may result in exponential execution time if the expressions are too complex:
https://bugs.llvm.org/show_bug.cgi?id=38208. For a quick fix we extended the
analyzer option to also cover the additive cases.

This is only a temporary fix, the final solution should be enforcing the
complexity threshold to the symbols.

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

llvm-svn: 337678

6 years ago[Support] Add a UniqueStringSaver: like StringSaver, but deduplicating.
Sam McCall [Mon, 23 Jul 2018 10:44:40 +0000 (10:44 +0000)]
[Support] Add a UniqueStringSaver: like StringSaver, but deduplicating.

Summary: Clarify contract of StringSaver (it null-terminates, callers rely on it).

Reviewers: hokein

Subscribers: llvm-commits

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

llvm-svn: 337677

6 years ago[NFC][MCA] ZnVer1: Update RegisterFile to identify false dependencies on partially...
Roman Lebedev [Mon, 23 Jul 2018 10:10:13 +0000 (10:10 +0000)]
[NFC][MCA] ZnVer1: Update RegisterFile to identify false dependencies on partially written registers.

Summary:
Pretty mechanical follow-up for D49196.

As microarchitecture.pdf notes, "20 AMD Ryzen pipeline",
"20.8 Register renaming and out-of-order schedulers":
  The integer register file has 168 physical registers of 64 bits each.
  The floating point register file has 160 registers of 128 bits each.
"20.14 Partial register access":
  The processor always keeps the different parts of an integer register together.
  ...
  An instruction that writes to part of a register will therefore have a false dependence
  on any previous write to the same register or any part of it.

Reviewers: andreadb, courbet, RKSimon, craig.topper, GGanesh

Reviewed By: GGanesh

Subscribers: gbedwell, llvm-commits

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

llvm-svn: 337676

6 years ago[NFC][MCA] ZnVer1: add partial-reg-update tests
Roman Lebedev [Mon, 23 Jul 2018 10:10:04 +0000 (10:10 +0000)]
[NFC][MCA] ZnVer1: add partial-reg-update tests

Reviewers: andreadb, courbet, RKSimon, craig.topper, GGanesh

Reviewed By: GGanesh

Subscribers: gbedwell, llvm-commits

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

llvm-svn: 337675

6 years ago[GVNHoist] safeToHoistLdSt allows illegal hoisting
Alexandros Lamprineas [Mon, 23 Jul 2018 09:42:35 +0000 (09:42 +0000)]
[GVNHoist] safeToHoistLdSt allows illegal hoisting

Bug fix for PR36787. When reasoning if it's safe to hoist a load we
want to make sure that the defining memory access dominates the new
insertion point of the hoisted instruction. safeToHoistLdSt calls
firstInBB(InsertionPoint,DefiningAccess) which returns false if
InsertionPoint == DefiningAccess, and therefore it falsely thinks
it's safe to hoist.

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

llvm-svn: 337674

6 years ago[x86/SLH] Fix a bug where we would harden tail calls twice -- once as
Chandler Carruth [Mon, 23 Jul 2018 07:56:15 +0000 (07:56 +0000)]
[x86/SLH] Fix a bug where we would harden tail calls twice -- once as
a call, and then again as a return.

Also added a comment to try and explain better why we would be doing
what we're doing when hardening the (non-call) returns.

llvm-svn: 337673

6 years ago[x86/SLH] Add a test covering indirect forms of control flow. NFC.
Chandler Carruth [Mon, 23 Jul 2018 07:51:51 +0000 (07:51 +0000)]
[x86/SLH] Add a test covering indirect forms of control flow. NFC.

This specifically covers different ways of making indirect calls and
jumps. There are some bugs in SLH that I will be fixing in subsequent
patches where the diff in the generated instructions makes the bug fix
much more clear, so just checking in a baseline of this test to start.

I'm also going to be adding direct mitigation for variant 1.2 which this
file very specifically tests in the various forms it can arise on x86.
Again, the diff to the generated instructions should make the change for
that much more clear, so having the test as a baseline seems useful.

llvm-svn: 337672

6 years agoRevert "Fold dangling-field warning into general initialization lifetime checks."
Ilya Biryukov [Mon, 23 Jul 2018 06:32:36 +0000 (06:32 +0000)]
Revert "Fold dangling-field warning into general initialization lifetime checks."

This reverts commit r337627.
After the change, clang started producing invalid warning on the following code:
    struct foo {
      foo(char *x) : x_(&x[10]) {}
    private:
      char *x_;
    };

1.cpp:2:21: warning: initializing pointer member 'x_' with the stack address of parameter 'x' [-Wdangling-field]

llvm-svn: 337671

6 years agoRevert "[CMake] Support statically linking dependencies only to shared or static...
Petr Hosek [Mon, 23 Jul 2018 05:07:44 +0000 (05:07 +0000)]
Revert "[CMake] Support statically linking dependencies only to shared or static library"

This reverts commit r337668: broke the cxxabi build when using Make.

llvm-svn: 337670

6 years agoUse possibly cached directory entry values when performing recursive directory iteration.
Eric Fiselier [Mon, 23 Jul 2018 04:55:57 +0000 (04:55 +0000)]
Use possibly cached directory entry values when performing recursive directory iteration.

llvm-svn: 337669

6 years ago[CMake] Support statically linking dependencies only to shared or static library
Petr Hosek [Mon, 23 Jul 2018 04:19:55 +0000 (04:19 +0000)]
[CMake] Support statically linking dependencies only to shared or static library

Currently it's possible to select whether to statically link unwinder
or the C++ ABI library, but this option applies to both the shared
and static library. However, in some scenarios it may be desirable to
only statically link unwinder and C++ ABI library into static C++
library since for shared C++ library we can rely on dynamic linking
and linker scripts. This change enables selectively enabling or
disabling statically linking only to shared or static library.

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

llvm-svn: 337668

6 years ago[x86/SLH] Rename and comment the main hardening function. NFC.
Chandler Carruth [Mon, 23 Jul 2018 04:01:34 +0000 (04:01 +0000)]
[x86/SLH] Rename and comment the main hardening function. NFC.

This provides an overview of the algorithm used to harden specific
loads. It also brings this our terminology further in line with
hardening rather than checking.

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

llvm-svn: 337667

6 years agoFix use of C++14 syntax in C++11 filesystem tests.
Eric Fiselier [Mon, 23 Jul 2018 03:41:46 +0000 (03:41 +0000)]
Fix use of C++14 syntax in C++11 filesystem tests.

llvm-svn: 337666

6 years agoWork around various GCC 4.9 build errors
Eric Fiselier [Mon, 23 Jul 2018 03:06:57 +0000 (03:06 +0000)]
Work around various GCC 4.9 build errors

llvm-svn: 337665

6 years agoImplement filesystem_error::what() and improve reporting.
Eric Fiselier [Mon, 23 Jul 2018 02:00:52 +0000 (02:00 +0000)]
Implement filesystem_error::what() and improve reporting.

This patch implements the `what()` for filesystem errors. The message
includes the 'what_arg', any paths that were specified, and the
error code message.

Additionally this patch refactors how errors are created, making it easier
to report them correctly.

llvm-svn: 337664

6 years agoFix the test
Brad Smith [Sun, 22 Jul 2018 22:04:28 +0000 (22:04 +0000)]
Fix the test

llvm-svn: 337663

6 years agoAdd GCC 9 to XFAILs list for test
Eric Fiselier [Sun, 22 Jul 2018 21:58:46 +0000 (21:58 +0000)]
Add GCC 9 to XFAILs list for test

llvm-svn: 337662

6 years agoWorkaround bug in GCC trunk.
Eric Fiselier [Sun, 22 Jul 2018 21:56:40 +0000 (21:56 +0000)]
Workaround bug in GCC trunk.

For some reason GCC ToT is failing to deduce the auto type for
a static data member from its initializer in some cases.

Though I'm sure the bug will be short lived, there is a trivial workaround for it.
So we might as well get the bot passing again.

llvm-svn: 337661

6 years agoOpenBSD/arm has switched to float ABI SoftFP.
Brad Smith [Sun, 22 Jul 2018 21:39:54 +0000 (21:39 +0000)]
OpenBSD/arm has switched to float ABI SoftFP.

llvm-svn: 337660

6 years agoHarden copy_file even more.
Eric Fiselier [Sun, 22 Jul 2018 21:15:15 +0000 (21:15 +0000)]
Harden copy_file even more.

This patch removes the O_CREAT open flag when we first
attempt to open the destination file but we expect it to
already exist.

This theoretically avoids the possibility that it was removed
between when we first stat'ed it, and when we attempt to open it.

llvm-svn: 337659

6 years agofix test failures with older clang versions
Eric Fiselier [Sun, 22 Jul 2018 20:50:16 +0000 (20:50 +0000)]
fix test failures with older clang versions

llvm-svn: 337658

6 years agoTest commit, fix a minor typo.
Jiading Gai [Sun, 22 Jul 2018 20:04:42 +0000 (20:04 +0000)]
Test commit, fix a minor typo.

llvm-svn: 337657

6 years ago[X86] Remove the max vector width restriction from combineLoopMAddPattern and rely...
Craig Topper [Sun, 22 Jul 2018 19:44:35 +0000 (19:44 +0000)]
[X86] Remove the max vector width restriction from combineLoopMAddPattern and rely splitOpsAndApply to handle splitting.

This seems to be a net improvement. There's still an issue under avx512f where we have a 512-bit vpaddd, but not vpmaddwd so we end up doing two 256-bit vpmaddwds and inserting the results before a 512-bit vpaddd. It might be better to do two 512-bits paddds with zeros in the upper half. Same number of instructions, but breaks a dependency.

llvm-svn: 337656

6 years ago[clangd] Unbreak fuzzer build.
Benjamin Kramer [Sun, 22 Jul 2018 15:55:57 +0000 (15:55 +0000)]
[clangd] Unbreak fuzzer build.

llvm-svn: 337655

6 years ago[ORE] Move loop invariant ORE checks outside the PM loop.
Xin Tong [Sun, 22 Jul 2018 05:27:41 +0000 (05:27 +0000)]
[ORE] Move loop invariant ORE checks outside the PM loop.

Summary:
This takes 22ms out of ~20s compiling sqlite3.c because we call it
for every unit of compilation and every pass.

Reviewers: paquette, anemet

Subscribers: mehdi_amini, llvm-commits

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

llvm-svn: 337654

6 years agoPR38257: don't perform ADL when instantiating a unary & operator that turns out
Richard Smith [Sun, 22 Jul 2018 05:21:47 +0000 (05:21 +0000)]
PR38257: don't perform ADL when instantiating a unary & operator that turns out
to be forming a pointer-to-member.

llvm-svn: 337653

6 years ago[SelectionDAGBuilder] Use APInt::isZero instead of comparing APInt::getZExtValue...
Craig Topper [Sun, 22 Jul 2018 05:16:50 +0000 (05:16 +0000)]
[SelectionDAGBuilder] Use APInt::isZero instead of comparing APInt::getZExtValue to 0 in a place where we can't be sure contents of the APInt fit in a uint64_t.

This is used on an extract vector element index which is most cases is going to be an i32 or i64 and the element will be a valid element number. But it is possible to construct IR with a larger type and large out of range value.

llvm-svn: 337652

6 years ago[SelectionDAGBuilder] Restrict vector reduction check to types with a power of 2...
Craig Topper [Sun, 22 Jul 2018 05:16:49 +0000 (05:16 +0000)]
[SelectionDAGBuilder] Restrict vector reduction check to types with a power of 2 number of elements.

The check for the shuffles usages probably isn't correct for non power of 2 vectors.

llvm-svn: 337651

6 years ago[X86] Add more MADD recurrence test cases with larger and narrower vector widths.
Craig Topper [Sun, 22 Jul 2018 05:16:47 +0000 (05:16 +0000)]
[X86] Add more MADD recurrence test cases with larger and narrower vector widths.

llvm-svn: 337650

6 years agoImplement a better copy_file.
Eric Fiselier [Sun, 22 Jul 2018 02:00:53 +0000 (02:00 +0000)]
Implement a better copy_file.

This patch improves both the performance, and the safety of the
copy_file implementation.

The performance improvements are achieved by using sendfile on
Linux and copyfile on OS X when available.

The TOCTOU hardening is achieved by opening the source and
destination files and then using fstat to check their attributes to
see if we can copy them.

Unfortunately for the destination file, there is no way to open
it without accidentally creating it, so we first have to use
stat to determine if it exists, and if we should copy to it.
Then, once we're sure we should try to copy, we open the dest
file and ensure it names the same entity we previously stat'ed.

llvm-svn: 337649

6 years ago[llvm-mca][docs] Add documentation for the statistic outputs from mca. NFC
Matt Davis [Sat, 21 Jul 2018 18:32:47 +0000 (18:32 +0000)]
[llvm-mca][docs] Add documentation for the statistic outputs from mca. NFC

Summary: The original text was lifted from the MCA README.  I re-ran the dot-product example and updated the output seen in the docs.  I also added a few paragraphs discussing the instruction issued and retired histograms, as well as discussing the register file stats.

Reviewers: andreadb, RKSimon, courbet, gbedwell, filcab

Reviewed By: andreadb

Subscribers: tschuett

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

llvm-svn: 337648

6 years ago[mips] Factor out register class selection for global base register. NFC
Simon Atanasyan [Sat, 21 Jul 2018 16:16:08 +0000 (16:16 +0000)]
[mips] Factor out register class selection for global base register. NFC

Factor out register class selection for global base register into a
separate function to escape long chain of ternary operators.

llvm-svn: 337647

6 years ago[mips] Move out the WrapperPat declaration from the NotInMicroMips predicate
Simon Atanasyan [Sat, 21 Jul 2018 16:16:03 +0000 (16:16 +0000)]
[mips] Move out the WrapperPat declaration from the NotInMicroMips predicate

This is a follow-up to the rL335185. Those commit adds some WrapperPat
patterns for microMIPS target. But declaration of the WrapperPat class
is under the NotInMicroMips predicate and microMIPS patterns cannot be
selected because predicate (Subtarget->inMicroMipsMode()) &&
(!Subtarget->inMicroMipsMode()) is always false.

This change move out the WrapperPat class declaration from the
NotInMicroMips predicate and enables microMIPS WrapperPat patterns.

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

llvm-svn: 337646

6 years ago[llvm-undname] Flush output before demangling.
Zachary Turner [Sat, 21 Jul 2018 15:39:05 +0000 (15:39 +0000)]
[llvm-undname] Flush output before demangling.

If an error occurs and we write it to stderr, it could appear
before we wrote the mangled name which we're undecorating.
By flushing stdout first, we ensure that the messages are always
sequenced in the correct order.

llvm-svn: 337645

6 years agoFix the MSVC Visualizers for SmallVector classes.
Zachary Turner [Sat, 21 Jul 2018 15:38:47 +0000 (15:38 +0000)]
Fix the MSVC Visualizers for SmallVector classes.

Recent changes to the internal structure of SmallVector<> broke
all of the MSVC visualizers.  This fixes them.

llvm-svn: 337644

6 years agoEarly exit with cheaper checks
Aditya Kumar [Sat, 21 Jul 2018 14:13:44 +0000 (14:13 +0000)]
Early exit with cheaper checks

Reviewers: sebpop,davide,fhahn,trentxintong
Differential Revision: https://reviews.llvm.org/D49617

llvm-svn: 337643

6 years ago[InstrSimplify] fold sdiv if two operands are negated and non-overflow
Chen Zheng [Sat, 21 Jul 2018 12:27:54 +0000 (12:27 +0000)]
[InstrSimplify] fold sdiv if two operands are negated and non-overflow

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

llvm-svn: 337642

6 years ago[DebugInfo] Add a new DI flag to record if a C++ record is a trivial type
Aaron Smith [Sat, 21 Jul 2018 05:42:13 +0000 (05:42 +0000)]
[DebugInfo] Add a new DI flag to record if a C++ record is a trivial type

Summary:
This flag is used when emitting debug info and is needed to initialize subprogram and member function attributes (function options) for Codeview. These function options are used to create an accurate compiler type for UDT symbols (class/struct/union) from PDBs.

It is not easy to determine if a C++ record is trivial or not based on the current DICompositeType flags and other accessible debug information from Codeview. For example, without this flag the metadata for a non-trivial C++ record with user-defined ctor and a trivial one with a defaulted ctor are the same.

    struct S { S(); }
    struct S { S() = default; }

This change introduces a new DI flag and corresponding clang::CXXRecordDecl::isTrivial method to set the flag in the frontend.

Reviewers: rnk, zturner, llvm-commits, dblaikie, aleksandr.urakov, deadalnix

Reviewed By: rnk

Subscribers: asmith, probinson, aprantl, JDevlieghere

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

llvm-svn: 337641

6 years agoELF: Read address significance tables with --icf=all.
Peter Collingbourne [Sat, 21 Jul 2018 02:14:59 +0000 (02:14 +0000)]
ELF: Read address significance tables with --icf=all.

Under --icf=all we now only apply KeepUnique to non-executable
address-significant sections. This has the effect of making --icf=all
mean unsafe ICF for executable sections and safe ICF for non-executable
sections.

With this change the meaning of the KeepUnique bit changes to
"does the current ICF mode (together with the --keep-unique and
--ignore-data-address-equality flags) require this section to be
kept unique".

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

llvm-svn: 337640

6 years ago[HIP] Support -fcuda-flush-denormals-to-zero for amdgcn
Yaxun Liu [Sat, 21 Jul 2018 02:02:22 +0000 (02:02 +0000)]
[HIP] Support -fcuda-flush-denormals-to-zero for amdgcn

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

llvm-svn: 337639

6 years agoELF: Make sections with KeepUnique bit eligible for ICF.
Peter Collingbourne [Sat, 21 Jul 2018 00:17:11 +0000 (00:17 +0000)]
ELF: Make sections with KeepUnique bit eligible for ICF.

The only restriction is that we cannot merge more than one KeepUnique
section together. This matches gold's behaviour and reduces code size
when using --icf=safe.

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

llvm-svn: 337638

6 years ago[ORC] Re-apply r336760 with fixes.
Lang Hames [Sat, 21 Jul 2018 00:12:05 +0000 (00:12 +0000)]
[ORC] Re-apply r336760 with fixes.

llvm-svn: 337637

6 years ago[NFC] CodeGen: rename memset to bzero
JF Bastien [Fri, 20 Jul 2018 23:37:12 +0000 (23:37 +0000)]
[NFC] CodeGen: rename memset to bzero

The optimization looks for opportunities to emit bzero, not memset. Rename the functions accordingly (and clang-format the diff) because I want to add a fallback optimization which actually tries to generate memset. bzero is still better and it would confuse the code to merge both.

llvm-svn: 337636

6 years ago[Driver] Sanitizer support based on runtime library presence
George Karpenkov [Fri, 20 Jul 2018 23:34:39 +0000 (23:34 +0000)]
[Driver] Sanitizer support based on runtime library presence

The runtime libraries of sanitizers are built in compiler-rt, and Clang
can be built without compiler-rt, or compiler-rt can be configured to
only build certain sanitizers. The driver should provide reasonable
diagnostics and not a link-time error when a runtime library is missing.

This patch changes the driver for OS X to only support sanitizers of
which we can find the runtime libraries. The discussion for this patch
explains the rationale

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

llvm-svn: 337635

6 years agoOmit path to lld binary from lld's error, warning, and log output.
Nico Weber [Fri, 20 Jul 2018 23:09:12 +0000 (23:09 +0000)]
Omit path to lld binary from lld's error, warning, and log output.

lld currently prepends the absolute path to itself to every diagnostic it
emits. This path can be longer than the diagnostic, and makes the actual error
message hard to read.

There isn't a good reason for printing this path: if you want to know which lld
you're running, pass -v to clang – chances are that if you're unsure of this,
you're not only unsure when it errors out. Some people want an indication that
the diagnostic is from the linker though, so instead print just the basename of
the linker's path.

Before:

```
$ out/bin/clang -target x86_64-unknown-linux -x c++ /dev/null -fuse-ld=lld
/Users/thakis/src/llvm-mono/out/bin/ld.lld: error: cannot open crt1.o: No such file or directory
/Users/thakis/src/llvm-mono/out/bin/ld.lld: error: cannot open crti.o: No such file or directory
/Users/thakis/src/llvm-mono/out/bin/ld.lld: error: cannot open crtbegin.o: No such file or directory
/Users/thakis/src/llvm-mono/out/bin/ld.lld: error: unable to find library -lgcc
/Users/thakis/src/llvm-mono/out/bin/ld.lld: error: unable to find library -lgcc_s
/Users/thakis/src/llvm-mono/out/bin/ld.lld: error: unable to find library -lc
/Users/thakis/src/llvm-mono/out/bin/ld.lld: error: unable to find library -lgcc
/Users/thakis/src/llvm-mono/out/bin/ld.lld: error: unable to find library -lgcc_s
/Users/thakis/src/llvm-mono/out/bin/ld.lld: error: cannot open crtend.o: No such file or directory
/Users/thakis/src/llvm-mono/out/bin/ld.lld: error: cannot open crtn.o: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

After:

```
$ out/bin/clang -target x86_64-unknown-linux -x c++ /dev/null -fuse-ld=lld
ld.lld: error: cannot open crt1.o: No such file or directory
ld.lld: error: cannot open crti.o: No such file or directory
ld.lld: error: cannot open crtbegin.o: No such file or directory
ld.lld: error: unable to find library -lgcc
ld.lld: error: unable to find library -lgcc_s
ld.lld: error: unable to find library -lc
ld.lld: error: unable to find library -lgcc
ld.lld: error: unable to find library -lgcc_s
ld.lld: error: cannot open crtend.o: No such file or directory
ld.lld: error: cannot open crtn.o: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

https://reviews.llvm.org/D49189

llvm-svn: 337634

6 years agoSimplify; no behavior change.
Nico Weber [Fri, 20 Jul 2018 23:06:34 +0000 (23:06 +0000)]
Simplify; no behavior change.

Reviewed as part of https://reviews.llvm.org/D49189

llvm-svn: 337633

6 years ago[clang-doc] Create a script to generate tests
Julie Hockett [Fri, 20 Jul 2018 23:00:34 +0000 (23:00 +0000)]
[clang-doc] Create a script to generate tests

Upstreaming the script I use to generate clang-doc tests (and updating
the existing tests to use it)

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

llvm-svn: 337632

6 years ago[HIP] Register/unregister device fat binary only once
Yaxun Liu [Fri, 20 Jul 2018 22:45:24 +0000 (22:45 +0000)]
[HIP] Register/unregister device fat binary only once

HIP generates one fat binary for all devices after linking. However, for each compilation
unit a ctor function is emitted which register the same fat binary. Measures need to be
taken to make sure the fat binary is only registered once.

Currently each ctor function calls __hipRegisterFatBinary and stores the returned value
to __hip_gpubin_handle. This patch changes the linkage of __hip_gpubin_handle to be linkonce
so that they are shared between LLVM modules. Then this patch adds check of value of
__hip_gpubin_handle to make sure __hipRegisterFatBinary is only called once. The code
is equivalent to

void *_gpubin_handle;
void ctor() {
  if (__hip_gpubin_handle == 0) {
    __hip_gpubin_handle = __hipRegisterFatBinary(...);
  }
  // register kernels and variables.
}
The patch also does similar change to dtors so that __hipUnregisterFatBinary
is called once.

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

llvm-svn: 337631

6 years ago[CMake] Install C++ ABI headers into the right location
Petr Hosek [Fri, 20 Jul 2018 22:45:24 +0000 (22:45 +0000)]
[CMake] Install C++ ABI headers into the right location

This is a follow-up to r335809 and r337118. While libc++ headers are now
installed into the right location in both standard as well as multiarch
runtimes layout, turned out C++ ABI headers are still installed into the
old location in the latter case. This change addresses that.

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

llvm-svn: 337630

6 years agoDisable clang crash-report-modules.m test on Windows again
Reid Kleckner [Fri, 20 Jul 2018 22:36:33 +0000 (22:36 +0000)]
Disable clang crash-report-modules.m test on Windows again

It still appears to be failing:
http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/12825

$ "rm" "-rf" "C:\b\slave\clang-x86-windows-msvc2015\clang-x86-windows-msvc2015\stage1\tools\clang\test\Driver\Output/crmdir"
Error: 'rm' command failed, [Error 3] The system cannot find the path specified: 'C:\\b\\slave\\clang-x86-windows-msvc2015\\clang-x86-windows-msvc2015\\stage1\\tools\\clang\\test\\Driver\\Output/crmdir\\crash-report-modules-300567.cache\\vfs\\b\\slave\\clang-x86-windows-msvc2015\\clang-x86-windows-msvc2015\\llvm\\tools\\clang\\test\\Driver\\Inputs\\module\\module.modulemap'
error: command failed with exit status: 1

llvm-svn: 337629

6 years ago[PDB] Write the command line after response file expansion
Reid Kleckner [Fri, 20 Jul 2018 22:34:20 +0000 (22:34 +0000)]
[PDB] Write the command line after response file expansion

Summary: Fixes PR38085

Reviewers: ruiu, zturner

Subscribers: llvm-commits

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

llvm-svn: 337628

6 years agoFold dangling-field warning into general initialization lifetime checks.
Richard Smith [Fri, 20 Jul 2018 22:25:55 +0000 (22:25 +0000)]
Fold dangling-field warning into general initialization lifetime checks.

llvm-svn: 337627

6 years agoRe-apply r337595 with fix for LLVM_ENABLE_THREADS=Off.
Lang Hames [Fri, 20 Jul 2018 22:22:19 +0000 (22:22 +0000)]
Re-apply r337595 with fix for LLVM_ENABLE_THREADS=Off.

llvm-svn: 337626

6 years ago[ADT] Only run death tests in !NDEBUG
Benjamin Kramer [Fri, 20 Jul 2018 22:15:09 +0000 (22:15 +0000)]
[ADT] Only run death tests in !NDEBUG

These invoke undefined behavior.

llvm-svn: 337625

6 years ago[Hexagon] Disable packets in test to avoid ordering issues in checks
Krzysztof Parzyszek [Fri, 20 Jul 2018 21:55:55 +0000 (21:55 +0000)]
[Hexagon] Disable packets in test to avoid ordering issues in checks

llvm-svn: 337624

6 years agoChange the cap on the amount of padding for each vtable to 32-byte (previously it...
Peter Collingbourne [Fri, 20 Jul 2018 21:43:20 +0000 (21:43 +0000)]
Change the cap on the amount of padding for each vtable to 32-byte (previously it was 128-byte)

We tested different cap values with a recent commit of Chromium. Our results show that the 32-byte cap yields the smallest binary and all the caps yield similar performance.
Based on the results, we propose to change the cap value to 32-byte.

Patch by Zhaomo Yang!

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

llvm-svn: 337622

6 years agoAMDGPU: Use existing function to check for VGPRs
Matt Arsenault [Fri, 20 Jul 2018 21:20:36 +0000 (21:20 +0000)]
AMDGPU: Use existing function to check for VGPRs

llvm-svn: 337621

6 years agofix typo
Nico Weber [Fri, 20 Jul 2018 21:06:41 +0000 (21:06 +0000)]
fix typo

llvm-svn: 337620

6 years ago[ms] Add __shiftleft128 / __shiftright128 intrinsics
Nico Weber [Fri, 20 Jul 2018 21:02:09 +0000 (21:02 +0000)]
[ms] Add __shiftleft128 / __shiftright128 intrinsics

Carefully match the pattern matched by ISel so that this produces shld / shrd
(unless Subtarget->isSHLDSlow() is true).

Thanks to Craig Topper for providing the LLVM IR pattern that gets successfully
matched.

Fixes PR37755.

llvm-svn: 337619

6 years agoRevert "[X86][AVX] Convert X86ISD::VBROADCAST demanded elts combine to use SimplifyDe...
Benjamin Kramer [Fri, 20 Jul 2018 20:59:46 +0000 (20:59 +0000)]
Revert "[X86][AVX] Convert X86ISD::VBROADCAST demanded elts combine to use SimplifyDemandedVectorElts"

This reverts commit r337547. It triggers an infinite loop.

llvm-svn: 337617

6 years ago[codeview] Don't emit variable templates as class members
Reid Kleckner [Fri, 20 Jul 2018 20:55:00 +0000 (20:55 +0000)]
[codeview] Don't emit variable templates as class members

MSVC doesn't, so neither should we.

Fixes PR38004, which is a crash that happens when we try to emit debug
info for a still-dependent partial variable template specialization.

As a follow-up, we should review what we're doing for function and class
member templates. It looks like we don't filter those out, but I can't
seem to get clang to emit any.

llvm-svn: 337616

6 years ago[llvm-undname] Remove a superfluous semicolon. NFC.
Martin Storsjo [Fri, 20 Jul 2018 20:48:36 +0000 (20:48 +0000)]
[llvm-undname] Remove a superfluous semicolon. NFC.

llvm-svn: 337615

6 years ago[COFF] Use symbolic constants instead of hardcoded numbers. NFCI.
Martin Storsjo [Fri, 20 Jul 2018 20:48:33 +0000 (20:48 +0000)]
[COFF] Use symbolic constants instead of hardcoded numbers. NFCI.

Patch by Martell Malone.

llvm-svn: 337614

6 years ago[COFF] Adjust how we flag weak externals
Martin Storsjo [Fri, 20 Jul 2018 20:48:29 +0000 (20:48 +0000)]
[COFF] Adjust how we flag weak externals

This fixes PR36096.

Originally based on a patch by Martell Malone.

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

llvm-svn: 337613

6 years agoAMDGPU: Switch default dwarf version to 2
Konstantin Zhuravlyov [Fri, 20 Jul 2018 20:46:25 +0000 (20:46 +0000)]
AMDGPU: Switch default dwarf version to 2

There were some problems unearthed with version 5,
which I am going to look at.

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

llvm-svn: 337612

6 years ago[CStringSyntaxChecker] Fix build bot builds != x86 archs
David Carlier [Fri, 20 Jul 2018 20:39:49 +0000 (20:39 +0000)]
[CStringSyntaxChecker] Fix build bot builds != x86 archs

Reviewers: NoQ,george.karpenkov

Reviewed By: NoQ

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

llvm-svn: 337611

6 years ago[ELF] Check eh_frame_hdr overflow with PC offsets instead of PC absolute addresses
Fangrui Song [Fri, 20 Jul 2018 20:27:42 +0000 (20:27 +0000)]
[ELF] Check eh_frame_hdr overflow with PC offsets instead of PC absolute addresses

Reviewers: grimar, ruiu, espindola

Subscribers: emaste, arichardson, llvm-commits

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

llvm-svn: 337610

6 years ago[FileCheck] Provide an option for FileCheck to dump original input to stderr on failure
George Karpenkov [Fri, 20 Jul 2018 20:21:57 +0000 (20:21 +0000)]
[FileCheck] Provide an option for FileCheck to dump original input to stderr on failure

The option can be either set using environment variable (e.g. env
FILECHECK_DUMP_INPUT_ON_FAILURE=1 ninja check-fuzzer) or with a
FileCheck flag.

This can be extremely useful for debugging, cf.
https://groups.google.com/forum/#!topic/llvm-dev/kLrzg8OM_h8 for
discussion.

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

llvm-svn: 337609

6 years agoRevert r337595 "[ORC] Add new symbol lookup methods to ExecutionSessionBase in prepar...
Reid Kleckner [Fri, 20 Jul 2018 20:20:45 +0000 (20:20 +0000)]
Revert r337595 "[ORC] Add new symbol lookup methods to ExecutionSessionBase in preparation for"

Breaks the build with LLVM_ENABLE_THREADS=OFF.

llvm-svn: 337608

6 years ago[AST] Various micro-optimizations in CXXInheritance
Benjamin Kramer [Fri, 20 Jul 2018 20:13:08 +0000 (20:13 +0000)]
[AST] Various micro-optimizations in CXXInheritance

1. Pack std::pair<bool, unsigned> in CXXBasePaths::ClassSubobjects.
2. Use a SmallPtrSet instead of a SmallDenseSet for CXXBasePaths::VisitedDependentRecords.
3. Reorder some members of CXXBasePaths to save 8 bytes.
4. Use a SmallSetVector instead of a SetVector in CXXBasePaths::ComputeDeclsFound to avoid some allocations.

This speeds up an -fsyntax-only on all of Boost by approx 0.15%,
mainly by speeding up CXXBasePaths::lookupInBases by
approx 10%. No functional changes.

Patch by Bruno Ricci!

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

llvm-svn: 337607

6 years agoReapply "[LSV] Refactoring + supporting bitcasts to a type of different size"
Roman Tereshin [Fri, 20 Jul 2018 20:10:04 +0000 (20:10 +0000)]
Reapply "[LSV] Refactoring + supporting bitcasts to a type of different size"

This reapplies commit r337489 reverted by r337541
Additionally, this commit contains a speculative fix to the issue reported in r337541
(the report does not contain an actionable reproducer, just a stack trace)

llvm-svn: 337606

6 years ago[FileCheck] Fix search ranges for DAG-NOT-DAG
Joel E. Denny [Fri, 20 Jul 2018 20:09:56 +0000 (20:09 +0000)]
[FileCheck] Fix search ranges for DAG-NOT-DAG

A DAG-NOT-DAG is a CHECK-DAG group, X, followed by a CHECK-NOT group,
N, followed by a CHECK-DAG group, Y.  Let y be the initial directive
of Y.  This patch makes the following changes to the behavior:

    1. Directives in N can no longer match within part of Y's match
       range just because y happens not to be the earliest match from
       Y.  Specifically, this patch withdraws N's search range end
       from y's match range start to Y's match range start.

    2. y can no longer match within X's match range, where a y match
       produced a reordering complaint, which is thus no longer
       possible.  Specifically, this patch withdraws y's search range
       start from X's permitted range start to X's match range end,
       which was already the search range start for other members of
       Y.

Both of these changes can only increase the number of test passes: #1
constrains the ability of CHECK-NOTs to match, and #2 expands the
ability of CHECK-DAGs to match without complaints.

These changes are based on discussions at:

   <http://lists.llvm.org/pipermail/llvm-dev/2018-May/123550.html>
   <https://reviews.llvm.org/D47106>

which conclude that:

    1. These changes simplify the FileCheck conceptual model.  First,
       it makes search ranges for DAG-NOT-DAG more consistent with
       other cases.  Second, it was confusing that y was treated
       differently from the rest of Y.

    2. These changes add theoretical use cases for DAG-NOT-DAG that
       had no obvious means to be expressed otherwise.  We can justify
       the first half of this assertion with the observation that
       these changes can only increase the number of test passes.

    3. Reordering detection for DAG-NOT-DAG had no obvious real
       benefit.

We don't have evidence from real uses cases to help us debate
conclusions #2 and #3, but #1 at least seems intuitive.

Reviewed By: probinson

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

llvm-svn: 337605

6 years ago[llvm-objcopy] Add basic support for --rename-section
Jordan Rupprecht [Fri, 20 Jul 2018 19:54:24 +0000 (19:54 +0000)]
[llvm-objcopy] Add basic support for --rename-section

Summary:
Add basic support for --rename-section=old=new to llvm-objcopy.

A full replacement for GNU objcopy requires also modifying flags (i.e. --rename-section=old=new,flag1,flag2); I'd like to keep that in a separate change to keep this simple.

Reviewers: jakehehrlich, alexshap

Subscribers: llvm-commits

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

llvm-svn: 337604

6 years agoMark REAL(swapcontext) with indirect_return attribute on x86
H.J. Lu [Fri, 20 Jul 2018 19:24:11 +0000 (19:24 +0000)]
Mark REAL(swapcontext) with indirect_return attribute on x86

When shadow stack from Intel CET is enabled, the first instruction of all
indirect branch targets must be a special instruction, ENDBR.

lib/asan/asan_interceptors.cc has

...
  int res = REAL(swapcontext)(oucp, ucp);
...

REAL(swapcontext) is a function pointer to swapcontext in libc.  Since
swapcontext may return via indirect branch on x86 when shadow stack is
enabled, as in this case,

int res = REAL(swapcontext)(oucp, ucp);
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^  This function may be
returned via an indirect branch.

Here compiler must insert ENDBR after call, like

call *bar(%rip)
endbr64

I opened an LLVM bug:

https://bugs.llvm.org/show_bug.cgi?id=38207

to add the indirect_return attribute so that it can be used to inform
compiler to insert ENDBR after REAL(swapcontext) call.  We mark
REAL(swapcontext) with the indirect_return attribute if it is available.

This fixed:

https://bugs.llvm.org/show_bug.cgi?id=38249

Reviewed By: eugenis

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

llvm-svn: 337603

6 years ago[clang-doc] Adding PublicOnly flag
Julie Hockett [Fri, 20 Jul 2018 18:49:55 +0000 (18:49 +0000)]
[clang-doc] Adding PublicOnly flag

Submitted on behalf of Annie Cherkaev (@anniecherk)

Added a flag which, when enabled, documents only those methods and
fields which have a Public attribute.

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

llvm-svn: 337602

6 years ago[clangd] Fix racy use-after-scope in unittest
Benjamin Kramer [Fri, 20 Jul 2018 18:45:25 +0000 (18:45 +0000)]
[clangd] Fix racy use-after-scope in unittest

This only shows up with asan when the stars align in a bad way.

llvm-svn: 337601

6 years agoAnd add a lit substitution for llvm-undname, as the comment says to
Reid Kleckner [Fri, 20 Jul 2018 18:45:01 +0000 (18:45 +0000)]
And add a lit substitution for llvm-undname, as the comment says to

llvm-svn: 337600

6 years agoRemove a superfluous semicolon
Martin Storsjo [Fri, 20 Jul 2018 18:43:42 +0000 (18:43 +0000)]
Remove a superfluous semicolon

llvm-svn: 337599

6 years ago[COFF] Sort .reloc before all other discardable sections
Martin Storsjo [Fri, 20 Jul 2018 18:43:35 +0000 (18:43 +0000)]
[COFF] Sort .reloc before all other discardable sections

If a binary is stripped, which can remove discardable sections (except
for the .reloc section, which also is marked as discardable as it isn't
loaded at runtime, only read by the loader), the .reloc section should
be first of them, in order not to create gaps in the image.

Previously, binaries with relocations were broken if they were stripped
by GNU binutils strip. Trying to execute such binaries produces an error
about "xx is not a valid win32 application".

This fixes GNU binutils bug 23348.

Prior to SVN r329370 (which didn't intend to have functional changes),
the code for moving discardable sections to the end didn't clearly
express how other discardable sections should be ordered compared to
.reloc, but the change retained the exact same end result as before.

After SVN r329370, the code (and comments) more clearly indicate that
it tries to make the .reloc section the absolutely last one; this patch
changes that.

This matches how GNU binutils ld sorts .reloc compared to dwarf debug
info sections.

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

Signed-off-by: Martin Storsjö <martin@martin.st>
llvm-svn: 337598

6 years agoMake check-llvm depend on llvm-undname
Reid Kleckner [Fri, 20 Jul 2018 18:42:19 +0000 (18:42 +0000)]
Make check-llvm depend on llvm-undname

llvm-svn: 337597

6 years ago[Demangler] Correctly factor in assignment when allocating.
Zachary Turner [Fri, 20 Jul 2018 18:35:06 +0000 (18:35 +0000)]
[Demangler] Correctly factor in assignment when allocating.

Incidentally all allocations that we currently perform were
properly aligned, but this was only an accident.

Thanks to Erik Pilkington for catching this.

llvm-svn: 337596

6 years ago[ORC] Add new symbol lookup methods to ExecutionSessionBase in preparation for
Lang Hames [Fri, 20 Jul 2018 18:31:53 +0000 (18:31 +0000)]
[ORC] Add new symbol lookup methods to ExecutionSessionBase in preparation for
deprecating SymbolResolver and AsynchronousSymbolQuery.

Both lookup overloads take a VSO search order to perform the lookup. The first
overload is non-blocking and takes OnResolved and OnReady callbacks. The second
is blocking, takes a boolean flag to indicate whether to wait until all symbols
are ready, and returns a SymbolMap. Both overloads take a RegisterDependencies
function to register symbol dependencies (if any) on the query.

llvm-svn: 337595

6 years ago[ORC] Simplify VSO::lookupFlags to return the flags map.
Lang Hames [Fri, 20 Jul 2018 18:31:52 +0000 (18:31 +0000)]
[ORC] Simplify VSO::lookupFlags to return the flags map.

This discards the unresolved symbols set and returns the flags map directly
(rather than mutating it via the first argument).

The unresolved symbols result made it easy to chain lookupFlags calls, but such
chaining should be rare to non-existant (especially now that symbol resolvers
are being deprecated) so the simpler method signature is preferable.

llvm-svn: 337594

6 years ago[ORC] Replace SymbolResolvers in the new ORC layers with search orders on VSOs.
Lang Hames [Fri, 20 Jul 2018 18:31:50 +0000 (18:31 +0000)]
[ORC] Replace SymbolResolvers in the new ORC layers with search orders on VSOs.

A search order is a list of VSOs to be searched linearly to find symbols. Each
VSO now has a search order that will be used when fixing up definitions in that
VSO. Each VSO's search order defaults to just that VSO itself.

This is a first step towards removing symbol resolvers from ORC altogether. In
practice symbol resolvers tended to be used to implement a search order anyway,
sometimes with additional programatic generation of symbols. Now that VSOs
support programmatic generation of definitions via fallback generators, search
orders provide a cleaner way to achieve the desired effect (while removing a lot
of boilerplate).

llvm-svn: 337593

6 years ago[Demangler] Add missing overrides
Benjamin Kramer [Fri, 20 Jul 2018 18:22:12 +0000 (18:22 +0000)]
[Demangler] Add missing overrides

-Winconsistent-missing-override complains about this.

llvm-svn: 337592

6 years agoFix a few warnings and style issues in MS demangler.
Zachary Turner [Fri, 20 Jul 2018 18:07:33 +0000 (18:07 +0000)]
Fix a few warnings and style issues in MS demangler.

Also remove a broken test case.

llvm-svn: 337591

6 years ago[X86] Remove isel patterns for MOVSS/MOVSD ISD opcodes with integer types.
Craig Topper [Fri, 20 Jul 2018 17:57:53 +0000 (17:57 +0000)]
[X86] Remove isel patterns for MOVSS/MOVSD ISD opcodes with integer types.

Ideally our ISD node types going into the isel table would have types consistent with their instruction domain. This prevents us having to duplicate patterns with different types for the same instruction.

Unfortunately, it seems our shuffle combining is currently relying on this a little remove some bitcasts. This seems to enable some switching between shufps and shufd. Hopefully there's some way we can address this in the combining.

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

llvm-svn: 337590

6 years ago[X86] Remove what appear to be unnecessary uses of DCI.CombineTo
Craig Topper [Fri, 20 Jul 2018 17:57:42 +0000 (17:57 +0000)]
[X86] Remove what appear to be unnecessary uses of DCI.CombineTo

CombineTo is most useful when you need to replace multiple results, avoid the worklist management, or you need to something else after the combine, etc. Otherwise you should be able to just return the new node and let DAGCombiner go through its usual worklist code.

All of the places changed in this patch look to be standard cases where we should be able to use the more stand behavior of just returning the new node.

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

llvm-svn: 337589

6 years agoFix linker failure with Any.
Zachary Turner [Fri, 20 Jul 2018 17:50:53 +0000 (17:50 +0000)]
Fix linker failure with Any.

This is due to a difference in MS ABI which is why I didn't see
it locally.  The included fix should work on all compilers.

llvm-svn: 337588

6 years ago[CUDA] Provide integer SIMD functions for CUDA-9.2
Artem Belevich [Fri, 20 Jul 2018 17:44:34 +0000 (17:44 +0000)]
[CUDA] Provide integer SIMD functions for CUDA-9.2

CUDA-9.2 made all integer SIMD functions into compiler builtins,
so clang no longer has access to the implementation of these
functions in either headers of libdevice and has to provide
its own implementation.

This is mostly a 1:1 mapping to a corresponding PTX instructions
with an exception of vhadd2/vhadd4 that don't have an equivalent
instruction and had to be implemented with a bit hack.

Performance of this implementation will be suboptimal for SM_50
and newer GPUs where PTXAS generates noticeably worse code for
the SIMD instructions compared to the code it generates
for the inline assembly generated by nvcc (or used to come
with CUDA headers).

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

llvm-svn: 337587

6 years ago[llvm-mca][x86] Add movsx/movzx instructions to general x86_64 resource tests
Simon Pilgrim [Fri, 20 Jul 2018 17:43:42 +0000 (17:43 +0000)]
[llvm-mca][x86] Add movsx/movzx instructions to general x86_64 resource tests

llvm-svn: 337586

6 years agoPrevent Scoped Enums from being Integral constant expressions:
Erich Keane [Fri, 20 Jul 2018 17:42:09 +0000 (17:42 +0000)]
Prevent Scoped Enums from being Integral constant expressions:

Discovered because of: https://bugs.llvm.org/show_bug.cgi?id=38235

It seems to me that a scoped enum should NOT be an integral constant expression
without a cast, so this seems like a sensical change.

Attributes that check for an integer parameter simply use this function to
ensure that they have an integer, so it was previously allowing a scoped enum.

Also added a test based on Richard's feedback to ensure that case labels still work.

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

llvm-svn: 337585