platform/upstream/llvm.git
4 years ago[ELF] Keep orphan section names (.rodata.foo .text.foo) unchanged if !hasSectionsCommand
Fangrui Song [Wed, 26 Feb 2020 02:00:13 +0000 (18:00 -0800)]
[ELF] Keep orphan section names (.rodata.foo .text.foo) unchanged if !hasSectionsCommand

This behavior matches GNU ld and seems reasonable.

```
// If a SECTIONS command is not specified
.text.* -> .text
.rodata.* -> .rodata
.init_array.* -> .init_array
```

A proposed Linux feature CONFIG_FG_KASLR may depend on the GNU ld behavior.

Reword a comment about -z keep-text-section-prefix and a comment about
CommonSection (deleted by rL286234).

Reviewed By: grimar

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

4 years ago[gn build] Port 57b8a407493
LLVM GN Syncbot [Mon, 23 Mar 2020 17:23:22 +0000 (17:23 +0000)]
[gn build] Port 57b8a407493

4 years ago[gn build] Port 24698e526f619271705fe72bcaa928be9bc82484. Fix AMDGPUTests
Fangrui Song [Mon, 23 Mar 2020 17:22:07 +0000 (10:22 -0700)]
[gn build] Port 24698e526f619271705fe72bcaa928be9bc82484. Fix AMDGPUTests

4 years ago[clang-format] No space inserted between commas in C#
Jonathan Coe [Mon, 23 Mar 2020 17:17:27 +0000 (17:17 +0000)]
[clang-format] No space inserted between commas in C#

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: cfe-commits, MyDeveloperDay

Tags: #clang-format, #clang

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

4 years ago[OPENMP50]Bassic support for exclusive clause.
Alexey Bataev [Mon, 23 Mar 2020 14:41:08 +0000 (10:41 -0400)]
[OPENMP50]Bassic support for exclusive clause.

Added basic support (parsing/sema/serialization) for exclusive clause in
scan directives.

4 years ago[openmp][runtime] Fixed hang for explicit task inside a taskloop.
AndreyChurbanov [Mon, 23 Mar 2020 17:02:19 +0000 (20:02 +0300)]
[openmp][runtime] Fixed hang for explicit task inside a taskloop.

Added missed initialization of td_last_tied field for taskloop tasks.

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

4 years ago[gn build] Port 24698e526f619271705fe72bcaa928be9bc82484
Fangrui Song [Mon, 23 Mar 2020 16:55:39 +0000 (09:55 -0700)]
[gn build] Port 24698e526f619271705fe72bcaa928be9bc82484

4 years ago[lldb/Reproducers] Mark reproducer test directory as unsupported on Windows
Jonas Devlieghere [Mon, 23 Mar 2020 16:52:42 +0000 (09:52 -0700)]
[lldb/Reproducers] Mark reproducer test directory as unsupported on Windows

Reproducers are unsupported on Windows. Rather than having a UNSUPPORTED
line in every test, just skip the whole subdirectory.

4 years ago[OpenMPOpt] Validate declaration types against the expected types
Johannes Doerfert [Mon, 23 Mar 2020 15:47:06 +0000 (10:47 -0500)]
[OpenMPOpt] Validate declaration types against the expected types

Validation of the found runtime library functions declarations types
(return and argument types) with the expected types.

Reviewed By: jdoerfert

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

4 years ago[OpenMPOpt][FIX] Resolve OpenMP runtime call type mismatches
Johannes Doerfert [Mon, 23 Mar 2020 16:39:34 +0000 (11:39 -0500)]
[OpenMPOpt][FIX] Resolve OpenMP runtime call type mismatches

Exposed by D76058 and tested once that one lands.

4 years ago[Attributor] Fold single-use variable into assert
Benjamin Kramer [Mon, 23 Mar 2020 16:41:52 +0000 (17:41 +0100)]
[Attributor] Fold single-use variable into assert

Fixes unused variable warning in Release builds.

4 years ago[ELF][test] Clean text-section-prefix.s
Fangrui Song [Mon, 23 Mar 2020 16:27:49 +0000 (09:27 -0700)]
[ELF][test] Clean text-section-prefix.s

4 years ago[Analyzer] IteratorRangeChecker verify `std::advance()`, `std::prev()` and `std:...
Adam Balogh [Wed, 18 Mar 2020 19:15:20 +0000 (20:15 +0100)]
[Analyzer] IteratorRangeChecker verify `std::advance()`, `std::prev()` and `std::next()`

Upon calling one of the functions `std::advance()`, `std::prev()` and
`std::next()` iterators could get out of their valid range which leads
to undefined behavior. If all these funcions are inlined together with
the functions they call internally (e.g. `__advance()` called by
`std::advance()` in some implementations) the error is detected by
`IteratorRangeChecker` but the bug location is inside the STL
implementation. Even worse, if the budget runs out and one of the calls
is not inlined the bug remains undetected. This patch fixes this
behavior: all the bugs are detected at the point of the STL function
invocation.

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

4 years ago[Support] Silence warning in Path unittests when compiling with clang-cl
Alexandre Ganea [Mon, 23 Mar 2020 16:19:07 +0000 (12:19 -0400)]
[Support] Silence warning in Path unittests when compiling with clang-cl

warning: comparison of integers of different signs: 'const unsigned long long' and 'const int' [-Wsign-compare]

4 years ago[ARM] Extra VMOVN and VMULL tests. NFC
David Green [Mon, 23 Mar 2020 12:39:00 +0000 (12:39 +0000)]
[ARM] Extra VMOVN and VMULL tests. NFC

4 years ago[libc++] Bump Clang support for Clang 4
Louis Dionne [Mon, 23 Mar 2020 15:37:40 +0000 (11:37 -0400)]
[libc++] Bump Clang support for Clang 4

It's hard to imagine someone using a recent version of libc++ with a
roughly 3 years old Clang. Since we're not testing libc++ with Clang 3.5
anyway, claiming support for it is somewhat of a lie.

Note that we don't test Clang 4 either, however I have no reason to bump
the requirement beyond Clang 4 at the moment, whereas removing Clang 3.5
allows simplifying the test suite.

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

4 years ago[lldb/testsuite] Skip part of TestSettings.py on windows
Fred Riss [Mon, 23 Mar 2020 16:13:40 +0000 (09:13 -0700)]
[lldb/testsuite] Skip part of TestSettings.py on windows

The newly introduced tests for unsetting environment variables
is failing on Windows. Skip the test there to allow investigation.

It seems like setting inherit-env to false was never tested
before. Could it be that the Windows process launcher doesn't
honor this setting?

4 years agoAdd AMDGPU MC unittests only when AMDGPU target is being built
Ram Nalamothu [Mon, 23 Mar 2020 15:56:02 +0000 (21:26 +0530)]
Add AMDGPU MC unittests only when AMDGPU target is being built

Fixes the build failures introduced by 24698e526f619271705fe72bcaa928be9bc82484

4 years ago[analyzer][NFC] Tie CheckerRegistry to CheckerManager, allow CheckerManager to be...
Kristóf Umann [Fri, 28 Feb 2020 14:07:50 +0000 (15:07 +0100)]
[analyzer][NFC] Tie CheckerRegistry to CheckerManager, allow CheckerManager to be constructed for non-analysis purposes

Its been a while since my CheckerRegistry related patches landed, allow me to
refresh your memory:

During compilation, TblGen turns
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td into
(build directory)/tools/clang/include/clang/StaticAnalyzer/Checkers/Checkers.inc.
This is a file that contains the full name of the checkers, their options, etc.

The class that is responsible for parsing this file is CheckerRegistry. The job
of this class is to establish what checkers are available for the analyzer (even
from plugins and statically linked but non-tblgen generated files!), and
calculate which ones should be turned on according to the analyzer's invocation.

CheckerManager is the class that is responsible for the construction and storage
of checkers. This process works by first creating a CheckerRegistry object, and
passing itself to CheckerRegistry::initializeManager(CheckerManager&), which
will call the checker registry functions (for example registerMallocChecker) on
it.

The big problem here is that these two classes lie in two different libraries,
so their interaction is pretty awkward. This used to be far worse, but I
refactored much of it, which made things better but nowhere near perfect.

---

This patch changes how the above mentioned two classes interact. CheckerRegistry
is mainly used by CheckerManager, and they are so intertwined, it makes a lot of
sense to turn in into a field, instead of a one-time local variable. This has
additional benefits: much of the information that CheckerRegistry conveniently
holds is no longer thrown away right after the analyzer's initialization, and
opens the possibility to pass CheckerManager in the shouldRegister* function
rather then LangOptions (D75271).

There are a few problems with this. CheckerManager isn't the only user, when we
honor help flags like -analyzer-checker-help, we only have access to a
CompilerInstance class, that is before the point of parsing the AST.
CheckerManager makes little sense without ASTContext, so I made some changes and
added new constructors to make it constructible for the use of help flags.

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

4 years agorecommit 1b978ddba05c [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing...
Yaxun (Sam) Liu [Wed, 26 Feb 2020 15:57:39 +0000 (10:57 -0500)]
recommit 1b978ddba05c [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

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

4 years ago[libc++] [NFC] Test that correct value category is used in scoped_allocator_adaptor...
zoecarver [Mon, 23 Mar 2020 16:05:47 +0000 (09:05 -0700)]
[libc++] [NFC] Test that correct value category is used in scoped_allocator_adaptor::construct

This patch fixes 2586. Just tests. NFC.

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

4 years agoAdd support for custom op parser/printer hooks to know about result names.
Chris Lattner [Mon, 16 Mar 2020 00:13:59 +0000 (17:13 -0700)]
Add support for custom op parser/printer hooks to know about result names.

Summary:
This allows the custom parser/printer hooks to do interesting things with
the SSA names.  This patch:

 - Adds a new 'getResultName' method to OpAsmParser that allows a parser
   implementation to get information about its result names, along with
   a getNumResults() method that allows op parser impls to know how many
   results are expected.
 - Adds a OpAsmPrinter::printOperand overload that takes an explicit stream.
 - Adds a test.string_attr_pretty_name operation that uses these hooks to
   do fancy things with the result name.

Reviewers: rriddle!

Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, Joonsoo, llvm-commits

Tags: #llvm

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

4 years ago[Win64] Insert int3 into trailing empty BBs
Reid Kleckner [Fri, 20 Mar 2020 21:06:27 +0000 (14:06 -0700)]
[Win64] Insert int3 into trailing empty BBs

Otherwise, the Win64 unwinder considers direct branches to such empty
trailing BBs to be a branch out of the function. It treats such a branch
as a tail call, which can only be part of an epilogue. If the unwinder
misclassifies such a branch as part of the epilogue, it will fail to
unwind the stack further. This can lead to bad stack traces, or failure
to handle exceptions properly. This is described in
https://llvm.org/PR45064#c4, and by the comment at the top of the
X86AvoidTrailingCallPass.cpp file.

It should be safe to insert int3 for such blocks. An empty trailing BB
that reaches this pass is pretty much guaranteed to be unreachable.  If
a program executed such a block, it would fall off the end of the
function.

Most of the complexity in this patch comes from threading through the
"EHFuncletEntry" boolean on the MIRParser and registering the pass so we
can stop and start codegen around it. I used an MIR test because we
should teach LLVM to optimize away these branches as a follow-up.

Reviewed By: hans

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

4 years ago[Analysis] simplify code for scaleShuffleMask
Sanjay Patel [Mon, 23 Mar 2020 15:34:09 +0000 (11:34 -0400)]
[Analysis] simplify code for scaleShuffleMask

This is NFC-ish. The results should be identical, but perf is hopefully
better with the fast-path for no scaling. Added a unit test for that.

The code is adapted from what used to be the DAGCombiner equivalent
function before D76508 (rG0eeee83d7513).

4 years ago[Attributor][NFC] Copy llvm::function_ref, don't use references
Johannes Doerfert [Mon, 23 Mar 2020 07:02:09 +0000 (02:02 -0500)]
[Attributor][NFC] Copy llvm::function_ref, don't use references

On IRC this was called a "code smell" so we get rid of it.

4 years ago[Attributor] Handle calls in AAValueConstantRange properly
Johannes Doerfert [Fri, 20 Mar 2020 06:37:27 +0000 (01:37 -0500)]
[Attributor] Handle calls in AAValueConstantRange properly

We did handle calls that were operands of certain instructions but not
standalone calls we visit via indirection, e.g., selects.

4 years ago[Attributor] Unify handling of must-tail calls
Johannes Doerfert [Tue, 17 Mar 2020 01:23:27 +0000 (20:23 -0500)]
[Attributor] Unify handling of must-tail calls

We special cased must-tail calls all over the place because they cannot
be modified as other calls can be. However, we already centralized the
modification API so we can centralize the handling as well. This
simplifies the code and allows to remove must-tail calls completely.

4 years ago[Attributor][NFC] Predetermine the module before verification
Johannes Doerfert [Tue, 17 Mar 2020 01:18:07 +0000 (20:18 -0500)]
[Attributor][NFC] Predetermine the module before verification

It could happen that we delete the first function in the SCC in the
future so we should be careful accessing `Functions` after the manifest
stage.

4 years ago[Attributor][NFC] clang-format Attributor.{h,cpp}
Johannes Doerfert [Mon, 23 Mar 2020 07:03:23 +0000 (02:03 -0500)]
[Attributor][NFC] clang-format Attributor.{h,cpp}

4 years ago[Syntax] Build mapping from AST to syntax tree nodes
Marcel Hlopko [Mon, 23 Mar 2020 15:05:13 +0000 (16:05 +0100)]
[Syntax] Build mapping from AST to syntax tree nodes

Summary:
Copy of https://reviews.llvm.org/D72446, submitting with Ilya's permission.

Only used to assign roles to child nodes for now. This is more efficient
than doing range-based queries.

In the future, will be exposed in the public API of syntax trees.

Reviewers: gribozavr2

Reviewed By: gribozavr2

Subscribers: cfe-commits

Tags: #clang

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

4 years ago[GlobalISel] Add generic opcodes for saturating add/subtract
Jay Foad [Mon, 24 Feb 2020 11:13:05 +0000 (11:13 +0000)]
[GlobalISel] Add generic opcodes for saturating add/subtract

Summary:
Add new generic MIR opcodes G_SADDSAT etc. Add support in IRTranslator
for translating the saturating add/subtract intrinsics to the new
opcodes.

Reviewers: aemerson, dsanders, paquette, arsenm

Subscribers: jvesely, wdng, nhaehnle, rovka, hiraditya, volkan, kerbowa, llvm-commits

Tags: #llvm

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

4 years agoAMDGPU/GlobalISel: Add some oversized G_IMPLICIT_DEF tests
Matt Arsenault [Mon, 23 Mar 2020 15:14:30 +0000 (11:14 -0400)]
AMDGPU/GlobalISel: Add some oversized G_IMPLICIT_DEF tests

Not all of these legalize correctly yet.

4 years agoRevert "Remove legacy CMake targets for libcxx and libcxxabi"
Louis Dionne [Mon, 23 Mar 2020 15:02:11 +0000 (11:02 -0400)]
Revert "Remove legacy CMake targets for libcxx and libcxxabi"

This reverts commit f383fb40b. It looks like several of our build bots
are still using the legacy target names, so we'll change those before
we commit this change again.

4 years ago[lldb/Target] Rework the way the inferior environment is created
Fred Riss [Fri, 20 Mar 2020 01:02:05 +0000 (18:02 -0700)]
[lldb/Target] Rework the way the inferior environment is created

Summary:
The interactions between the environment settings (`target.env-vars`,
`target.inherit-env`) and the inferior life-cycle are non-obvious
today. For example, if `target.inherit-env` is set, the `target.env-vars`
setting will be augmented with the contents of the host environment
the first time the launch environment is queried (usually at
launch). After that point, toggling `target.inherit-env` will have no
effect as there's no tracking of what comes from the host and what is
a user setting.

This patch computes the environment every time it is queried rather
than updating the contents of the `target.env-vars` property. This
means that toggling the `target.inherit-env` property later will now
have the intended effect.

This patch also adds a `target.unset-env-vars` settings that one can
use to remove variables from the launch environment. Using this, you
can inherit all but a few of the host environment.

The way the launch environment is constructed is:
  1/ if `target.inherit-env` is set, then read the host environment
  into the launch environment.
  2/ Remove for the environment the variables listed in
  `target.unset-env`.
  3/ Augment the launch environment with the contents of
  `target.env-vars`. This overrides any common values with the host
  environment.

The one functional difference here that could be seen as a regression
is that `target.env-vars` will not contain the inferior environment
after launch. The patch implements a better alternative in the
`target show-launch-environment` command which will return the
environment computed through the above rules.

Reviewers: labath, jingham

Subscribers: lldb-commits

Tags: #lldb

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

4 years ago[lldb/API] Make Launch(Simple) use args and env from target properties
Fred Riss [Thu, 12 Mar 2020 05:09:11 +0000 (22:09 -0700)]
[lldb/API] Make Launch(Simple) use args and env from target properties

Summary:
When no arguments or environment is provided to SBTarget::LaunchSimple,
make it use the values surrently set in the target properties. You can
get the current behavior back by passing an empty array instead.

It seems like using the target defaults is a much more intuitive
behavior for those APIs. It's unllikely that anyone passed NULL/None to
this API after having set properties in order to explicitely ignore them.

One direct application of this change is within the testsuite. We have
plenty of tests calling LaunchSimple and passing None as environment.
If you passed --inferior-env to dotest.py to, for example, set
(DY)LD_LIBRARY_PATH, it wouldn't be taken into account.

Reviewers: jingham, labath, #libc_abi!

Subscribers: libcxx-commits, lldb-commits

Tags: #lldb, #libc_abi

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

4 years ago[lldb/Target] Initialize new targets environment variables from target.env-vars
Fred Riss [Wed, 11 Mar 2020 17:26:03 +0000 (10:26 -0700)]
[lldb/Target] Initialize new targets environment variables from target.env-vars

Summary:
The TargetProperties constructor invokes a series of callbacks to
prime the properties from the default ones. The one callback in
charge of updating the inferior environment was commented out
because it crashed.

The reason for the crash is that TargetProperties is a parent class
of Target and the callbacks were invoked using a Target that was
not fully initialized. This patch moves the initial callback
invocations to a separate function that can be called at the end
the Target constructor, thus preventing the crash.

One existing test had to be modified, because the initialization of
the environment properties now take place at the time the target is
created, not at the first use of the environment (usually launch
time).

The added test checks that the LaunchInfo object returned by
the target has been primed with the values from the settings.

Reviewers: jingham, labath

Subscribers: lldb-commits

Tags: #lldb

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

4 years agoRemove legacy CMake targets for libcxx and libcxxabi
Louis Dionne [Wed, 11 Mar 2020 21:03:00 +0000 (17:03 -0400)]
Remove legacy CMake targets for libcxx and libcxxabi

We've been meaning to remove those targets for a while, and the fix is
simple enough cause they're all just aliases to other targets.

There's no doubt this commit will break some CI systems, however the
fix is trivial.

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

4 years ago[InstCombine] Limit CTPOP -> CTTZ simplifications to one use
Simon Pilgrim [Mon, 23 Mar 2020 14:24:05 +0000 (14:24 +0000)]
[InstCombine] Limit CTPOP -> CTTZ simplifications to one use

Tweak D76568 so we only combine if it will remove the bit-twiddling.

Suggested by @spatel

4 years ago[clang-format] Do not indent C# array initialisers as continuations
Jonathan Coe [Mon, 23 Mar 2020 14:23:52 +0000 (14:23 +0000)]
[clang-format] Do not indent C# array initialisers as continuations

Summary: Flag '= {' as a braced init list when parsing C# code.

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: cfe-commits, MyDeveloperDay

Tags: #clang-format, #clang

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

4 years ago[Analyzer] Iterator Modeling - Model `std::advance()`, `std::prev()` and `std::next()`
Adam Balogh [Wed, 19 Feb 2020 08:03:39 +0000 (09:03 +0100)]
[Analyzer] Iterator Modeling - Model `std::advance()`, `std::prev()` and `std::next()`

Whenever the analyzer budget runs out just at the point where
`std::advance()`, `std::prev()` or `std::next()` is invoked the function
are not inlined. This results in strange behavior such as
`std::prev(v.end())` equals `v.end()`. To prevent this model these
functions if they were not inlined. It may also happend that although
`std::advance()` is inlined but a function it calls inside (e.g.
`__advance()` in some implementations) is not. This case is also handled
in this patch.

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

4 years ago[lldb] Mark expressions that couldn't be parsed or executed as failed expressions
Raphael Isemann [Mon, 23 Mar 2020 14:25:51 +0000 (15:25 +0100)]
[lldb] Mark expressions that couldn't be parsed or executed as failed expressions

Summary:
LLDB keeps statistics of how many expression evaluations are 'successful' and 'failed'
which are updated after each expression evaluation (assuming statistics are enabled).
From what I understand the idea is that this could be used to define how well LLDB's
expression evaluator is working.

Currently all expressions are considered successful unless the user passes an explicit
positive element counting to the expression command (with the `-Z` flag) and then passes
an expression that successfully evaluates to a type that doesn't support element counting.
Expressions that fail to parse, execute or any other outcome are considered successful
at the moment which means we nearly always have a 100% expression evaluation
success rate.

This patch makes that expressions that fail to parse or execute to count as failed
expressions.

We can't know whether the expression failed because of an user error
of because LLDB couldn't correctly parse/compile it, but I would argue that this is
still an improvement. Assuming that the percentage of valid user expressions stays
mostly constant over time (which seems like a reasonable assumption), then this
way we can still see if we are doing relatively better/worse from release to release.

Reviewers: davide, aprantl, JDevlieghere

Reviewed By: aprantl

Subscribers: abidh

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

4 years agoImplement wave32 DWARF register mapping
Ram Nalamothu [Mon, 23 Mar 2020 10:56:51 +0000 (16:26 +0530)]
Implement wave32 DWARF register mapping

Implement the DWARF register mapping described in llvm/docs/AMDGPUUsage.rst.

This enables generating appropriate DWARF register numbers for wave64 and
wave32 modes.

4 years ago[SCCP] Precommit additional range propagation test.
Florian Hahn [Mon, 23 Mar 2020 14:15:19 +0000 (14:15 +0000)]
[SCCP] Precommit additional range propagation test.

4 years ago[VectorUtils] move x86's scaleShuffleMask to generic VectorUtils
Sanjay Patel [Mon, 23 Mar 2020 13:47:16 +0000 (09:47 -0400)]
[VectorUtils] move x86's scaleShuffleMask to generic VectorUtils

We have some long-standing missing shuffle optimizations that could
use this transform via VectorCombine now:
https://bugs.llvm.org/show_bug.cgi?id=35454
(and we still don't get that case in the backend either)

This function is apparently templated because there's existing code
in IR that treats mask values as unsigned and backend code that
treats masks values as signed.

The mask values are not endian-dependent (as shown by the existing
bitcast transform from DAGCombiner).

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

4 years ago[clang-tidy] Fix RenamerClangTidy handling qualified TypeLocs
Nathan James [Sun, 22 Mar 2020 19:09:00 +0000 (19:09 +0000)]
[clang-tidy] Fix RenamerClangTidy handling qualified TypeLocs

Summary:
Previously if a type was accessed with a qualifier, RenamerClangTidy wouldn't rename the TypeLoc, this patch addresses this shortfall by trying to find the Unqualified TypeLoc first. Also fixed a broken test case that was dependent on this broken behaviour.

Example:
```
struct a{};

void foo(const a&);
void foo(a&);
void foo(a);
void foo(a&&);
void foo(const a);
```
exec `-checks=readability-identifier-naming --config="{CheckOptions: [{key: readability-identifier-naming.StructCase, value: CamelCase}]}" -fix`
Current Behaviour:
```
struct A{};

void foo(const a&);
void foo(A&);
void foo(A);
void foo(A&&);
void foo(const a);
```
Proposed new behaviour:
```
struct A{};

void foo(const A&);
void foo(A&);
void foo(A);
void foo(A&&);
void foo(const A);
```

Reviewers: aaron.ballman, gribozavr2, alexfh

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

4 years ago[clang-format] Reflow long C# generic type constraints correctly
Jonathan Coe [Mon, 23 Mar 2020 12:50:44 +0000 (12:50 +0000)]
[clang-format] Reflow long C# generic type constraints correctly

Summary:
Align sequential generic type constraints on a type.

Indent sequential generic type constraints on different types as continuations.

Do not allow '(' and '<' within a generic type constraint to open new scopes.

Reviewers: krasimir

Subscribers: cfe-commits, MyDeveloperDay

Tags: #clang-format, #clang

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

4 years ago[VectorCombine] add more tests for extract-extract patterns; NFC
Sanjay Patel [Mon, 23 Mar 2020 13:33:29 +0000 (09:33 -0400)]
[VectorCombine] add more tests for extract-extract patterns; NFC

4 years agoAdd ParsedAttrInfo::handleDeclAttribute
John Brawn [Fri, 28 Feb 2020 14:51:30 +0000 (14:51 +0000)]
Add ParsedAttrInfo::handleDeclAttribute

This makes it possible for plugin attributes to actually do something, and also
removes a lot of boilerplate for simple attributes in SemaDeclAttr.cpp.

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

4 years ago[SystemZ] Perform instruction shortening for fused fp ops.
Jonas Paulsson [Wed, 18 Mar 2020 15:41:32 +0000 (16:41 +0100)]
[SystemZ]  Perform instruction shortening for fused fp ops.

Replace single-lane (W... form) vector "multiply and add" and "multiply and
subtract" instructions with equivalent floating point instructions whenever
possible in SystemZShortenInst.

Review: Ulrich Weigand

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

4 years ago[Alignment][NFC] Deprecate VectorUtils::getAlignment
Guillaume Chatelet [Sat, 21 Mar 2020 11:30:46 +0000 (12:30 +0100)]
[Alignment][NFC] Deprecate VectorUtils::getAlignment

Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet

Subscribers: hiraditya, rogfer01, llvm-commits

Tags: #llvm

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

4 years ago[Alignment][NFC] Use TFL::getStackAlign()
Guillaume Chatelet [Sat, 21 Mar 2020 20:41:33 +0000 (21:41 +0100)]
[Alignment][NFC] Use TFL::getStackAlign()

Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet

Subscribers: dylanmckay, sdardis, nemanjai, hiraditya, kbarton, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, Jim, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, llvm-commits

Tags: #llvm

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

4 years ago[InstCombine] Add ub-safe negation patterns (PR27817)
Simon Pilgrim [Mon, 23 Mar 2020 12:20:38 +0000 (12:20 +0000)]
[InstCombine] Add ub-safe negation patterns (PR27817)

4 years ago[SCCP] Extend test coverage in conditions-ranges.ll to false branches.
Florian Hahn [Mon, 23 Mar 2020 12:32:14 +0000 (12:32 +0000)]
[SCCP] Extend test coverage in conditions-ranges.ll to false branches.

4 years ago[llvm-readobj] Derive dynamic symtab size from DT_HASH
James Henderson [Mon, 16 Mar 2020 16:33:27 +0000 (16:33 +0000)]
[llvm-readobj] Derive dynamic symtab size from DT_HASH

If the section headers have been removed by a tool such as llvm-objcopy
or llvm-strip, previously llvm-readobj/llvm-readelf would not dump the
dynamic symbols when --dyn-symbols was specified. However, the nchain
value of the DT_HASH data specifies the number of dynamic symbols, so if
it is present, we can use that. This patch implements this behaviour.

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

Reviewed by: grimar, MaskRay

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

4 years ago[InstCombine] Add CTPOP -> CTTZ simplifications (PR43513)
Simon Pilgrim [Mon, 23 Mar 2020 10:50:51 +0000 (10:50 +0000)]
[InstCombine] Add CTPOP -> CTTZ simplifications (PR43513)

As detailed on PR43513, we can simplify:

ctpop(x | -x) -> bitwidth - cttz(x, false)
Alive2: http://volta.cs.utah.edu:8080/z/caw49X

ctpop(~x & (x - 1)) -> cttz(x, false)
Alive2: http://volta.cs.utah.edu:8080/z/5zfVrx

I've tweaked the initial test cases I added at rG2d712fb75584 to increase commutativity testing.

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

4 years agoApply function attributes through array declarators
Momchil Velikov [Mon, 23 Mar 2020 09:23:35 +0000 (09:23 +0000)]
Apply function attributes through array declarators

There's inconsistency in handling array types between the
`distributeFunctionTypeAttrXXX` functions and the
`FunctionTypeUnwrapper` in `SemaType.cpp`.

This patch lets `FunctionTypeUnwrapper` apply function type attributes
through array types.

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

4 years agoFix all-reduce int tests by host-registering memrefs.
Christian Sigg [Sun, 22 Mar 2020 19:18:23 +0000 (20:18 +0100)]
Fix all-reduce int tests by host-registering memrefs.

Reduce amount of boiler plate to register host memory.

Summary: Fix all-reduce int tests by host-registering memrefs.

Reviewers: herhut

Reviewed By: herhut

Subscribers: clementval, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, Joonsoo, llvm-commits

Tags: #llvm

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

4 years ago[Alignment][NFC] Deprecate ensureMaxAlignment
Guillaume Chatelet [Wed, 18 Mar 2020 16:04:10 +0000 (17:04 +0100)]
[Alignment][NFC] Deprecate ensureMaxAlignment

Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

4 years agoMergeFunctions.rst - multiply vs shift typo (PR44717)
Simon Pilgrim [Mon, 23 Mar 2020 10:13:25 +0000 (10:13 +0000)]
MergeFunctions.rst - multiply vs shift typo (PR44717)

The doc is suggesting that a mul-by-2 is the same as a ashr-by-1 instead of shl-by-1

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

4 years ago[clang-tidy][NFC] Add missing check group docs and order entries
Whisperity [Sat, 21 Mar 2020 10:30:30 +0000 (11:30 +0100)]
[clang-tidy][NFC] Add missing check group docs and order entries

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

4 years agoMake use of APInt::countLeadingOnes. NFC.
Jay Foad [Mon, 23 Mar 2020 08:55:40 +0000 (08:55 +0000)]
Make use of APInt::countLeadingOnes. NFC.

4 years ago[DAGCombine] Skip PostInc combine with later users
Sam Parker [Mon, 23 Mar 2020 08:39:53 +0000 (08:39 +0000)]
[DAGCombine] Skip PostInc combine with later users

When decided whether to generate a post-inc load/store, look at the
other memory nodes that use the same base address and, if any proceed
the current node, then don't do the combine.
The change only seems to be affecting the Arm backend, which I was
surprised at, but it appears to fix a lot of our issues around MVE
masked load/stores having to store a temporary address after an early
post-increment on a shared base address.

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

4 years ago[NFC][DAGCombine] Refactor post-inc logic
Sam Parker [Mon, 23 Mar 2020 08:29:41 +0000 (08:29 +0000)]
[NFC][DAGCombine] Refactor post-inc logic

Extract the decision to combine into a post-inc address into a
couple of functions to make the logic more clear and re-usable.

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

4 years ago[GlobalISel] support widen unmerge if WideTy > SrcTy
Dominik Montada [Fri, 20 Mar 2020 13:46:01 +0000 (14:46 +0100)]
[GlobalISel] support widen unmerge if WideTy > SrcTy

Summary:
Widening G_UNMERGE_VALUES to a type which is larger than the
original source type is the same as widening it to the same
type as the source type: in both cases, G_UNMERGE_VALUES has
to be replaced with bit arithmetic which. Although the arithmetic
itself is independent of whether the source type is smaller
or equal to the widen type, widening the source type to the
widen type should result in less artifacts being emitted,
since this is the type that the user explicitly requested.

Reviewers: arsenm, dsanders, aemerson, aditya_nandakumar

Reviewed By: arsenm, dsanders

Subscribers: jvesely, wdng, nhaehnle, rovka, hiraditya, volkan, kerbowa, llvm-commits

Tags: #llvm

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

4 years ago[llvm-objdump][test] Improve PowerPC branch offset tests
Fangrui Song [Mon, 23 Mar 2020 06:57:22 +0000 (23:57 -0700)]
[llvm-objdump][test] Improve PowerPC branch offset tests

4 years ago[libc] Don't configure test and fuzzer when -DLLVM_INCLUDE_TESTS=OFF
Alex Brachet [Mon, 23 Mar 2020 05:50:16 +0000 (01:50 -0400)]
[libc] Don't configure test and fuzzer when -DLLVM_INCLUDE_TESTS=OFF

Summary:  Fixes problem reported in D74397#1935863

Reviewers: nathanchance, gchatelet, sivachandra, MaskRay

Reviewed By: sivachandra, MaskRay

Subscribers: mgorny, MaskRay, tschuett

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

4 years agoBuildbot debugging of 0d0b90105f92f6cd9cc7004d565834f4429183fb (lambda/function_ref...
David Blaikie [Mon, 23 Mar 2020 05:39:16 +0000 (22:39 -0700)]
Buildbot debugging of 0d0b90105f92f6cd9cc7004d565834f4429183fb (lambda/function_ref lifetime issues)

This is failing on several buildbots with some inexplicable (to me,
right now) crashes. Let's see if this change is adequate to unblock the
buildbots & further understanding can be gained later.

4 years agoAdd test cases that are addressed by D76010
Juneyoung Lee [Mon, 23 Mar 2020 04:49:29 +0000 (13:49 +0900)]
Add test cases that are addressed by D76010

4 years ago[NFC] [PowerPC] Prepare test for FMA negate check
Qiu Chaofan [Mon, 23 Mar 2020 03:40:07 +0000 (11:40 +0800)]
[NFC] [PowerPC] Prepare test for FMA negate check

This patch adds a test file, covering outputs when some operands in FMA
is negative.

4 years ago[MLIR][NFC] Move some of the affine transforms / tests to dialect dirs
Uday Bondhugula [Sun, 22 Mar 2020 11:25:36 +0000 (16:55 +0530)]
[MLIR][NFC] Move some of the affine transforms / tests to dialect dirs

Move some of the affine transforms and their test cases to their
respective dialect directory. This patch does not complete the move, but
takes care of a good part.

Renames: prefix 'affine' to affine loop tiling cl options,
vectorize -> super-vectorize

Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Differential Revision: https://reviews.llvm.org/D76565

4 years ago[MLIR][NFC] rename ConvertStandardToLLVM, ConvertLoopToStandard to drop Convert prefix
Uday Bondhugula [Mon, 23 Mar 2020 01:34:04 +0000 (07:04 +0530)]
[MLIR][NFC] rename ConvertStandardToLLVM, ConvertLoopToStandard to drop Convert prefix

This is in line with the convention agreed on https://llvm.discourse.group/t/rfc-canonical-file-paths-to-dialects/621

Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>
Differential Revision: https://reviews.llvm.org/D76583

4 years agoRevert "[FIX] Do not copy an llvm::function_ref if it has to be reused"
David Blaikie [Mon, 23 Mar 2020 01:43:39 +0000 (18:43 -0700)]
Revert "[FIX] Do not copy an llvm::function_ref if it has to be reused"

This fix doesn't seem to be right (function_ref can/should be passed by
value) so I'm reverted it to see if the buildbots decide to explain
what's wrong.

This reverts commit 857bf5da35af8e1f9425e1865dab5f5fce5e38f2.

4 years agoRoll an expression into an assert to remove the need for a (void) cast.
David Blaikie [Mon, 23 Mar 2020 01:17:53 +0000 (18:17 -0700)]
Roll an expression into an assert to remove the need for a (void) cast.

4 years ago[X86] Remove maximum vector length limit from combineBasicSADPattern.
Craig Topper [Sun, 22 Mar 2020 21:20:50 +0000 (14:20 -0700)]
[X86] Remove maximum vector length limit from combineBasicSADPattern.

createPSADBW uses SplitsOpsAndApply so should be able to handle
any size.

Restrict the extract result type to i32 or i64 since that's what
we have coverage for today and probably matches what the
isSimple() check gave us before.

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

4 years agodoc: use the right url to bugzilla
Sylvestre Ledru [Sun, 22 Mar 2020 21:45:15 +0000 (22:45 +0100)]
doc: use the right url to bugzilla

4 years agoDoc: Links should use https
Sylvestre Ledru [Sun, 22 Mar 2020 21:42:03 +0000 (22:42 +0100)]
Doc: Links should use https

4 years ago[SCCP] Add a few more tests for conditional propagation,XOR.
Florian Hahn [Sat, 21 Mar 2020 23:38:37 +0000 (23:38 +0000)]
[SCCP] Add a few more tests for conditional propagation,XOR.

4 years agoupdate of the llvm doc: we moved to git
Sylvestre Ledru [Sun, 22 Mar 2020 21:31:18 +0000 (22:31 +0100)]
update of the llvm doc: we moved to git

4 years ago[X86] More accurately model the cost of horizontal reductions.
Craig Topper [Sun, 22 Mar 2020 18:09:55 +0000 (11:09 -0700)]
[X86] More accurately model the cost of horizontal reductions.

This patch attempts to more accurately model the reduction of
power of 2 vectors of types we natively support. This takes into
account the narrowing of vectors that occur as we go from 512
bits to 256 bits, to 128 bits. It also takes into account the use
of wider elements in the shuffles for the first 2 steps of a
reduction from 128 bits. And uses a v8i16 shift for the final step
of vXi8 reduction.

The default implementation uses the legalized type for the arithmetic
for all levels. And uses the single source permute cost of the
legalized type for all levels. This penalizes things like
lack of v16i8 pshufb on pre-sse3 targets and the splitting and
joining that needs to be done for integer types on AVX1. We never
need v16i8 shuffle for a reduction and we only need split AVX1 ops
when type the type wide and needs to be split. I think we're still
over costing splits and joins for AVX1, but we're closer now.

I've also removed all pairwise special casing because I don't
think we ever want to generate that on X86. I've also adjusted
the add handling to more accurately account for any type splitting
that occurs before we reach a legal type.

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

4 years agoclang/release notes: s/Subversion/git/
Sylvestre Ledru [Sun, 22 Mar 2020 21:18:40 +0000 (22:18 +0100)]
clang/release notes: s/Subversion/git/

4 years ago[mips] Implement .cpadd directive
Simon Atanasyan [Sun, 22 Mar 2020 17:20:00 +0000 (20:20 +0300)]
[mips] Implement .cpadd directive

This directive inserts code to add $gp to the argument's register when
support for position independent code is enabled.

For example, this code:
  .cpadd $4
expands to:
  addu $4, $4, $gp

4 years ago[mips] Implement sne pseudo instruction
Simon Atanasyan [Sun, 22 Mar 2020 17:10:00 +0000 (20:10 +0300)]
[mips] Implement sne pseudo instruction

The `sne Dst, Src1, Src2/Imm` pseudo instruction sets register `Dst` to
1 if register `Src1` is not equal to `Src2/Imm` and to 0 otherwise.

4 years ago[mips] Implement sle/sleu pseudo instructions
Simon Atanasyan [Sun, 22 Mar 2020 17:00:00 +0000 (20:00 +0300)]
[mips] Implement sle/sleu pseudo instructions

The `sle/sleu Dst, Src1, Src2/Imm` pseudo instructions set register
`Dst` to 1 if register `Src1` is less than or equal `Src2/Imm` and
to 0 otherwise.

4 years ago[mips] Remove instructions related to "wired paired single" from the P5600 model.
Simon Atanasyan [Sun, 22 Mar 2020 15:23:28 +0000 (18:23 +0300)]
[mips] Remove instructions related to "wired paired single" from the P5600 model.

4 years ago[mips] Add HasMips3D to the list of features unsupported by P5600 model.
Simon Atanasyan [Sun, 22 Mar 2020 15:22:23 +0000 (18:22 +0300)]
[mips] Add HasMips3D to the list of features unsupported by P5600 model.

4 years ago[mips] Rename target feature Mips3D => HasMips3D. NFC
Simon Atanasyan [Sun, 22 Mar 2020 15:18:25 +0000 (18:18 +0300)]
[mips] Rename target feature Mips3D => HasMips3D. NFC

4 years ago[mlir] Change include image to be toplevel
Jacques Pienaar [Sun, 22 Mar 2020 20:13:17 +0000 (13:13 -0700)]
[mlir] Change include image to be toplevel

This will match the changes mlir.llvm.org side.

4 years ago[libc][NFC] Fix typo in milliseconds
Alex Brachet [Sun, 22 Mar 2020 19:11:22 +0000 (15:11 -0400)]
[libc][NFC] Fix typo in milliseconds

4 years ago[NFC] Refactor handling of Xarch option
Yaxun (Sam) Liu [Thu, 19 Mar 2020 21:11:35 +0000 (17:11 -0400)]
[NFC] Refactor handling of Xarch option

Extract common code to a function. To prepare for
adding an option for CUDA/HIP host and device only
option.

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

4 years agoAdd Triple::isAMDGPU
Yaxun (Sam) Liu [Sun, 22 Mar 2020 17:43:33 +0000 (13:43 -0400)]
Add Triple::isAMDGPU

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

4 years ago[libc] Add signal
Alex Brachet [Sun, 22 Mar 2020 18:15:47 +0000 (14:15 -0400)]
[libc] Add signal

Summary:
This patch adds a Linux implementation for `signal`
It also fixes `ASSERT|EXPECT_THAT` macros

Reviewers: sivachandra, PaulkaToast, MaskRay

Reviewed By: sivachandra

Subscribers: mgorny, tschuett, libc-commits

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

4 years ago[X86] Remove maximum vector width restriction from combineLoopSADPattern.
Craig Topper [Sun, 22 Mar 2020 17:54:50 +0000 (10:54 -0700)]
[X86] Remove maximum vector width restriction from combineLoopSADPattern.

SplitsOpsAndApply will take care of any needed splitting correctly.
All that we need to check is that the vector element count is a
power of 2.

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

4 years agoRemove a dead function.
Nico Weber [Sun, 22 Mar 2020 17:27:51 +0000 (13:27 -0400)]
Remove a dead function.

4 years agoVerifier: Check bswap is supported size
Matt Arsenault [Sun, 22 Mar 2020 15:36:44 +0000 (11:36 -0400)]
Verifier: Check bswap is supported size

Make sure it is a multiple of 2 bytes as specified in the LangRef.

4 years ago[InstCombine] Remove ExpensiveCombines option
Nikita Popov [Sat, 21 Mar 2020 09:14:17 +0000 (10:14 +0100)]
[InstCombine] Remove ExpensiveCombines option

D75801 removed the last and only user of this option, so we can
drop it now. The original idea behind this was to only run expensive
transforms under -O3, but apart from the one known bits transform,
this has never really taken off. I believe nowadays the recommendation
is to put expensive transforms in AggressiveInstCombine instead,
though that isn't terribly popular either :)

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

4 years agoUtils: Mostly convert memcpy expansion to use Align
Matt Arsenault [Sun, 22 Mar 2020 14:45:36 +0000 (10:45 -0400)]
Utils: Mostly convert memcpy expansion to use Align

The TTI hooks aren't converted. I also think the intrinsics should
have mandatory alignment and never return MaybeAlign.

4 years ago[DAGCombiner] Require nsz for aggressive fma fold
Qiu Chaofan [Sun, 22 Mar 2020 15:10:07 +0000 (23:10 +0800)]
[DAGCombiner] Require nsz for aggressive fma fold

For folding pattern `x-(fma y,z,u*v) -> (fma -y,z,(fma -u,v,x))`, if
`yz` is 1, `uv` is -1 and `x` is -0, sign of result would be changed.

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

4 years ago[NFC] [PowerPC] Remove unsafe-fp-math in FMA test
Qiu Chaofan [Sun, 22 Mar 2020 14:40:49 +0000 (22:40 +0800)]
[NFC] [PowerPC] Remove unsafe-fp-math in FMA test

4 years ago[X86][SSE] Add some additional irregular AVG tests
Simon Pilgrim [Sun, 22 Mar 2020 14:02:08 +0000 (14:02 +0000)]
[X86][SSE] Add some additional irregular AVG tests

Finally resurrecting D56506 and want to improve test coverage.

4 years ago[ValueTracking] Avoid blind cast from Operator to Instruction
Bjorn Pettersson [Sun, 22 Mar 2020 11:16:42 +0000 (12:16 +0100)]
[ValueTracking] Avoid blind cast from Operator to Instruction

Summary:
Avoid blind cast from Operator to ExtractElementInst in
computeKnownBitsFromOperator. This resulted in some crashes
in downstream fuzzy testing. Instead we use getOperand directly
on the Operator when accessing the vector/index operands.

Haven't seen any problems with InsertElement and ShuffleVector,
but I believe those could be used in constant expressions as well.
So the same kind of fix as for ExtractElement was also applied for
InsertElement.

When it comes to ShuffleVector we now simply bail out if a dynamic
cast of the Operator to ShuffleVectorInst fails. I've got no
reproducer indicating problems for ShuffleVector, and a fix would be
slightly more complicated as getShuffleDemandedElts is involved.

Reviewers: RKSimon, nikic, spatel, efriedma

Reviewed By: RKSimon

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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