platform/upstream/llvm.git
3 years ago[verify-uselistorder] Support -force-opaque-pointers
Nikita Popov [Sat, 4 Sep 2021 20:40:39 +0000 (22:40 +0200)]
[verify-uselistorder] Support -force-opaque-pointers

By creating LLVMContext after parsing parameters.

3 years ago[CMake] Re-enable use --gc-sections on OpenBSD
Brad Smith [Sat, 4 Sep 2021 18:14:35 +0000 (14:14 -0400)]
[CMake] Re-enable use --gc-sections on OpenBSD

Most archs have switched to lld.

3 years ago[NFC] Added testcases for new binop with select transformation
Dávid Bolvanský [Sat, 4 Sep 2021 18:06:10 +0000 (20:06 +0200)]
[NFC] Added testcases for new binop with select transformation

3 years ago[AsmPrinter] Remove unneeded MCSubtargetInfo temporary after D14346. NFC
Fangrui Song [Sat, 4 Sep 2021 17:50:10 +0000 (10:50 -0700)]
[AsmPrinter] Remove unneeded MCSubtargetInfo temporary after D14346. NFC

The temporary object was used as a workaround when the target parser may
change STI. D14346 made the MCSubtargetInfo argument to
createMCAsmParser const, so we no longer need the temporary object.

3 years ago[InstCombine] rotate(X,Z) eq/ne rotate(Y,Z) ---> X eq/ne Y (PR51565)
Dávid Bolvanský [Sat, 4 Sep 2021 16:57:50 +0000 (18:57 +0200)]
[InstCombine] rotate(X,Z) eq/ne rotate(Y,Z) ---> X eq/ne Y (PR51565)

```

----------------------------------------
define i1 @src(i8 %x, i8 %y, i8 %z) {
%0:
  %f = fshl i8 %x, i8 %x, i8 %z
  %f2 = fshl i8 %y, i8 %y, i8 %z
  %r = icmp eq i8 %f, %f2
  ret i1 %r
}
=>
define i1 @tgt(i8 %x, i8 %y, i8 %z) {
%0:
  %r = icmp eq i8 %x, %y
  ret i1 %r
}
Transformation seems to be correct!

```

https://alive2.llvm.org/ce/z/qAZp8f

Solves PR51565

Reviewed By: spatel

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

3 years ago[SimpleLoopUnswitch] Inform pass manager when child loops are deleted
Bjorn Pettersson [Fri, 3 Sep 2021 18:50:33 +0000 (20:50 +0200)]
[SimpleLoopUnswitch] Inform pass manager when child loops are deleted

As part of the nontrivial unswitching we could end up removing child
loops. This patch add a notification to the pass manager when
that happens (using the markLoopAsDeleted callback).

Without this there could be stale LoopAccessAnalysis results cached
in the analysis manager. Those analysis results are cached based on
a Loop* as key. Since the BumpPtrAllocator used to allocate
Loop objects could be resetted between different runs of for
example the loop-distribute pass (running on different functions),
a new Loop object could be created using the same Loop pointer.
And then when requiring the LoopAccessAnalysis for the loop we
got the stale (corrupt) result from the destroyed loop.

Reviewed By: aeubanks

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

3 years ago[LLDB][Docs] Indicate `PS1` variable by $
Shivam Gupta [Sat, 4 Sep 2021 15:24:32 +0000 (20:54 +0530)]
[LLDB][Docs] Indicate `PS1` variable by $

3 years ago[Driver] Drop unnecessary const from return types (NFC)
Kazu Hirata [Sat, 4 Sep 2021 15:05:27 +0000 (08:05 -0700)]
[Driver] Drop unnecessary const from return types (NFC)

Identified with readability-const-return-type.

3 years ago[NFC] Run clang-format on llvm/lib/Trget/AVR/
Shivam Gupta [Sat, 4 Sep 2021 14:35:04 +0000 (20:05 +0530)]
[NFC] Run clang-format on llvm/lib/Trget/AVR/

The current inconsistency confuse contributors which coding guidlines to follow.
It would be better to have it consistent using clang-format tool.

Reviewed By: mhjacobson

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

3 years agoFix Wdocumentation unknown parameter warning. NFCI.
Simon Pilgrim [Sat, 4 Sep 2021 14:06:53 +0000 (15:06 +0100)]
Fix Wdocumentation unknown parameter warning. NFCI.

3 years ago[X86][SLM] WriteVecIMul instructions only take 1uop (REAPPLIED)
Simon Pilgrim [Sat, 4 Sep 2021 14:03:56 +0000 (15:03 +0100)]
[X86][SLM] WriteVecIMul instructions only take 1uop (REAPPLIED)

The xmm variant have half the throughput (and +1cy latency) of the mmx variants, but are still 1uop.

I still need to do more thorough testing of SLM on test-suite before fixing the obvious bad numbers for WritePMULLD.

But this helps the D103695 helper script get to more accurate numbers for vXi32 multiplies of extended operands (i.e. we can use PMADDWD, PMULLW/PMULHW etc). Matches what Intel AoM / Agner / llvm-exegesis reports.

3 years agoRevert rG994da657076900f5ad7fe593c3b5e5f89ab3d53d "[X86][SLM] WriteVecIMul instructio...
Simon Pilgrim [Sat, 4 Sep 2021 12:38:55 +0000 (13:38 +0100)]
Revert rG994da657076900f5ad7fe593c3b5e5f89ab3d53d "[X86][SLM] WriteVecIMul instructions only take 1uop"

This changed some codegen tests that I forgot about in my rebase, I'll recommit shortly with a fix.

3 years ago[NFC] Added tests for PR51565
Dávid Bolvanský [Sat, 4 Sep 2021 12:38:01 +0000 (14:38 +0200)]
[NFC] Added tests for PR51565

3 years ago[X86][SLM] WriteVecIMul instructions only take 1uop
Simon Pilgrim [Sat, 4 Sep 2021 12:21:25 +0000 (13:21 +0100)]
[X86][SLM] WriteVecIMul instructions only take 1uop

The xmm variant have half the throughput (and +1cy latency) of the mmx variants, but are still 1uop.

I still need to do more thorough testing of SLM on test-suite before fixing the obvious bad numbers for WritePMULLD.

But this helps the D103695 helper script get to more accurate numbers for vXi32 multiplies of extended operands (i.e. we can use PMADDWD, PMULLW/PMULHW etc). Matches what Intel AoM / Agner / llvm-exegesis reports.

3 years ago[X86][SLM] RMW instructions don't require an extra uop
Simon Pilgrim [Sat, 4 Sep 2021 11:57:15 +0000 (12:57 +0100)]
[X86][SLM] RMW instructions don't require an extra uop

For RMW instructions, the load and store hold the MEC for an extra cycle, but within the same single uop. This is alluded to in the Intel AOM:

"The MEC also owns the MEC RSV, which is responsible for scheduling of all loads and stores. Load and
store instructions go through addresses generation phase in program order to avoid on-the-fly memory
ordering later in the pipeline. Therefore, an unknown address will stall younger memory instructions."

Noticed while trying to get a cheap SLM test box up and running with llvm-exegesis - RMW arithmetic is always 1uop - and matches what Agner / InstLatX64 report as well.

3 years ago[X86][SLM] Fix MUL uops, latency and throughput
Simon Pilgrim [Sat, 4 Sep 2021 11:25:29 +0000 (12:25 +0100)]
[X86][SLM] Fix MUL uops, latency and throughput

These were all set to the same best case mul i32 values (which seems to be the only version of MUL that SLM actually performs well with).

Noticed while trying to improve multiplication costs for vectorization via the D103695 helper script. Confirmed with Intel AoM / Agner / InstLatX64.

3 years ago[mlir] Async: check awaited operand error state after sync await
Eugene Zhulenev [Fri, 3 Sep 2021 12:27:30 +0000 (05:27 -0700)]
[mlir] Async: check awaited operand error state after sync await

Previously only await inside the async function (coroutine after lowering to async runtime) would check the error state

Reviewed By: mehdi_amini

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

3 years ago[Sanitizers] netbsd build fix due to wordexp interception.
David Carlier [Sat, 4 Sep 2021 11:50:28 +0000 (12:50 +0100)]
[Sanitizers] netbsd build fix due to wordexp interception.

3 years ago[libc++][doc] Update format status.
Mark de Wever [Sat, 4 Sep 2021 11:31:29 +0000 (13:31 +0200)]
[libc++][doc] Update format status.

Marked the entries solely depending on D103357 or D96664 as complete.
Initial work on implementing P2216 has started.

3 years ago[X86][Atom] MUL/DIV instructions require both ports, not either.
Simon Pilgrim [Sat, 4 Sep 2021 10:57:08 +0000 (11:57 +0100)]
[X86][Atom] MUL/DIV instructions require both ports, not either.

Noticed while trying to improve multiplication costs for vectorization via the D103695 helper script. Confirmed with Intel AoM.

3 years ago[X86][Atom] Add missing UOps override to AtomWriteResPair multiclass
Simon Pilgrim [Sat, 4 Sep 2021 10:43:38 +0000 (11:43 +0100)]
[X86][Atom] Add missing UOps override to AtomWriteResPair multiclass

Make it easier to describe microcoded instructions.

3 years ago[Sanitizers][PGO] missing return statement
David Carlier [Sat, 4 Sep 2021 10:40:50 +0000 (11:40 +0100)]
[Sanitizers][PGO] missing return statement

3 years ago[libc++][format] Add a CMake Unicode option.
Mark de Wever [Tue, 25 May 2021 18:11:08 +0000 (20:11 +0200)]
[libc++][format] Add a CMake Unicode option.

This option is used to select between the format headers output column
width option. This option should be independent of the locale setting.
It's encouraged to default to Unicode unless the platform doesn't offer
that option.

[format.string.std]/10
```
  For the purposes of width computation, a string is assumed to be in a
  locale-independent, implementation-defined encoding. Implementations
  should use a Unicode encoding on platforms capable of displaying Unicode
```

Reviewed By: #libc, ldionne, vitaut

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

3 years ago[gn build] Port d7444d9f41e3
LLVM GN Syncbot [Sat, 4 Sep 2021 09:41:32 +0000 (09:41 +0000)]
[gn build] Port d7444d9f41e3

3 years ago[libc++][format] Implement formatters.
Mark de Wever [Sat, 19 Dec 2020 12:52:07 +0000 (13:52 +0100)]
[libc++][format] Implement formatters.

This implements the initial version of the `std::formatter` class and its specializations. It also implements the following formatting functions:
- `format`
- `vformat`
- `format_to`
- `vformat_to`
- `format_to_n`
- `formatted_size`

All functions have a `char` and `wchar_t` version. Parsing the format-spec and
using the parsed format-spec hasn't been implemented. The code isn't optimized,
neither for speed, nor for size.

The goal is to have the rudimentary basics working, which can be used as a
basis to improve upon. The formatters used in this commit are simple stubs that
will be replaced by real formatters in later commits.

The formatters that are slated to be replaced in this patch series don't have
an availability macro to avoid merge conflicts.

Note the formatter for `bool` uses `0` and `1` instead of "false" and
"true". This will be fixed when the stub is replaced with a real
formatter.

Implements parts of:
- P0645 Text Formatting

Completes:
- LWG3539 format_to must not copy models of output_iterator<const charT&>

Reviewed By: ldionne, #libc, vitaut

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

3 years ago[WebAssembly] Support opaque pointers in AddMissingPrototypes
Nikita Popov [Fri, 3 Sep 2021 19:53:01 +0000 (21:53 +0200)]
[WebAssembly] Support opaque pointers in AddMissingPrototypes

The change here is basically the same as in D108880: Rather than
looking at bitcasts, look at calls and their function type. We
still need to look through bitcasts to find those calls.

The change in llvm/test/CodeGen/WebAssembly/add-prototypes-conflict.ll
is due to different visitation order. add-prototypes-opaque-ptrs.ll
is a copy of add-prototypes.ll with -force-opaque-pointers.

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

3 years ago[NFC] Added testcase for PR39116
Dávid Bolvanský [Sat, 4 Sep 2021 08:52:46 +0000 (10:52 +0200)]
[NFC] Added testcase for PR39116

3 years ago[NFC] Added testcase for PR48641
Dávid Bolvanský [Sat, 4 Sep 2021 08:44:21 +0000 (10:44 +0200)]
[NFC] Added testcase for PR48641

3 years ago[compiler-rt] NFC: Fix trivial typo
Kazuaki Ishizaki [Sat, 4 Sep 2021 07:31:34 +0000 (13:01 +0530)]
[compiler-rt] NFC: Fix trivial typo

Reviewed By: xgupta

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

3 years ago[clang][AST] Add support for SubstTemplateTypeParmPackType to ASTImporter
Balazs Benics [Sat, 4 Sep 2021 08:19:57 +0000 (10:19 +0200)]
[clang][AST] Add support for SubstTemplateTypeParmPackType to ASTImporter

Thank you @martong for acquiring a suitable test case!

Reviewed By: shafik, martong

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

3 years ago[analyzer] SValBuilder should have an easy access to AnalyzerOptions
Balazs Benics [Sat, 4 Sep 2021 08:19:57 +0000 (10:19 +0200)]
[analyzer] SValBuilder should have an easy access to AnalyzerOptions

`SVB.getStateManager().getOwningEngine().getAnalysisManager().getAnalyzerOptions()`
is quite a mouthful and might involve a few pointer indirections to get
such a simple thing like an analyzer option.

This patch introduces an `AnalyzerOptions` reference to the `SValBuilder`
abstract class, while refactors a few cases to use this /simpler/ accessor.

Reviewed By: martong, Szelethus

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

3 years ago[analyzer] Ignore single element arrays in getStaticSize() conditionally
Balazs Benics [Sat, 4 Sep 2021 08:19:57 +0000 (10:19 +0200)]
[analyzer] Ignore single element arrays in getStaticSize() conditionally

Quoting https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html:
> In the absence of the zero-length array extension, in ISO C90 the contents
> array in the example above would typically be declared to have a single
> element.

We should not assume that the size of the //flexible array member// field has
a single element, because in some cases they use it as a fallback for not
having the //zero-length array// language extension.
In this case, the analyzer should return `Unknown` as the extent of the field
instead.

Reviewed By: martong

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

3 years ago[clang] NFC: Fix trivial typo in comments and document
Kazuaki Ishizaki [Sat, 4 Sep 2021 07:25:40 +0000 (12:55 +0530)]
[clang] NFC: Fix trivial typo in comments and document

`the the` -> `the`

Reviewed By: xgupta

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

3 years ago[mlir] create gpu memset op
Loren Maggiore [Sat, 4 Sep 2021 06:03:33 +0000 (08:03 +0200)]
[mlir] create gpu memset op

Create a gpu memset op and corresponding CUDA and ROCm wrappers.

Reviewed By: herhut, lorenrose1013

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

3 years ago[ForceFunctionAttrs] Add const (NFC)
Kazu Hirata [Sat, 4 Sep 2021 05:29:58 +0000 (22:29 -0700)]
[ForceFunctionAttrs] Add const (NFC)

3 years agoFix for commit d8cd7806310c51af912a647a6ca46de62ff13214.
Brad Smith [Sat, 4 Sep 2021 01:20:37 +0000 (21:20 -0400)]
Fix for commit d8cd7806310c51af912a647a6ca46de62ff13214.

3 years ago[clang] OpenBSD does not support C11 atomics or threads.
Brad Smith [Sat, 4 Sep 2021 01:11:32 +0000 (21:11 -0400)]
[clang] OpenBSD does not support C11 atomics or threads.

3 years agoRevert "[AArch64] Implement target hook function to decide folding (mul (add x, c1...
Kevin Athey [Sat, 4 Sep 2021 01:00:50 +0000 (18:00 -0700)]
Revert "[AArch64] Implement target hook function to decide folding (mul (add x, c1), c2)"

This reverts commit 095bea23d048672b0ad785c93263442694a160b9.

Broke buildbot: https://lab.llvm.org/buildbot/#/builders/5/builds/11411

3 years ago[MLIR] Primitive linkage lowering of FuncOp
William S. Moses [Sun, 22 Aug 2021 20:44:17 +0000 (16:44 -0400)]
[MLIR] Primitive linkage lowering of FuncOp

FuncOp always lowers to an LLVM external linkage presently. This makes it impossible to define functions in mlir which are local to the current module. Until MLIR FuncOps have a more formal linkage specification, this commit allows funcop's to have an optionally specified llvm.linkage attribute, whose value will be used as the linkage of the llvm funcop when lowered.

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

Support LLVM linkage

3 years agoSupport linking against OpenMP runtime on OpenBSD.
Brad Smith [Fri, 3 Sep 2021 23:32:31 +0000 (19:32 -0400)]
Support linking against OpenMP runtime on OpenBSD.

3 years ago[AArch64] Implement target hook function to decide folding (mul (add x, c1), c2)
Ben Shi [Fri, 27 Aug 2021 13:31:57 +0000 (21:31 +0800)]
[AArch64] Implement target hook function to decide folding (mul (add x, c1), c2)

Prevent the folding if it leads to worse code.

Reviewed By: dmgreen

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

3 years ago[ORC] Silence a buggy GCC unused argument warning.
Lang Hames [Fri, 3 Sep 2021 22:08:31 +0000 (08:08 +1000)]
[ORC] Silence a buggy GCC unused argument warning.

3 years agoDebugInfo: additional fix missed in bc066e2.
Richard Smith [Fri, 3 Sep 2021 22:14:00 +0000 (15:14 -0700)]
DebugInfo: additional fix missed in bc066e2.

3 years ago[lldb/Plugins] Move member template specialization out of class
Med Ismail Bennani [Fri, 3 Sep 2021 22:03:06 +0000 (22:03 +0000)]
[lldb/Plugins] Move member template specialization out of class

This patch should fix the build failure that surfaced when build llvm
with GCC: https://lab.llvm.org/staging/#/builders/16/builds/10450

GCC complained that I explicitely specialized
 `ScriptedPythonInterface::ExtractValueFromPythonObject` in a
in non-namespace scope, which is tolerated by Clang.

To solve this issue, the specialization were declared out of the class
and implemented in the source file.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
3 years agoOpenBSD also needs execinfo
Brad Smith [Fri, 3 Sep 2021 21:31:26 +0000 (17:31 -0400)]
OpenBSD also needs execinfo

3 years agoMake LLVM Linkage a first class attribute instead of using an integer attribute
Mehdi Amini [Fri, 3 Sep 2021 21:18:39 +0000 (21:18 +0000)]
Make LLVM Linkage a first class attribute instead of using an integer attribute

This makes the IR more readable, in particular when this will be used on
the builtin func outside of the LLVM dialect.

Reviewed By: wsmoses

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

3 years ago[clang] Allow the OpenBSD driver to link the libclang_rt.profile library.
Frederic Cambus [Fri, 3 Sep 2021 20:53:36 +0000 (16:53 -0400)]
[clang] Allow the OpenBSD driver to link the libclang_rt.profile library.

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

3 years agoDebugInfo: Fix a few bot failures for type dumping fixes
David Blaikie [Fri, 3 Sep 2021 21:08:30 +0000 (14:08 -0700)]
DebugInfo: Fix a few bot failures for type dumping fixes

3 years ago[flang] Use CMake to determine endianness.
Michael Kruse [Fri, 3 Sep 2021 19:48:40 +0000 (14:48 -0500)]
[flang] Use CMake to determine endianness.

The preprocessor definitions __BYTE_ORDER__, __ORDER_BIG_ENDIAN__, and
__ORDER_LITTLE_ENDIAN__ are gcc extensions (also supported by clang),
but msvc (and others) do not define them. As a result __BYTE_ORDER__
and __ORDER_BIG_ENDIAN__ both evaluate to 0 by the prepreprocessor,
and __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__, the first `#if` condition
to 1, hence assuming the wrong byte order for x86(_64).

This patch instead uses CMake's TestBigEndian module to determine
target architecture's endianness at configure-time.

Note this also uses the same mechanism for the runtime. If compiling
flang as a cross-compiler, the runtime for the compile-target must be
built separately (Flang does not support the LLVM_ENABLE_RUNTIMES
mechanism yet).

Fixes llvm.org/PR51597

Reviewed By: ijan1, Leporacanthicus

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

3 years ago[libc] fix strtointeger hex prefix parsing
Michael Jones [Wed, 1 Sep 2021 20:09:29 +0000 (20:09 +0000)]
[libc] fix strtointeger hex prefix parsing

Fix edge case where "0x" would be considered a complete hexadecimal
number for purposes of str_end. Now the hexadecimal prefix needs a valid
digit after it, else just the 0 will be counted as the number.

Reviewed By: sivachandra

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

3 years ago[mlir][sparse] add convenience method for sparse tensor setup
Aart Bik [Fri, 3 Sep 2021 18:23:38 +0000 (11:23 -0700)]
[mlir][sparse] add convenience method for sparse tensor setup

This simplifies setting up sparse tensors through C-style data structures.
Useful for runtimes that want to interact with MLIR-generated code
without knowning about all bufferization details (viz. memrefs).

Reviewed By: bixia

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

3 years ago[NFC][OpenMP] Use clang_cc1 to driver tests
Jinsong Ji [Fri, 3 Sep 2021 20:33:47 +0000 (20:33 +0000)]
[NFC][OpenMP] Use clang_cc1 to driver tests

The test driver-fopenmp-extensions.c is failing on platforms that does
not use integrated-as. It can be reproduced using -fno-integrated-as on
Linux too.

bin/clang -c -Xclang -verify=omp -fopenmp      -fopenmp-extensions
-fno-openmp-extensions
../llvm-project/clang/test/OpenMP/driver-fopenmp-extensions.c
-fno-integrated-as
Assembler messages:
Error: can't open /tmp/driver-fopenmp-extensions-8fafe8.s for reading:
No such file or directory
clang-14: error: assembler command failed with exit code 1 (use -v to
see invocation)

The goal of this test is to verify syntax diags only,
so we should use clang_cc1 to test.

Reviewed By: jdenny, ABataev

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

3 years ago[lldb] Adjust parse_frames for unnamed images
Jonas Devlieghere [Fri, 3 Sep 2021 20:23:03 +0000 (13:23 -0700)]
[lldb] Adjust parse_frames for unnamed images

Follow up to 2cbd3b04feaaaff7fab4c6500476839a23180886 which added
support for unnamed images but missed the use case in parse_frames.

3 years ago[libc++] Add an assertion in the subrange constructors with a size hint
Louis Dionne [Fri, 27 Aug 2021 16:04:58 +0000 (12:04 -0400)]
[libc++] Add an assertion in the subrange constructors with a size hint

Those constructors are very easy to misuse -- one could easily think that
the size passed to the constructor is the size of the range to exhibit
from the subrange. Instead, it's a size hint and it's UB to get it wrong.
Hence, when it's cheap to compute the real size of the range, it's cheap
to make sure that the user didn't get it wrong.

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

3 years agoRevert "[Coroutines] [Clang] Look up coroutine component in std namespace first"
Louis Dionne [Fri, 3 Sep 2021 20:01:09 +0000 (16:01 -0400)]
Revert "[Coroutines] [Clang] Look up coroutine component in std namespace first"

This reverts commit 2fbd254aa46b, which broke the libc++ CI. I'm reverting
to get things stable again until we've figured out a way forward.

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

3 years agoDebugInfo: Correct/improve type formatting (pointers to function types especially)
David Blaikie [Fri, 3 Sep 2021 19:18:13 +0000 (12:18 -0700)]
DebugInfo: Correct/improve type formatting (pointers to function types especially)

This does add some extra superfluous whitespace (eg: "int *") intended
to make the Simplified Template Names work easier - this makes the
DIE-based names match more exactly the clang-generated names, so it's
easier to identify cases that don't generate matching names.

(arguably we could change clang to skip that whitespace or add some
fuzzy matching to accommodate differences in certain whitespace - but
this seemed easier and fairly low-impact)

3 years ago[SampleFDO] Fix -Wnon-virtual-dtor
Rong Xu [Fri, 3 Sep 2021 19:19:03 +0000 (12:19 -0700)]
[SampleFDO] Fix -Wnon-virtual-dtor

Make the dtor virtual to fix the warning.

3 years ago[libc++][NFC] Mark values in gdb pretty print comparison functions as live to prevent...
Amy Kwan [Fri, 3 Sep 2021 18:53:57 +0000 (14:53 -0400)]
[libc++][NFC] Mark values in gdb pretty print comparison functions as live to prevent values being optimized out.

It appears when testing LLVM 13 on Power, we run into failures with the
`libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp` test case optimizing
values out.

Despite some the functions in the test already being marked with optnone,
adding the `MarkAsLive()` calls inside of the pretty printer comparison functions
resolves the issues of the values being optimized out.

This patch aims to address https://llvm.org/PR51675.

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

3 years ago[InstCombine] fold (rotate X) eq/ne (0/-1)
Sanjay Patel [Fri, 3 Sep 2021 18:35:10 +0000 (14:35 -0400)]
[InstCombine] fold (rotate X) eq/ne (0/-1)

This generalizes the examples shown in:
https://llvm.org/PR51566

https://alive2.llvm.org/ce/z/V-sEy9

3 years ago[InstCombine] reduce code duplication; NFC
Sanjay Patel [Fri, 3 Sep 2021 18:04:32 +0000 (14:04 -0400)]
[InstCombine] reduce code duplication; NFC

3 years ago[InstCombine] add tests for icmp of rotate (PR51566); NFC
Sanjay Patel [Fri, 3 Sep 2021 16:50:43 +0000 (12:50 -0400)]
[InstCombine] add tests for icmp of rotate (PR51566); NFC

3 years ago[compiler-rt][Profile] Wait for child threads in set-file-object test
David Spickett [Fri, 3 Sep 2021 18:48:06 +0000 (11:48 -0700)]
[compiler-rt][Profile] Wait for child threads in set-file-object test

We've been seeing this test return 31 instead of 32 for the "functions"
line in this test on our AArch64 bots.

One possible cause is some of the children not finishing in time
before the llvm-profdata commands are run, if the machine is heavily loaded.

Wait for all the children to finish before exiting the parent.

Reviewed By: zequanwu

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

3 years ago[clang] fix error recovery ICE on copy elision when returing invalid variable
Matheus Izvekov [Thu, 2 Sep 2021 20:21:51 +0000 (22:21 +0200)]
[clang] fix error recovery ICE on copy elision when returing invalid variable

See PR51708.

Attempting copy elision in dependent contexts with invalid variable,
such as a variable with incomplete type, would cause a crash when attempting
to calculate it's alignment.

The fix is to just skip this optimization on invalid VarDecl, as otherwise this
provides no benefit to error recovery: This functionality does not try to
diagnose anything, it only calculates a flag which will affect where the
variable will be allocated during codegen.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Reviewed By: rtrieu

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

3 years ago[AMDGPU] Small cleanup in optimizeCompareInstr. NFC.
Stanislav Mekhanoshin [Fri, 3 Sep 2021 18:21:02 +0000 (11:21 -0700)]
[AMDGPU] Small cleanup in optimizeCompareInstr. NFC.

3 years ago[libc++] Remove _LIBCPP_HAS_NO_LONG_LONG in favour of using_if_exists
Louis Dionne [Tue, 24 Aug 2021 14:30:39 +0000 (10:30 -0400)]
[libc++] Remove _LIBCPP_HAS_NO_LONG_LONG in favour of using_if_exists

_LIBCPP_HAS_NO_LONG_LONG was only defined on FreeBSD. Instead, use the
using_if_exists attribute to skip over declarations that are not available
on the base system. Note that there's an annoying limitation that we can't
conditionally define a function based on whether the base system provides
a function, so for example we still need preprocessor logic to define the
abs() and div() overloads.

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

3 years ago[libc++abi] Remove workarounds for missing -Wno-exceptions on older GCCs
Louis Dionne [Thu, 2 Sep 2021 20:23:36 +0000 (16:23 -0400)]
[libc++abi] Remove workarounds for missing -Wno-exceptions on older GCCs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97675 has now been resolved
in GCC 11, so we can remove those workarounds.

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

3 years ago[ARM] Add patterns for store(fptosisat(..))
David Green [Fri, 3 Sep 2021 18:22:11 +0000 (19:22 +0100)]
[ARM] Add patterns for store(fptosisat(..))

As an extension to D107866, this adds store(fptosisat(..)) patterns,
similar to the existing fptosi patterns, to prevent unnecessarily moving
into gpr regs where we can use fp stores directly.

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

3 years ago[gn build] Reformat all files
Nico Weber [Fri, 3 Sep 2021 18:17:26 +0000 (14:17 -0400)]
[gn build] Reformat all files

Ran `git ls-files '*.gn' '*.gni' | xargs llvm/utils/gn/gn.py format`.

3 years ago[NFC][DWARF] Add triple to new TAG test file
Jinsong Ji [Fri, 3 Sep 2021 18:12:46 +0000 (18:12 +0000)]
[NFC][DWARF] Add triple to new TAG test file

The file is requiring x86, but using llc without triple.

This will cause problem on non-x86 platforms, as the default triple will
not be x86.

eg: On PowerPC le, it will emit warnings as:

'x86-64' is not a recognized processor for this target (ignoring
processor)
'+cx8' is not a recognized feature for this target (ignoring feature)
'+fxsr' is not a recognized feature for this target (ignoring feature)
'+mmx' is not a recognized feature for this target (ignoring feature)
'+sse' is not a recognized feature for this target (ignoring feature)
..

On some other platform, it may even crash -- if some of the feature are
with same name (eg: soft-float).

Add the triple as this was the intention test target.

3 years ago[modules] Use `HashBuilder` and `MD5` for the module hash.
Alexandre Rames [Fri, 3 Sep 2021 18:12:27 +0000 (11:12 -0700)]
[modules] Use `HashBuilder` and `MD5` for the module hash.

Per the comments, `hash_code` values "are not stable to save or
persist", so are unsuitable for the module hash, which must persist
across compilations for the implicit module hashes to match. Note that
in practice, today, `hash_code` are stable. But this is an
implementation detail, with a clear `FIXME` indicating we should switch
to a per-execution seed.

The stability of `MD5` also allows modules cross-compilation use-cases.
The `size_t` underlying storage for `hash_code` varying across platforms
could cause mismatching hashes when cross-compiling from a 64bit
target to a 32bit target.

Note that native endianness is still used for the hash computation. So hashes
will differ between platforms of different endianness.

Reviewed By: jansvoboda11

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

3 years ago[flang] Move runtime API headers to flang/include/flang/Runtime
Peter Klausler [Wed, 1 Sep 2021 23:00:53 +0000 (16:00 -0700)]
[flang] Move runtime API headers to flang/include/flang/Runtime

Move the closure of the subset of flang/runtime/*.h header files that
are referenced by source files outside flang/runtime (apart from unit tests)
into a new directory (flang/include/flang/Runtime) so that relative
include paths into ../runtime need not be used.

flang/runtime/pgmath.h.inc is moved to flang/include/flang/Evaluate;
it's not used by the runtime.

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

3 years ago[NFC][CSSPGO] Add end of file newline to test input
Jinsong Ji [Fri, 3 Sep 2021 17:40:01 +0000 (17:40 +0000)]
[NFC][CSSPGO] Add end of file newline to test input

On some platform (eg: AIX), diff will complain about newline.

diff: Missing newline at the end of file
.../llvm/test/tools/llvm-profdata/Inputs/cs-sample.proftext.

3 years ago[gn build] Port b9e57e030560
LLVM GN Syncbot [Fri, 3 Sep 2021 17:37:49 +0000 (17:37 +0000)]
[gn build] Port b9e57e030560

3 years ago[lldb/Plugins] Introduce Scripted Interface Factory
Med Ismail Bennani [Fri, 3 Sep 2021 17:35:02 +0000 (17:35 +0000)]
[lldb/Plugins] Introduce Scripted Interface Factory

This patch splits the previous `ScriptedProcessPythonInterface` into
multiple specific classes:

1. The `ScriptedInterface` abstract class that carries the interface
   instance object and its virtual pure abstract creation method.

2. The `ScriptedPythonInterface` that holds a generic `Dispatch` method that
   can be used by various interfaces to call python methods and also keeps a
   reference to the Python Script Interpreter instance.

3. The `ScriptedProcessInterface` that describes the base Scripted
   Process model with all the methods used in the underlying script.

All these components are used to refactor the `ScriptedProcessPythonInterface`
class, making it more modular.

This patch is also a requirement for the upcoming work on `ScriptedThread`.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
3 years agoRevert "[analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire...
Jessica Paquette [Fri, 3 Sep 2021 17:28:07 +0000 (10:28 -0700)]
Revert "[analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire function calls, rather than each ExplodedNode in it"

This reverts commit a375bfb5b729e0f3ca8d5e001f423fa89e74de87.

This was causing a bot to crash:

https://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/23380/

3 years ago[libc++][NFC] Remove uses of 'using namespace std;' in the test suite
Louis Dionne [Wed, 1 Sep 2021 20:52:52 +0000 (16:52 -0400)]
[libc++][NFC] Remove uses of 'using namespace std;' in the test suite

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

3 years ago[ARM] Add VFP lowering for fptosi.sat
David Green [Fri, 3 Sep 2021 17:11:08 +0000 (18:11 +0100)]
[ARM] Add VFP lowering for fptosi.sat

This extends D107865 to the VFP insructions, lowering llvm.fptosi.sat
and llvm.fptoui.sat to VCVT instructions that inherently perform the
saturate.

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

3 years agoAdd missing `REQUIRES: asserts` to combine-icmp-to-lhs-known-bits.mir
Jessica Paquette [Fri, 3 Sep 2021 16:25:37 +0000 (09:25 -0700)]
Add missing `REQUIRES: asserts` to combine-icmp-to-lhs-known-bits.mir

3 years ago[lld/mac] Don't assert during thunk insertion if there are undefined symbols
Nico Weber [Wed, 1 Sep 2021 18:28:51 +0000 (14:28 -0400)]
[lld/mac] Don't assert during thunk insertion if there are undefined symbols

We end up calling resolveBranchVA(), which asserts for Undefineds.

As fix, just return early in Writer::run() if there are any diagnostics
after processing relocations (which is where undefined symbol errors are
emitted). This matches what the ELF port does.

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

3 years ago[RISCV] Change how we encode AVL operands in vector pseudoinstructions to use GPRNoX0.
Craig Topper [Fri, 3 Sep 2021 16:05:15 +0000 (09:05 -0700)]
[RISCV] Change how we encode AVL operands in vector pseudoinstructions to use GPRNoX0.

This patch changes the register class to avoid accidentally setting
the AVL operand to X0 through MachineIR optimizations.

There are cases where we really want to use X0, but we can't get that
past the MachineVerifier with the register class as GPRNoX0. So I've
use a 64-bit -1 as a sentinel for X0. All other immediate values should
be uimm5. I convert it to X0 at the earliest possible point in the VSETVLI
insertion pass to avoid touching the rest of the algorithm. In
SelectionDAG lowering I'm using a -1 TargetConstant to hide it from
instruction selection and treat it differently than if the user
used -1. A user -1 should be selected to a register since it doesn't
fit in uimm5.

This is the rest of the changes started in D109110. As mentioned there,
I don't have a failing test from MachineIR optimizations anymore.

Reviewed By: frasercrmck

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

3 years ago[mlir][linalg] Extend tiled_loop to SCF conversion to generate scf.parallel.
Alexander Belyaev [Fri, 3 Sep 2021 15:41:40 +0000 (17:41 +0200)]
[mlir][linalg] Extend tiled_loop to SCF conversion to generate scf.parallel.

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

3 years ago[CMake] Add targets for generating coverage reports
Chris Bieneman [Tue, 31 Aug 2021 19:20:16 +0000 (12:20 -0700)]
[CMake] Add targets for generating coverage reports

This is a pretty small bit of CMake goop to generate code coverage
reports. I always forget the right script invocation and end up
fumbling around too much.

Wouldn't it be great to have targets that "Just Work"?

Well, I thought so.

At present this only really works correctly for LLVM, but I'll extend
it in subsequent patches to work for subprojects.

Reviewed By: phosek

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

3 years ago[clangd] Use the active file's language for hover code blocks
David Goldman [Mon, 23 Aug 2021 17:58:43 +0000 (13:58 -0400)]
[clangd] Use the active file's language for hover code blocks

This helps improve the syntax highlighting for Objective-C code,
although it currently doesn't work well in VS Code with
methods/properties/ivars since we don't currently include the proper
decl context (e.g. class).

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

3 years ago[mlir][sparse] refine heuristic for iteration graph topsort
Aart Bik [Wed, 1 Sep 2021 22:29:52 +0000 (15:29 -0700)]
[mlir][sparse] refine heuristic for iteration graph topsort

The sparse index order must always be satisfied, but this
may give a choice in topsorts for several cases. We broke
ties in favor of any dense index order, since this gives
good locality. However, breaking ties in favor of pushing
unrelated indices into sparse iteration spaces gives better
asymptotic complexity. This revision improves the heuristic.

Note that in the long run, we are really interested in using
ML for ML to find the best loop ordering as a replacement for
such heuristics.

Reviewed By: bixia

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

3 years ago[mlir] Update EmitC documentation
Marius Brehler [Fri, 3 Sep 2021 15:22:24 +0000 (15:22 +0000)]
[mlir] Update EmitC documentation

3 years agoRemove blank from NaN string representation
V Donaldson [Wed, 1 Sep 2021 01:26:58 +0000 (18:26 -0700)]
Remove blank from NaN string representation

Flang front end function DumpHexadecimal generates a string
representation of a REAL value.  When the value is a NaN, the string
contains a blank, as in "NaN 0x7fc00000".  This function is used by
lowering to generate a string that is then passed to llvm Support
function convertFromStringSpecials, which does not expect a blank
in the string.  Remove the blank to allow correct recognition of a
NaN by this llvm function.

Note that function DumpHexadecimal is not exercised by the front end
itself.  This functionality is only exercised by code that is not yet
present in llvm.

3 years ago[CUDA][NFC] Fix wrong assert information
Ben Shi [Fri, 3 Sep 2021 14:33:47 +0000 (22:33 +0800)]
[CUDA][NFC] Fix wrong assert information

Reviewed By: fodinabor

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

3 years ago[lldb] [test] Mark the remaining vfork-follow-child test unsupported (flaky) on aarch64
Michał Górny [Fri, 3 Sep 2021 14:30:25 +0000 (16:30 +0200)]
[lldb] [test] Mark the remaining vfork-follow-child test unsupported (flaky) on aarch64

3 years ago[lldb] [test] Mark vfork-follow-child-* tests unsupported (flaky) on aarch64
Michał Górny [Fri, 3 Sep 2021 14:04:03 +0000 (16:04 +0200)]
[lldb] [test] Mark vfork-follow-child-* tests unsupported (flaky) on aarch64

3 years agoRevert "[NFC] Recommit "Regenerate SVE ACLE intrinsics tests""
Nico Weber [Fri, 3 Sep 2021 13:24:19 +0000 (09:24 -0400)]
Revert "[NFC] Recommit "Regenerate SVE ACLE intrinsics tests""

This reverts commit 91eda9c30f33da6ec6da70b59a5f5da6c6397039.
Breaks tests on macOS, both intel and arm. See e.g.
https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket/8837137028177680097/+/u/package_clang/stdout?format=raw
https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket/8837137028177680081/+/u/package_clang/stdout?format=raw
http://45.33.8.238/macm1/17258/step_7.txt
http://45.33.8.238/mac/35004/step_7.txt

3 years ago[lldb] Support .debug_rnglists.dwo sections in dwp file
Kim-Anh Tran [Fri, 3 Sep 2021 12:57:45 +0000 (14:57 +0200)]
[lldb] Support .debug_rnglists.dwo sections in dwp file

This patch considers the CU index entry
when reading the .debug_rnglists.dwo section.

Reviewed By: jankratochvil

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

3 years agoRevert "[gn build] (manually) port 6fe2beba7d2a (ExceptionTests)"
Nico Weber [Fri, 3 Sep 2021 13:19:11 +0000 (09:19 -0400)]
Revert "[gn build] (manually) port 6fe2beba7d2a (ExceptionTests)"

This reverts commit da47c2719b1094a29427917ddb157c9c716e876d.
6fe2beba7d2a was reverted in 885964046114.

3 years agoRevert "Reland "[clang-repl] Re-implement clang-interpreter as a test case.""
Vassil Vassilev [Fri, 3 Sep 2021 13:17:52 +0000 (13:17 +0000)]
Revert "Reland "[clang-repl] Re-implement clang-interpreter as a test case.""

This reverts commit 6fe2beba7d2a41964af658c8c59dd172683ef739 which fails on
clang-hexagon-elf

3 years ago[gn build] (manually) port 6fe2beba7d2a (ExceptionTests)
Nico Weber [Wed, 1 Sep 2021 12:31:11 +0000 (08:31 -0400)]
[gn build] (manually) port 6fe2beba7d2a (ExceptionTests)

3 years ago[compiler-rt][Profile] Disable test on Arm/AArch64 Linux
David Spickett [Fri, 3 Sep 2021 12:58:09 +0000 (12:58 +0000)]
[compiler-rt][Profile] Disable test on Arm/AArch64 Linux

While a fix for flaky results is being reviewed.

3 years ago[ORC] Static cast more uint64_t to size_t
David Spickett [Fri, 3 Sep 2021 12:27:05 +0000 (12:27 +0000)]
[ORC] Static cast more uint64_t to size_t

These instances don't have an obvious way to fail
nicely so I've just asserted they are within range.

Fixes the Arm 32 bit builds.

3 years agoReland "[clang-repl] Re-implement clang-interpreter as a test case."
Vassil Vassilev [Fri, 3 Sep 2021 09:37:13 +0000 (09:37 +0000)]
Reland "[clang-repl] Re-implement clang-interpreter as a test case."
Original commit message: "
    Original commit message:"
      The current infrastructure in lib/Interpreter has a tool, clang-repl, very
      similar to clang-interpreter which also allows incremental compilation.

      This patch moves clang-interpreter as a test case and drops it as conditionally
      built example as we already have clang-repl in place.

      Differential revision: https://reviews.llvm.org/D107049
    "

    This patch also ignores ppc due to missing weak symbol for __gxx_personality_v0
    which may be a feature request for the jit infrastructure. Also, adds a missing
    build system dependency to the orc jit.
"

Additionally, this patch defines a custom exception type and thus avoids the
requirement to include header <exception>, making it easier to deploy across
systems without standard location of the c++ headers.

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

3 years ago[gn build] Port a375bfb5b729
LLVM GN Syncbot [Fri, 3 Sep 2021 11:51:19 +0000 (11:51 +0000)]
[gn build] Port a375bfb5b729

3 years ago[analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire function...
Kristóf Umann [Thu, 19 Aug 2021 13:37:02 +0000 (15:37 +0200)]
[analyzer][NFCI] Allow clients of NoStateChangeFuncVisitor to check entire function calls, rather than each ExplodedNode in it

D105553 added NoStateChangeFuncVisitor, an abstract class to aid in creating
notes such as "Returning without writing to 'x'", or "Returning without changing
the ownership status of allocated memory". Its clients need to define, among
other things, what a change of state is.

For code like this:

f() {
  g();
}

foo() {
  f();
  h();
}

We'd have a path in the ExplodedGraph that looks like this:

             -- <g> -->
            /          \
         ---     <f>    -------->        --- <h> --->
        /                        \      /            \
--------        <foo>             ------    <foo>     -->

When we're interested in whether f neglected to change some property,
NoStateChangeFuncVisitor asks these questions:

                       ÷×~
                -- <g> -->
           ß   /          \$    @&#*
            ---     <f>    -------->        --- <h> --->
           /                        \      /            \
   --------        <foo>             ------    <foo>     -->

Has anything changed in between # and *?
Has anything changed in between & and *?
Has anything changed in between @ and *?
...
Has anything changed in between $ and *?
Has anything changed in between × and ~?
Has anything changed in between ÷ and ~?
...
Has anything changed in between ß and *?
...
This is a rather thorough line of questioning, which is why in D105819, I was
only interested in whether state *right before* and *right after* a function
call changed, and early returned to the CallEnter location:

if (!CurrN->getLocationAs<CallEnter>())
  return;
Except that I made a typo, and forgot to negate the condition. So, in this
patch, I'm fixing that, and under the same hood allow all clients to decide to
do this whole-function check instead of the thorough one.

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

3 years ago[LoopDeletion] Move ICmpInst handling to getValueOnFirstIteration()
Max Kazantsev [Fri, 3 Sep 2021 09:32:47 +0000 (16:32 +0700)]
[LoopDeletion] Move ICmpInst handling to getValueOnFirstIteration()

As noticed in https://reviews.llvm.org/D105688, it would be great to move
handling of ICmpInst which was in canProveExitOnFirstIteration() to
getValueOnFirstIteration().

Patch by Dmitry Makogon!

Differential Revision: https://reviews.llvm.org/D108978
Reviewed By: reames