platform/upstream/llvm.git
4 years ago[clang][Tooling] Add support for .rsp files in compile_commands.json
Kadir Cetinkaya [Fri, 29 Nov 2019 11:14:25 +0000 (12:14 +0100)]
[clang][Tooling] Add support for .rsp files in compile_commands.json

Summary:
Add support for .rsp files.

Fixes https://github.com/clangd/clangd/issues/81

Patch By: liu hui(@lh123)

Reviewers: sammccall, ilya-biryukov, hokein, kadircet

Reviewed By: kadircet

Subscribers: merge_guards_bot, mgorny, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang-tools-extra, #clang

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

4 years ago[Support] add vfs support for ExpandResponseFiles
Kadir Cetinkaya [Fri, 29 Nov 2019 11:14:24 +0000 (12:14 +0100)]
[Support] add vfs support for ExpandResponseFiles

Summary: add vfs support for `ExpandResponseFiles`.

Patch By: liu hui(@lh123)

Reviewers: kadircet, espindola, alexshap, rupprecht, jhenderson

Reviewed By: kadircet

Subscribers: mgorny, sammccall, merge_guards_bot, emaste, sbc100, arichardson, hiraditya, aheejin, jakehehrlich, MaskRay, rupprecht, seiya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

4 years ago[clangd] register cuda language activation event and activate for .cuh files
ptaylor [Wed, 4 Dec 2019 13:58:23 +0000 (14:58 +0100)]
[clangd] register cuda language activation event and activate for .cuh files

Patch by Paul Taylor!

Reviewers: hokein

Reviewed By: hokein

Subscribers: jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

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

4 years ago[lldb] Fix macOS build by replacing nullptr with FileSpec()
Raphael Isemann [Wed, 4 Dec 2019 13:36:14 +0000 (14:36 +0100)]
[lldb] Fix macOS build by replacing nullptr with FileSpec()

Before we had a implicit conversion from nullptr to FileSpec
which was thankfully removed.

4 years ago[NFC][InstCombine] Update sub-of-negatible.ll test
Roman Lebedev [Wed, 4 Dec 2019 12:48:19 +0000 (15:48 +0300)]
[NFC][InstCombine] Update sub-of-negatible.ll test

4 years ago[OpenCL] Allow addr space qualifiers on lambda call expressions
Anastasia Stulova [Tue, 3 Dec 2019 17:24:33 +0000 (17:24 +0000)]
[OpenCL] Allow addr space qualifiers on lambda call expressions

The addr space qualifier can be added optionally for lambdas after
the attributes. They will alter the default addr space of lambda
call operator that is in generic address space by default for OpenCL.

Syntax:

[ captures ] ( params ) specifiers exception attr opencl_addrspace
                    -> ret { body }

Example:

[&] (int i) mutable __global { ... };

On the call into lambda a compatibility check will be performed to
determine whether address space of lambda object and its call operator
are compatible. This will follow regular addr space conversion rules
and there will be no difference to how addr spaces work in method
qualifiers.

Tags: #clang

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

4 years agoActually delay processing DelayedDllExportClasses until the outermost class is finish...
Hans Wennborg [Mon, 2 Dec 2019 15:25:23 +0000 (16:25 +0100)]
Actually delay processing DelayedDllExportClasses until the outermost class is finished (PR40006)

This was already the intention of DelayedDllExportClasses, but code such as
this would break it:

template<typename> struct Tmpl {};
struct Outer {
    struct Inner {
        __declspec(dllexport) Inner() = default;
        unsigned int x = 0;
    };
    Tmpl<Inner> y;
};

ActOnFinishCXXNonNestedClass() would get called when the instantiation of
Templ<Inner> is finished, even though the compiler is still not finished with
Outer, causing the compile fail.

This hooks into Sema::{Push,Pop}ParsingClass() to avoid calling
ActOnFinishCXXNonNestedClass() for template instantiations while a class is
being parsed.

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

4 years ago[AArch64][SVE] Implement reversal intrinsics
Cullen Rhodes [Wed, 4 Dec 2019 11:36:30 +0000 (11:36 +0000)]
[AArch64][SVE] Implement reversal intrinsics

Summary:
Adds intrinsics for the following:

    * rbit
    * revb
    * revh
    * revw

Patterns are also defined to map the 'llvm.bswap.*' intrinsic to the SVE
revb instruction.

Reviewers: sdesmalen, huntergr, dancgr, rengolin, efriedma, rovka

Reviewed By: sdesmalen

Subscribers: tschuett, kristof.beyls, hiraditya, rkruppe, psnobl, llvm-commits

Tags: #llvm

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

4 years ago[AMDGPU][MC] Remove duplicate code introduced in r359316.
Jay Foad [Wed, 4 Dec 2019 11:40:09 +0000 (11:40 +0000)]
[AMDGPU][MC] Remove duplicate code introduced in r359316.

4 years ago[clangd] Remove the hanging lit exit-signal.test.
Haojian Wu [Wed, 4 Dec 2019 11:29:53 +0000 (12:29 +0100)]
[clangd] Remove the hanging lit exit-signal.test.

The test was introduced in
https://github.com/llvm/llvm-project/commit/19ac0eaf07e60173baa7ee77fa11568c30b87455.

The test keeps hanging after running "check-clangd", remove it now
and will add it back later after investigations.

4 years ago[SimpleLoopUnswitch] Invalidate the topmost loop with ExitBB as exiting.
Florian Hahn [Wed, 4 Dec 2019 11:24:10 +0000 (11:24 +0000)]
[SimpleLoopUnswitch] Invalidate the topmost loop with ExitBB as exiting.

SCEV caches the exiting blocks when computing exit counts. In
SimpleLoopUnswitch, we split the exit block of the loop to unswitch.

Currently we only invalidate the loop containing that exit block, but if
that block is the exiting block for a parent loop, we have stale cache
entries. We have to invalidate the top-most loop that contains the exit
block as exiting block. We might also be able to skip invalidating the
loop containing the exit block, if the exit block is not an exiting
block of that loop.

There are also 2 more places in SimpleLoopUnswitch, that use a similar
problematic approach to get the loop to invalidate. If the patch makes
sense, I will also update those places to a similar approach (they deal
with multiple exit blocks, so we cannot directly re-use
getTopMostExitingLoop).

Fixes PR43972.

Reviewers: skatkov, reames, asbirlea, chandlerc

Reviewed By: asbirlea

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

4 years agoAllow negative offsets in MipsMCInstLower::LowerOperand
Alex Richardson [Wed, 4 Dec 2019 10:06:24 +0000 (10:06 +0000)]
Allow negative offsets in MipsMCInstLower::LowerOperand

Summary:
We rely on this in our CHERI backend to address the GOT by generating a
$pc-relative addresses. For this we emit the following code sequence:

lui $1, %pcrel_hi(_CHERI_CAPABILITY_TABLE_-8)
daddiu $1, $1, %pcrel_lo(_CHERI_CAPABILITY_TABLE_-4)
cgetpccincoffset $c1, $1

However, without this change the addend is implicitly converted to
UINT32_MAX and an invalid pointer value is generated.

Reviewers: atanasyan

Reviewed By: atanasyan

Subscribers: merge_guards_bot, sdardis, hiraditya, jrtc27, llvm-commits

Tags: #llvm

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

4 years agoHandle BUNDLE instructions in MipsAsmPrinter
Alex Richardson [Wed, 4 Dec 2019 10:06:12 +0000 (10:06 +0000)]
Handle BUNDLE instructions in MipsAsmPrinter

Summary:
In our CHERI fork we use BUNDLE instructions to ensure that a
three-instruction sequence to generate a program-counter-relative value is
emitted without reordering or insertions (since that would break the 32-bit
offset computation).

Currently MipsAsmPrinter asserts when it encounters a pseudo instruction.
To handle BUNDLE we can simply skip the instruction which will then make
EmitInstruction() process the contents of the bundle in order.

Reviewers: atanasyan

Reviewed By: atanasyan

Subscribers: merge_guards_bot, sdardis, hiraditya, jrtc27, llvm-commits

Tags: #llvm

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

4 years agoMipsDelaySlotFiller: Don't move BUNDLE instructions into the delay slot
Alex Richardson [Wed, 4 Dec 2019 10:06:02 +0000 (10:06 +0000)]
MipsDelaySlotFiller: Don't move BUNDLE instructions into the delay slot

Summary:
In our CHERI fork we use BUNDLE instructions to ensure that a
three-instruction sequence to generate a program-counter-relative value is
emitted without reordering or insertions (since that would break the 32-bit
offset computation). This sequence is created in MipsExpandPseudo and we use
finalizeBundle() to create the BUNDLE instruction.

However, the delay slot filler currently breaks this pattern since the BUNDLE
will be removed and so all instructions are moved into the delay slot.
Since the delay slot only executes the first instruction, this results in
incorrect computations (and run-time crashes) if the branch is taken.

The original test cases uses CHERI instructions, so for the test case here
I simple filled a BUNDLE with a no-op DADDiu $sp_64, -16 and DADDiu $sp_64, 16.

Reviewers: atanasyan

Reviewed By: atanasyan

Subscribers: merge_guards_bot, sdardis, hiraditya, jrtc27, llvm-commits

Tags: #llvm

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

4 years agoAdd debug output to MipsDelaySlotFiller pass
Alex Richardson [Wed, 4 Dec 2019 10:05:02 +0000 (10:05 +0000)]
Add debug output to MipsDelaySlotFiller pass

Summary:
I was tracking down a code-generation bug in this pass and found that the
added output was useful. It is also helpful to find out why a delay slot
could not be filled even though there is clearly a valid instruction (which
appears to mostly be caused by CFI instructions).

Reviewers: atanasyan

Reviewed By: atanasyan

Subscribers: merge_guards_bot, sdardis, hiraditya, jrtc27, llvm-commits

Tags: #llvm

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

4 years ago[clangd] Add no delayed templates to outline tests
Kadir Cetinkaya [Wed, 4 Dec 2019 11:19:08 +0000 (12:19 +0100)]
[clangd] Add no delayed templates to outline tests

4 years ago[AArch64TTI] Compute imm materialization cost for AArch64 intrinsics
Florian Hahn [Wed, 4 Dec 2019 10:49:24 +0000 (10:49 +0000)]
[AArch64TTI] Compute imm materialization cost for AArch64 intrinsics

Currently, getIntImmCost returns TCC_Free for almost all intrinsics.
For most AArch64 specific intrinsics however, it looks like integer
constants cannot be folded into most of them (at least the ones I checked).

Unless we know that we can fold integer operands with the intrinsic, we
handle more cases correctly by returning the cost to materialize the
immediate than return TCC_Free.

Reviewers: SjoerdMeijer, dmgreen, t.p.northover, ributzka

Reviewed By: SjoerdMeijer

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

4 years ago[NFC] Use default case in EVT::getEVTString
Cullen Rhodes [Wed, 4 Dec 2019 09:55:26 +0000 (09:55 +0000)]
[NFC] Use default case in EVT::getEVTString

Summary:
The default case handles the majority of MVTs so most of the individual
cases can be removed. Also added a case for floating point types.

Reviewed By: sdesmalen

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

4 years agoAMDGPU: Avoid folding 2 constant operands into an SALU operation
David Stuttard [Mon, 2 Dec 2019 13:01:26 +0000 (13:01 +0000)]
AMDGPU: Avoid folding 2 constant operands into an SALU operation

Summary:
Catch the (admittedly unusual) case where SIFoldOperands attempts to fold 2
constant operands into the same SALU operation, with neither operand able to be
encoded as an inline constant.

Change-Id: Ibc48d662c9ffd8bbacd154976b0b1c257ace0927

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

Tags: #llvm

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

4 years ago[yaml2obj] - Make DynamicSymbols to be Optional<> too.
Georgii Rymar [Tue, 3 Dec 2019 12:48:29 +0000 (15:48 +0300)]
[yaml2obj] - Make DynamicSymbols to be Optional<> too.

We already have Symbols property to list regular symbols and
it is currently Optional<>. This patch makes DynamicSymbols to be optional
too. With this there is no need to define a dummy symbol anymore to trigger
creation of the .dynsym and it is now possible to define an empty .dynsym using
just the following line:

DynamicSymbols: []
(it is important to have when you do not want to have dynamic symbols,
but want to have a .dynsym)

Now the code is consistent and it helped to fix a bug: previously we
did not report an error when both Content/Size and an empty
Symbols/DynamicSymbols list were specified.

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

4 years ago[lldb] Remove some (almost) unused Stream::operator<<'s
Pavel Labath [Tue, 26 Nov 2019 13:45:15 +0000 (14:45 +0100)]
[lldb] Remove some (almost) unused Stream::operator<<'s

llvm::raw_ostream provides equivalent functionality.

4 years ago[APFloat] Prevent construction of APFloat with Semantics and FP value
Ehud Katz [Wed, 4 Dec 2019 09:57:38 +0000 (11:57 +0200)]
[APFloat] Prevent construction of APFloat with Semantics and FP value

Constructor invocations such as `APFloat(APFloat::IEEEdouble(), 0.0)`
may seem like they accept a FP (floating point) value, but the overload
they reach is actually the `integerPart` one, not a `float` or `double`
overload (which only exists when `fltSemantics` isn't passed).

This may lead to possible loss of data, by the conversion from `float`
or `double` to `integerPart`.

To prevent future mistakes, a new constructor overload, which accepts
any FP value and marked with `delete`, to prevent its usage.

Fixes PR34095.

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

4 years ago[lldb] s/assertTrue/assertEqual in TestStepTarget.py
Pavel Labath [Thu, 28 Nov 2019 08:14:44 +0000 (09:14 +0100)]
[lldb] s/assertTrue/assertEqual in TestStepTarget.py

this improves error messages.

4 years ago[lldb] Remove FileSpec(FileSpec*) constructor
Pavel Labath [Thu, 28 Nov 2019 16:02:07 +0000 (17:02 +0100)]
[lldb] Remove FileSpec(FileSpec*) constructor

This constructor was the cause of some pretty weird behavior. Remove it,
and update all code to properly dereference the argument instead.

4 years ago[lldb] Add test for Stream::Address and Stream::AddressRange
Raphael Isemann [Wed, 4 Dec 2019 09:27:18 +0000 (10:27 +0100)]
[lldb] Add test for Stream::Address and Stream::AddressRange

I'm refactoring those functions, so we should have some tests for
them before doing that.

4 years ago[lldb/Editline] Fix a -Wreturn-type warning with gcc
Pavel Labath [Wed, 4 Dec 2019 09:44:12 +0000 (10:44 +0100)]
[lldb/Editline] Fix a -Wreturn-type warning with gcc

4 years ago[lldb] s/FileSpec::Equal/FileSpec::Match
Pavel Labath [Fri, 29 Nov 2019 10:31:00 +0000 (11:31 +0100)]
[lldb] s/FileSpec::Equal/FileSpec::Match

Summary:
The FileSpec class is often used as a sort of a pattern -- one specifies
a bare file name to search, and we check if in matches the full file
name of an existing module (for example).

These comparisons used FileSpec::Equal, which had some support for it
(via the full=false argument), but it was not a good fit for this job.

For one, it did a symmetric comparison, which makes sense for a function
called "equal", but not for typical searches (when searching for
"/foo/bar.so", we don't want to find a module whose name is just
"bar.so"). This resulted in patterns like:
    if (FileSpec::Equal(pattern, file, pattern.GetDirectory()))
which would request a "full" match only if the pattern really contained
a directory. This worked, but the intended behavior was very unobvious.

On top of that, a lot of the code wanted to handle the case of an
"empty" pattern, and treat it as matching everything. This resulted in
conditions like:
    if (pattern && !FileSpec::Equal(pattern, file, pattern.GetDirectory())
which are nearly impossible to decipher.

This patch introduces a FileSpec::Match function, which does exactly
what most of FileSpec::Equal callers want, an asymmetric match between a
"pattern" FileSpec and a an actual FileSpec. Empty paterns match
everything, filename-only patterns match only the filename component.

I've tried to update all callers of FileSpec::Equal to use a simpler
interface. Those that hardcoded full=true have been changed to use
operator==. Those passing full=pattern.GetDirectory() have been changed
to use FileSpec::Match.

There was also a handful of places which hardcoded full=false. I've
changed these to use FileSpec::Match too. This is a slight change in
semantics, but it does not look like that was ever intended, and it was
more likely a result of a misunderstanding of the "proper" way to use
FileSpec::Equal.

[In an ideal world a "FileSpec" and a "FileSpec pattern" would be two
different types, but given how widespread FileSpec is, it is unlikely
we'll get there in one go. This at least provides a good starting point
by centralizing all matching behavior.]

Reviewers: teemperor, JDevlieghere, jdoerfert

Subscribers: emaste, lldb-commits

Tags: #lldb

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

4 years ago[DWARFDebugLoclists] Add support for other DW_LLE encodings
Pavel Labath [Fri, 22 Nov 2019 09:53:09 +0000 (10:53 +0100)]
[DWARFDebugLoclists] Add support for other DW_LLE encodings

Summary:
lldb's loclists parser has support for DW_LLE_start_end(x) encodings. To
avoid regressing when switching the implementation to llvm's, I add
parsing support for all previously unsupported location list encodings.

Reviewers: dblaikie, JDevlieghere, aprantl, SouraVX

Subscribers: hiraditya, probinson, llvm-commits

Tags: #llvm

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

4 years ago[DWARFDebugRnglists] Add a callback-based version of the getAbsoluteRanges function
Pavel Labath [Tue, 26 Nov 2019 09:40:30 +0000 (10:40 +0100)]
[DWARFDebugRnglists] Add a callback-based version of the getAbsoluteRanges function

Summary:
The dump() function already accepts a callback. This makes
getAbsoluteRanges do the same. The existing DWARFUnit overload is
implemented on top of the new function.

This enables usage of the debug_rnglists parser from within lldb (which
has it's own dwarf parser).

Reviewers: dblaikie, JDevlieghere, aprantl

Subscribers: hiraditya, probinson, llvm-commits

Tags: #llvm

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

4 years ago[SelectionDAG] Expand nnan FMINNUM/FMAXNUM to select sequence
Ulrich Weigand [Wed, 4 Dec 2019 09:27:02 +0000 (10:27 +0100)]
[SelectionDAG] Expand nnan FMINNUM/FMAXNUM to select sequence

InstCombine may synthesize FMINNUM/FMAXNUM nodes from fcmp+select
sequences (where the fcmp is marked nnan).  Currently, if the
target does not otherwise handle these nodes, they'll get expanded
to libcalls to fmin/fmax.  However, these functions may reside in
libm, which may introduce a library dependency that was not originally
present in the source code, potentially resulting in link failures.

To fix this problem, add code to TargetLowering::expandFMINNUM_FMAXNUM
to expand FMINNUM/FMAXNUM to a compare+select sequence instead of the
libcall. This is done only if the node is marked as "nnan"; in this case,
the expansion to compare+select is always correct. This also suffices to
catch all cases where FMINNUM/FMAXNUM was synthesized as above.

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

4 years ago[lldb][NFC] Extract single member parsing out of DWARFASTParserClang::ParseChildMembers
Raphael Isemann [Wed, 4 Dec 2019 08:38:49 +0000 (09:38 +0100)]
[lldb][NFC] Extract single member parsing out of DWARFASTParserClang::ParseChildMembers

ParseChildMembers does a few things, only one part is actually parsing a single
member. This extracts the member parsing logic into its own function.

This commit just moves the code as-is into its own function and forwards the parameters/
local variables to it, which means it should be NFC.

The only actual changes to the code are replacing 'break's (and one very curious 'continue'
that behaves like a 'break') with 'return's.

4 years ago[yaml2obj][test] - Remove excessive symtab-shinfo.yaml.
Georgii Rymar [Tue, 3 Dec 2019 13:11:10 +0000 (16:11 +0300)]
[yaml2obj][test] - Remove excessive symtab-shinfo.yaml.

The same testing is performed in `implicit-sections-info.yaml`:
https://github.com/llvm-mirror/llvm/blob/master/test/tools/yaml2obj/implicit-sections-info.yaml

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

4 years ago[lldb][NFC] Migrate to raw_ostream in Module::GetDescription
Raphael Isemann [Wed, 4 Dec 2019 08:20:42 +0000 (09:20 +0100)]
[lldb][NFC] Migrate to raw_ostream in Module::GetDescription

4 years ago[CodeGen][ObjC] Emit a primitive store to store a __strong field in
Akira Hatanaka [Fri, 29 Nov 2019 17:56:02 +0000 (09:56 -0800)]
[CodeGen][ObjC] Emit a primitive store to store a __strong field in
ExpandTypeFromArgs

This fixes a bug in IRGen where a call to `llvm.objc.storeStrong` was
being emitted to initialize a __strong field of an uninitialized
temporary struct, which caused crashes at runtime.

rdar://problem/51807365

4 years agogn build: Merge 9f251eece46
LLVM GN Syncbot [Wed, 4 Dec 2019 07:32:05 +0000 (07:32 +0000)]
gn build: Merge 9f251eece46

4 years agoRevert "Enable `-funwind-tables` flag when building libunwind"
Martin Storsjö [Wed, 4 Dec 2019 07:22:08 +0000 (09:22 +0200)]
Revert "Enable `-funwind-tables` flag when building libunwind"

This reverts commit b3fdf33ba6aa7ef80621696f74aaf2f6f8e1d1de.

This change broke building libunwind for Windows/MinGW, and broke
on aspect of the CMake tests in libunwind in general.

After set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY), CMake
skips the linking step in tests, but cmake/config-ix.cmake also
does a few checks for functions in libraries (looking for whether
-lc provides fopen and whether -ldl provides dladdr).

As CMake only tests building a static library, these tests
incorrectly succeed and CMake concludes "Looking for fopen in c -
found" and "Looking for dladdr in dl - found", while building
then fails at the end with errors about unable to find -lc and -ldl.

4 years ago[lldb][NFC] Migrate to raw_ostream in ArchSpec::DumpTriple
Raphael Isemann [Wed, 4 Dec 2019 07:27:43 +0000 (08:27 +0100)]
[lldb][NFC] Migrate to raw_ostream in ArchSpec::DumpTriple

Reviewers: labath, davide

Reviewed By: davide

Subscribers: clayborg, JDevlieghere, lldb-commits

Tags: #lldb

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

4 years ago[clangd] Define out-of-line qualify function name
Kadir Cetinkaya [Fri, 22 Nov 2019 12:56:02 +0000 (13:56 +0100)]
[clangd] Define out-of-line qualify function name

Summary:
When moving function definitions to a different context, the function
name might need a different spelling, for example in the header it might be:

```
namespace a {
  void foo() {}
}
```

And we might want to move it into a context which doesn't have `namespace a` as
a parent, then we must re-spell the function name, i.e:
```
void a::foo() {}
```

This patch implements a version of this which ignores using namespace
declarations in the source file.

Reviewers: hokein

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

Tags: #clang

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

4 years ago[clangd] Define out-of-line qualify return value
Kadir Cetinkaya [Tue, 22 Oct 2019 15:02:29 +0000 (17:02 +0200)]
[clangd] Define out-of-line qualify return value

Summary:
Return type might need qualification if insertion context doesn't have
the same decls visible as the source context.

This patch adds qualification for return value to cover such cases.

Reviewers: hokein

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

Tags: #clang

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

4 years ago[clangd] Define out-of-line initial apply logic
Kadir Cetinkaya [Mon, 21 Oct 2019 16:16:40 +0000 (18:16 +0200)]
[clangd] Define out-of-line initial apply logic

Summary:
Initial implementation for apply logic, replaces function body with a
semicolon in source location and copies the full function definition into target
location.

Will handle qualification of return type and function name in following patches
to keep the changes small.

Reviewers: hokein

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

Tags: #clang

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

4 years ago[clangd] Define out-of-line availability checks
Kadir Cetinkaya [Mon, 21 Oct 2019 16:03:38 +0000 (18:03 +0200)]
[clangd] Define out-of-line availability checks

Summary:
Initial availability checks for performing define out-of-line code
action, which is a refactoring that will help users move function/method
definitions from headers to implementation files.

Proposed implementation only checks whether we have an interesting selection,
namely function name or full function definition/body.

Reviewers: hokein

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

Tags: #clang

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

4 years ago[llvm-strip][MachO] Test llvm-strip --strip-debug
Fangrui Song [Wed, 4 Dec 2019 03:54:11 +0000 (19:54 -0800)]
[llvm-strip][MachO] Test llvm-strip --strip-debug

Reviewed By: smeenai

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

4 years ago[MacroFusion] Limit the max fused number as 2 to reduce the dependency
QingShan Zhang [Wed, 4 Dec 2019 04:58:34 +0000 (04:58 +0000)]
[MacroFusion] Limit the max fused number as 2 to reduce the dependency

This is the example:

int foo(int a, int b, int c, int d) {
  return a + b + c + d;
}

And this is the Dependency Graph:
+------+       +------+       +------+       +------+
|  A   |       |  B   |       |  C   |       |  D   |
+--+--++       +---+--+       +--+---+       +--+---+
   ^  ^            ^  ^          ^              ^
   |  |            |  |          |              |
   |  |            |  |New1      +--------------+
   |  |            |  |          |
   |  |            |  |       +--+---+
   |  |New2        |  +-------+ ADD1 |
   |  |            |          +--+---+
   |  |            |    Fuse     ^
   |  |            +-------------+
   |  +------------+
   |               |
   |   Fuse     +--+---+
   +----------->+ ADD2 |
   |            +------+
+--+---+
| ADD3 |
+------+

We need also create an artificial edge from ADD1 to A if
https://reviews.llvm.org/D69998 is landed. That will force the Node A scheduled
before the ADD1 and ADD2. But in fact, it is ok to schedule the Node A
in-between ADD3 and ADD2, as ADD3 and ADD2 are NOT a fusion pair because
ADD2 has been matched to ADD1. We are creating these unnecessary dependency
edges that override the heuristics.

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

4 years ago[PowerPC] folding rlwinm + rlwinm to rlwinm
czhengsz [Wed, 4 Dec 2019 02:48:12 +0000 (21:48 -0500)]
[PowerPC] folding rlwinm + rlwinm to rlwinm

  For example:
    x3 = rlwinm x3, 27, 5, 31
    x3 = rlwinm x3, 19, 0, 12
  can be combined to
    x3 = rlwinm x3, 14, 0, 12

Reviewed by: steven.zhang, lkail

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

4 years ago[Clang] Define Fuchsia C++ABI
Petr Hosek [Sat, 7 Sep 2019 01:59:43 +0000 (18:59 -0700)]
[Clang] Define Fuchsia C++ABI

Currently, it is a modified version of the Itanium ABI, with the only
change being that constructors and destructors return 'this'.

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

4 years agoFix warning on unused variable. NFC.
Michael Liao [Wed, 4 Dec 2019 02:15:17 +0000 (21:15 -0500)]
Fix warning on unused variable. NFC.

4 years ago[dsymutil] Support --out (NFC)
Jonas Devlieghere [Wed, 4 Dec 2019 01:06:05 +0000 (17:06 -0800)]
[dsymutil] Support --out (NFC)

Seems like this got lost during the libOption conversion.

4 years ago[Process] GetLanguageRuntimes() takes an argument that's always constant.
Davide Italiano [Wed, 4 Dec 2019 00:54:04 +0000 (16:54 -0800)]
[Process] GetLanguageRuntimes() takes an argument that's always constant.

And arguably `retry_if_null` isn't really descriptive of what
the flag did anyway.

4 years ago[Diagnostic][test] Remove an unneeded change to pragma_diagnostic_sections.cpp after...
Fangrui Song [Wed, 4 Dec 2019 00:39:48 +0000 (16:39 -0800)]
[Diagnostic][test] Remove an unneeded change to pragma_diagnostic_sections.cpp after D70638

4 years agogn build: (manually) merge ad871e42958
Nico Weber [Wed, 4 Dec 2019 00:22:40 +0000 (19:22 -0500)]
gn build: (manually) merge ad871e42958

4 years ago[ClangASTContext] Remove a very old hack.
Davide Italiano [Wed, 4 Dec 2019 00:31:44 +0000 (16:31 -0800)]
[ClangASTContext] Remove a very old hack.

This was fixed in clang a while ago, and the rdar associated
is now closed.

4 years ago[X86] Model DAZ and FTZ
Wang, Pengfei [Tue, 3 Dec 2019 03:10:22 +0000 (11:10 +0800)]
[X86] Model DAZ and FTZ

Summary: This is a follow-up of D70881. It models DAZ and FTZ for releated instructions.

Reviewers: craig.topper, RKSimon, andrew.w.kaylor

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[X86] Model MXCSR for all AVX512 instructions
Wang, Pengfei [Wed, 27 Nov 2019 13:13:35 +0000 (21:13 +0800)]
[X86] Model MXCSR for all AVX512 instructions

Summary: Model MXCSR for all AVX512 instructions

Reviewers: craig.topper, RKSimon, andrew.w.kaylor

Subscribers: hiraditya, llvm-commits, LuoYuanke, LiuChen3

Tags: #llvm

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

4 years agoAdd discussion of git-format-patch to Phabricator.html
Kit Barton [Fri, 29 Nov 2019 17:05:43 +0000 (12:05 -0500)]
Add discussion of git-format-patch to Phabricator.html

Summary: There is a discussion of git-format-patch in GettingStarted guide, but no mention of it in the Phabricator.html page.

Reviewers: jyknight, delcypher

Reviewed By: delcypher

Subscribers: llvm-commits

Tags: #llvm

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

4 years ago[TypeCategory] HasLanguage() is now unused.
Davide Italiano [Tue, 3 Dec 2019 23:06:04 +0000 (15:06 -0800)]
[TypeCategory] HasLanguage() is now unused.

4 years agoFix `sed -e s@FOO@%/S@` and similar when there's @'s in the working directory
Daniel Sanders [Tue, 3 Dec 2019 23:22:30 +0000 (15:22 -0800)]
Fix `sed -e s@FOO@%/S@` and similar when there's @'s in the working directory

Jenkins sometimes starts a new working directory by appending @2 (or
incrementing the number if the @n suffix is already there). This causes
several clang tests to fail as:
  s@INPUT_DIR@%/S/Inputs@g
gets expanded to the invalid:
  s@INPUT_DIR@/path/to/workdir@2/Inputs@g
                               ~~~~~~~~~~
where the part marked with ~'s is interpreted as the flags. These are
invalid and the test fails.

Previous fixes simply exchanged the @ character for another like | but
that's just moving the problem. Address it by adding an expansion that
escapes the @ character we're using as a delimiter as well as other magic
characters in the replacement of sed's s@@@.

There's still room for expansions to cause trouble though. One I ran into
while testing this was that having a directory called foo@bar causes lots
of `CHECK-NOT: foo` directives to match. There's also things like
directories containing `\1`

4 years agoReapply "Fix crash on switch conditions of non-integer types in templates"
Elizabeth Andrews [Tue, 3 Dec 2019 22:20:52 +0000 (14:20 -0800)]
Reapply "Fix crash on switch conditions of non-integer types in templates"

This patch reapplies commit 759948467ea. Patch was reverted due to a
clang-tidy test fail on Windows. The test has been modified. There
are no additional code changes.

Patch was tested with ninja check-all on Windows and Linux.

Summary of code changes:

Clang currently crashes for switch statements inside a template when the
condition is a non-integer field member because contextual implicit
conversion is skipped when parsing the condition. This conversion is
however later checked in an assert when the case statement is handled.
The conversion is skipped when parsing the condition because
the field member is set as type-dependent based on its containing class.
This patch sets the type dependency based on the field's type instead.

This patch fixes Bug 40982.

4 years ago[NFC] Pass a reference to CodeGenFunction to methods of LValue and
Akira Hatanaka [Tue, 3 Dec 2019 23:17:01 +0000 (15:17 -0800)]
[NFC] Pass a reference to CodeGenFunction to methods of LValue and
AggValueSlot

This reapplies 8a5b7c35709d9ce1f44a99f0c5b084bf2696ea17 after a null
dereference bug in CGOpenMPRuntime::emitUserDefinedMapper.

Original commit message:

This is needed for the pointer authentication work we plan to do in the
near future.

https://github.com/apple/llvm-project/blob/a63a81bd9911f87a0b5dcd5bdd7ccdda7124af87/clang/docs/PointerAuthentication.rst

4 years ago[FormatManager] Provide only one variant of EnableCategory.
Davide Italiano [Tue, 3 Dec 2019 23:02:54 +0000 (15:02 -0800)]
[FormatManager] Provide only one variant of EnableCategory.

All the callers pass a single language anyway.

4 years ago[DataVisualization] Simplify. NFCI.
Davide Italiano [Tue, 3 Dec 2019 22:54:59 +0000 (14:54 -0800)]
[DataVisualization] Simplify. NFCI.

4 years ago[MS] Emit exported complete/vbase destructors
Reid Kleckner [Mon, 2 Dec 2019 23:22:44 +0000 (15:22 -0800)]
[MS] Emit exported complete/vbase destructors

Summary:
Fixes PR44205

I checked, and deleting destructors are not affected.

Reviewers: hans

Subscribers: cfe-commits

Tags: #clang

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

4 years ago[compiler-rt] Disable fuzzer large.test when LLVM_ENABLE_EXPENSIVE_CHECKS=ON
Alex Lorenz [Tue, 3 Dec 2019 22:34:02 +0000 (14:34 -0800)]
[compiler-rt] Disable fuzzer large.test when LLVM_ENABLE_EXPENSIVE_CHECKS=ON

This test is timing out on Green Dragon http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-expensive/
and looks like it's not executed on other bots with expensive checks
enabled
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-ubuntu
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win

The test times out at the C++ source file takes too long to build (2+ hours on my machine), as
clang spends a lot of time in IR/MIR verifiers.

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

4 years ago[FPEnv] [PowerPC] Lowering ppc_fp128 StrictFP Nodes to libcalls
Craig Topper [Tue, 3 Dec 2019 22:05:04 +0000 (14:05 -0800)]
[FPEnv] [PowerPC] Lowering ppc_fp128 StrictFP Nodes to libcalls

This is an alternative to D64662 that shares more code between
strict and non-strict nodes. It's modeled after the implementation
that I did for softening.

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

4 years ago[RISCV] Don't force Local Exec TLS for non-PIC
James Clarke [Tue, 3 Dec 2019 22:04:24 +0000 (22:04 +0000)]
[RISCV] Don't force Local Exec TLS for non-PIC

Summary:
Forcing Local Exec TLS requires the use of copy relocations. Copy
relocations need special handling in the runtime linker when being used
against TLS symbols, which is present in glibc, but not in FreeBSD nor
musl, and so cannot be relied upon. Moreover, copy relocations are a
hack that embed the size of an object in the ABI when it otherwise
wouldn't be, and break protected symbols (which are expected to be DSO
local), whilst also wasting space, thus they should be avoided whenever
possible. As discussed in D70398, RISC-V should move away from forcing
Local Exec, and instead use Initial Exec like other targets, with
possible linker relaxation to follow. The RISC-V GCC maintainers also
intend to adopt this more-conventional behaviour (see
https://github.com/riscv/riscv-elf-psabi-doc/issues/122).

Reviewers: asb, MaskRay

Reviewed By: MaskRay

Subscribers: emaste, krytarowski, hiraditya, rbar, johnrusso, simoncook, sabuasal, niosHD, kito-cheng, shiva0217, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, psnobl, benna, Jim, lenary, s.egerton, pzheng, sameer.abuasal, apazos, llvm-commits, bsdjhb

Tags: #llvm

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

4 years ago[InstCombine] Revert aafde063aaf09285c701c80cd4b543c2beb523e8 and 6749dc3446671df0523...
Craig Topper [Tue, 3 Dec 2019 21:48:39 +0000 (13:48 -0800)]
[InstCombine] Revert aafde063aaf09285c701c80cd4b543c2beb523e8 and 6749dc3446671df05235d0a218c426a314ac33cd related to bitcast handling of x86_mmx

This reverts these two commits
[InstCombine] Turn (extractelement <1 x i64/double> (bitcast (x86_mmx))) into a single bitcast from x86_mmx to i64/double.
[InstCombine] Don't transform bitcasts between x86_mmx and v1i64 into insertelement/extractelement

We're seeing at least one internal test failure related to a
bitcast that was previously before an inline assembly block
containing emms being placed after it. This leads to the mmx
state ending up not empty after the emms. IR has no way to
make any specific guarantees about this. Reverting these patches
to get back to previous behavior which at least worked for this
test.

4 years ago[TypeCategory] Nothing passes down a list of languages.
Davide Italiano [Tue, 3 Dec 2019 21:36:50 +0000 (13:36 -0800)]
[TypeCategory] Nothing passes down a list of languages.

Summary: This should allow further simplifications, but it's a first step.

Reviewers: teemperor, jingham, friss

Subscribers: lldb-commits

Tags: #lldb

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

4 years agoEnable `-funwind-tables` flag when building libunwind
Sergej Jaskiewicz [Tue, 5 Nov 2019 11:47:24 +0000 (14:47 +0300)]
Enable `-funwind-tables` flag when building libunwind

Summary:
Or, rather, don't accidentally forget to pass it.

This is aimed to solve the problem discussed in [this thread](http://lists.llvm.org/pipermail/llvm-dev/2019-November/136890.html), and to fix [a year-old bug](https://bugs.llvm.org/show_bug.cgi?id=38468).

TL;DR: when building libunwind for ARM Linux, we **need** libunwind to be built with the `-funwind-tables` flag, because, well ARM EHABI needs unwind info produced by this flag. Without the flag all the procedures in libunwind are marked `.cantunwind`, which causes all sorts of bad things. From `_Unwind_Backtrace` not working, to C++ exceptions not being caught (which is the aforementioned bug is about).

Previously, this flag was not added because the CMake check `add_compile_flags_if_supported(-funwind-tables)` produced a false negative. Why? With this flag, the compiler generates calls to the `__aeabi_unwind_cpp_pr0` symbol, which is defined in libunwind itself and obviously is not available at configure time, before libunwind is built. This led to failure at link time during the CMake check. We handle this by disabling the linker for CMake checks in linbunwind.

Also, this patch introduces a lit feature `libunwind-arm-ehabi`, which is used to mark the `signal_frame.pass.cpp` test as unsupported (as was advised by @miyuki in D70397).

Reviewers: peter.smith, phosek, EricWF, compnerd, jroelofs, saugustine, miyuki, jfb

Subscribers: mgorny, kristof.beyls, christof, libcxx-commits, miyuki

Tags: #libc

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

4 years ago[UpdateTestChecks] Change shebang from python to python3
Fangrui Song [Tue, 26 Nov 2019 18:40:52 +0000 (10:40 -0800)]
[UpdateTestChecks] Change shebang from python to python3

'python' means Python 2 on some platforms while Python 3 on others.
'python3' is Python 3 only. Python 2.7 End of Life is set to January 1,
2020. Getting rid of Python 2 support reduces maintenance burden.

Reviewed By: lebedev.ri

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

4 years ago[clangd] Fix comparator const after c9c714c7054d555398c767cb39d7d97600b3d9d1
Sam McCall [Tue, 3 Dec 2019 21:13:45 +0000 (22:13 +0100)]
[clangd] Fix comparator const after c9c714c7054d555398c767cb39d7d97600b3d9d1

4 years agoRevert "[NFC] Pass a reference to CodeGenFunction to methods of LValue and"
Akira Hatanaka [Tue, 3 Dec 2019 21:07:22 +0000 (13:07 -0800)]
Revert "[NFC] Pass a reference to CodeGenFunction to methods of LValue and"

This reverts commit 8a5b7c35709d9ce1f44a99f0c5b084bf2696ea17. This seems
to have broken UBSan because of a null dereference.

4 years agoFix warning on extra ';'. NFC.
Michael Liao [Tue, 3 Dec 2019 21:02:55 +0000 (16:02 -0500)]
Fix warning on extra ';'. NFC.

4 years ago[Coverage] Emit a gap region to cover switch bodies
Vedant Kumar [Thu, 21 Nov 2019 22:17:04 +0000 (14:17 -0800)]
[Coverage] Emit a gap region to cover switch bodies

Emit a gap region beginning where the switch body begins. This sets line
execution counts in the areas between non-overlapping cases to 0.

This also removes some special handling of the first case in a switch:
these are now treated like any other case.

This does not resolve an outstanding issue with case statement regions
that do not end when a region is terminated. But it should address
llvm.org/PR44011.

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

4 years agoSwitch to opening the temp file in binary mode
Aaron Ballman [Tue, 3 Dec 2019 20:31:46 +0000 (15:31 -0500)]
Switch to opening the temp file in binary mode

This corrects an issue where the script would write the file with the
incorrect line endings on Windows.

4 years ago[Diagnostic] add a warning which warns about misleading indentation
Tyker [Tue, 3 Dec 2019 19:05:29 +0000 (20:05 +0100)]
[Diagnostic] add a warning which warns about misleading indentation

Summary: Add a warning for misleading indentation similar to GCC's -Wmisleading-indentation

Reviewers: aaron.ballman, xbolva00

Reviewed By: aaron.ballman, xbolva00

Subscribers: tstellar, cfe-commits, arphaman, Ka-Ka, thakis

Tags: #clang

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

4 years ago[NFCI] update formating for misleading indentation warning
Tyker [Tue, 3 Dec 2019 19:05:28 +0000 (20:05 +0100)]
[NFCI] update formating for misleading indentation warning

Reviewers: xbolva00

Reviewed By: xbolva00

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

4 years agoRemove unused variable. NFC.
Michael Liao [Tue, 3 Dec 2019 20:14:41 +0000 (15:14 -0500)]
Remove unused variable. NFC.

4 years agoFix signed mismatch warnings in MetadataTests.cpp
David Blaikie [Tue, 3 Dec 2019 19:36:12 +0000 (11:36 -0800)]
Fix signed mismatch warnings in MetadataTests.cpp

4 years agoRevert "Fix llvm-namespace-comment for macro expansions"
Alexander Kornienko [Tue, 3 Dec 2019 15:27:57 +0000 (16:27 +0100)]
Revert "Fix llvm-namespace-comment for macro expansions"

This reverts commit 4736d63f752f8d13f4c6a9afd558565c32119718.
This commit introduces a ton of false positives and incorrect fixes. See https://reviews.llvm.org/D69855#1767089 for details.

4 years ago[NFC] Pass a reference to CodeGenFunction to methods of LValue and
Akira Hatanaka [Tue, 3 Dec 2019 19:24:46 +0000 (11:24 -0800)]
[NFC] Pass a reference to CodeGenFunction to methods of LValue and
AggValueSlot

This is needed for the pointer authentication work we plan to do in the
near future.

https://github.com/apple/llvm-project/blob/a63a81bd9911f87a0b5dcd5bdd7ccdda7124af87/clang/docs/PointerAuthentication.rst

4 years ago[FileCheck] Given multiple -dump-input, prefer most verbose
Joel E. Denny [Tue, 3 Dec 2019 15:13:00 +0000 (10:13 -0500)]
[FileCheck] Given multiple -dump-input, prefer most verbose

Problem: `FILECHECK_OPTS` was implemented so that a test runner, such
as a bot, can specify FileCheck debugging options, such as
`-dump-input=fail`.  However, some existing test suites have FileCheck
calls that already specify `-dump-input=fail` or `-dump-input=always`.
Without this patch, such tests fail under such a test runner because
FileCheck doesn't accept multiple occurrences of `-dump-input`.

Solution: This patch permits multiple occurrences of `-dump-input` by
assigning precedence to its values in the following descending order:
`help`, `always`, `fail`, and `never`.  That is, any occurrence of
`help` always obtains help, and otherwise the behavior is similar to
`-v` vs. `-vv` in that the option specifying the greatest verbosity
has precedence.

Rationale: My justification for the new behavior is as follows.  I
have not experienced use cases where, either as a test runner or as a
test author, I want to **limit** the permitted debugging verbosity
(except as a test author in FileCheck's or lit's test suites where the
FileCheck debugging output itself is under test, but the solution
there is `env FILECHECK_OPTS=`, and I imagine we should use the same
solution anywhere else this need might occur).  Of course, as either a
test runner or test author, it is useful to **increase** debugging
verbosity.

Reviewed By: probinson

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

4 years ago[GlobalISel]: Allow targets to override how to widen constants during legalization
Aditya Nandakumar [Tue, 3 Dec 2019 18:40:03 +0000 (10:40 -0800)]
[GlobalISel]: Allow targets to override how to widen constants during legalization

https://reviews.llvm.org/D70922

This adds a hook to allow targets to define exactly what extension
operation should be performed for widening constants. This handles cases
like widening i1 true which would end up becoming -1 which affects code
quality during combines.
Additionally, in order to stay consistent with how DAG is promoting
constants, we now signextend for byte sized types and zero extend
otherwise (by default). Targets can of course override this if
necessary.

4 years ago[APInt][PatternMatch] Add 'is non-positive' predicate
Roman Lebedev [Tue, 3 Dec 2019 18:17:51 +0000 (21:17 +0300)]
[APInt][PatternMatch] Add 'is non-positive' predicate

It will be useful for implementing the fold mentioned in
https://bugs.llvm.org/show_bug.cgi?id=44100#c4

4 years agoCorrecting the offsets within the test to fix the bots.
Aaron Ballman [Tue, 3 Dec 2019 18:21:35 +0000 (13:21 -0500)]
Correcting the offsets within the test to fix the bots.

4 years agoDifferentiate between the presumed and actual file when dumping the AST to JSON
Aaron Ballman [Tue, 3 Dec 2019 18:04:45 +0000 (13:04 -0500)]
Differentiate between the presumed and actual file when dumping the AST to JSON

Currently, when dumping the AST to JSON, the presumed file is what is included
when dumping a source location. This patch changes the behavior to instead dump
the actual file, and only dump a presumed file name when it differs from the
actual file.

This also corrects an issue with the test script generator that would prevent
it from working on Windows due to file permissions issues.

4 years ago[LV] Scalar with predication must not be uniform
Ayal Zaks [Tue, 26 Nov 2019 22:08:29 +0000 (00:08 +0200)]
[LV] Scalar with predication must not be uniform

Fix PR40816: avoid considering scalar-with-predication instructions as also
uniform-after-vectorization.

Instructions identified as "scalar with predication" will be "vectorized" using
a replicating region. If such instructions are also optimized as "uniform after
vectorization", namely when only the first of VF lanes is used, such a
replicating region becomes erroneous - only the first instance of the region can
and should be formed. Fix such cases by not considering such instructions as
"uniform after vectorization".

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

4 years agoRename `tsan/race_range_pc.cc` to `test/tsan/race_range_pc.cpp`.
Dan Liew [Tue, 3 Dec 2019 17:48:07 +0000 (09:48 -0800)]
Rename `tsan/race_range_pc.cc` to `test/tsan/race_range_pc.cpp`.

The old suffix was preventing it from being executed by default.

4 years agoRevert "[libomptarget] Build a minimal deviceRTL for amdgcn"
Alexey Bataev [Tue, 3 Dec 2019 17:35:08 +0000 (12:35 -0500)]
Revert "[libomptarget] Build a minimal deviceRTL for amdgcn"

This reverts commit 877ffa716fba52251a7454ffd3727d025b617a1f because it
breaks the build.

4 years agoRevert "Temporarily revert "build: avoid hardcoding the libxml2 library name""
Saleem Abdulrasool [Tue, 3 Dec 2019 17:27:14 +0000 (09:27 -0800)]
Revert "Temporarily revert "build: avoid hardcoding the libxml2 library name""

This reverts commit 2e75681b55ab55301022533b203269f5f3d6f909.  Restore
the clean up change.  The underlying CMake issue was resolved in
372ad32734ecb455f9fb4d0601229ca2dfc78b66.

4 years ago[clang-format] Add new option to add spaces around conditions
Mitchell Balan [Tue, 3 Dec 2019 17:20:30 +0000 (12:20 -0500)]
[clang-format] Add new option to add spaces around conditions
Summary:
This diff adds a new option SpacesAroundConditions that inserts spaces inside the braces for conditional statements.

Reviewers: klimek, owenpan, mitchell-stellar, MyDeveloperDay

Patch by: timwoj

Subscribers: rsmmr, cfe-commits

Tags: clang, clang-format

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

4 years ago[NFC][KnownBits] Add getMinValue() / getMaxValue() methods
Roman Lebedev [Tue, 3 Dec 2019 14:45:47 +0000 (17:45 +0300)]
[NFC][KnownBits] Add getMinValue() / getMaxValue() methods

As it can be seen from accompanying cleanup, it is not unheard of
to write `~Known.Zero` meaning "what maximal value can this KnownBits
produce". But i think `~Known.Zero` isn't *that* self-explanatory,
as compared to a method with a name.

Note that not all `~Known.Zero` places were cleaned up,
only those where this arguably improves things.

4 years agollvm-config: do not link absolute paths with `-l`
Saleem Abdulrasool [Tue, 3 Dec 2019 16:52:21 +0000 (08:52 -0800)]
llvm-config: do not link absolute paths with `-l`

When dealing with system libraries which are absolute paths, use the
absolute path rather than the `-l` option.  This ensures that the system
library can be properly linked against.  This is needed to enable using
proper link dependencies in CMake.

4 years agoReland [clangd] Rethink how SelectionTree deals with macros and #includes.
Sam McCall [Tue, 3 Dec 2019 15:59:52 +0000 (16:59 +0100)]
Reland [clangd] Rethink how SelectionTree deals with macros and #includes.

This reverts commit 905b002c139f039a32ab9bf1fad63d745d12423f.

Avoid tricky (and invalid) comparator for std::set.

4 years ago[scudo][standalone] Add chunk ownership function
Kostya Kortchinsky [Mon, 2 Dec 2019 16:50:10 +0000 (08:50 -0800)]
[scudo][standalone] Add chunk ownership function

Summary:
In order to be compliant with tcmalloc's extension ownership
determination function, we have to expose a function that will
say if a chunk was allocated by us.

As to whether or not this has security consequences: someone
able to call this function repeatedly could use it to determine
secrets (cookie) or craft a valid header. So this should not be
exposed directly to untrusted user input.

Add related tests.

Additionally clang-format caught a few things to change.

Reviewers: hctim, pcc, cferris, eugenis, vitalybuka

Subscribers: JDevlieghere, jfb, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

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

4 years ago[SLP] Enhance SLPVectorizer to vectorize different combinations of aggregates
Anton Afanasyev [Thu, 21 Nov 2019 15:41:52 +0000 (18:41 +0300)]
[SLP] Enhance SLPVectorizer to vectorize different combinations of aggregates

Summary:
Make SLPVectorize to recognize homogeneous aggregates like
`{<2 x float>, <2 x float>}`, `{{float, float}, {float, float}}`,
`[2 x {float, float}]` and so on.
It's a follow-up of https://reviews.llvm.org/D70068.
Merged `findBuildVector()` and `findBuildAggregate()` to
one `findBuildAggregate()` function making it recursive
to recognize multidimensional aggregates. Aggregates required
to be homogeneous.

Reviewers: RKSimon, ABataev, dtemirbulatov, spatel, vporpo

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[SYCL] Add sycl_kernel attribute for accelerated code outlining
Mariya Podchishchaeva [Wed, 6 Nov 2019 14:35:50 +0000 (17:35 +0300)]
[SYCL] Add sycl_kernel attribute for accelerated code outlining

SYCL is single source offload programming model relying on compiler to
separate device code (i.e. offloaded to an accelerator) from the code
executed on the host.

Here is code example of the SYCL program to demonstrate compiler
outlining work:

```
int foo(int x) { return ++x; }
int bar(int x) { throw std::exception("CPU code only!"); }
...
using namespace cl::sycl;
queue Q;
buffer<int, 1> a(range<1>{1024});
Q.submit([&](handler& cgh) {
  auto A = a.get_access<access::mode::write>(cgh);
  cgh.parallel_for<init_a>(range<1>{1024}, [=](id<1> index) {
    A[index] = index[0] + foo(42);
  });
}
...
```

SYCL device compiler must compile lambda expression passed to
cl::sycl::handler::parallel_for method and function foo called from this
lambda expression for an "accelerator". SYCL device compiler also must
ignore bar function as it's not required for offloaded code execution.

This patch adds the sycl_kernel attribute, which is used to mark code
passed to cl::sycl::handler::parallel_for as "accelerated code".

Attribute must be applied to function templates which parameters include
at least "kernel name" and "kernel function object". These parameters
will be used to establish an ABI between the host application and
offloaded part.

Reviewers: jlebar, keryell, Naghasan, ABataev, Anastasia, bader, aaron.ballman, rjmccall, rsmith

Reviewed By: keryell, bader

Subscribers: mgorny, OlegM, ArturGainullin, agozillon, aaron.ballman, ebevhan, Anastasia, cfe-commits

Tags: #clang

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

Signed-off-by: Alexey Bader <alexey.bader@intel.com>
4 years ago[EditLine] Fix RecallHistory to make it go in the right direction.
Jonas Devlieghere [Tue, 3 Dec 2019 16:10:49 +0000 (08:10 -0800)]
[EditLine] Fix RecallHistory to make it go in the right direction.

The naming used by editline for the history operations is counter
intuitive to how it's used in lldb for the REPL.

 - The H_PREV operation returns the previous element in the history,
   which is newer than the current one.
 - The H_NEXT operation returns the next element in the history, which
   is older than the current one.

This exposed itself as a bug in the REPL where the behavior of up- and
down-arrow was inverted. This wasn't immediately obvious because of how
we save the current "live" entry.

This patch fixes the bug and introduces and enum to wrap the editline
operations that match the semantics of lldb.

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

4 years ago[OpenCL] Use generic addr space for lambda call operator
Anastasia Stulova [Tue, 3 Dec 2019 12:55:50 +0000 (12:55 +0000)]
[OpenCL] Use generic addr space for lambda call operator

Since lambdas are represented by callable objects, we add
generic addr space for implicit object parameter in call
operator.

Any lambda variable declared in __constant addr space
(which is not convertible to generic) fails to compile with
a diagnostic. To support constant addr space we need to
add a way to qualify the lambda call operators.

Tags: #clang

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

4 years ago[lldb/Reproducer] Add version check
Jonas Devlieghere [Tue, 3 Dec 2019 15:53:23 +0000 (07:53 -0800)]
[lldb/Reproducer] Add version check

To ensure a reproducer works correctly, the version of LLDB used for
capture and replay must match. Right now the reproducer already contains
the LLDB version. However, this is purely informative. LLDB will happily
replay a reproducer generated with a different version of LLDB, which
can cause subtle differences.

This patch adds a version check which compares the current LLDB version
with the one in the reproducer. If the version doesn't match, LLDB will
refuse to replay. It also adds an escape hatch to make it possible to
still replay the reproducer without having to mess with the recorded
version. This might prove useful when you know two versions of LLDB
match, even though the version string doesn't. This behavior is
triggered by passing a new flag -reproducer-skip-version-check to the
lldb driver.

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

4 years ago[AArch64] Fix over-eager fusing of NEON SIMD MUL/ADD
Sanne Wouda [Mon, 25 Nov 2019 16:40:39 +0000 (16:40 +0000)]
[AArch64] Fix over-eager fusing of NEON SIMD MUL/ADD

Summary:
The ISel pattern for SIMD MLA is a bit too eager: it replaces the ADD with an
MLA even when the MUL cannot be eliminated, e.g. when it has another use.  An
MLA is usually has a higher latency than an ADD (and there are fewer pipes
available that can execute it), so trading an MLA for an ADD is not great.

ISel is not taking the number of uses of the MUL result into account, nor any
other factors such as the length of the critical path or other resource pressure.

The MachineCombiner is able to make these judgments so this patch ports the ISel
pattern for MUL/ADD fusing to the MachineCombiner.

Similarly for MUL/SUB -> MLS, as well as the indexed variants.

The change has no impact on SPEC CPU© intrate nor fprate.

Reviewers: dmgreen, SjoerdMeijer, fhahn, Gerolf

Subscribers: kristof.beyls, hiraditya, llvm-commits

Tags: #llvm

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

4 years ago[SelectionDAG] Reoder ViewXXXDAGs declarations to match execution order. NFC
Amaury Séchet [Tue, 3 Dec 2019 15:10:38 +0000 (16:10 +0100)]
[SelectionDAG] Reoder ViewXXXDAGs declarations to match execution order. NFC