platform/upstream/llvm.git
2 years ago[InstCombine] Refactor and/or of icmp with constant (NFCI)
Nikita Popov [Sat, 6 Nov 2021 21:15:26 +0000 (22:15 +0100)]
[InstCombine] Refactor and/or of icmp with constant (NFCI)

Rather than testing for many specific combinations of predicates
and values, compute the exact icmp regions for both comparisons
and check whether they union/intersect exactly. If they do,
construct the equivalent icmp for the new range. Assuming that the
existing code handled all possible cases, this should be NFC.

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

2 years agoBPF: change btf_type_tag BTF output format
Yonghong Song [Mon, 8 Nov 2021 04:36:52 +0000 (20:36 -0800)]
BPF: change btf_type_tag BTF output format

For the declaration like below:
  int __tag1 * __tag1 __tag2 *g
Commit 41860e602aaa ("BPF: Support btf_type_tag attribute")
implemented the following encoding:
  VAR(g) -> __tag1 --> __tag2 -> pointer -> __tag1 -> pointer -> int

Some further experiments with linux btf_type_tag support, esp.
with generating attributes in vmlinux.h, and also some internal
discussion showed the following format is more desirable:
  VAR(g) -> pointer -> __tag2 -> __tag1 -> pointer -> __tag1 -> int

The format makes it similar to other modifier like 'const', e.g.,
  const int *g
which has encoding VAR(g) -> PTR -> CONST -> int

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

2 years ago[InstCombine] Fuse checks for LHS (~(A | B) & C) | ... NFC.
Stanislav Mekhanoshin [Wed, 3 Nov 2021 18:10:26 +0000 (11:10 -0700)]
[InstCombine] Fuse checks for LHS (~(A | B) & C) | ... NFC.

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

2 years agoRevert "[clang-tidy] Fix lint warning in ClangTidyDiagnosticConsumer.cpp (NFC)"
Jorge Gorbe Moya [Tue, 9 Nov 2021 19:24:05 +0000 (11:24 -0800)]
Revert "[clang-tidy] Fix lint warning in ClangTidyDiagnosticConsumer.cpp (NFC)"

The change causes multiple clang-tidy tests to fail under ASan.

This reverts commit 00769572025f9b0d36dc832d3c1bc61500091ed5.

2 years ago[InstCombine] fix code comment to match code; NFC
Sanjay Patel [Tue, 9 Nov 2021 18:26:04 +0000 (13:26 -0500)]
[InstCombine] fix code comment to match code; NFC

2 years ago[libc++] Adds missing forward_list merge tests.
Mark de Wever [Sat, 6 Nov 2021 19:30:08 +0000 (20:30 +0100)]
[libc++] Adds missing forward_list merge tests.

During the review of D112660 it turned out the tests for
`std::forward_list::merge` are incomplete.

Adds tests for the rvalue reference overloads. The tests are extended to
better test the Effects [forward.list.ops]/25 and Remarks
[forward.list.ops]/27 of the function:
- x is empty after the merge.
- Pointers and references to the moved elements of x now refer to those
  same elements but as members of *this.
- Iterators referring to the moved elements will continue to refer to
  their elements, but they now behave as iterators into *this, not into x.
- The algorithm is stable.

Reviewed By: Quuxplusone, #libc, ldionne

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

2 years ago[Sema] Mark virtual method declaration in union as invalid
Yuanfang Chen [Tue, 9 Nov 2021 18:33:33 +0000 (10:33 -0800)]
[Sema] Mark virtual method declaration in union as invalid

Currently, this is only diagnosed but the decl is not marked invalid. This may hit assertions down the path.

This also reverts the fix for PR49534 since it is not needed anymore.

Reviewed By: hubert.reinterpretcast

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

2 years ago[DebugInfo] Only create concrete DIEs of concrete functions
Ellis Hoag [Tue, 9 Nov 2021 18:52:10 +0000 (10:52 -0800)]
[DebugInfo] Only create concrete DIEs of concrete functions

At the begining of the module we can iterate through the functions to
see which SPs should have concrete DIEs. Then when we need to reference
a DIE for a SP we can decide if it's ok to create a concrete DIE or not.

Fixes
 * https://bugs.llvm.org/show_bug.cgi?id=52159
 * https://bugs.llvm.org/show_bug.cgi?id=30637

Reviewed By: dblaikie

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

2 years ago[lldb] XFAIL TestPlatformKill on windows
Pavel Labath [Tue, 9 Nov 2021 18:39:17 +0000 (19:39 +0100)]
[lldb] XFAIL TestPlatformKill on windows

-> PR52451

2 years agoUse yaml2obj instead of relying on invoking the Darwin system assembler.
Adrian Prantl [Tue, 9 Nov 2021 18:46:09 +0000 (10:46 -0800)]
Use yaml2obj instead of relying on invoking the Darwin system assembler.

2 years ago[llvm-reduce] Fix invalid reduction in basic-blocks delta pass
Dwight Guth [Tue, 9 Nov 2021 18:42:52 +0000 (10:42 -0800)]
[llvm-reduce] Fix invalid reduction in basic-blocks delta pass

Previously, if the basic-blocks delta pass tried to remove a basic block
that was the last basic block in a function that did not have external
or weak linkage, the resulting IR would become invalid. Since removing
the last basic block in a function is effectively identical to removing
the function body itself, we check explicitly for this case and if we
detect it, we run the same logic as in ReduceFunctionBodies.cpp

Reviewed By: aeubanks

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

2 years ago[gn build] Port 533862933398
LLVM GN Syncbot [Tue, 9 Nov 2021 18:38:40 +0000 (18:38 +0000)]
[gn build] Port 533862933398

2 years ago[NFC] Rename GVN -> GVNPass and SROA -> SROAPass
Arthur Eubanks [Mon, 1 Nov 2021 15:56:48 +0000 (08:56 -0700)]
[NFC] Rename GVN -> GVNPass and SROA -> SROAPass

To be more consistent with other pass struct names.

There are still more passes that don't end with "Pass", but these are the important ones.

Reviewed By: asbirlea

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

2 years ago[ProfileData] Fix a warning
Kazu Hirata [Tue, 9 Nov 2021 18:34:00 +0000 (10:34 -0800)]
[ProfileData] Fix a warning

This patch fixes:

  llvm/lib/ProfileData/InstrProf.cpp:146:3: error: default label in
  switch which covers all enumeration values
  [-Werror,-Wcovered-switch-default]

2 years agoRevert "Reapply db28934 "[IndVars] Pass TTI to replaceCongruentIVs""
Douglas Yung [Tue, 9 Nov 2021 18:28:41 +0000 (10:28 -0800)]
Revert "Reapply db28934 "[IndVars] Pass TTI to replaceCongruentIVs""

This reverts commit 5ec23863320ca12bfabb6dcff1d0425cb614b7a5.

This change is causing test failures on the PS4 linux build bot: https://lab.llvm.org/buildbot/#/builders/139/builds/12871

2 years agoRevert rG299aa4dfa1d8c120648b1404b481d858b76c8173 "Misleading unicode identifier...
Simon Pilgrim [Tue, 9 Nov 2021 18:25:07 +0000 (18:25 +0000)]
Revert rG299aa4dfa1d8c120648b1404b481d858b76c8173 "Misleading unicode identifier detection pass"

This is failing on various buildbots: https://lab.llvm.org/buildbot/#/builders/109/builds/25932

2 years ago[gn build] Port 299aa4dfa1d8
Arthur Eubanks [Tue, 9 Nov 2021 18:20:43 +0000 (10:20 -0800)]
[gn build] Port 299aa4dfa1d8

2 years ago[gn build] Port 22a1aa5a43cb
Arthur Eubanks [Tue, 9 Nov 2021 18:20:42 +0000 (10:20 -0800)]
[gn build] Port 22a1aa5a43cb

2 years ago[DebugInfo] Enforce implicit constraints on `distinct` MDNodes
Scott Linder [Thu, 4 Nov 2021 16:52:32 +0000 (16:52 +0000)]
[DebugInfo] Enforce implicit constraints on `distinct` MDNodes

Add UNIQUED and DISTINCT properties in Metadata.def and use them to
implement restrictions on the `distinct` property of MDNodes:

* DIExpression can currently be parsed from IR or read from bitcode
  as `distinct`, but this property is silently dropped when printing
  to IR. This causes accepted IR to fail to round-trip. As DIExpression
  appears inline at each use in the canonical form of IR, it cannot
  actually be `distinct` anyway, as there is no syntax to describe it.
* Similarly, DIArgList is conceptually always uniqued. It is currently
  restricted to only appearing in contexts where there is no syntax for
  `distinct`, but for consistency it is treated equivalently to
  DIExpression in this patch.
* DICompileUnit is already restricted to always being `distinct`, but
  along with adding general support for the inverse restriction I went
  ahead and described this in Metadata.def and updated the parser to be
  general. Future nodes which have this restriction can share this
  support.

The new UNIQUED property applies to DIExpression and DIArgList, and
forbids them to be `distinct`. It also implies they are canonically
printed inline at each use, rather than via MDNode ID.

The new DISTINCT property applies to DICompileUnit, and requires it to
be `distinct`.

A potential alternative change is to forbid the non-inline syntax for
DIExpression entirely, as is done with DIArgList implicitly by requiring
it appear in the context of a function. For example, we would forbid:

    !named = !{!0}
    !0 = !DIExpression()

Instead we would only accept the equivalent inlined version:

    !named = !{!DIExpression()}

This essentially removes the ability to create a `distinct` DIExpression
by construction, as there is no syntax for `distinct` inline. If this
patch is accepted as-is, the result would be that the non-canonical
version is accepted, but the following would be an error and produce a diagnostic:

    !named = !{!0}
    ; error: 'distinct' not allowed for !DIExpression()
    !0 = distinct !DIExpression()

Also update some documentation to consistently use the inline syntax for
DIExpression, and to describe the restrictions on `distinct` for nodes
where applicable.

Reviewed By: StephenTozer, t-tye

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

2 years ago[libc++] Simplify selftest to avoid passing arguments to it
Louis Dionne [Wed, 4 Nov 2020 13:56:04 +0000 (08:56 -0500)]
[libc++] Simplify selftest to avoid passing arguments to it

This makes the test pass on executors that don't support passing additional
arguments.

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

2 years ago[CodeView] Properly handle a DISubprogram in getScopeIndex.
Chih-Ping Chen [Wed, 3 Nov 2021 20:44:00 +0000 (16:44 -0400)]
[CodeView] Properly handle a DISubprogram in getScopeIndex.

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

2 years ago[libc++] Enable -Wformat-nonliteral when building libc++
Louis Dionne [Fri, 29 Oct 2021 16:36:57 +0000 (12:36 -0400)]
[libc++] Enable -Wformat-nonliteral when building libc++

Using user-provided data as a format string is a well known source of
security vulnerabilities. For this reason, it is a good idea to compile
our code with -Wformat-nonliteral, which basically warns if a non-constant
string is used as a format specifier. This is the compiler’s best signal
that a format string call may be insecure.

I audited the code after adding the warning and made sure that the few
places where we used a non-literal string as a format string were not
potential security issues. I either disabled the warning locally for
those instances or fixed the warning by using a literal. The idea is
that after we add the warning to the build, any new use of a non-literal
string in a format string will trigger a diagnostic, and we can either
get rid of it or disable the warning locally, which is a way of
acknowledging that it has been audited.

I also looked into enabling it in the test suite, which would perhaps
allow finding additional instances of it in our headers, however that
is not possible at the moment because Clang doesn't support putting
__attribute__((__format__(...))) on variadic templates, which would
be needed.

rdar://84571685

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

2 years agoAdd a requires line to test.
Adrian Prantl [Tue, 9 Nov 2021 18:15:54 +0000 (10:15 -0800)]
Add a requires line to test.

2 years ago[llvm-reduce] Add flag to start at finer granularity
Dwight Guth [Tue, 9 Nov 2021 18:13:33 +0000 (10:13 -0800)]
[llvm-reduce] Add flag to start at finer granularity

Sometimes if llvm-reduce is interrupted in the middle of a delta pass on
a large file, it can take quite some time for the tool to start actually
doing new work if it is restarted again on the partially-reduced file. A
lot of time ends up being spent testing large chunks when these large
chunks are very unlikely to actually pass the interestingness test. In
cases like this, the tool will complete faster if the starting
granularity is reduced to a finer amount. Thus, we introduce a command
line flag that automatically divides the chunks into smaller subsets a
fixed, user-specified number of times prior to beginning the core loop.

Reviewed By: aeubanks

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

2 years agoRevert "[mlir] Add nano precision clock to execution engine"
Mehdi Amini [Tue, 9 Nov 2021 18:11:59 +0000 (18:11 +0000)]
Revert "[mlir] Add nano precision clock to execution engine"

This reverts commit 48d1f099d492b0d796743d1528f09947e4d2d864.

Broke the MLIR buildbots

2 years ago[libc] refactor atof string parsing
Michael Jones [Mon, 1 Nov 2021 17:32:19 +0000 (10:32 -0700)]
[libc] refactor atof string parsing

Split the code for parsing hexadecimal floating point numbers from the
code for parsing the decimal floating point numbers so that the parsing
can be faster for both of them.

This decreases the time for the benchmark in release mode by about 15%,
which noticeably beats GLibc.

Old version: 2.299s
New version: 1.893s
GLibc: 2.133s

Tests run by running the following command 10 times for each version:
time ~/llvm-project/build/bin/libc_str_to_float_comparison_test ~/parse-number-fxx-test-data/data/*

the parse-number-fxx-test-data-repository is here:
https://github.com/nigeltao/parse-number-fxx-test-data/tree/fe94de252c691900982050c8e7c503d1efd1299a

It's important to build llvm-libc in Release mode for accurate
performance comparisons against glibc (set -DCMAKE_BUILD_TYPE=Release in
your cmake).
You also have to build the libc_str_to_float_comparison_test target.

Reviewed By: lntue

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

2 years ago[llvm-objdump] -p: Dump PE header for PE/COFF
Fangrui Song [Tue, 9 Nov 2021 18:08:41 +0000 (10:08 -0800)]
[llvm-objdump] -p: Dump PE header for PE/COFF

For a trivial DLL built with `clang --target=x86_64-windows -O2 -c a.c; lld-link -subsystem:console -dll a.o -out:a.dll`,
`objdump -p` vs `llvm-objdump -p`:

```
-a.dll:     file format pei-x86-64
-
+a.dll: file format coff-x86-64
 Characteristics 0x2022
        executable
        large address aware
@@ -57,4 +56,4 @@
 Entry d 0000000000000000 00000000 Delay Import Directory
 Entry e 0000000000000000 00000000 CLR Runtime Header
 Entry f 0000000000000000 00000000 Reserved
-
+Export Table:
```

For a Linux image (`vmlinuz-5.10.76-gentoo-r1`) built with `CONFIG_EFI_STUB=y`

```
-vmlinuz-5.10.76-gentoo-r1:     file format pei-x86-64
-
-Characteristics 0x20e
+vmlinuz-5.10.76-gentoo-r1:     file format coff-x86-64
+Characteristics 0x206
        executable
        line numbers stripped
-       symbols stripped
        debugging information removed

 Time/Date              Wed Dec 31 16:00:00 1969
@@ -55,10 +53,4 @@
 Entry d 0000000000000000 00000000 Delay Import Directory
 Entry e 0000000000000000 00000000 CLR Runtime Header
 Entry f 0000000000000000 00000000 Reserved
-
-
-PE File Base Relocations (interpreted .reloc section contents)
-
-Virtual Address: 000037ca Chunk size 10 (0xa) Number of fixups 1
-       reloc    0 offset    0 [37ca] ABSOLUTE
-
+Export Table:
```

`symbols stripped` looks like a GNU objdump problem.

Reviewed By: jhenderson, alexander-shaposhnikov

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

2 years ago[compiler-rt] Add more diagnostic to InstrProfError
Gulfem Savrun Yeniceri [Mon, 30 Aug 2021 19:12:16 +0000 (19:12 +0000)]
[compiler-rt] Add more diagnostic to InstrProfError

If profile data is malformed for any kind of reason, we generate
an error that only reports "malformed instrumentation profile data"
without any further information. This patch extends InstrProfError
class to receive an optional error message argument, so that we can
do better error reporting.

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

2 years ago[libc++] Fix lifetime issues of temporaries.
Mark de Wever [Wed, 3 Nov 2021 19:50:59 +0000 (20:50 +0100)]
[libc++] Fix lifetime issues of temporaries.

The ASAN build failed due to using pointers to a temporary whose
lifetime had expired.

Updating the libc++ Docker image to Ubuntu Focal caused some breakage.
This was temporary disabled in D112737. This re-enables two of these
tests.

Reviewed By: ldionne, #libc

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

2 years ago[libc++] Mark a failing test.
Mark de Wever [Wed, 3 Nov 2021 20:09:59 +0000 (21:09 +0100)]
[libc++] Mark a failing test.

The tests fails in debug mode since it manipulates an iterator to a
`std::string` returned from the dylib. This is a known issue for the
debug iterators.

Updating the libc++ Docker image to Ubuntu Focal caused some breakage.
This was temporary disabled in D112737. This re-enables one of these
tests.

Reviewed By: ldionne, #libc, Quuxplusone

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

2 years ago[libc++][cmake] Improves benchmark build.
Mark de Wever [Mon, 8 Nov 2021 17:58:18 +0000 (18:58 +0100)]
[libc++][cmake] Improves benchmark build.

The CMake dependencies don't properly list the libc++ headers. When a
libc++ header is modified the affected benchmarks aren't rebuild. This
makes testing benchmarks tricky and may cause accidentally not using the
latest modifications during testing. This change causes CMake to
determine the proper dependencies.

This shouldn't affect the CI build.

Reviewed By: #libc, ldionne

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

2 years ago[ARM] Fix unused variable warning in Release builds
Benjamin Kramer [Tue, 9 Nov 2021 17:55:52 +0000 (18:55 +0100)]
[ARM] Fix unused variable warning in Release builds

2 years ago[ELF] Improve sh_info=0 and sh_info>=num_sections diagnostic for SHT_REL/SHT_RELA
Fangrui Song [Tue, 9 Nov 2021 17:54:12 +0000 (09:54 -0800)]
[ELF] Improve sh_info=0 and sh_info>=num_sections diagnostic for SHT_REL/SHT_RELA

PR52408 reported an sh_info=0 instance. I have seen sh_info=0
independently before.

sh_info>=num_sections is probably very rare. Just use one diagnostic for
the two types of errors.

Delete invalid-relocations.test which is covered by invalid/bad-reloc-target.test

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

2 years ago[flang] Fix error in characteristics check at procedure pointer assignment
Emil Kieri [Tue, 9 Nov 2021 15:10:42 +0000 (16:10 +0100)]
[flang] Fix error in characteristics check at procedure pointer assignment

If the procedure pointer has an explicit interface, its characteristics must
equal the characteristics of its target, except that the target may be pure or
elemental also when the pointer is not (cf. F2018 10.2.2.4(3)). In the semantics
check for assignment of procedure pointers, the attributes of the procedures
were not checked correctly due to a typo. This caused some illegal
pointer-target-combinations to pass without raising an error. Fix this, and
expand the test case to improve the coverage of procedure pointer assignment
checks.

Reviewed By: PeteSteinfeld

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

2 years ago[InstCombine] fold sub-of-umax to 0-usubsat
Sanjay Patel [Tue, 9 Nov 2021 17:31:15 +0000 (12:31 -0500)]
[InstCombine] fold sub-of-umax to 0-usubsat

Op0 - umax(X, Op0) --> 0 - usub.sat(X, Op1)

I'm not sure if this is really an improvement in IR because
we probably have better recognition/analysis for min/max,
but this lines up with the fold we do for the icmp+select
idiom and removes another diff from D98152.

This is similar to the previous fold in the code that was
added with:
83c2fb9f66be
baa6a851308d

https://alive2.llvm.org/ce/z/5MrVB9

2 years ago[InstCombine] fix typo in test; NFC
Sanjay Patel [Tue, 9 Nov 2021 16:24:35 +0000 (11:24 -0500)]
[InstCombine] fix typo in test; NFC

This was intended to commute the previous test, but failed to swap the values.

2 years agoSupport looking up absolute symbols
Adrian Prantl [Tue, 9 Nov 2021 01:01:21 +0000 (17:01 -0800)]
Support looking up absolute symbols

The Swift stdlib uses absolute symbols in the dylib to communicate
feature flags to the process. LLDB's expression evaluator needs to be
able to find them. This wires up absolute symbols so they show up in
the symtab lookup command, which is also all that's needed for them to
be visible to the expression evaluator JIT.

rdar://85093828

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

2 years agoComment parsing: Complete list of Doxygen commands
Aaron Puchert [Tue, 9 Nov 2021 14:05:30 +0000 (15:05 +0100)]
Comment parsing: Complete list of Doxygen commands

These should be all the commands from [1] except those that are marked
obsolete, and "link" / "endlink", as that conflicts with the existing
HeaderDoc pair "link / "/link". For some commands we don't have the
ideal category, but it should work good enough for most cases.

There seems to be no existing test for most commands (except the ones
interpreted by -Wdocumentation), and to some extent such a test wouldn't
look very interesting. But I added a test for the correct parsing of
formulas, as they're a bit special. And I had to adapt
comment-lots-of-unknown-commands.c because typo correction was kicking
in and recognizing some of the commands.

This should fix a couple of reported bugs: PR17437, PR19581, PR24062
(partially, no diagnostic for matching cond/endcond), PR32909, PR37813,
PR44243 (partially, email@domain.com must be addressed separately).

[1] https://www.doxygen.nl/manual/commands.html

Reviewed By: gribozavr2

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

2 years ago[libc++] P0433R2: test that deduction guides are properly SFINAEd away.
Konstantin Varlamov [Tue, 9 Nov 2021 17:21:02 +0000 (09:21 -0800)]
[libc++] P0433R2: test that deduction guides are properly SFINAEd away.

Deduction guides for containers should not participate in overload
resolution when called with certain incorrect types (e.g. when called
with a template argument in place of an `InputIterator` that doesn't
qualify as an input iterator). Similarly, class template argument
deduction should not select `unique_ptr` constructors that take a
a pointer.

The tests try out every possible incorrect parameter (but never more
than one incorrect parameter in the same invocation).

Also add deduction guides to the synopsis for associative and unordered
containers (this was accidentally omitted from [D112510](https://reviews.llvm.org/D112510)).

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

2 years ago[mlir] Flip math dialect to _Both prefixed form (NFC)
Jacques Pienaar [Tue, 9 Nov 2021 17:30:37 +0000 (09:30 -0800)]
[mlir] Flip math dialect to _Both prefixed form (NFC)

See https://llvm.discourse.group/t/psa-ods-generated-accessors-will-change-to-have-a-get-prefix-update-you-apis/4476

2 years ago[ARM] reject -mtp=cp15 if target subarch does not support it
Ard Biesheuvel [Tue, 9 Nov 2021 17:26:29 +0000 (18:26 +0100)]
[ARM] reject -mtp=cp15 if target subarch does not support it

Currently, we permit -mtp=cp15 even for targets that don't implement the
TLS register. When building for ARMv6 or earlier, this means we emit
instructions that will UNDEF at runtime. For Thumb1, passing -mtp=cp15
will trigger an assert in the backend.

So let's add some diagnostics to ensure that -mtp=cp15 is only accepted
for ARMv6T2 or newer.

Reviewed By: nickdesaulniers

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

2 years ago[Demangle] Add minimal support for D programming language
Luís Ferreira [Tue, 9 Nov 2021 17:04:46 +0000 (09:04 -0800)]
[Demangle] Add minimal support for D programming language

This patch adds minimal support for D programming language demangling on LLVM
core based on the D name mangling spec. This will allow easier integration on a
future LLDB plugin for D either in the upstream tree or outside of it.

Minimal support includes recognizing D demangling encoding and at least one
mangling name, which in this case is `_Dmain` mangle.

Reviewed By: jhenderson, lattner

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

2 years ago[ARM] implement support for TLS register based stack protector
Ard Biesheuvel [Tue, 9 Nov 2021 09:18:09 +0000 (10:18 +0100)]
[ARM] implement support for TLS register based stack protector

Implement support for loading the stack canary from a memory location held in
the TLS register, with an optional offset applied. This is used by the Linux
kernel to implement per-task stack canaries, which is impossible on SMP systems
when using a global variable for the stack canary.

Reviewed By: nickdesaulniers

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

2 years ago[OpenMP][libomp][CMake] use uppercase_CMAKE_BUILD_TYPE
Jonathan Peyton [Mon, 1 Nov 2021 19:23:54 +0000 (14:23 -0500)]
[OpenMP][libomp][CMake] use uppercase_CMAKE_BUILD_TYPE

Have standalone builds define uppercase_CMAKE_BUILD_TYPE and use it.
llvm/CMakeLists.txt defines uppercase_CMAKE_BUILD_TYPE for regular LLVM
builds with OpenMP enabled.

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

2 years agoReland "[lld-macho] Fix assertion failure in registerCompactUnwind""
Vy Nguyen [Tue, 9 Nov 2021 15:42:21 +0000 (10:42 -0500)]
Reland "[lld-macho] Fix assertion failure in registerCompactUnwind""

PR/52372

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

New changes:
- use llvm-otool instead of `otool` which doesn't in exist on non-OSX platforms
- add llvm-otool to the set of tools used by test so that the bot will use the <build_dir>/bin/llvm-otool instead of the unqualified `llvm-otool` (which may not exist)
- update tests since the latest (TOT) llvm-otool prints a space between two bytes and the old one doesn't.

2 years ago[lldb-vscode] Add presentation hints for scopes
Andy Yankovsky [Mon, 8 Nov 2021 14:44:31 +0000 (15:44 +0100)]
[lldb-vscode] Add presentation hints for scopes

Scopes can have an optional hint for how to present this scope in the UI:
https://microsoft.github.io/debug-adapter-protocol/specification#Types_Scope

The IDEs can use the hint to present the data accordingly. For example,
Visual Studio has a separate Registers window, which is populated with the
data from the scope with `presentationHint: "registers"`.

Reviewed By: wallace

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

2 years agoRevert "add tsan shared lib"
zijunzhao [Tue, 9 Nov 2021 16:36:06 +0000 (16:36 +0000)]
Revert "add tsan shared lib"

This reverts commit 92c9b340be4164f44772ddf5a50a4a5acdbd6607.

2 years ago[InstCombine] allow commute in sub-of-umax fold
Sanjay Patel [Tue, 9 Nov 2021 15:48:47 +0000 (10:48 -0500)]
[InstCombine] allow commute in sub-of-umax fold

This fold was added with:
83c2fb9f66be
...but missed the commuted pattern:
https://alive2.llvm.org/ce/z/_tYEGy

2 years ago[InstCombine] add/move tests for sub-of-umax; NFC
Sanjay Patel [Tue, 9 Nov 2021 15:35:13 +0000 (10:35 -0500)]
[InstCombine] add/move tests for sub-of-umax; NFC

2 years ago[libcxx] Add a dependency on unwind in cxx_static, if LIBCXXABI_USE_LLVM_UNWINDER...
Martin Storsjö [Tue, 9 Nov 2021 08:14:16 +0000 (10:14 +0200)]
[libcxx] Add a dependency on unwind in cxx_static, if LIBCXXABI_USE_LLVM_UNWINDER is set

Even if building cxx_static in itself doesn't actually link in the
requested unwinder, add a synthetic dependency so that building
cxx_static makes sure that the unwinder that was requested to be used
also gets built.

This makes sure that tests (when run with just a plain "ninja check-cxx")
actually use the newly built unwinder, as intended.

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

2 years ago[clang] [docs] Fix markup
Nathan Sidwell [Tue, 9 Nov 2021 15:39:22 +0000 (07:39 -0800)]
[clang] [docs]  Fix markup

code-block needs a blank line

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

2 years agoRevert "[lld-macho] Fix assertion failure in registerCompactUnwind"
Vy Nguyen [Tue, 9 Nov 2021 15:31:47 +0000 (10:31 -0500)]
Revert "[lld-macho] Fix assertion failure in registerCompactUnwind"

broke windows build - reverting to investigate
This reverts commit b2d92584742e333799ed6a3687c801dde9bb6174.

2 years ago[clang] GCC directive extension extension: Hash NNN lines
Nathan Sidwell [Mon, 8 Nov 2021 17:45:26 +0000 (09:45 -0800)]
[clang] GCC directive extension extension: Hash NNN lines

Some time back I extended GCC's '# NNN' line marker semantics.
Specifically popping to a blank filename will restore the filename to
that of the popped-to include.  Restore to line 5 of including file
(escaped BOL #'s to avoid git eliding them):

\# 5 "" 2

Added documentation for this line control extension.

This was useful in developing modules tests, but turned out to also be
useful with machine-generated source code.  Specifically, a generated
include file that itself includes fragments from elsewhere.  The
ability to pop to the generated include file -- with its full path
prefix -- is useful for diagnostic & debug purposes.  For instance
something like:

// Machine generated -- DO NOT EDIT
Type Var = {
\# 7 "encoded.dsl" 1 // push to snippet-container
{snippet, of, code}
\# 6 " 2 // Restore to machined-generated source
,
};

// user-code
...
\#include "dsl.h"
...

That pop to "" will restore the filename to '..includepath../dsl.h',
which is better than restoring to plain "dsl.h".

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

2 years ago[X86] combineMulToPMADDWD - handle any pow2 vector type and split to legal types
Simon Pilgrim [Tue, 9 Nov 2021 15:11:21 +0000 (15:11 +0000)]
[X86] combineMulToPMADDWD - handle any pow2 vector type and split to legal types

combineMulToPMADDWD is currently limited to legal types, but there's no reason why we can't handle any larger type that the existing SplitOpsAndApply code can use to split to legal X86ISD::VPMADDWD ops.

This also exposed a missed opportunity for pre-SSE41 targets to handle SEXT ops from types smaller than vXi16 - without PMOVSX instructions these will always be expanded to unpack+shifts, so we can cheat and convert this into a ZEXT(SEXT()) sequence to make it a valid PMADDWD op.

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

2 years ago[llvm] Use MachineBasicBlock::{successors,predecessors} (NFC)
Kazu Hirata [Tue, 9 Nov 2021 15:11:13 +0000 (07:11 -0800)]
[llvm] Use MachineBasicBlock::{successors,predecessors} (NFC)

2 years ago[lld-macho] Fix assertion failure in registerCompactUnwind
Vy Nguyen [Tue, 2 Nov 2021 20:28:31 +0000 (16:28 -0400)]
[lld-macho] Fix assertion failure in registerCompactUnwind

PR/52372

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

2 years ago[HWASan] Ensure RNG is initialized in GenerateRandomTag
Matt Morehouse [Tue, 9 Nov 2021 14:52:32 +0000 (06:52 -0800)]
[HWASan] Ensure RNG is initialized in GenerateRandomTag

Fixes a CHECK-failure caused by glibc's pthread_getattr_np
implementation calling realloc.  Essentially, Thread::GenerateRandomTag
gets called during Thread::Init and before Thread::InitRandomState:

  HWAddressSanitizer: CHECK failed: hwasan_thread.cpp:134 "((random_buffer_)) != (0)" (0x0, 0x0) (tid=314)
    #0 0x55845475a662 in __hwasan::CheckUnwind()
    #1 0x558454778797 in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long)
    #2 0x558454766461 in __hwasan::Thread::GenerateRandomTag(unsigned long)
    #3 0x55845475c58b in __hwasan::HwasanAllocate(__sanitizer::StackTrace*, unsigned long, unsigned long, bool)
    #4 0x55845475c80a in __hwasan::hwasan_realloc(void*, unsigned long, __sanitizer::StackTrace*)
    #5 0x5584547608aa in realloc
    #6 0x7f6f3a3d8c2c in pthread_getattr_np
    #7 0x5584547790dc in __sanitizer::GetThreadStackTopAndBottom(bool, unsigned long*, unsigned long*)
    #8 0x558454779651 in __sanitizer::GetThreadStackAndTls(bool, unsigned long*, unsigned long*, unsigned long*, unsigned long*)
    #9 0x558454761bca in __hwasan::Thread::InitStackAndTls(__hwasan::Thread::InitState const*)
    #10 0x558454761e5c in __hwasan::HwasanThreadList::CreateCurrentThread(__hwasan::Thread::InitState const*)
    #11 0x55845476184f in __hwasan_thread_enter
    #12 0x558454760def in HwasanThreadStartFunc(void*)
    #13 0x7f6f3a3d6fa2 in start_thread
    #14 0x7f6f3a15b4ce in __clone

Also reverts 7a3fb71c3cbdd80666335fa8f6f071b43f0b922a, as it's now
unneeded.

Reviewed By: vitalybuka

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

2 years agoMisleading unicode identifier detection pass
serge-sans-paille [Fri, 15 Oct 2021 13:18:52 +0000 (15:18 +0200)]
Misleading unicode identifier detection pass

Detect when an identifier contains some Right-To-Left characters.
This pass relates to https://trojansource.codes/

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

2 years agoUpdate MaxMinLatency even if dependencies have been already scheduled.
Sergei Larin [Wed, 7 Feb 2018 17:55:58 +0000 (11:55 -0600)]
Update MaxMinLatency even if dependencies have been already scheduled.

Covers an extremely rare corner case on internal book keeping.

2 years ago[LoopVectorize] Extract the last lane from a uniform store
Kerry McLaughlin [Tue, 9 Nov 2021 09:51:00 +0000 (09:51 +0000)]
[LoopVectorize] Extract the last lane from a uniform store

Changes VPReplicateRecipe to extract the last lane from an unconditional,
uniform store instruction. collectLoopUniforms will also add stores to
the list of uniform instructions where Legal->isUniformMemOp is true.

setCostBasedWideningDecision now sets the widening decision for
all uniform memory ops to Scalarize, where previously GatherScatter
may have been chosen for scalable stores.

This fixes an assert ("Cannot yet scalarize uniform stores") in
setCostBasedWideningDecision when we have a loop containing a
uniform i1 store and a scalable VF, which we cannot create a scatter for.

Reviewed By: sdesmalen, david-arm, fhahn

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

2 years ago[fir] Add fir.convert op conversion from FIR to LLVM IR
Valentin Clement [Tue, 9 Nov 2021 14:37:49 +0000 (15:37 +0100)]
[fir] Add fir.convert op conversion from FIR to LLVM IR

Add conversion pattern for the `fir.convert` operation.

This patch is part of the upstreaming effort from fir-dev branch.

This patch was previously landed with a truncated version that
was failing the windows buildbot.

Reviewed By: rovka, awarzynski

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[lldb] Fix cross-platform kills
Pavel Labath [Thu, 4 Nov 2021 12:23:12 +0000 (13:23 +0100)]
[lldb] Fix cross-platform kills

This patch fixes an amusing bug where a Platform::Kill operation would
happily terminate a proces on a completely different platform, as long
as they have the same process ID. This was due to the fact that the
implementation was iterating through all known (debugged) processes in
order terminate them directly.

This patch just deletes that logic, and makes everything go through the
OS process termination APIs. While it would be possible to fix the logic
to check for a platform match, it seemed to me that the implementation
was being too smart for its own good -- accessing random Process
objects without knowing anything about their state is risky at best.
Going through the os ensures we avoid any races.

I also "upgrade" the termination signal to a SIGKILL to ensure the
process really dies after this operation.

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

2 years ago[analyzer][docs] Fix the incorrect structure of the checker docs
Kristóf Umann [Mon, 8 Nov 2021 13:40:45 +0000 (14:40 +0100)]
[analyzer][docs] Fix the incorrect structure of the checker docs

The alpha.security.cert section came right after alpha.security, making it look
like checkers like alpha.security.MmapWriteExec belonged to that package.

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

2 years agoRevert "[fir] Add fir.convert op conversion from FIR to LLVM IR"
Valentin Clement [Tue, 9 Nov 2021 14:03:51 +0000 (15:03 +0100)]
Revert "[fir] Add fir.convert op conversion from FIR to LLVM IR"

This reverts commit 165879ec31ed5cc6e4e1a2524c86fc80b81ebbda.

Windows buildbot failure

2 years ago[fir] Add fir.convert op conversion from FIR to LLVM IR
Valentin Clement [Tue, 9 Nov 2021 13:54:21 +0000 (14:54 +0100)]
[fir] Add fir.convert op conversion from FIR to LLVM IR

Add conversion pattern for the `fir.convert` operation.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: rovka, awarzynski

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[InstCombine] enhance vector bitwise select matching
Sanjay Patel [Tue, 9 Nov 2021 13:27:09 +0000 (08:27 -0500)]
[InstCombine] enhance vector bitwise select matching

(Cond & C) | (~bitcast(Cond) & D) --> bitcast (select Cond, (bc C), (bc D))

This is part of fixing:
https://llvm.org/PR34047

That report shows a case where a bitcast is sitting between the select condition
candidate and its 'not' value due to current cast canonicalization rules.

There's a bitcast type restriction that might be violated in existing matching,
but I still need to investigate if that is possible -
Alive2 shows we can only do this transform safely when the bitcast is from
narrow to wide vector elements (otherwise poison could leak into elements
that were safe in the original code):
https://alive2.llvm.org/ce/z/Hf66qh

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

2 years ago[DebugInfo][LSR] Add test for use of IV with a SCEV containing undef
Chris Jackson [Tue, 9 Nov 2021 13:26:54 +0000 (13:26 +0000)]
[DebugInfo][LSR] Add test for use of IV with a SCEV containing undef

Added a lit test that checks scev-based salvagaing does not select IVs
that have a SCEV containing an undef.

Original Differential Revision: https://reviews.llvm.org/D111810

2 years ago[mlir] Add nano precision clock to execution engine
Denys Shabalin [Tue, 9 Nov 2021 11:02:33 +0000 (12:02 +0100)]
[mlir] Add nano precision clock to execution engine

Reviewed By: ftynse, nicolasvasilache

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

2 years ago[fir] Force target for FIR to LLVM IR conversion
Valentin Clement [Tue, 9 Nov 2021 13:26:40 +0000 (14:26 +0100)]
[fir] Force target for FIR to LLVM IR conversion

2 years ago[fir] Add complex operations conversion from FIR LLVM IR
Valentin Clement [Tue, 9 Nov 2021 13:15:07 +0000 (14:15 +0100)]
[fir] Add complex operations conversion from FIR LLVM IR

This patch add conversion for primitive operations on complex types.
- fir.addc
- fir.subc
- fir.mulc
- fir.divc
- fir.negc

This adds also the type conversion for !fir.complex<KIND> type.

This patch is part of the upstreaming effort from fir-dev branch.

This patch was updated to avoid failure on windows buildbot.
Flang codegen does not support windows target so we force the test
to use a known target instead.

Reviewed By: kiranchandramohan, rovka

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[DebugInfo][LSR] Add more stringent checks on IV selection and salvage
Chris Jackson [Tue, 9 Nov 2021 12:22:59 +0000 (12:22 +0000)]
[DebugInfo][LSR] Add more stringent checks on IV selection and salvage
attempts

Prevent the selection of IVs that have a SCEV containing an undef. Also
prevent salvaging attempts for values for which a SCEV could not be
created by ScalarEvolution and have only SCEVUknown.

Reviewed by: Orlando

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

2 years ago[SimplifyCFG] Add early bailout if Use is not in same BB.
Florian Hahn [Tue, 9 Nov 2021 12:56:22 +0000 (12:56 +0000)]
[SimplifyCFG] Add early bailout if Use is not in same BB.

Without this patch, passingValueIsAlwaysUndefined will iterate over all
instructions from I to the end of the basic block, even if the use is
outside the block.

This patch adds an early bail out, if the use instruction is outside I's
BB. This can greatly reduce compile-time in cases where very large basic
blocks are involved, with a large number of PHI nodes and incoming
values.

Note that the refactoring makes the handling of the case where I is a
phi and Use is in PHI more explicit  as well: for phi nodes, we can also
directly bail out. In the existing code, we would iterate until we reach
the end and return false.

Based on an earlier patch by Matt Wala.

Reviewed By: lebedev.ri

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

2 years agoInitial parsing/sema for 'align' clause
David Pagan [Tue, 9 Nov 2021 12:33:39 +0000 (07:33 -0500)]
Initial parsing/sema for 'align' clause

Added basic parsing/sema/serialization support for 'align' clause for use with
'allocate' directive.

2 years ago[AArch64] Add Machine InstCombiner patterns for FMUL indexed variant
Andrew Savonichev [Tue, 9 Nov 2021 12:30:19 +0000 (15:30 +0300)]
[AArch64] Add Machine InstCombiner patterns for FMUL indexed variant

This patch adds DUP+FMUL => FMUL_indexed pattern to InstCombiner.
FMUL_indexed is normally selected during instruction selection, but it
does not work in cases when VDUP and VMUL are in different basic
blocks.

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

2 years ago[clang-tidy] Fix lint warning in ClangTidyDiagnosticConsumer.cpp (NFC)
Salman Javed [Tue, 9 Nov 2021 12:03:26 +0000 (01:03 +1300)]
[clang-tidy] Fix lint warning in ClangTidyDiagnosticConsumer.cpp (NFC)

Calling clang-tidy on ClangTidyDiagnosticConsumer.cpp gives a
"unmatched NOLINTBEGIN without a subsequent NOLINTEND" warning.

The "NOLINTBEGIN" and "NOLINTEND" string literals used in the
implementation of `createNolintError()` get mistaken for actual
NOLINTBEGIN/END comments used to suppress clang-tidy warnings.

Rewrite the string literals so that they can no longer be mistaken for
actual suppression comments.

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

2 years agoRevert "[fir] Add complex operations conversion from FIR LLVM IR"
Valentin Clement [Tue, 9 Nov 2021 12:07:36 +0000 (13:07 +0100)]
Revert "[fir] Add complex operations conversion from FIR LLVM IR"

This reverts commit b9bc64ba147fb90c199c56ec644e24fcabe74a5c.

flang-x86_64-windows is failing with this patch

2 years agoReland "[libcxxabi][ARM] Make CXX_end_cleanup compatible with Armv6-M"
Daniel Kiss [Thu, 4 Nov 2021 15:29:12 +0000 (16:29 +0100)]
Reland "[libcxxabi][ARM] Make CXX_end_cleanup compatible with Armv6-M"

On Armv6-M the branch may not able to reach the _Unwind_Resume function because it's relocation(R_ARM_THM_JUMP11) is in -2048, 2047 range only.

Reviewed By: chill, stuij, lenary

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

2 years ago[SelectionDAG] Merge FoldConstantVectorArithmetic into FoldConstantArithmetic (PR36544)
Simon Pilgrim [Tue, 9 Nov 2021 10:18:00 +0000 (10:18 +0000)]
[SelectionDAG] Merge FoldConstantVectorArithmetic into FoldConstantArithmetic (PR36544)

This patch merges FoldConstantVectorArithmetic back into FoldConstantArithmetic.

Like FoldConstantVectorArithmetic we now handle vector ops with any operand count, but we currently still only handle binops for scalar types - this can be improved in future patches - in particular some common unary/trinary ops still have poor constant folding.

There's one change in functionality causing test changes - FoldConstantVectorArithmetic bails early if the build/splat vector isn't all constant (with some undefs) elements, but FoldConstantArithmetic doesn't - it instead attempts to fold the scalar nodes and bails if they fail to regenerate a constant/undef result, allowing some additional identity/undef patterns to be handled.

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

2 years ago[NFC][X86][Costmodel] Add i16 replication shuffle costmodel test coverage
Roman Lebedev [Tue, 9 Nov 2021 11:19:18 +0000 (14:19 +0300)]
[NFC][X86][Costmodel] Add i16 replication shuffle costmodel test coverage

2 years ago[llvm-dwarfdump] dump link to the immediate parent.
Alexey Lapshin [Mon, 8 Nov 2021 15:34:32 +0000 (18:34 +0300)]
[llvm-dwarfdump] dump link to the immediate parent.

It is often useful to know which die is the parent of the current die.
This patch adds information about parent offset into the dump:

0x0000000b: DW_TAG_compile_unit
              DW_AT_producer    ("by_hand")

0x00000014:   DW_TAG_base_type (0x0000000b)  <<<<<<<<<<<<<<
                DW_AT_name      ("int")

Now it is easy to see which die is the parent of the current die.
This patch makes that behaviour to be default.
We can make it to be opt-in if neccessary.

This functionality differs from already existed "--show-parents"
in that sence that parent information is shown for all dies and
only link to the immediate parent is shown.

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

2 years ago[NFC] Get rid of hardcoded magical constant and use Optionals instead
Max Kazantsev [Tue, 9 Nov 2021 11:11:46 +0000 (18:11 +0700)]
[NFC] Get rid of hardcoded magical constant and use Optionals instead

Refactor calculateIterationsToInvariance so that it doesn't need a magical
constant to signify unknown answer.

2 years ago[TTI] Adjust `getReplicationShuffleCost()` interface
Roman Lebedev [Tue, 9 Nov 2021 10:59:40 +0000 (13:59 +0300)]
[TTI] Adjust `getReplicationShuffleCost()` interface

It is trivial to produce DemandedSrcElts given DemandedReplicatedElts,
so don't pass the former. Also, it isn't really useful so far
to have the overload taking the Mask, so just inline it.

2 years agoRevert rGe1eec7601b6988b35ae3cdc8d67cf3cf4e1361dd "[XCOFF][yaml2obj] support for...
Simon Pilgrim [Tue, 9 Nov 2021 11:02:13 +0000 (11:02 +0000)]
Revert rGe1eec7601b6988b35ae3cdc8d67cf3cf4e1361dd "[XCOFF][yaml2obj] support for the auxiliary file header."

This is failing on MSVC builds: https://lab.llvm.org/buildbot/#/builders/86/builds/23436

2 years agoReapply db28934 "[IndVars] Pass TTI to replaceCongruentIVs"
Dmitry Makogon [Tue, 9 Nov 2021 09:51:41 +0000 (16:51 +0700)]
Reapply db28934 "[IndVars] Pass TTI to replaceCongruentIVs"

This reapplies patch db289340c841990055a164e8eb2a3b5ff25677bf.

The test failures on build with expensive checks caused by the patch happened due
to the fact that we sorted loop Phis in replaceCongruentIVs using llvm::sort,
which shuffles the given container if the expensive checks are enabled,
so equivalent Phis in the sorted vector had different mutual order from run
to run. replaceCongruentIVs tries to replace narrow Phis with truncations
of wide ones. In some test cases there were several Phis with the same
width, so if their order differs from run to run, the narrow Phis would
be replaced with a different Phi, depending on the shuffling result.

The patch ae14fae0ff4304022beda5ab484f84ac0fdda807 fixed this issue by
replacing llvm::sort with llvm::stable_sort.

2 years ago[VPlan] Guard code to dump instructions after d9361bfbe2ce.
Florian Hahn [Tue, 9 Nov 2021 10:28:06 +0000 (10:28 +0000)]
[VPlan] Guard code to dump instructions after d9361bfbe2ce.

This should fix build failures when built without assertions enabled,
e.g.
    https://lab.llvm.org/buildbot/#/builders/205/builds/172

2 years ago[VPlan] Add initial inner-loop VPlan verification.
Florian Hahn [Tue, 9 Nov 2021 10:18:16 +0000 (10:18 +0000)]
[VPlan] Add initial inner-loop VPlan verification.

This patch adds a function to verify general properties of VPlans. The
first check makes sure that all phi-like recipes are at the beginning of
a block, with no other recipes in between.

Note that this currently may not hold for VPBlendRecipes at the moment,
as other recipes may be inserted before the VPBlendRecipe during mask
creation.

Note that this patch depends on D111300 and D111301, which fix code that
breaks the checked invariant.

Reviewed By: Ayal

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

2 years ago[fir] Add complex operations conversion from FIR LLVM IR
Valentin Clement [Tue, 9 Nov 2021 10:04:55 +0000 (11:04 +0100)]
[fir] Add complex operations conversion from FIR LLVM IR

This patch add conversion for primitive operations on complex types.
- fir.addc
- fir.subc
- fir.mulc
- fir.divc
- fir.negc

This adds also the type conversion for !fir.complex<KIND> type.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: rovka

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[cmake] By default do not instrument compiler-rt if LLVM_BUILD_INSTRUMENTED_COVERAGE...
Djordje Todorovic [Tue, 9 Nov 2021 09:55:34 +0000 (10:55 +0100)]
[cmake] By default do not instrument compiler-rt if LLVM_BUILD_INSTRUMENTED_COVERAGE is ON

Applying the same rules as for LLVM_BUILD_INSTRUMENTED build in the cmake files.
By having this patch, we are able to disable/enable instrument+coverage build
of the compiler-rt project when building instrumented LLVM.

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

2 years ago[XCOFF][yaml2obj] support for the auxiliary file header.
Esme-Yi [Tue, 9 Nov 2021 09:48:40 +0000 (09:48 +0000)]
[XCOFF][yaml2obj] support for the auxiliary file header.

Summary:
  This patch adds yaml2obj supporting for the auxiliary
  file header of XCOFF.

Reviewed By: DiggerLin, jhenderson

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

2 years agoRevert "[OpenCL] Allow optional __generic in __remove_address_space utility"
Justas Janickas [Tue, 9 Nov 2021 09:42:17 +0000 (09:42 +0000)]
Revert "[OpenCL] Allow optional __generic in __remove_address_space utility"

This reverts commit 81081daef0299ad59fca299c7cde3888fa691c6a.

2 years ago[SCEVExpander] Use stable_sort to sort loop Phis in SCEVExpander::replaceCongruentIVs
Dmitry Makogon [Tue, 9 Nov 2021 08:41:47 +0000 (15:41 +0700)]
[SCEVExpander] Use stable_sort to sort loop Phis in SCEVExpander::replaceCongruentIVs

This is a fix for test failures on expensive checks build caused by db289340c841990055a164e8eb2a3b5ff25677bf.

With LLVM_ENABLE_EXPENSIVE_CHECKS enabled the llvm::sort shuffles the given container.
However, the sort is only called when the TTI is passed to replaceCongruentIVs.
In the mentioned patch we pass it TTI, so the sort happens. But due to shuffling
equivalent Phis may appear in different order from run to run.
With the stable_sort instead of sort this is impossible - the order of sorted Phis
is preserved.

2 years ago[fir] TargetRewrite: Rewrite COMPLEX values
Diana Picus [Mon, 1 Nov 2021 10:07:34 +0000 (10:07 +0000)]
[fir] TargetRewrite: Rewrite COMPLEX values

Rewrite function signatures and calls to functions that accept or return
COMPLEX values.

Also teach insert_value and extract_value about the MLIR ComplexType, by
adding AnyComplex to AnyCompositeLike.

This patch is part of the effort for upstreaming the fir-dev branch.

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Kiran Chandramohan <kiran.chandramohan@arm.com>
Co-authored-by: Tim Keith <tkeith@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[CodeGen] Fix assertion failure in TwoAddressInstructionPass::rescheduleMIBelowKill
Jay Foad [Wed, 3 Nov 2021 15:45:24 +0000 (15:45 +0000)]
[CodeGen] Fix assertion failure in TwoAddressInstructionPass::rescheduleMIBelowKill

This fixes an assertion failure with -early-live-intervals when trying
to update the live intervals for a debug instruction, which don't even
have slot indexes.

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

2 years ago[NFC][RISCV] Fix wrong predicates of vfwredsum
Shao-Ce SUN [Tue, 9 Nov 2021 09:19:50 +0000 (17:19 +0800)]
[NFC][RISCV] Fix wrong predicates of vfwredsum

2 years ago[MLIR][NFC] FlatAffineConstraints: Refactor division representation computation
Groverkss [Tue, 9 Nov 2021 08:37:59 +0000 (14:07 +0530)]
[MLIR][NFC] FlatAffineConstraints: Refactor division representation computation

This patch factors out division representation computation from upper-lower bound
inequalities to a separate function. This is done to improve readability and reuse.

This patch is marked NFC since the only change is factoring out existing code
to a separate function.

Reviewed By: grosser

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

2 years ago[Hexagon] Use MachineBasicBlock::{successors,predecessors} (NFC)
Kazu Hirata [Tue, 9 Nov 2021 08:26:06 +0000 (00:26 -0800)]
[Hexagon] Use MachineBasicBlock::{successors,predecessors} (NFC)

2 years ago[CUDA] Bump supported CUDA version to 11.5
Carlos Galvez [Fri, 5 Nov 2021 09:13:33 +0000 (09:13 +0000)]
[CUDA] Bump supported CUDA version to 11.5

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

2 years ago[OpenCL] Allow optional __generic in __remove_address_space utility
Justas Janickas [Tue, 21 Sep 2021 11:47:00 +0000 (12:47 +0100)]
[OpenCL] Allow optional __generic in __remove_address_space utility

Clang builtin utility `__remove_address_space` now works if generic
address space is not supported in C++ for OpenCL 2021.

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

2 years ago[flang] Add TargetRewrite pass
Diana Picus [Fri, 29 Oct 2021 07:11:12 +0000 (07:11 +0000)]
[flang] Add TargetRewrite pass

This patch adds the basic infrastructure for the TargetRewrite pass,
which rewrites certain FIR dialect operations into target specific
forms. In particular, it converts boxchar function parameters, call
arguments and return values. Other convertions will be included in
future patches.

This patch is part of the effort for upstreaming the fir-dev branch.

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Kiran Chandramohan <kiran.chandramohan@arm.com>
Co-authored-by: Tim Keith <tkeith@nvidia.com>
2 years ago[gn build] Port ef717f385232
LLVM GN Syncbot [Tue, 9 Nov 2021 07:11:34 +0000 (07:11 +0000)]
[gn build] Port ef717f385232