platform/upstream/llvm.git
6 years ago[lld] Switch to add_llvm_install_targets
Shoaib Meenai [Fri, 1 Dec 2017 04:17:45 +0000 (04:17 +0000)]
[lld] Switch to add_llvm_install_targets

This adds install-*-stripped targets that strip during installation.

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

llvm-svn: 319517

6 years agoClangASTContext::ParseClassTemplateDecl doesn't always succeed.
Jim Ingham [Fri, 1 Dec 2017 03:41:30 +0000 (03:41 +0000)]
ClangASTContext::ParseClassTemplateDecl doesn't always succeed.
When it does, it returns a NULL ClassTemplateDecl.  Don't use
it if it is NULL...

<rdar://problem/35672107>

llvm-svn: 319516

6 years agoInclude AddLLVM needed for tests in the right context
Petr Hosek [Fri, 1 Dec 2017 03:16:50 +0000 (03:16 +0000)]
Include AddLLVM needed for tests in the right context

AddLLVM is needed for several functions that are used in tests and
as such needs to be included from the right context which previously
wasn't the case.

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

llvm-svn: 319515

6 years ago[X86] Add a DAG combine to simplify masks for AVX2 gather instructions.
Craig Topper [Fri, 1 Dec 2017 02:49:07 +0000 (02:49 +0000)]
[X86] Add a DAG combine to simplify masks for AVX2 gather instructions.

AVX2 gathers only use the upper bit of the mask allowing us to simplify sign_extend_inreg to a shift left.

llvm-svn: 319514

6 years ago[c++2a] P0515R3: Support for overloaded operator<=>.
Richard Smith [Fri, 1 Dec 2017 02:13:10 +0000 (02:13 +0000)]
[c++2a] P0515R3: Support for overloaded operator<=>.

No CodeGen support for MSABI yet, we don't know how to mangle this there.

llvm-svn: 319513

6 years agoclang-format.
Rui Ueyama [Fri, 1 Dec 2017 02:11:29 +0000 (02:11 +0000)]
clang-format.

llvm-svn: 319512

6 years ago[cmake] Expose opt-viewer availability
Adam Nemet [Fri, 1 Dec 2017 01:44:26 +0000 (01:44 +0000)]
[cmake] Expose opt-viewer availability

This will be used in https://github.com/apple/swift/pull/12938

llvm-svn: 319511

6 years ago[WebAssembly] Update MC tests now that hidden attr is supported
Sam Clegg [Fri, 1 Dec 2017 01:18:47 +0000 (01:18 +0000)]
[WebAssembly] Update MC tests now that hidden attr is supported

Summary:
Support was added in rL319488 but these tests were not
updated.

Subscribers: jfb, dschuff, jgravelle-google, aheejin, sunfish

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

llvm-svn: 319510

6 years ago[c++2a] P0515R3: lexer support for new <=> token.
Richard Smith [Fri, 1 Dec 2017 01:07:10 +0000 (01:07 +0000)]
[c++2a] P0515R3: lexer support for new <=> token.

llvm-svn: 319509

6 years agoRevert "Merge .xdata into .rdata by default"
Reid Kleckner [Fri, 1 Dec 2017 01:04:31 +0000 (01:04 +0000)]
Revert "Merge .xdata into .rdata by default"

This reverts commit r318699, it is breaking 32-bit SEH handlers in
Chromium.

llvm-svn: 319508

6 years agoAdd flag to ArchiveWriter to test GNU64 format more efficiently
Jake Ehrlich [Fri, 1 Dec 2017 00:54:28 +0000 (00:54 +0000)]
Add flag to ArchiveWriter to test GNU64 format more efficiently

Even with the sparse file optimizations the SYM64 test can still be painfully
slow. This unnecessarily slows down devs. It's critical that we test that the
switch to the SYM64 format occurs at 4GB but there isn't any better of a way to
fake the size of the file than sparse files. This change introduces a flag that
allows the cutoff to be arbitrarily set to whatever power of two is desired.
The flag is hidden as it really isn't meant to be used outside this one test.
This is unfortunate but appears necessary, at least until the average hard
drive is much faster.

The changes to the test require some explanation. Prior to this change we knew
that the SYM64 format was being used because the file was simply too large to
have validly handled this case if the SYM64 format were not used. To ensure
that the SYM64 format is still being used I am grepping the file for "SYM64".
Without changing the filename however this would be pointless because "SYM64"
would occur in the file either way. So the filename of the test is also changed
in order to avoid this issue.

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

llvm-svn: 319507

6 years ago[WebAssembly] Fix typos
Sam Clegg [Fri, 1 Dec 2017 00:53:21 +0000 (00:53 +0000)]
[WebAssembly] Fix typos

Patch by Nicholas Wilson

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

llvm-svn: 319506

6 years agoMark all library options as hidden.
Zachary Turner [Fri, 1 Dec 2017 00:53:10 +0000 (00:53 +0000)]
Mark all library options as hidden.

These command line options are not intended for public use, and often
don't even make sense in the context of a particular tool anyway. About
90% of them are already hidden, but when people add new options they
forget to hide them, so if you were to make a brand new tool today, link
against one of LLVM's libraries, and run tool -help you would get a
bunch of junk that doesn't make sense for the tool you're writing.

This patch hides these options. The real solution is to not have
libraries defining command line options, but that's a much larger effort
and not something I'm prepared to take on.

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

llvm-svn: 319505

6 years agoAdd lldb-test.
Zachary Turner [Fri, 1 Dec 2017 00:52:51 +0000 (00:52 +0000)]
Add lldb-test.

This is basically a proof-of-concept and starting point for having a
testing-centric tool in LLDB.  I'm sure this leaves a lot of room to be
desired, but this at least allows us to have something to build on.

Right now there is only one command, the `module-sections` command, and I
created this command not because it was particularly special, but
because it addressed an immediate use case and was extremely simple.

Run the tool as `lldb-test module-sections <path-to-object>`.

Feel free to add testing related stuff to your heart's content after
this goes in.  Implementing the commands themselves takes some work, but
once they're there they can be reused without writing any code and
result in very easy to use and maintain tests.

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

llvm-svn: 319504

6 years agoMake .gnu.hash section smaller.
Rui Ueyama [Thu, 30 Nov 2017 23:59:40 +0000 (23:59 +0000)]
Make .gnu.hash section smaller.

Our on-disk hash table was unnecessarily large. The cost of collision is
not high in the .gnu.hash table because each symbol in the .gnu.hash
table has a hash value with it. So, for each collided symbol, the
dynamic linker just compares an integer, which is pretty cheap.

This patch increases the load factor by about 8. Here's a comparison.

  $ readelf --histogram libclangSema.so.6.0.0svn-new-lld
  Histogram for `.gnu.hash' bucket list length (total of 582 buckets):
   Length  Number     % of total  Coverage
        0  11         (  1.9%)
        1  35         (  6.0%)      1.5%
        2  93         ( 16.0%)      9.5%
        3  108        ( 18.6%)     23.4%
        4  121        ( 20.8%)     44.1%
        5  86         ( 14.8%)     62.6%
        6  63         ( 10.8%)     78.8%
        7  38         (  6.5%)     90.2%
        8  18         (  3.1%)     96.4%
        9  6          (  1.0%)     98.7%
       10  3          (  0.5%)    100.0%

  $ readelf --histogram libclangSema.so.6.0.0svn-old-lld
  Histogram for `.gnu.hash' bucket list length (total of 4093 buckets):
   Length  Number     % of total  Coverage
        0  1498       ( 36.6%)
        1  1545       ( 37.7%)     37.7%
        2  712        ( 17.4%)     72.5%
        3  251        (  6.1%)     90.9%
        4  66         (  1.6%)     97.3%
        5  16         (  0.4%)     99.3%
        6  5          (  0.1%)    100.0%

  $ readelf --histogram libclangSema.so.6.0.0svn-bfd
  Histogram for `.gnu.hash' bucket list length (total of 1004 buckets):
   Length  Number     % of total  Coverage
      0  92         (  9.2%)
        1  227        ( 22.6%)      9.8%
        2  266        ( 26.5%)     32.6%
        3  222        ( 22.1%)     61.2%
        4  115        ( 11.5%)     81.0%
        5  55         (  5.5%)     92.8%
        6  21         (  2.1%)     98.2%
        7  6          (  0.6%)    100.0%

  $ readelf --histogram libclangSema.so.6.0.0svn-gold
  Histogram for `.gnu.hash' bucket list length (total of 2053 buckets):
   Length  Number     % of total  Coverage
        0  671        ( 32.7%)
        1  709        ( 34.5%)     30.4%
        2  470        ( 22.9%)     70.7%
        3  141        (  6.9%)     88.9%
        4  54         (  2.6%)     98.2%
        5  5          (  0.2%)     99.2%
        6  3          (  0.1%)    100.0%

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

llvm-svn: 319503

6 years agodocs/GettingStarted.rst: Update the list of release versions and tags
Hans Wennborg [Thu, 30 Nov 2017 23:47:30 +0000 (23:47 +0000)]
docs/GettingStarted.rst: Update the list of release versions and tags

llvm-svn: 319502

6 years agoAMDGPU: Use carry-less adds in FI elimination
Matt Arsenault [Thu, 30 Nov 2017 23:42:30 +0000 (23:42 +0000)]
AMDGPU: Use carry-less adds in FI elimination

llvm-svn: 319501

6 years agoWe had a situation where a kext was inlined into the kernel,
Jason Molenda [Thu, 30 Nov 2017 23:31:18 +0000 (23:31 +0000)]
We had a situation where a kext was inlined into the kernel,
but still listed in the kernel's kext table with the kernel
binary UUID.  This resulted in the kernel text section being
loaded at the kext address and problems ensuing.  Instead,
if there is a kext with the same UUID as the kernel, lldb
should skip over it.

<rdar://problem/35757689>

llvm-svn: 319500

6 years ago[libc++abi] Add install-cxxabi-stripped target
Shoaib Meenai [Thu, 30 Nov 2017 23:25:51 +0000 (23:25 +0000)]
[libc++abi] Add install-cxxabi-stripped target

LLVM is gaining install-*-stripped targets to perform stripped installs,
and in order for this to be useful for install-distribution, all
potential distribution components should have stripped installation
targets. LLVM has a function to create these install targets, but since
we can't use LLVM CMake functions in libc++abi, let's do it manually.

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

llvm-svn: 319499

6 years ago[libunwind] Switch to add_llvm_install_targets
Shoaib Meenai [Thu, 30 Nov 2017 23:24:08 +0000 (23:24 +0000)]
[libunwind] Switch to add_llvm_install_targets

This gains us the install-unwind-stripped target, to perform stripping
during installation.

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

llvm-svn: 319498

6 years ago[clangd] Logger implicitly adds newline
Sam McCall [Thu, 30 Nov 2017 23:21:34 +0000 (23:21 +0000)]
[clangd] Logger implicitly adds newline

llvm-svn: 319497

6 years ago[clangd] Log file compile commands
Sam McCall [Thu, 30 Nov 2017 23:16:23 +0000 (23:16 +0000)]
[clangd] Log file compile commands

llvm-svn: 319496

6 years agoUpdate website to mention that you still need -frelaxed-template-template-args to...
Richard Smith [Thu, 30 Nov 2017 23:07:29 +0000 (23:07 +0000)]
Update website to mention that you still need -frelaxed-template-template-args to enable the corresponding C++17 feature in Clang 5.

llvm-svn: 319495

6 years agoThinLTOBitcodeWriter: Try harder to discard unused references to the merged module.
Peter Collingbourne [Thu, 30 Nov 2017 23:05:52 +0000 (23:05 +0000)]
ThinLTOBitcodeWriter: Try harder to discard unused references to the merged module.

If the thin module has no references to an internal global in the
merged module, we need to make sure to preserve that property if the
global is a member of a comdat group, as otherwise promotion can end
up adding global symbols to the comdat, which is not allowed.

This situation can arise if the external global in the thin module
has dead constant users, which would cause use_empty() to return
false and would cause us to try to promote it. To prevent this from
happening, discard the dead constant users before asking whether a
global is empty.

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

llvm-svn: 319494

6 years agoSimplify the DenseSet used for hashing CodeView records.
Zachary Turner [Thu, 30 Nov 2017 23:00:30 +0000 (23:00 +0000)]
Simplify the DenseSet used for hashing CodeView records.

This was storing the hash alongside the key so that the hash
doesn't need to be re-computed every time, but in doing so it
was allocating a structure to keep the key size small in the
DenseMap.  This is a noble goal, but it also leads to a pointer
indirection on every probe, and this cost of this pointer
indirection ends up being higher than the cost of having a
slightly larger entry in the hash table.  Removing this not only
simplifies the code, but yields a small but noticeable
performance improvement in the type merging algorithm.

llvm-svn: 319493

6 years ago[lldb] A few minor fixes in TaskPool
Alexander Shaposhnikov [Thu, 30 Nov 2017 22:56:11 +0000 (22:56 +0000)]
[lldb] A few minor fixes in TaskPool

1. Move TaskPool into the namespace lldb_private.
2. Add missing std::move in TaskPoolImpl::Worker.
3. std::thread::hardware_concurrency may return 0,
handle this case correctly.

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

Test plan: make check-all

llvm-svn: 319492

6 years agoAMDGPU: Use gfx9 carry-less add/sub instructions
Matt Arsenault [Thu, 30 Nov 2017 22:51:26 +0000 (22:51 +0000)]
AMDGPU: Use gfx9 carry-less add/sub instructions

llvm-svn: 319491

6 years agoXOR the frame pointer with the stack cookie when protecting the stack
Reid Kleckner [Thu, 30 Nov 2017 22:41:21 +0000 (22:41 +0000)]
XOR the frame pointer with the stack cookie when protecting the stack

Summary: This strengthens the guard and matches MSVC.

Reviewers: hans, etienneb

Subscribers: hiraditya, JDevlieghere, vlad.tsyrklevich, llvm-commits

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

llvm-svn: 319490

6 years ago[clang] Use add_llvm_install_targets
Shoaib Meenai [Thu, 30 Nov 2017 22:35:02 +0000 (22:35 +0000)]
[clang] Use add_llvm_install_targets

Use this function to create the install targets rather than doing so
manually, which gains us the `-stripped` install targets to perform
stripped installations.

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

llvm-svn: 319489

6 years agoAdd visibility flag to Wasm symbol flags
Sam Clegg [Thu, 30 Nov 2017 22:34:58 +0000 (22:34 +0000)]
Add visibility flag to Wasm symbol flags

The LLVM "hidden" flag needs to be passed through the Wasm
intermediate objects in order for the linker to apply
it to the final Wasm object.

The corresponding change in LLD is here: https://github.com/WebAssembly/lld/pull/14

Patch by Nicholas Wilson

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

llvm-svn: 319488

6 years ago[AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor...
Eugene Zelenko [Thu, 30 Nov 2017 22:33:48 +0000 (22:33 +0000)]
[AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 319487

6 years agoAdd missing test. NFC.
Rafael Espindola [Thu, 30 Nov 2017 22:29:14 +0000 (22:29 +0000)]
Add missing test. NFC.

We had no tests for what PROVIDE should do if there is a shared symbol
with the same name.

In both bfd and our existing implementation PROVIDE wins. Add a test
for that.

llvm-svn: 319486

6 years ago[CUDA] Tweak CUDA wrappers to make cuda-9 work with libc++
Artem Belevich [Thu, 30 Nov 2017 22:22:21 +0000 (22:22 +0000)]
[CUDA] Tweak CUDA wrappers to make cuda-9 work with libc++

CUDA-9 headers check for specific libc++ version and ifdef out
some of the definitions we need if LIBCPP_VERSION >= 3800.

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

llvm-svn: 319485

6 years ago[msan] Fix return type of mbrtowc
Vitaly Buka [Thu, 30 Nov 2017 22:15:39 +0000 (22:15 +0000)]
[msan] Fix return type of mbrtowc

Summary: Fixes https://github.com/google/oss-fuzz/issues/1009

Reviewers: eugenis

Subscribers: llvm-commits

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

llvm-svn: 319484

6 years ago[memcpyopt] Commit file missed in r319482.
Dan Gohman [Thu, 30 Nov 2017 22:13:13 +0000 (22:13 +0000)]
[memcpyopt] Commit file missed in r319482.

This change was meant to be included with r319482 but was accidentally
omitted.

llvm-svn: 319483

6 years ago[memcpyopt] Teach memcpyopt to optimize across basic blocks
Dan Gohman [Thu, 30 Nov 2017 22:10:53 +0000 (22:10 +0000)]
[memcpyopt] Teach memcpyopt to optimize across basic blocks

This teaches memcpyopt to make a non-local memdep query when a local query
indicates that the dependency is non-local. This notably allows it to
eliminate many more llvm.memcpy calls in common Rust code, often by 20-30%.

Fixes PR28958.

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

llvm-svn: 319482

6 years ago[InlineCost] Prefer getFunction() to two calls to getParent().
Davide Italiano [Thu, 30 Nov 2017 22:10:35 +0000 (22:10 +0000)]
[InlineCost] Prefer getFunction() to two calls to getParent().

Improves clarity, also slightly cheaper. NFCI.

llvm-svn: 319481

6 years ago[llvm] Add stripped installation targets
Shoaib Meenai [Thu, 30 Nov 2017 21:48:26 +0000 (21:48 +0000)]
[llvm] Add stripped installation targets

CMake's generated installation scripts support `CMAKE_INSTALL_DO_STRIP`
to enable stripping the installed binaries. LLVM's build system doesn't
expose this option to the `install-` targets, but it's useful in
conjunction with `install-distribution`.

Add a new function to create the install targets, which creates both the
regular install target and a second install target that strips during
installation. Change the creation of all installation targets to use
this new function. Stripping doesn't make a whole lot of sense for some
installation targets (e.g. the LLVM headers), but consistency doesn't
hurt.

I'll make other repositories (e.g. clang, compiler-rt) use this in a
follow-up, and then add an `install-distribution-stripped` target to
actually accomplish the end goal of creating a stripped distribution. I
don't want to do that step yet because the creation of that target would
depend on the presence of the `install-*-stripped` target for each
distribution component, and the distribution components from other
repositories will be missing that target right now.

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

llvm-svn: 319480

6 years ago[Documentation] Style fixes for Objective-C checks documentation to follow C/C++...
Eugene Zelenko [Thu, 30 Nov 2017 21:42:27 +0000 (21:42 +0000)]
[Documentation] Style fixes for Objective-C checks documentation to follow C/C++ example.

Release Notes should just repeat first sentence from documentation.

Remove duplicated entry from Release Notes.

llvm-svn: 319479

6 years ago[clangd] New conventions for JSON-marshalling functions, centralize machinery
Sam McCall [Thu, 30 Nov 2017 21:32:29 +0000 (21:32 +0000)]
[clangd] New conventions for JSON-marshalling functions, centralize machinery

Summary:
 - JSON<->Obj interface is now ADL functions, so they play nicely with enums
 - recursive vector/map parsing and ObjectMapper moved to JSONExpr and tested
 - renamed (un)parse to (de)serialize, since text -> JSON is called parse
 - Protocol.cpp gets a bit shorter

Sorry for the giant patch, it's prety mechanical though

Reviewers: ilya-biryukov

Subscribers: klimek, cfe-commits

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

llvm-svn: 319478

6 years ago[Hexagon] Implement HexagonSubtarget::useAA()
Krzysztof Parzyszek [Thu, 30 Nov 2017 21:25:28 +0000 (21:25 +0000)]
[Hexagon] Implement HexagonSubtarget::useAA()

llvm-svn: 319477

6 years ago[Hexagon] Fix wrong check in test/CodeGen/Hexagon/newvaluejump-solo.mir
Krzysztof Parzyszek [Thu, 30 Nov 2017 21:23:19 +0000 (21:23 +0000)]
[Hexagon] Fix wrong check in test/CodeGen/Hexagon/newvaluejump-solo.mir

llvm-svn: 319476

6 years ago[globalisel][tablegen] Add support for relative AtomicOrderings
Daniel Sanders [Thu, 30 Nov 2017 21:05:59 +0000 (21:05 +0000)]
[globalisel][tablegen] Add support for relative AtomicOrderings

No test yet because the relevant rules are blocked on the atomic_load,
and atomic_store nodes.

llvm-svn: 319475

6 years agoAdd powerpc64 to compiler-rt build infrastructure.
Sterling Augustine [Thu, 30 Nov 2017 21:04:11 +0000 (21:04 +0000)]
Add powerpc64 to compiler-rt build infrastructure.

Now that we have disabled the run-forever tests, and cleaned up the
intel 80-bit float based tests, we should be able to enable testing
compiler-rt for powerpc64.

llvm-svn: 319474

6 years agoError on -no-define-common if the output is not relocatable.
Rafael Espindola [Thu, 30 Nov 2017 20:46:33 +0000 (20:46 +0000)]
Error on -no-define-common if the output is not relocatable.

The ELF spec says

Symbols with section index SHN_COMMON may appear only in relocatable
objects.

Currently lld can produce file that break that requirement.

llvm-svn: 319473

6 years agoFix this test so that the breakpoints you set are
Jim Ingham [Thu, 30 Nov 2017 20:43:00 +0000 (20:43 +0000)]
Fix this test so that the breakpoints you set are
unambiguously on one bit of code.  On macOS these
lines mapped to two distinct locations, and that
was artificially throwing off the test.

llvm-svn: 319472

6 years ago[Hexagon] Fix wrong pass in testcase
Krzysztof Parzyszek [Thu, 30 Nov 2017 20:39:15 +0000 (20:39 +0000)]
[Hexagon] Fix wrong pass in testcase

llvm-svn: 319471

6 years ago[Hexagon] Solo instructions cannot be used with new value jumps
Krzysztof Parzyszek [Thu, 30 Nov 2017 20:32:54 +0000 (20:32 +0000)]
[Hexagon] Solo instructions cannot be used with new value jumps

llvm-svn: 319470

6 years ago[AMDGPU] Convert test/tools/llvm-objdump/AMDGPU/source-lines.ll to amdgiz
Yaxun Liu [Thu, 30 Nov 2017 20:27:56 +0000 (20:27 +0000)]
[AMDGPU] Convert test/tools/llvm-objdump/AMDGPU/source-lines.ll to amdgiz

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

llvm-svn: 319469

6 years ago[X86] Promote i8 CTPOP to i32 instead of i16 when we have the POPCNT instruction.
Craig Topper [Thu, 30 Nov 2017 20:15:31 +0000 (20:15 +0000)]
[X86] Promote i8 CTPOP to i32 instead of i16 when we have the POPCNT instruction.

The 32-bit version is shorter to encode and the zext we emit for the promotion is likely going to be a 32-bit zero extend anyway.

llvm-svn: 319468

6 years ago[llvm-objcopy] Add support for --only-keep/-j and --keep
Jake Ehrlich [Thu, 30 Nov 2017 20:14:53 +0000 (20:14 +0000)]
[llvm-objcopy] Add support for --only-keep/-j and --keep

This change adds support for the --only-keep option and the -j alias as well.
A common use case for these being used together is to dump a specific section's
data. Additionally the --keep option is added (GNU objcopy doesn't have this)
to avoid removing a bunch of things. This allows people to err on the side of
stripping aggressively and then to keep the specific bits that they need for
their application.

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

llvm-svn: 319467

6 years ago[aarch64][globalisel] Legalize G_ATOMIC_CMPXCHG_WITH_SUCCESS and G_ATOMICRMW_*
Daniel Sanders [Thu, 30 Nov 2017 20:11:42 +0000 (20:11 +0000)]
[aarch64][globalisel] Legalize G_ATOMIC_CMPXCHG_WITH_SUCCESS and G_ATOMICRMW_*

G_ATOMICRMW_* is generally legal on AArch64. The exception is G_ATOMICRMW_NAND.

G_ATOMIC_CMPXCHG_WITH_SUCCESS needs to be lowered to G_ATOMIC_CMPXCHG with an
external comparison.

Note that IRTranslator doesn't generate these instructions yet.

llvm-svn: 319466

6 years ago[GlobalISel][IRTranslator] Fix crash during translation of zero sized loads/stores...
Amara Emerson [Thu, 30 Nov 2017 20:06:02 +0000 (20:06 +0000)]
[GlobalISel][IRTranslator] Fix crash during translation of zero sized loads/stores/args/returns.

This fixes PR35358.

rdar://35619533

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

llvm-svn: 319465

6 years agoMove x86-specific sources to x86-specific source lists.
Sterling Augustine [Thu, 30 Nov 2017 19:39:33 +0000 (19:39 +0000)]
Move x86-specific sources to x86-specific source lists.

llvm-svn: 319464

6 years ago[PGO] Add a test case for infinite loops
Xinliang David Li [Thu, 30 Nov 2017 19:37:56 +0000 (19:37 +0000)]
[PGO] Add a test case for infinite loops

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

llvm-svn: 319463

6 years ago[PGO] Skip counter promotion for infinite loops
Xinliang David Li [Thu, 30 Nov 2017 19:16:25 +0000 (19:16 +0000)]
[PGO] Skip counter promotion for infinite loops

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

llvm-svn: 319462

6 years ago[cmake] Include project name in Sphinx doctree dir to fix race conditions
Michal Gorny [Thu, 30 Nov 2017 19:09:22 +0000 (19:09 +0000)]
[cmake] Include project name in Sphinx doctree dir to fix race conditions

Modify add_sphinx_target() to include the project name alongside builder
in Sphinx doctree directory. This aims to avoid crashes due to race
conditions between multiple Sphinx instances running in parallel that
attempt to create or read that directory simultaneously.

This problem has originally been addressed in r283188. However, that
commit presumed that there will be only one target per builder being
run. However, r314863 introduced a second manpage target, reintroducing
the race condition.

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

llvm-svn: 319461

6 years agoadd new check to find NSError init invocation
Yan Zhang [Thu, 30 Nov 2017 19:05:09 +0000 (19:05 +0000)]
add new check to find NSError init invocation

Subscribers: klimek, mgorny, cfe-commits

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

llvm-svn: 319460

6 years agoadd new check to find NSError init invocation
Yan Zhang [Thu, 30 Nov 2017 19:05:08 +0000 (19:05 +0000)]
add new check to find NSError init invocation

Summary:
This check will find out improper initialization of NSError objects.

According to Apple developer document, we should always use factory method errorWithDomain:code:userInfo: to create new NSError objects instead of [NSError alloc] init]. Otherwise it will lead to a warning message during runtime in Xcode.

The corresponding information about NSError creation: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/CreateCustomizeNSError/CreateCustomizeNSError.html

Reviewers: hokein, benhamilton

Reviewed By: benhamilton

Subscribers: klimek, mgorny, cfe-commits

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

llvm-svn: 319459

6 years ago[OpenMP] Diagnose undeclared variables on declare target clause
Kelvin Li [Thu, 30 Nov 2017 18:52:06 +0000 (18:52 +0000)]
[OpenMP] Diagnose undeclared variables on declare target clause

Clang asserts on undeclared variables on the to or link clause in the declare
target directive. The patch is to properly diagnose the error.

// foo1 and foo2 are not declared
#pragma omp declare target to(foo1)
#pragma omp declare target link(foo2)

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

llvm-svn: 319458

6 years ago[globalisel][tablegen] Add support for specific immediates in the match pattern
Daniel Sanders [Thu, 30 Nov 2017 18:48:35 +0000 (18:48 +0000)]
[globalisel][tablegen] Add support for specific immediates in the match pattern

This enables a few rules such as ARM's uxtb instruction.

llvm-svn: 319457

6 years agoSplit TypeTableBuilder into two classes.
Zachary Turner [Thu, 30 Nov 2017 18:39:50 +0000 (18:39 +0000)]
Split TypeTableBuilder into two classes.

llvm-svn: 319456

6 years agoFix the MIPS baremetal build
Alexander Richardson [Thu, 30 Nov 2017 18:37:04 +0000 (18:37 +0000)]
Fix the MIPS baremetal build

Summary:
Currently sys/cachectl.h is used unconditionally on MIPS although it is
only available on Linux and will fail the build when targeting baremetal

Reviewers: petarj

Reviewed By: petarj

Subscribers: sdardis, krytarowski

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

llvm-svn: 319455

6 years agoRemove a long out-of-date comment.
Jim Ingham [Thu, 30 Nov 2017 18:35:35 +0000 (18:35 +0000)]
Remove a long out-of-date comment.

llvm-svn: 319454

6 years ago[llvm-readobj] Fix mismatched line endings
Zachary Turner [Thu, 30 Nov 2017 18:33:34 +0000 (18:33 +0000)]
[llvm-readobj] Fix mismatched line endings

llvm-svn: 319453

6 years ago[WebAssembly] Revert r319186 "Support bitcasted function addresses with varargs."
Dan Gohman [Thu, 30 Nov 2017 18:16:49 +0000 (18:16 +0000)]
[WebAssembly] Revert r319186 "Support bitcasted function addresses with varargs."

The patch broke Emscripten's EM_ASM macros, which utiltize unprototyped
functions.

See https://bugs.llvm.org/show_bug.cgi?id=35385 for details.

llvm-svn: 319452

6 years agoSimplify. NFC.
Rafael Espindola [Thu, 30 Nov 2017 18:02:04 +0000 (18:02 +0000)]
Simplify. NFC.

This particular reportDuplicate is only used with Defined.

llvm-svn: 319451

6 years ago[OPENMP] Fix possible assert for target regions with incorrect inner
Alexey Bataev [Thu, 30 Nov 2017 18:01:54 +0000 (18:01 +0000)]
[OPENMP] Fix possible assert for target regions with incorrect inner
teams region.

If the inner teams region is not correct, it may cause an assertion when
processing outer target region. Patch fixes this problem.

llvm-svn: 319450

6 years agoHandle copy relocations in symbol assignments.
Rafael Espindola [Thu, 30 Nov 2017 17:51:10 +0000 (17:51 +0000)]
Handle copy relocations in symbol assignments.

When a linker script has "foo = bar" and bar is the result of a copy
relocation foo should point to the same location in .bss.

This is part of a growing evidence that copy relocations should be
implemented by using replaceSymbol to replace the SharedSymbol with a
Defined.

llvm-svn: 319449

6 years ago[CMake] Detect information about test compiler
Jonas Hahnfeld [Thu, 30 Nov 2017 17:08:31 +0000 (17:08 +0000)]
[CMake] Detect information about test compiler

Perform a nested CMake invocation to avoid writing our own parser
for compiler versions when we are not testing the in-tree compiler.
Use the extracted information to mark a test as unsupported that
hangs with Clang prior to version 4.0.1 and restrict tests for
libomptarget to Clang version 6.0.0 and later.

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

llvm-svn: 319448

6 years ago[MIR] Fix DebugInfo tests after r319445
Francis Visoiu Mistrih [Thu, 30 Nov 2017 16:48:53 +0000 (16:48 +0000)]
[MIR] Fix DebugInfo tests after r319445

llvm-svn: 319447

6 years agoFix __has_unique_object_representations implementation
Erich Keane [Thu, 30 Nov 2017 16:37:02 +0000 (16:37 +0000)]
Fix __has_unique_object_representations implementation

As rsmith pointed out, the original implementation of this intrinsic
missed a number of important situations.  This patch fixe a bunch of
shortcomings and implementation details to make it work correctly.

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

llvm-svn: 319446

6 years ago[CodeGen] Always use `printReg` to print registers in both MIR and debug
Francis Visoiu Mistrih [Thu, 30 Nov 2017 16:12:24 +0000 (16:12 +0000)]
[CodeGen] Always use `printReg` to print registers in both MIR and debug
output

As part of the unification of the debug format and the MIR format,
always use `printReg` to print all kinds of registers.

Updated the tests using '_' instead of '%noreg' until we decide which
one we want to be the default one.

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

llvm-svn: 319445

6 years ago[FuzzMutate] Bailout from injecting into empty basic blocks.
Igor Laevsky [Thu, 30 Nov 2017 15:41:58 +0000 (15:41 +0000)]
[FuzzMutate] Bailout from injecting into empty basic blocks.
In rare cases we can receive request to inject into completelly empty basic block. In the normal case
all basic blocks contain at least terminator instruction, but it is possible that the only instruction is
catchpad instruction which is not part of the instruction iterator. This case seems rare enough to not care
about it.
Submiting without review, since it seems almost NFC. I couldn't come up with any reasonable way to test this.

llvm-svn: 319444

6 years agoAdd a test case for open bug 35480
Pavel Labath [Thu, 30 Nov 2017 15:39:57 +0000 (15:39 +0000)]
Add a test case for open bug 35480

The test is about failing to hit breakpoints in global constructors in
shared libraries.

llvm-svn: 319443

6 years ago[FuzzMutate] Correctly handle vector types in the insertvalue operation
Igor Laevsky [Thu, 30 Nov 2017 15:31:13 +0000 (15:31 +0000)]
[FuzzMutate] Correctly handle vector types in the insertvalue operation

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

llvm-svn: 319442

6 years ago[FuzzMutate] Don't use index operands as sinks
Igor Laevsky [Thu, 30 Nov 2017 15:29:16 +0000 (15:29 +0000)]
[FuzzMutate] Don't use index operands as sinks

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

llvm-svn: 319441

6 years ago[FuzzMutate] Pick correct index for the insertvalue instruction
Igor Laevsky [Thu, 30 Nov 2017 15:26:48 +0000 (15:26 +0000)]
[FuzzMutate] Pick correct index for the insertvalue instruction

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

llvm-svn: 319440

6 years ago[FuzzMutate] Don't create load as a new source if it doesn't match with the descriptor
Igor Laevsky [Thu, 30 Nov 2017 15:24:41 +0000 (15:24 +0000)]
[FuzzMutate] Don't create load as a new source if it doesn't match with the descriptor

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

llvm-svn: 319439

6 years ago[FuzzMutate] Don't crash when we can't remove instruction from empty function
Igor Laevsky [Thu, 30 Nov 2017 15:07:38 +0000 (15:07 +0000)]
[FuzzMutate] Don't crash when we can't remove instruction from empty function

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

llvm-svn: 319438

6 years ago[LangRef] clarify semantics of the frem instruction
Sanjay Patel [Thu, 30 Nov 2017 14:59:03 +0000 (14:59 +0000)]
[LangRef] clarify semantics of the frem instruction

As noted in D40594, the frem instruction corresponds to fmod() except that it can't set errno.
I modified the text that we currently use for intrinsics that map to libm functions and applied
it to frem.

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

llvm-svn: 319437

6 years ago[InstCombine] Additional test for PR35354, NFC.
Alexey Bataev [Thu, 30 Nov 2017 14:33:58 +0000 (14:33 +0000)]
[InstCombine] Additional test for PR35354, NFC.

llvm-svn: 319436

6 years ago[ELF] - Handle EhInputSection Live bit in MarkLive.cpp
George Rimar [Thu, 30 Nov 2017 14:01:06 +0000 (14:01 +0000)]
[ELF] - Handle EhInputSection Live bit in MarkLive.cpp

Since MarkLive.cpp is the place where we set Live flags for
other sections, it looks correct to do that there.
Benefit is that we stop spreading GC logic outsize of MarkLive.cpp.

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

llvm-svn: 319435

6 years ago[PowerPC] Recommit r314244 with refactoring and off by default
Nemanja Ivanovic [Thu, 30 Nov 2017 13:39:10 +0000 (13:39 +0000)]
[PowerPC] Recommit r314244 with refactoring and off by default

This re-commits everything that was pulled in r314244. The transformation
is off by default (patch to enable it to follow). The code is refactored
to have a single entry-point and provide fine-grained control over patterns
that it selects. This patch also fixes the bugs in the original code.

Everything that failed with the original patch has been re-tested with this
patch (with the transformation turned on). So the patch to turn this on is
soon to follow.

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

llvm-svn: 319434

6 years ago[X86][AVX512] Tag fcmp/ptest/ternlog instructions scheduler classes
Simon Pilgrim [Thu, 30 Nov 2017 13:18:06 +0000 (13:18 +0000)]
[X86][AVX512] Tag fcmp/ptest/ternlog instructions scheduler classes

llvm-svn: 319433

6 years ago[X86][AVX512] Regenerate avx512 schedule tests
Simon Pilgrim [Thu, 30 Nov 2017 13:09:21 +0000 (13:09 +0000)]
[X86][AVX512] Regenerate avx512 schedule tests

llvm-svn: 319432

6 years agoHandle Top-Level-Regions in polly::isHoistableLoad
Philip Pfaffe [Thu, 30 Nov 2017 13:06:10 +0000 (13:06 +0000)]
Handle Top-Level-Regions in polly::isHoistableLoad

Summary:
This can be seen as a follow-up on my previous differential [D33411](https://reviews.llvm.org/D33411).
We received a bug report where this error was triggered. I have tried my best to recreate the issue in a minimal lit testcase which is also part of this differential.

I only handle return instructions as predecessors to a virtual TLR-exit right now. From inspecting the codebase, it seems `unreachable` instructions may also be of interest here. If requested, I can extend my patches to consider them as well. I would also apply this on `ScopHelper.cpp::isErrorBlock` (see D33411), of course.

Reviewers: philip.pfaffe, bollu

Reviewed By: bollu

Subscribers: Meinersbur, pollydev, llvm-commits

Tags: #polly

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

llvm-svn: 319431

6 years ago[MC] Function stack size section.
Sean Eveson [Thu, 30 Nov 2017 13:05:14 +0000 (13:05 +0000)]
[MC] Function stack size section.

Re applying after fixing issues in the diff, sorry for any painful conflicts/merges!

Original RFC: http://lists.llvm.org/pipermail/llvm-dev/2017-August/117028.html

This change adds a '.stack-size' section containing metadata on function stack sizes to output ELF files behind the new -stack-size-section flag. The section contains pairs of function symbol references (8 byte) and stack sizes (unsigned LEB128).

The contents of this section can be used to measure changes to stack sizes between different versions of the compiler or a source base. The advantage of having a section is that we can extract this information when examining binaries that we didn't build, and it allows users and tools easy access to that information just by referencing the binary.

There is a follow up change to add an option to clang.

Thanks.

Reviewers: hfinkel, MatzeB

Reviewed By: MatzeB

Subscribers: thegameg, asb, llvm-commits

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

llvm-svn: 319430

6 years agoRevert r319423: [MC] Function stack size section.
Sean Eveson [Thu, 30 Nov 2017 12:43:25 +0000 (12:43 +0000)]
Revert r319423: [MC] Function stack size section.

I messed up the diff.

llvm-svn: 319429

6 years ago[ARM GlobalISel] Bail out for byval
Diana Picus [Thu, 30 Nov 2017 12:23:44 +0000 (12:23 +0000)]
[ARM GlobalISel] Bail out for byval

Fallback if we have a byval parameter or argument since we don't support
them yet.

llvm-svn: 319428

6 years ago[CodeGen] Print "%vreg0" as "%0" in both MIR and debug output
Francis Visoiu Mistrih [Thu, 30 Nov 2017 12:12:19 +0000 (12:12 +0000)]
[CodeGen] Print "%vreg0" as "%0" in both MIR and debug output

As part of the unification of the debug format and the MIR format, avoid
printing "vreg" for virtual registers (which is one of the current MIR
possibilities).

Basically:

* find . \( -name "*.mir" -o -name "*.cpp" -o -name "*.h" -o -name "*.ll" \) -type f -print0 | xargs -0 sed -i '' -E "s/%vreg([0-9]+)/%\1/g"
* grep -nr '%vreg' . and fix if needed
* find . \( -name "*.mir" -o -name "*.cpp" -o -name "*.h" -o -name "*.ll" \) -type f -print0 | xargs -0 sed -i '' -E "s/ vreg([0-9]+)/ %\1/g"
* grep -nr 'vreg[0-9]\+' . and fix if needed

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

llvm-svn: 319427

6 years agoUpdate format after clang-format change. NFC.
Michael Kruse [Thu, 30 Nov 2017 12:05:48 +0000 (12:05 +0000)]
Update format after clang-format change. NFC.

In r319314 clang-format changed its reflowing logic.

llvm-svn: 319426

6 years agoRevert [ARM] disable FPU features when using soft floating point.
Keith Walker [Thu, 30 Nov 2017 12:05:18 +0000 (12:05 +0000)]
Revert [ARM] disable FPU features when using soft floating point.

This reverts r319420
It is failing the test Driver/arm-mfpu.c so reverting while I investigate the failure.

llvm-svn: 319425

6 years ago[X86][AVX512] Tag binop/rounding/sae instructions scheduler classes
Simon Pilgrim [Thu, 30 Nov 2017 12:01:52 +0000 (12:01 +0000)]
[X86][AVX512] Tag binop/rounding/sae instructions scheduler classes

llvm-svn: 319424

6 years ago[MC] Function stack size section.
Sean Eveson [Thu, 30 Nov 2017 12:01:16 +0000 (12:01 +0000)]
[MC] Function stack size section.

Summary:
Original RFC: http://lists.llvm.org/pipermail/llvm-dev/2017-August/117028.html

I wasn't sure who to put as reviewers, so please add/remove people as appropriate.

This change adds a '.stack-size' section containing metadata on function stack sizes to output ELF files behind the new -stack-size-section flag. The section contains pairs of function symbol references (8 byte) and stack sizes (unsigned LEB128).

The contents of this section can be used to measure changes to stack sizes between different versions of the compiler or a source base. The advantage of having a section is that we can extract this information when examining binaries that we didn't build, and it allows users and tools easy access to that information just by referencing the binary.

There is a follow up change to add an option to clang.

Thanks.

Reviewers: hfinkel, MatzeB

Reviewed By: MatzeB

Subscribers: thegameg, asb, llvm-commits

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

llvm-svn: 319423

6 years agoExtension of HWLOC topology discovery with NUMA nodes and tiles
Andrey Churbanov [Thu, 30 Nov 2017 11:51:47 +0000 (11:51 +0000)]
Extension of HWLOC topology discovery with NUMA nodes and tiles

Patch by Olga Malysheva

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

llvm-svn: 319422

6 years ago[DAGCombine] Refactor ReduceLoadWidth
Sam Parker [Thu, 30 Nov 2017 11:49:11 +0000 (11:49 +0000)]
[DAGCombine] Refactor ReduceLoadWidth

visitAND attempts to narrow the width of extending loads that are
then masked off. ReduceLoadWidth already exists for a similar purpose
and handles shifts, so I've moved the code to handle AND nodes there.

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

llvm-svn: 319421

6 years ago[ARM] disable FPU features when using soft floating point.
Keith Walker [Thu, 30 Nov 2017 11:38:56 +0000 (11:38 +0000)]
[ARM] disable FPU features when using soft floating point.

To be compatible with GCC if soft floating point is in effect any FPU
specified is effectively ignored, eg,

  -mfloat-abi=soft -fpu=neon

If any floating point features which require FPU hardware are enabled
they must be disable.

There was some support for doing this for NEON, but it did not handle
VFP, nor did it prevent the backend from emitting the build attribute
Tag_FP_arch describing the generated code as using the floating point
hardware if a FPU was specified (even though soft float does not use
the FPU).

Disabling the hardware floating point features for targets which are
compiling for soft float has meant that some tests which were incorrectly
checking for hardware support also needed to be updated. In such cases,
where appropriate the tests have been updated to check compiling for
soft float and a non-soft float variant (usually softfp). This was
usually because the target specified in the test defaulted to soft float.

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

llvm-svn: 319420

6 years agoSupport generic lowering of vector bswap
Serge Guelton [Thu, 30 Nov 2017 11:06:22 +0000 (11:06 +0000)]
Support generic lowering of vector bswap

llvm-svn: 319419

6 years ago[X86][AVX512] Tag RCP/RSQRT/GETEXP instructions scheduler classes
Simon Pilgrim [Thu, 30 Nov 2017 10:48:47 +0000 (10:48 +0000)]
[X86][AVX512] Tag RCP/RSQRT/GETEXP instructions scheduler classes

llvm-svn: 319418