platform/upstream/llvm.git
5 years ago[Docs] Add LLDB bots
Jonas Devlieghere [Thu, 18 Apr 2019 17:31:20 +0000 (17:31 +0000)]
[Docs] Add LLDB bots

llvm-svn: 358693

5 years ago[X86] combineVectorTruncationWithPACKUS - remove split/concatenation of mask
Simon Pilgrim [Thu, 18 Apr 2019 17:23:09 +0000 (17:23 +0000)]
[X86] combineVectorTruncationWithPACKUS - remove split/concatenation of mask

combineVectorTruncationWithPACKUS is currently splitting the upper bit bit masking into 128-bit subregs and then concatenating them back together.

This was originally done to avoid regressions that caused existing subregs to be concatenated to the larger type just for the AND masking before being extracted again. This was fixed by @spatel (notably rL303997 and rL347356).

This also lets SimplifyDemandedBits do some further improvements before it hits the recursive depth limit.

My only annoyance with this is that we were broadcasting some xmm masks but we seem to have lost them by moving to ymm - but that's a known issue as the logic in lowerBuildVectorAsBroadcast isn't great.

Differential Revision: https://reviews.llvm.org/D60375#inline-539623

llvm-svn: 358692

5 years ago[LibTooling] Add Stencil library for format-string style codegen.
Yitzhak Mandelbaum [Thu, 18 Apr 2019 17:23:01 +0000 (17:23 +0000)]
[LibTooling] Add Stencil library for format-string style codegen.

Summary:
This file defines the *Stencil* abstraction: a code-generating object, parameterized by named references to (bound) AST nodes.  Given a match result, a stencil can be evaluated to a string of source code.

A stencil is similar in spirit to a format string: it is composed of a series of raw text strings, references to nodes (the parameters) and helper code-generation operations.

See thread on cfe-dev list with subject "[RFC] Easier source-to-source transformations with clang tooling" for background.

Reviewers: sbenza

Reviewed By: sbenza

Subscribers: ilya-biryukov, mgorny, jfb, jdoerfert, cfe-commits

Tags: #clang

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

llvm-svn: 358691

5 years ago[libc++] Make sure we re-export some missing libc++abi symbols from libc++
Louis Dionne [Thu, 18 Apr 2019 17:18:15 +0000 (17:18 +0000)]
[libc++] Make sure we re-export some missing libc++abi symbols from libc++

Summary:
Ensure we re-export __cxa_throw_bad_array_new_length and
__cxa_uncaught_exceptions from libc++, since they are now
provided by libc++abi.

Doing this allows us to stop linking explicitly against libc++abi in
the libc++abi tests, since libc++ re-exports all the necessary symbols.
However, there is one caveat to that. We don't want libc++ to re-export
__cxa_uncaught_exception (the singular form), since it's only provided
for backwards compatibility. Hence, for the single test where we check
this backwards compatibility, we explicitly link against libc++abi.

PR27405
PR22654

Reviewers: EricWF

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

Tags: #libc

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

llvm-svn: 358690

5 years ago[clang-format] Fix indent of trailing raw string param after newline
Krasimir Georgiev [Thu, 18 Apr 2019 17:14:05 +0000 (17:14 +0000)]
[clang-format] Fix indent of trailing raw string param after newline

Summary:
Currently clang-format uses ContinuationIndent to indent the contents of a raw
string literal that is the last parameter of the function call. This is to
achieve formatting similar to trailing:
```
f(1, 2, R"pb(
    x: y)pb");
```
However this had the unfortunate consequence of producing format like this:
```
fffffff(1, 2,
        R"pb(
    a: b
        )pb");
```

This patch makes clang-format consider indenting a trailing raw string param
after a newline based off the start of the format delimiter, producing:
```
fffffff(1, 2,
        R"pb(
          a: b
        )pb");
```

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 358689

5 years ago[LoopPred] Fix a blatantly obvious bug in r358684
Philip Reames [Thu, 18 Apr 2019 17:01:19 +0000 (17:01 +0000)]
[LoopPred] Fix a blatantly obvious bug in r358684

The bug is that I didn't check whether the operand of the invariant_loads were themselves invariant.  I don't know how this got missed in the patch and review.  I even had an unreduced test case locally, and I remember handling this case, but I must have lost it in one of the rebases.  Oops.

llvm-svn: 358688

5 years ago[x86] add tests for improved insertelement to index 0 (PR41512); NFC
Sanjay Patel [Thu, 18 Apr 2019 16:58:50 +0000 (16:58 +0000)]
[x86] add tests for improved insertelement to index 0 (PR41512); NFC

Patch proposal in D60852.

llvm-svn: 358687

5 years ago[CMake] Emit LLDB.framework.dSYM to avoid potential name collision with driver's...
Stefan Granitz [Thu, 18 Apr 2019 16:37:22 +0000 (16:37 +0000)]
[CMake] Emit LLDB.framework.dSYM to avoid potential name collision with driver's lldb.dSYM

Summary:
Emit framework's dSYM bundle as LLDB.framework.dSYM instead of LLDB.dSYM, because the latter could conflict with the driver's lldb.dSYM when emitted in the same directory on case-insensitive file systems.
Requires https://reviews.llvm.org/D60862

Reviewers: friss, beanz, bogner

Subscribers: mgorny, lldb-commits, #lldb

Tags: #lldb

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

llvm-svn: 358686

5 years ago[CMake] Allow custom extensions for externalized debug info
Stefan Granitz [Thu, 18 Apr 2019 16:37:07 +0000 (16:37 +0000)]
[CMake] Allow custom extensions for externalized debug info

Summary:
Extra flexibility for emitting debug info to external files (remains Darwin only for now).
LLDB needs this functionality to emit a LLDB.framework.dSYM instead of LLDB.dSYM when building the framework, because the latter could conflict with the driver's lldb.dSYM when emitted in the same directory on case-insensitive file systems.

Reviewers: friss, bogner, beanz

Subscribers: mgorny, aprantl, llvm-commits, #lldb

Tags: #llvm

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

llvm-svn: 358685

5 years ago[LoopPredication] Allow predication of loop invariant computations (within the loop)
Philip Reames [Thu, 18 Apr 2019 16:33:17 +0000 (16:33 +0000)]
[LoopPredication] Allow predication of loop invariant computations (within the loop)

The purpose of this patch is to eliminate a pass ordering dependence between LoopPredication and LICM. To understand the purpose, consider the following snippet of code inside some loop 'L' with IV 'i'
A = _a.length;
guard (i < A)
a = _a[i]
B = _b.length;
guard (i < B);
b = _b[i];
...
Z = _z.length;
guard (i < Z)
z = _z[i]
accum += a + b + ... + z;

Today, we need LICM to hoist the length loads, LoopPredication to make the guards loop invariant, and TrivialUnswitch to eliminate the loop invariant guard to establish must execute for the next length load. Today, if we can't prove speculation safety, we'd have to iterate these three passes 26 times to reduce this example down to the minimal form.

Using the fact that the array lengths are known to be invariant, we can short circuit this iteration. By forming the loop invariant form of all the guards at once, we remove the need for LoopPredication from the iterative cycle. At the moment, we'd still have to iterate LICM and TrivialUnswitch; we'll leave that part for later.

As a secondary benefit, this allows LoopPred to expose peeling oppurtunities in a much more obvious manner.  See the udiv test changes as an example.  If the udiv was not hoistable (i.e. we couldn't prove speculation safety) this would be an example where peeling becomes obviously profitable whereas it wasn't before.

A couple of subtleties in the implementation:
- SCEV's isSafeToExpand guarantees speculation safety (i.e. let's us expand at a new point).  It is not a precondition for expansion if we know the SCEV corresponds to a Value which dominates the requested expansion point.
- SCEV's isLoopInvariant returns true for expressions which compute the same value across all iterations executed, regardless of where the original Value is located.  (i.e. it can be in the loop)  This implies we have a speculation burden to prove before expanding them outside loops.
- invariant_loads and AA->pointsToConstantMemory are two cases that SCEV currently does not handle, but meets the SCEV definition of invariance.  I plan to sink this part into SCEV once this has baked for a bit.

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

llvm-svn: 358684

5 years agoClean up docstrings in swig interface files
Pavel Labath [Thu, 18 Apr 2019 16:23:33 +0000 (16:23 +0000)]
Clean up docstrings in swig interface files

Summary:
This patch removes the "//----" frames and "///" leading lines from
docstring comments.  We already have code doing transformations like this in
modify-python-lldb.py, but that's a script I'd like to remove. Instead
of running these transformations everytime we run swig, we can just
perform equivalent on its input once.

This patch can be reproduced (e.g. for downstream merges) with the
following "sweet" perl command:

  perl -i -p -e 'BEGIN{ $/ = undef;} s:(" *\n) *//-----*\n:\1:gs; s:^(     *)/// ?:\1:gsm; s:^ *//------*\n( *\n)?( *"):\2:gsm; s: *$::gsm; s:\n *"\):"):gsm' scripts/interface/*.i

This command produces nearly equivalent python files to those produced
by the relevant code in modify-python-lldb.py. The only difference I
noticed is that here I am slightly more agressive in removing trailing
newlines from docstring comments (the python script seems to leave
newlines in class-level docstrings).

Reviewers: amccarth, clayborg, jingham, aprantl

Subscribers: lldb-commits

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

llvm-svn: 358683

5 years ago[asan_symbolize] Workaround bug in old Python 2 versions.
Dan Liew [Thu, 18 Apr 2019 16:22:55 +0000 (16:22 +0000)]
[asan_symbolize] Workaround bug in old Python 2 versions.

The change landed in r358657 broke some of the buildbots because they
use an older version of Python 2 that raises this error.

```
File "/Volumes/data/dev/llvm/upstream/master/src/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py", line 509
  exec(f.read(), globals_space, None)
SyntaxError: unqualified exec is not allowed in function 'load_plugin_from_file' it contains a nested function with free variables
```

I can reproduce this problem when using Python 2.7.6.

To workaround this some indirection has been added to prevent the broken
(the line at fault would never be executed) SyntaxError error in old
Python versions from being raised.

rdar://problem/49476995

llvm-svn: 358682

5 years ago[SDA] Bug fix: Use IPD outside the loop as divergence bound
Nicolai Haehnle [Thu, 18 Apr 2019 16:17:35 +0000 (16:17 +0000)]
[SDA] Bug fix: Use IPD outside the loop as divergence bound

Summary:
The immediate post dominator of the loop header may be part of the divergent loop.
Since this /was/ the divergence propagation bound the SDA would not detect joins of divergent paths outside the loop.

Reviewers: nhaehnle

Reviewed By: nhaehnle

Subscribers: mmasten, arsenm, jvesely, llvm-commits

Tags: #llvm

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

llvm-svn: 358681

5 years agoFix a bug in SCEV's isSafeToExpand around speculation safety
Philip Reames [Thu, 18 Apr 2019 16:10:21 +0000 (16:10 +0000)]
Fix a bug in SCEV's isSafeToExpand around speculation safety

isSafeToExpand was making a common, but dangerously wrong, mistake in assuming that if any instruction within a basic block executes, that all instructions within that block must execute.  This can be trivially shown to be false by considering the following small example:
bb:
  add x, y  <-- InsertionPoint
  call @throws()
  udiv x, y <-- SCEV* S
  br ...

It's clearly not legal to expand S above the throwing call, but the previous logic would do so since S dominates (but not properlyDominates) the block containing the InsertionPoint.

Since iterating instructions w/in a block is expensive, this change special cases two cases: 1) S is an operand of InsertionPoint, and 2) InsertionPoint is the terminator of it's block.  These two together are enough to keep all current optimizations triggering while fixing the latent correctness issue.

As best I can tell, this is a silent bug in current ToT.  Given that, there's no tests with this change.  It was noticed in an upcoming optimization change (D60093), and was reviewed as part of that.  That change will include the test which caused me to notice the issue.  I'm submitting this seperately so that anyone bisecting a problem gets a clear explanation.

llvm-svn: 358680

5 years ago[Sema][NFC] Mark DR1563 as done (List-initialization and overloaded function disambig...
Bruno Ricci [Thu, 18 Apr 2019 15:45:08 +0000 (15:45 +0000)]
[Sema][NFC] Mark DR1563 as done (List-initialization and overloaded function disambiguation)

It has been supported since at least clang 3.1 so just mark it as done.

llvm-svn: 358679

5 years ago[Sema][NFC] Mark DR705 (Suppressing argument-dependent lookup via parentheses) as...
Bruno Ricci [Thu, 18 Apr 2019 15:34:03 +0000 (15:34 +0000)]
[Sema][NFC] Mark DR705 (Suppressing argument-dependent lookup via parentheses) as done

It was supported since at least clang 3 so just mark it as done.

llvm-svn: 358678

5 years ago[libc++] Unconditionally enable the __pad_and_output optimization
Louis Dionne [Thu, 18 Apr 2019 15:19:35 +0000 (15:19 +0000)]
[libc++] Unconditionally enable the __pad_and_output optimization

This used to be guarded on whether the deployment target was greater
than macosx10.8, however testing against the dylibs for 10.8 and earlier
with the function enabled works too. The revision that introduced
__pad_and_output is r164241 and it does not mention a reason for the
guard.

llvm-svn: 358677

5 years ago[analyzer][NFC] Use capital variable names, move methods out-of-line, rename some...
Kristof Umann [Thu, 18 Apr 2019 15:19:16 +0000 (15:19 +0000)]
[analyzer][NFC] Use capital variable names, move methods out-of-line, rename some in CheckerRegistry

There are barely any lines I haven't changed in these files, so I think I could
might as well leave it in an LLVM coding style conforming state. I also renamed
2 functions and moved addDependency out of line to ease on followup patches.

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

llvm-svn: 358676

5 years ago[clangd] Support relatedInformation in diagnostics.
Sam McCall [Thu, 18 Apr 2019 15:17:07 +0000 (15:17 +0000)]
[clangd] Support relatedInformation in diagnostics.

Summary: We already have the structure internally, we just need to expose it.

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 358675

5 years ago[Serialization] Stable serialization order for OpenCLTypeExtMap and OpenCLDeclExtMap
Bruno Ricci [Thu, 18 Apr 2019 15:13:27 +0000 (15:13 +0000)]
[Serialization] Stable serialization order for OpenCLTypeExtMap and OpenCLDeclExtMap

Sort the elements of Sema::OpenCLTypeExtMap and Sema::OpenCLDeclExtMap
by TypeIDs and DeclIDs to guarantee a stable serialization order.

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

Reviewed By: Anastasia

Reviewers: Anastasia, lebedev.ri
llvm-svn: 358674

5 years agoMinidumpYAML: Fix ambiguity between std::make_unique and llvm::make_unique
Benjamin Kramer [Thu, 18 Apr 2019 15:06:03 +0000 (15:06 +0000)]
MinidumpYAML: Fix ambiguity between std::make_unique and llvm::make_unique

llvm-svn: 358673

5 years agoMinidumpYAML: Add support for ModuleList stream
Pavel Labath [Thu, 18 Apr 2019 14:57:31 +0000 (14:57 +0000)]
MinidumpYAML: Add support for ModuleList stream

Summary:
This patch adds support for yaml (de)serialization of the minidump
ModuleList stream. It's a fairly straight forward-application of the
existing patterns to the ModuleList structures defined in previous
patches.

One thing, which may be interesting to call out explicitly is the
addition of "new" allocation functions to the helper BlobAllocator
class. The reason for this was, that there was an emerging pattern of a
need to allocate space for entities, which do not have a suitable
lifetime for use with the existing allocation functions. A typical
example of that was the "size" of various lists, which is only available
as a temporary returned by the .size() method of some container. For
these cases, one can use the new set of allocation functions, which
will take a temporary object, and store it in an allocator-managed
buffer until it is written to disk.

Reviewers: amccarth, jhenderson, clayborg, zturner

Subscribers: lldb-commits, llvm-commits

Tags: #llvm

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

llvm-svn: 358672

5 years ago[libc++][CMake] Always provide new/delete in libc++ unless specified otherwise
Louis Dionne [Thu, 18 Apr 2019 14:47:46 +0000 (14:47 +0000)]
[libc++][CMake] Always provide new/delete in libc++ unless specified otherwise

Summary:
Let's not try to be clever and detect it based on the libc++abi setting.
The only build that puts new/delete in libc++abi is Apple's and we set
this CMake option explicitly in both libc++ and libc++abi. Complicated
dependent options hurt, let's avoid them when possible.

Reviewers: phosek, EricWF

Subscribers: mgorny, christof, jkorous, dexonsmith, libcxx-commits

Tags: #libc

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

llvm-svn: 358671

5 years agogn build: Merge r358607
Nico Weber [Thu, 18 Apr 2019 14:27:38 +0000 (14:27 +0000)]
gn build: Merge r358607

llvm-svn: 358670

5 years agogn build: Merge r358633
Nico Weber [Thu, 18 Apr 2019 14:26:52 +0000 (14:26 +0000)]
gn build: Merge r358633

llvm-svn: 358669

5 years agogn build: Merge r358620
Nico Weber [Thu, 18 Apr 2019 14:25:45 +0000 (14:25 +0000)]
gn build: Merge r358620

llvm-svn: 358668

5 years ago[llvm-objcopy] Add -B mips
Jordan Rupprecht [Thu, 18 Apr 2019 14:22:37 +0000 (14:22 +0000)]
[llvm-objcopy] Add -B mips

llvm-svn: 358667

5 years ago[clang-tidy] Address post-commit comments
Haojian Wu [Thu, 18 Apr 2019 14:18:14 +0000 (14:18 +0000)]
[clang-tidy] Address post-commit comments

Summary:
Also add a test to verify clang-tidy only apply the first alternative
fix.

Reviewers: alexfh

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 358666

5 years ago[clang][CIndex] Use llvm::set_thread_priority
Kadir Cetinkaya [Thu, 18 Apr 2019 13:49:20 +0000 (13:49 +0000)]
[clang][CIndex] Use llvm::set_thread_priority

Reviewers: jkorous, gribozavr

Subscribers: dexonsmith, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 358665

5 years ago[clangd] Use llvm::set_thread_priority in background-index
Kadir Cetinkaya [Thu, 18 Apr 2019 13:46:40 +0000 (13:46 +0000)]
[clangd] Use llvm::set_thread_priority in background-index

Reviewers: gribozavr

Subscribers: krytarowski, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jfb, cfe-commits

Tags: #clang

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

llvm-svn: 358664

5 years ago[wasm] Simplify. NFC
Fangrui Song [Thu, 18 Apr 2019 13:33:29 +0000 (13:33 +0000)]
[wasm] Simplify. NFC

llvm-svn: 358663

5 years ago[MSVC] Use the correct casing of HostX64/HostX86
Martin Storsjo [Thu, 18 Apr 2019 13:27:31 +0000 (13:27 +0000)]
[MSVC] Use the correct casing of HostX64/HostX86

If accessing the MSVC installation root directly on a case sensitive
filesystem, these details matter.

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

llvm-svn: 358662

5 years ago[Sema] Delete unused parameters/variables
Fangrui Song [Thu, 18 Apr 2019 12:35:02 +0000 (12:35 +0000)]
[Sema] Delete unused parameters/variables

llvm-svn: 358661

5 years ago[lldb] [test] Mark three more tests flakey/xfail on NetBSD
Michal Gorny [Thu, 18 Apr 2019 12:31:48 +0000 (12:31 +0000)]
[lldb] [test] Mark three more tests flakey/xfail on NetBSD

llvm-svn: 358660

5 years ago[LLD][ELF] - Convert out-of-order-section-in-region.s to *.test. NFCI.
George Rimar [Thu, 18 Apr 2019 12:13:41 +0000 (12:13 +0000)]
[LLD][ELF] - Convert out-of-order-section-in-region.s to *.test. NFCI.

This is consistent with the our others tests that has large scripts.

llvm-svn: 358659

5 years ago[clangd] Emit better error messages when rename fails.
Haojian Wu [Thu, 18 Apr 2019 11:35:22 +0000 (11:35 +0000)]
[clangd] Emit better error messages when rename fails.

Summary:
Currently we emit an unfriendly "clang diagnostic" message when rename fails. This
patch makes clangd to emit a detailed diagnostic message.

Reviewers: sammccall

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

Tags: #clang

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

llvm-svn: 358658

5 years ago[asan_symbolize] Add a simple plugin architecture
Dan Liew [Thu, 18 Apr 2019 11:34:31 +0000 (11:34 +0000)]
[asan_symbolize] Add a simple plugin architecture

Summary:
This change adds a simple plugin architecture to `asan_symbolize.py`.
The motivation here is that sometimes it's necessary to perform extra
work to figure out where binaries with debug symbols can actually be
found. For example it might be the case that a remote service needs
to be queried for binaries and then copied to the local system.

This "extra work" can be extremely site-specific such that adding the
code directly into the `asan_symbolize.py` would just clutter the code
for a very niche use case. To avoid this, the `asan_symbolize.py` can
now load external code via a new `--plugins` command line option.

These plugins are loaded before main command line argument parsing so
that they can add their own command line options.

Right now the only hook into the behaviour of symbolization is the
`filter_binary_path()` function which assumes a very similar role
to the `binary_name_filter` function that was previously in the code.
We can add more hooks as necessary.

Code in the `asan_symbolize.py` script does not call plugin code
directly. Instead it uses a `AsanSymbolizerPlugInProxy` object.
This object

* Loads plugins from files.
* Manages the lifetime of the plugins.
* Provides an interface for calling into plugin functions and handles
  calling into multiple plugins.

To unify the way binary paths are filtered the old `sysroot_path_filter`
function (and associated code) has been turned into a simple plugin
(`SysRootFilterPlugIn`) that is always loaded. The plugin unloads
itself if the `-s` option is not present on the command line. Users
should not see any functional change relating to this command line
option.

Some simple tests are provided to illustrate what plugin code looks
like and also to check the functionality continues to work.

rdar://problem/49476995

Reviewers: kubamracek, yln, samsonov, dvyukov, vitalybuka

Subscribers: srhines, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

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

llvm-svn: 358657

5 years ago[yaml2elf/obj2yaml] - Allow normal parsing/dumping of the .rela.dyn section
George Rimar [Thu, 18 Apr 2019 11:02:07 +0000 (11:02 +0000)]
[yaml2elf/obj2yaml] - Allow normal parsing/dumping of the .rela.dyn section

.rela.dyn is a section that has sh_info normally
set to zero. And Info is an optional field in the description
of the relocation section in YAML.

But currently, yaml2obj would fail to produce the object when
Info is not explicitly listed.

The patch fixes the issue.

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

llvm-svn: 358656

5 years ago[clangd] Log verbosely (LSP bodies) in lit tests. NFC
Sam McCall [Thu, 18 Apr 2019 10:32:08 +0000 (10:32 +0000)]
[clangd] Log verbosely (LSP bodies) in lit tests. NFC

llvm-svn: 358655

5 years ago[CUDA][Windows] Restrict long double device functions declarations to Windows
Evgeny Mankov [Thu, 18 Apr 2019 10:08:55 +0000 (10:08 +0000)]
[CUDA][Windows] Restrict long double device functions declarations to Windows

As agreed in D60220, make long double declarations unobservable on non-windows platforms.

[Testing]
{Windows 10, Ubuntu 16.04.5}/{Visual C++ 2017 15.9.11 & 2019 16.0.1, gcc+ 5.4.0}/CUDA {8.0, 9.0, 9.1, 9.2, 10.0, 10.1}

Reviewed by: Artem Belevich

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

llvm-svn: 358654

5 years ago[LLD][ELF] - A fix for "linker script assignment loses relative nature of section...
George Rimar [Thu, 18 Apr 2019 10:00:37 +0000 (10:00 +0000)]
[LLD][ELF] - A fix for "linker script assignment loses relative nature of section" bug.

This is https://bugs.llvm.org//show_bug.cgi?id=39857.
I added the comment with much more details to the bug page,
the short version is below.

The following script and code demonstrates the issue:

aliasto__text = __text;
 SECTIONS {
  .text 0x1000 : { __text = . ; *(.text) }
 }
...
call aliasto__text

LLD fails with "cannot refer to absolute symbol: aliasto__text" error.
It happens because at the moment of scanning the relocations
we do not yet assign the correct/final/any section value for the symbol aliasto__text.
I made a change to Relocations.cpp to fix that.

Also, I had to remove the symbol-location.s test case completely, because now it does not
trigger any error. Since now all linker scripts symbols are resolved to constants, no
errors can be triggered at all it seems. I checked that it is consistent with the behavior
of bfd and gold (they do not trigger errors for the case from symbol-location.s), so it should
be OK. I.e. at least it is probably not the best possible, but natural behavior we obtained.

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

llvm-svn: 358652

5 years ago[X86][SSE] Lower ICMP EQ(AND(X,C),C) -> SRA(SHL(X,LOG2(C)),BW-1) iff C is power-of-2.
Simon Pilgrim [Thu, 18 Apr 2019 09:58:59 +0000 (09:58 +0000)]
[X86][SSE] Lower ICMP EQ(AND(X,C),C) -> SRA(SHL(X,LOG2(C)),BW-1) iff C is power-of-2.

This replaces the MOVMSK combine introduced at D52121/rL342326

(movmsk (setne (and X, (1 << C)), 0)) -> (movmsk (X << C))

with the more general icmp lowering so it can pick up more cases through bitcasts - notably vXi8 cases which use vXi16 shifts+masks, this patch can remove the mask and use pcmpgtb(0,x) for the sra.

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

llvm-svn: 358651

5 years ago[ELF] Respect NonAlloc when copying flags from the previous sections
Fangrui Song [Thu, 18 Apr 2019 09:22:05 +0000 (09:22 +0000)]
[ELF] Respect NonAlloc when copying flags from the previous sections

Summary:
If the output section contains only symbol assignments, we copy flags
from the previous sections. Don't set SHF_ALLOC if NonAlloc is true.

We also have to change the type from SHT_NOBITS to SHT_PROGBITS.
In ld.bfd, bfd_elf_get_default_section_type maps non-alloctable sections to SHT_PROGBITS.
Non-alloctable SHT_NOBITS sections do not make sense.

Fixes PR38626

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

llvm-svn: 358650

5 years ago[llvm-objcopy][llvm-strip] Add switch to allow removing referenced sections
James Henderson [Thu, 18 Apr 2019 09:13:30 +0000 (09:13 +0000)]
[llvm-objcopy][llvm-strip] Add switch to allow removing referenced sections

llvm-objcopy currently emits an error if a section to be removed is
referenced by another section. This is a reasonable thing to do, but is
different to GNU objcopy. We should allow users who know what they are
doing to have a way to produce the invalid ELF. This change adds a new
switch --allow-broken-links to both llvm-strip and llvm-objcopy to do
precisely that. The corresponding sh_link field is then set to 0 instead
of an error being emitted.

I cannot use llvm-readelf/readobj to test the link fields because they
emit an error if any sections, like the .dynsym, cannot be properly
loaded.

Reviewed by: rupprecht, grimar

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

llvm-svn: 358649

5 years agoTest commit access [NFC]
Cullen Rhodes [Thu, 18 Apr 2019 08:57:58 +0000 (08:57 +0000)]
Test commit access [NFC]

Remove a trailing space

llvm-svn: 358648

5 years ago[NewPM] Add Option handling for LoopVectorize
Serguei Katkov [Thu, 18 Apr 2019 08:46:11 +0000 (08:46 +0000)]
[NewPM] Add Option handling for LoopVectorize

This patch enables passing options to LoopVectorizePass via the passes pipeline.

Reviewers: chandlerc, fedor.sergeev, leonardchan, philip.pfaffe
Reviewed By: fedor.sergeev
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D60681

llvm-svn: 358647

5 years ago[LLD][ELF] - Fix the different behavior of the linker script symbols on different...
George Rimar [Thu, 18 Apr 2019 08:15:54 +0000 (08:15 +0000)]
[LLD][ELF] - Fix the different behavior of the linker script symbols on different platforms.

This generalizes code and also fixes the broken behavior shown in
one of our test cases for some targets, like x86-64.

The issue occurs when the forward declarations are used in the script.
One of the samples is:

SECTIONS {
  foo = ADDR(.text) - ABSOLUTE(ADDR(.text));
};

In that case, we have a broken output when output target does
not use thunks. That happens because thunks creating code
(called from maybeAddThunks)
calls Script->assignAddresses() at least one more time,
what fixups the values. As a result final symbols values can
be different on AArch64 and x86, for example.

In this patch, I generalize and rename maybeAddThunks to
finalizeAddressDependentContent and now it is used and called
by all targets.

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

llvm-svn: 358646

5 years ago[ELF] Place SectionPiece::{Live,Hash} bit fields together
Fangrui Song [Thu, 18 Apr 2019 07:46:09 +0000 (07:46 +0000)]
[ELF] Place SectionPiece::{Live,Hash} bit fields together

Summary:
We access Live and OutputOff (which may share the same memory location)
concurrently in 2 parallelForEachN loops. Separating them avoids subtle
data races like D41884/PR35788. This patch places Live and Hash
together.

2 reasons this is appealing:

1) Hash is immutable. Live is almost read-only - only written once in MarkLive.cpp where
   Hash is not accessed
2) we already discard low bits of Hash to decide ShardID. It doesn't
   matter much if we make 32-bit Hash to 31-bit.

   For a huge internal clang -O3 executable (1.6GiB),
   `Strings` in StringTableBuilder::finalizeStringTable contains at most 310253 elements.
   The expected number of pair-wise collisions 2^(-31) * C(310253,2) ~= 22.41 is too small to have a negative impact on performance.
   Actually, my benchmark shows there is actually a minor performance improvement.

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

llvm-svn: 358645

5 years ago[PowerPC] Fix wrong ElemSIze when calling isConsecutiveLS()
Kang Zhang [Thu, 18 Apr 2019 07:24:15 +0000 (07:24 +0000)]
[PowerPC] Fix wrong ElemSIze when calling isConsecutiveLS()

Summary:
This issue from the bugzilla: https://bugs.llvm.org/show_bug.cgi?id=41177

When the two operands for BUILD_VECTOR are same, we will get assert error.
llvm::SDValue combineBVOfConsecutiveLoads(llvm::SDNode*, llvm::SelectionDAG&):
Assertion `!(InputsAreConsecutiveLoads && InputsAreReverseConsecutive) &&
"The loads cannot be both consecutive and reverse consecutive."' failed.

This error caused by the wrong ElemSIze when calling isConsecutiveLS(). We
should use `getScalarType().getStoreSize();` to get the ElemSize instread of
 `getScalarSizeInBits() / 8`.

Reviewed By: jsji

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

llvm-svn: 358644

5 years ago[llvm-profdata] Fix one bad format in llvm-profdata CommandGuide doc. NFC
Rong Xu [Thu, 18 Apr 2019 07:11:05 +0000 (07:11 +0000)]
[llvm-profdata] Fix one bad format in llvm-profdata CommandGuide doc. NFC

llvm-svn: 358643

5 years agoAdd support for ARMv7-M architecture which uses the Thumb 2 ISA (unified syntax)
Martin Storsjo [Thu, 18 Apr 2019 06:35:42 +0000 (06:35 +0000)]
Add support for ARMv7-M architecture which uses the Thumb 2 ISA (unified syntax)

Patch by Jérémie Faucher-Goulet!

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

llvm-svn: 358642

5 years agoElaborate why we have an option on by default for enabling chr.
Eric Christopher [Thu, 18 Apr 2019 06:17:40 +0000 (06:17 +0000)]
Elaborate why we have an option on by default for enabling chr.

llvm-svn: 358641

5 years ago[AMDGPU] Avoid DAG combining assert with fneg(fadd(A,0))
Tim Renouf [Thu, 18 Apr 2019 05:27:01 +0000 (05:27 +0000)]
[AMDGPU] Avoid DAG combining assert with fneg(fadd(A,0))

fneg combining attempts to turn it into fadd(fneg(A), fneg(0)), but
creating the new fadd folds to just fneg(A). When A has multiple uses,
this confuses it and you get an assert. Fixed.

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

Change-Id: I0ddc9b7286abe78edc0cd8d734fdeb05ff09821c
llvm-svn: 358640

5 years agoFix a typo in comments. [NFC]
Ali Tamur [Thu, 18 Apr 2019 02:39:37 +0000 (02:39 +0000)]
Fix a typo in comments. [NFC]

llvm-svn: 358639

5 years agolld: elf: Fix sections with explict addresses in regions
Rui Ueyama [Thu, 18 Apr 2019 02:32:12 +0000 (02:32 +0000)]
lld: elf: Fix sections with explict addresses in regions

Patch by Gabriel Smith.

The address for a section would be evaluated before the region was
switched to. Because of this, the position within the region would not
be updated. After the region is swapped to the dot would be set to the
out of date position within the region, undoing the section address
evaluation.

To fix this, the region is swapped to before the section's address is
evaluated. As part of the fallout of this, expandMemoryRegions needed
to be gated in setDot on the condition that the evaluated address is
less than the dot. This is for the case where sections are not listed
from lowest address to highest address.

Finally, a test for the case where sections are listed "out of order"
was added.

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

llvm-svn: 358638

5 years ago[GISel]:IRTranslator: Prefer a buidInstr form that allows CSE of cast instructions
Aditya Nandakumar [Thu, 18 Apr 2019 02:19:29 +0000 (02:19 +0000)]
[GISel]:IRTranslator: Prefer a buidInstr form that allows CSE of cast instructions

https://reviews.llvm.org/D60844

Use the style of buildInstr that allows CSEing.

llvm-svn: 358637

5 years agoFix bad compare function over FusionCandidate.
Richard Trieu [Thu, 18 Apr 2019 01:39:45 +0000 (01:39 +0000)]
Fix bad compare function over FusionCandidate.

Reverse the checking of the domiance order so that when a self compare happens,
it returns false.  This makes compare function have strict weak ordering.

llvm-svn: 358636

5 years ago[Shell] Simplify Extracting Python Version
Jonas Devlieghere [Thu, 18 Apr 2019 01:37:19 +0000 (01:37 +0000)]
[Shell] Simplify Extracting Python Version

Instead of parsing the Python version with a fairly convoluted regex,
just print the major and minor version and call it a day.

llvm-svn: 358635

5 years agoRevert Implement sys::fs::copy_file using the macOS copyfile(3) API to support APFS...
Adrian Prantl [Thu, 18 Apr 2019 01:21:10 +0000 (01:21 +0000)]
Revert Implement sys::fs::copy_file using the macOS copyfile(3) API to support APFS clones.

This reverts r358628 (git commit 91a06bee788262a294527b815354f380d99dfa9b)
while investigating a crash reproducer bot failure.

llvm-svn: 358634

5 years agoSplit out modules-specific declaration handling from SemaDecl.cpp into a
Richard Smith [Thu, 18 Apr 2019 00:57:02 +0000 (00:57 +0000)]
Split out modules-specific declaration handling from SemaDecl.cpp into a
new SemaModule.cpp.

llvm-svn: 358633

5 years agoAdd '#pragma clang __debug module_map module.name' to dump the module
Richard Smith [Thu, 18 Apr 2019 00:57:01 +0000 (00:57 +0000)]
Add '#pragma clang __debug module_map module.name' to dump the module
map being used for the module 'module.name'.

llvm-svn: 358632

5 years ago[c++2a] Improve diagnostic for use of declaration from another TU's
Richard Smith [Thu, 18 Apr 2019 00:56:58 +0000 (00:56 +0000)]
[c++2a] Improve diagnostic for use of declaration from another TU's
global module fragment.

We know that the declaration in question should have been introduced by
a '#include', so try to figure out which one and suggest it. Don't
suggest importing the global module fragment itself!

llvm-svn: 358631

5 years ago[clang-format] Remove unused Environment constructor.
Alexander Kornienko [Thu, 18 Apr 2019 00:36:51 +0000 (00:36 +0000)]
[clang-format] Remove unused Environment constructor.

llvm-svn: 358630

5 years ago[lldb] Don't filter variable list when doing a lookup by mangled name in SymbolFileDW...
Kuba Mracek [Thu, 18 Apr 2019 00:15:44 +0000 (00:15 +0000)]
[lldb] Don't filter variable list when doing a lookup by mangled name in SymbolFileDWARF::FindGlobalVariables

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

llvm-svn: 358629

5 years agoImplement sys::fs::copy_file using the macOS copyfile(3) API
Adrian Prantl [Thu, 18 Apr 2019 00:01:05 +0000 (00:01 +0000)]
Implement sys::fs::copy_file using the macOS copyfile(3) API
to support APFS clones.

This patch adds a Darwin-specific implementation of
llvm::sys::fs::copy_file() that uses the macOS copyfile(3) API to
support APFS copy-on-write clones, which should be faster and much
more space efficient.

https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/APFS_Guide/ToolsandAPIs/ToolsandAPIs.html

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

llvm-svn: 358628

5 years agoMove the implementation of getInnermostBlockDecl to the .cpp file to fix
Akira Hatanaka [Thu, 18 Apr 2019 00:00:16 +0000 (00:00 +0000)]
Move the implementation of getInnermostBlockDecl to the .cpp file to fix
failing bots.

llvm-svn: 358627

5 years agoFix test on PS4 which defaults to gnu99 which does not emit the expected warnings.
Douglas Yung [Thu, 18 Apr 2019 00:00:06 +0000 (00:00 +0000)]
Fix test on PS4 which defaults to gnu99 which does not emit the expected warnings.

llvm-svn: 358626

5 years ago[Cmake] Add missing dependency for running tests.
Davide Italiano [Wed, 17 Apr 2019 23:43:01 +0000 (23:43 +0000)]
[Cmake] Add missing dependency for running tests.

This is needed now that we marked lldb-test as EXCLUDE_ALL, to
make sure `ninja lldb-test-deps` doesn't fail.

llvm-svn: 358625

5 years ago[Sema][ObjC] Don't warn about an implicitly retained self if the
Akira Hatanaka [Wed, 17 Apr 2019 23:14:44 +0000 (23:14 +0000)]
[Sema][ObjC] Don't warn about an implicitly retained self if the
retaining block and all of the enclosing blocks are non-escaping.

If the block implicitly retaining self doesn't escape, there is no risk
of creating retain cycles, so clang shouldn't diagnose it and force
users to add self-> to silence the diagnostic.

Also, fix a bug where clang was failing to diagnose an implicitly
retained self inside a c++ lambda nested inside a block.

rdar://problem/25059955

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

llvm-svn: 358624

5 years agoFix formatting. NFC
Akira Hatanaka [Wed, 17 Apr 2019 23:14:39 +0000 (23:14 +0000)]
Fix formatting. NFC

llvm-svn: 358623

5 years ago[x86] try to widen 'shl' as part of LEA formation
Sanjay Patel [Wed, 17 Apr 2019 22:38:51 +0000 (22:38 +0000)]
[x86] try to widen 'shl' as part of LEA formation

The test file has pairs of tests that are logically equivalent:
https://rise4fun.com/Alive/2zQ

%t4 = and i8 %t1, 8
%t5 = zext i8 %t4 to i16
%sh = shl i16 %t5, 2
%t6 = add i16 %sh, %t0
=>
%t4 = and i8 %t1, 8
%sh2 = shl i8 %t4, 2
%z5 = zext i8 %sh2 to i16
%t6 = add i16 %z5, %t0

...so if we can fold the shift op into LEA in the 1st pattern, then we
should be able to do the same in the 2nd pattern (unnecessary 'movzbl'
is a separate bug I think).

We don't want to do this any sooner though because that would conflict
with generic transforms that try to narrow the width of the shift.

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

llvm-svn: 358622

5 years ago[clang-tidy] Don't issue cppcoreguidelines-macro-usage on builtin macros
Alexander Kornienko [Wed, 17 Apr 2019 22:35:36 +0000 (22:35 +0000)]
[clang-tidy] Don't issue cppcoreguidelines-macro-usage on builtin macros

Before the patch calling clang-tidy with -header-filter=.* -system-headers would
result in a few hundred useless warnings:
  warning: macro '_GNU_SOURCE' used to declare a constant; consider using a 'constexpr' constant [cppcoreguidelines-macro-usage]
  warning: macro '_LP64' used to declare a constant; consider using a 'constexpr' constant [cppcoreguidelines-macro-usage]
  warning: macro '__ATOMIC_ACQUIRE' used to declare a constant; consider using a 'constexpr' constant [cppcoreguidelines-macro-usage]
  warning: macro '__ATOMIC_ACQ_REL' used to declare a constant; consider using a 'constexpr' constant [cppcoreguidelines-macro-usage]
  warning: macro '__ATOMIC_CONSUME' used to declare a constant; consider using a 'constexpr' constant [cppcoreguidelines-macro-usage]
  warning: macro '__ATOMIC_RELAXED' used to declare a constant; consider using a 'constexpr' constant [cppcoreguidelines-macro-usage]
  warning: macro '__ATOMIC_RELEASE' used to declare a constant; consider using a 'constexpr' constant [cppcoreguidelines-macro-usage]
  warning: macro '__ATOMIC_SEQ_CST' used to declare a constant; consider using a 'constexpr' constant [cppcoreguidelines-macro-usage]
  warning: macro '__BIGGEST_ALIGNMENT__' used to declare a constant; consider using a 'constexpr' constant [cppcoreguidelines-macro-usage]
  ... and so on

llvm-svn: 358621

5 years ago[clang-tidy] Add a check for [super self] in initializers 🔍
Stephane Moore [Wed, 17 Apr 2019 22:29:06 +0000 (22:29 +0000)]
[clang-tidy] Add a check for [super self] in initializers 🔍

Summary:
This check aims to address a relatively common benign error where
Objective-C subclass initializers call -self on their superclass instead
of invoking a superclass initializer, typically -init. The error is
typically benign because libobjc recognizes that improper initializer
chaining is common¹.

One theory for the frequency of this error might be that -init and -self
have the same return type which could potentially cause inappropriate
autocompletion to -self instead of -init. The equal selector lengths and
triviality of common initializer code probably contribute to errors like
this slipping through code review undetected.

This check aims to flag errors of this form in the interests of
correctness and reduce incidence of initialization failing to chain to
-[NSObject init].

[1] "In practice, it will be hard to rely on this function.
     Many classes do not properly chain -init calls."
From  _objc_rootInit in https://opensource.apple.com/source/objc4/objc4-750.1/runtime/NSObject.mm.auto.html.

Test Notes:
Verified via `make check-clang-tools`.

Subscribers: mgorny, xazax.hun, jdoerfert, cfe-commits

Tags: #clang

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

llvm-svn: 358620

5 years agoTest commit by Denis Bakhvalov
Denis Bakhvalov [Wed, 17 Apr 2019 22:27:30 +0000 (22:27 +0000)]
Test commit by Denis Bakhvalov

Change-Id: I4d85123a157d957434902fb14ba50926b2d56212
llvm-svn: 358619

5 years ago[AsmPrinter] hoist %a output template to base class for ARM+Aarch64
Nick Desaulniers [Wed, 17 Apr 2019 22:21:10 +0000 (22:21 +0000)]
[AsmPrinter] hoist %a output template to base class for ARM+Aarch64

Summary:
X86 is quite complicated; so I intend to leave it as is. ARM+Aarch64 do
basically the same thing (Aarch64 did not correctly handle immediates,
ARM has a test llvm/test/CodeGen/ARM/2009-04-06-AsmModifier.ll that uses
%a with an immediate) for a flag that should be target independent
anyways.

Reviewers: echristo, peter.smith

Reviewed By: echristo

Subscribers: javed.absar, eraman, kristof.beyls, hiraditya, llvm-commits, srhines

Tags: #llvm

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

llvm-svn: 358618

5 years agoAdd a getSizeInBits() accessor to MachineMemOperand. NFC.
Amara Emerson [Wed, 17 Apr 2019 22:21:05 +0000 (22:21 +0000)]
Add a getSizeInBits() accessor to MachineMemOperand. NFC.

Cleans up a bunch of places where we do getSize() * 8.

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

llvm-svn: 358617

5 years ago[libc++][CMake] Remove unnecessary conditional for defining new handlers
Louis Dionne [Wed, 17 Apr 2019 21:57:49 +0000 (21:57 +0000)]
[libc++][CMake] Remove unnecessary conditional for defining new handlers

It turns out that whether the new handlers should be provided is orthogonal
to whether new/delete are provided in libc++ or libc++abi. The reason why
I initially added this conditional is because of an incorrect understanding
of the path we're taking when building on Apple platforms. In fact, we
always build libc++ on top of libc++abi on Apple platforms, so we take
the branch for `LIBCXX_BUILDING_LIBCXXABI` there.

llvm-svn: 358616

5 years ago[crashlog] Use the right path for dsymforUUID and remove an unnecessary import.
Davide Italiano [Wed, 17 Apr 2019 21:51:55 +0000 (21:51 +0000)]
[crashlog] Use the right path for dsymforUUID and remove an unnecessary import.

<rdar://problem/49925960>

llvm-svn: 358615

5 years ago[CMake] Split linked libraries for shared and static libc++
Petr Hosek [Wed, 17 Apr 2019 21:41:09 +0000 (21:41 +0000)]
[CMake] Split linked libraries for shared and static libc++

Some linker libraries are only needed for shared libc++, some only
for static libc++, combining these together in LIBCXX_LIBRARIES and
LIBCXX_INTERFACE_LIBRARIES can introduce unnecessary dependencies.

This changes splits those up into LIBCXX_SHARED_LIBRARIES and
LIBCXX_STATIC_LIBRARIES matching what libc++abi already does.

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

llvm-svn: 358614

5 years ago[GlobalISel] Add legalization support for non-power-2 loads and stores
Amara Emerson [Wed, 17 Apr 2019 21:30:07 +0000 (21:30 +0000)]
[GlobalISel] Add legalization support for non-power-2 loads and stores

Legalize things like i24 load/store by splitting them into smaller power of 2 operations.

This matches how SelectionDAG handles these operations.

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

llvm-svn: 358613

5 years ago[clangd] Strip the ' [some-check-name]' suffix from clang-tidy diagnostics. The check...
Sam McCall [Wed, 17 Apr 2019 20:15:08 +0000 (20:15 +0000)]
[clangd] Strip the ' [some-check-name]' suffix from clang-tidy diagnostics. The check name is reported in Diagnostic.code.

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 358612

5 years ago[clangd] Use shorter, more recognizable codes for diagnostics.
Sam McCall [Wed, 17 Apr 2019 20:12:03 +0000 (20:12 +0000)]
[clangd] Use shorter, more recognizable codes for diagnostics.

Summary:
 - for warnings, use the flag the warning is controlled by (-Wfoo)
 - for errors, keep using the internal name (there's nothing better) but
   drop the err_ prefix

This comes at the cost of uniformity, it's no longer totally obvious
exactly what the code field contains. But the -Wname flags are so much
more useful to end-users than the internal warn_foo that this seems worth it.

Reviewers: kadircet

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

Tags: #clang

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

llvm-svn: 358611

5 years ago[libc++] (Take 2) Add a test that uses the debug database from multiple threads
Louis Dionne [Wed, 17 Apr 2019 20:07:39 +0000 (20:07 +0000)]
[libc++] (Take 2) Add a test that uses the debug database from multiple threads

In r358591, I added a test that uses the debug database from multiple
threads and that helped us uncover the problem that was fixed in r355367.
However, the test broke the tsan CI bots, and I think the problem is the
test allocator that was used in the test (which is not thread safe).

I'm committing again without using the test allocator, and in a separate
test file.

llvm-svn: 358610

5 years ago[analyzer] PR41185: Fix regression where __builtin_* functions weren't recognized
Kristof Umann [Wed, 17 Apr 2019 19:56:40 +0000 (19:56 +0000)]
[analyzer] PR41185: Fix regression where __builtin_* functions weren't recognized

For the following code snippet:

void builtin_function_call_crash_fixes(char *c) {
  __builtin_strncpy(c, "", 6);
  __builtin_memset(c, '\0', (0));
  __builtin_memcpy(c, c, 0);
}
security.insecureAPI.DeprecatedOrUnsafeBufferHandling caused a regression, as it
didn't recognize functions starting with __builtin_. Fixed exactly that.

I wanted to modify an existing test file, but the two I found didn't seem like
perfect candidates. While I was there, I prettified their RUN: lines.

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

llvm-svn: 358609

5 years ago[libc++][CMake] Allow building neither the shared nor the static library
Louis Dionne [Wed, 17 Apr 2019 19:47:27 +0000 (19:47 +0000)]
[libc++][CMake] Allow building neither the shared nor the static library

It's possible to build just the headers, and we actually do it.

llvm-svn: 358608

5 years agoAdd basic loop fusion pass.
Kit Barton [Wed, 17 Apr 2019 18:53:27 +0000 (18:53 +0000)]
Add basic loop fusion pass.

This patch adds a basic loop fusion pass. It will fuse loops that conform to the
following 4 conditions:
  1. Adjacent (no code between them)
  2. Control flow equivalent (if one loop executes, the other loop executes)
  3. Identical bounds (both loops iterate the same number of iterations)
  4. No negative distance dependencies between the loop bodies.

The pass does not make any changes to the IR to create opportunities for fusion.
Instead, it checks if the necessary conditions are met and if so it fuses two
loops together.

The pass has not been added to the pass pipeline yet, and thus is not enabled by
default. It can be run stand alone using the -loop-fusion option.

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

llvm-svn: 358607

5 years ago[clangd] Recognize "don't include me directly" pattern, and suppress include insertion.
Sam McCall [Wed, 17 Apr 2019 18:33:07 +0000 (18:33 +0000)]
[clangd] Recognize "don't include me directly" pattern, and suppress include insertion.

Summary:
Typically used with umbrella headers, e.g. GTK:

 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
 #error "Only <gtk/gtk.h> can be included directly."
 #endif

Heuristic is fairly conservative, a quick code search over github showed
a fair number of hits and few/no false positives. (Not all were umbrella
headers, but I'd be happy avoiding include insertion for all of them).

We may want to relax the heuristic later to catch more cases.

Reviewers: ioeric

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

Tags: #clang

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

llvm-svn: 358605

5 years ago[CMake] Remove Apple-specific version logic.
Frederic Riss [Wed, 17 Apr 2019 18:23:22 +0000 (18:23 +0000)]
[CMake] Remove Apple-specific version logic.

We were using the LLDB-Info.plist as the canonical holder of the
version number, but there is really no good reason to do this. If
anything the plist should be generated using the information provided
to CMake.

For now just remove the logic extracting the version from the plist
and rely on LLDB_VERSION_STRING.

llvm-svn: 358604

5 years ago[AsmPrinter] defer %c to base class for ARM, PPC, and Hexagon. NFC
Nick Desaulniers [Wed, 17 Apr 2019 18:22:48 +0000 (18:22 +0000)]
[AsmPrinter] defer %c to base class for ARM, PPC, and Hexagon. NFC

Summary:
None of these derived classes do anything that the base class cannot.
If we remove these case statements, then the base class can handle them
just fine.

Reviewers: peter.smith, echristo

Reviewed By: echristo

Subscribers: nemanjai, javed.absar, eraman, kristof.beyls, hiraditya, kbarton, jsji, llvm-commits, srhines

Tags: #llvm

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

llvm-svn: 358603

5 years ago[libc++] Use the no_destroy attribute to avoid destroying debug DB statics
Louis Dionne [Wed, 17 Apr 2019 18:20:19 +0000 (18:20 +0000)]
[libc++] Use the no_destroy attribute to avoid destroying debug DB statics

Summary:
Otherwise, we can run into problems when the program has static variables
that need to use the debug database during their deinitialization, if
the debug DB has already been deinitialized.

Reviewers: EricWF

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

Tags: #libc

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

llvm-svn: 358602

5 years ago[ThinLTO] Fix ThinLTOCodegenerator to export llvm.used symbols
Steven Wu [Wed, 17 Apr 2019 17:38:09 +0000 (17:38 +0000)]
[ThinLTO] Fix ThinLTOCodegenerator to export llvm.used symbols

Summary:
Reapply r357931 with fixes to ThinLTO testcases and llvm-lto tool.

ThinLTOCodeGenerator currently does not preserve llvm.used symbols and
it can internalize them. In order to pass the necessary information to the
legacy ThinLTOCodeGenerator, the input to the code generator is
rewritten to be based on lto::InputFile.

Now ThinLTO using the legacy LTO API will requires data layout in
Module.

"internalize" thinlto action in llvm-lto is updated to run both
"promote" and "internalize" with the same configuration as
ThinLTOCodeGenerator. The old "promote" + "internalize" option does not
produce the same output as ThinLTOCodeGenerator.

This fixes: PR41236
rdar://problem/49293439

Reviewers: tejohnson, pcc, kromanova, dexonsmith

Reviewed By: tejohnson

Subscribers: ormris, bd1976llvm, mehdi_amini, inglorion, eraman, hiraditya, jkorous, dexonsmith, arphaman, dang, llvm-commits

Tags: #llvm

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

llvm-svn: 358601

5 years ago[InstCombine] Factor out unreachable inst idiom creation [NFC]
Philip Reames [Wed, 17 Apr 2019 17:37:58 +0000 (17:37 +0000)]
[InstCombine] Factor out unreachable inst idiom creation [NFC]

In InstCombine, we use an idiom of "store i1 true, i1 undef" to indicate we've found a path which we've proven unreachable.  We can't actually insert the unreachable instruction since that would require changing the CFG.  We leave that to simplifycfg later.

This just factors out that idiom creation so we don't duplicate the same mostly undocument idiom creation in multiple places.

llvm-svn: 358600

5 years ago[LVI][CVP] Constrain values in with.overflow branches
Nikita Popov [Wed, 17 Apr 2019 16:57:42 +0000 (16:57 +0000)]
[LVI][CVP] Constrain values in with.overflow branches

If a branch is conditional on extractvalue(op.with.overflow(%x, C), 1)
then we can constrain the value of %x inside the branch based on
makeGuaranteedNoWrapRegion(). We do this by extending the edge-value
handling in LVI. This allows CVP to then fold comparisons against %x,
as illustrated in the tests.

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

llvm-svn: 358597

5 years ago[AMDGPU][MC] Corrected handling of "-" before expressions
Dmitry Preobrazhensky [Wed, 17 Apr 2019 16:56:34 +0000 (16:56 +0000)]
[AMDGPU][MC] Corrected handling of "-" before expressions

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

Reviewers: artem.tamazov, arsenm

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

llvm-svn: 358596

5 years ago[OPENMP][NVPTX]Run combined constructs with if clause in SPMD mode.
Alexey Bataev [Wed, 17 Apr 2019 16:53:08 +0000 (16:53 +0000)]
[OPENMP][NVPTX]Run combined constructs with if clause in SPMD mode.

All target-parallel-based constructs can be run in SPMD mode from now
on. Even if num_threads clauses or if clauses are used, such constructs
can be executed in SPMD mode.

llvm-svn: 358595

5 years ago[ARM] tighten test checks; NFC
Sanjay Patel [Wed, 17 Apr 2019 16:51:09 +0000 (16:51 +0000)]
[ARM] tighten test checks; NFC

llvm-svn: 358594

5 years agoRevert "[libc++] Add a test that uses the debug database from multiple threads"
Louis Dionne [Wed, 17 Apr 2019 16:43:03 +0000 (16:43 +0000)]
Revert "[libc++] Add a test that uses the debug database from multiple threads"

This reverts r358591, which seems to have uncovered an actual bug and
causes the tsan CI to fail. We need to fix the bug and re-commit the
test.

llvm-svn: 358593

5 years agoAMDGPU: Force skip over SMRD, VMEM and s_waitcnt instructions
Rhys Perry [Wed, 17 Apr 2019 16:31:52 +0000 (16:31 +0000)]
AMDGPU: Force skip over SMRD, VMEM and s_waitcnt instructions

Summary: This fixes a large Dawn of War 3 performance regression with RADV from Mesa 19.0 to master which was caused by creating less code in some branches.

Reviewers: arsen, nhaehnle

Reviewed By: nhaehnle

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

Tags: #llvm

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

llvm-svn: 358592

5 years ago[libc++] Add a test that uses the debug database from multiple threads
Louis Dionne [Wed, 17 Apr 2019 16:21:55 +0000 (16:21 +0000)]
[libc++] Add a test that uses the debug database from multiple threads

This test helped us concurrently discover the problem that was fixed
in r355367.

llvm-svn: 358591

5 years agoRemove --show-includes flag in crash reduce script
Amy Huang [Wed, 17 Apr 2019 16:20:56 +0000 (16:20 +0000)]
Remove --show-includes flag in crash reduce script

llvm-svn: 358590