platform/upstream/llvm.git
2 years ago[mlir][linalg] Fix `FoldInitTensorWithDimOp` if dim(init_tensor) is static.
Alexander Belyaev [Fri, 3 Sep 2021 17:06:15 +0000 (19:06 +0200)]
[mlir][linalg] Fix `FoldInitTensorWithDimOp` if dim(init_tensor) is static.

It looks like it was a typo. Instead of `*maybeConstantIndex`,
`initTensorOp.getStaticSize(*maybeConstantIndex)` should be used to access the
dim size of the tensor. There is a test for that in `canonicalize.mlir`, but it
was working correctly because `ReplaceStaticShapeDims` was canonicalizing DimOp
before `FoldInitTensorWithDimOp`. So, to make the patterns more "orthogonal",
this case is disabled.

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

2 years agoRevert "[compiler-rt][Profile] Disable test on Arm/AArch64 Linux"
David Spickett [Mon, 6 Sep 2021 08:45:06 +0000 (08:45 +0000)]
Revert "[compiler-rt][Profile] Disable test on Arm/AArch64 Linux"

This reverts commit 8b86f8a3256a59cbaa12858cb0842025d48f549f.

The inconsistent behaviour has been fixed with
5e50d3073a5ead122a731580ded3f1cb3c21ee54.

2 years ago[RuntimeDyld] Implemented relocation of TLS symbols in ELF
Moritz Sichert [Fri, 27 Aug 2021 13:51:58 +0000 (15:51 +0200)]
[RuntimeDyld] Implemented relocation of TLS symbols in ELF

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

2 years ago[RuntimeDyld] Implemented relocation for ELF::R_X86_64_GOTPC32
Moritz Sichert [Fri, 30 Oct 2020 10:36:53 +0000 (11:36 +0100)]
[RuntimeDyld] Implemented relocation for ELF::R_X86_64_GOTPC32

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

2 years ago[Flang] Ported test_errors.sh to Python
Ivan Zhechev [Mon, 6 Sep 2021 08:19:20 +0000 (08:19 +0000)]
[Flang] Ported test_errors.sh to Python

To enable Flang testing on Windows, shell scripts have to be ported to Python. In this patch the "test_errors.sh" script is ported to python ("test_errors.py"). The RUN line of existing tests was changed to make use of the python script.

Used python regex in place of awk/sed.

Reviewed By: Meinersbur

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

2 years ago[clang-nvlink-wrapper] Add documentation in clang docs
Saiyedul Islam [Fri, 3 Sep 2021 11:14:22 +0000 (16:44 +0530)]
[clang-nvlink-wrapper] Add documentation in clang docs

Add documentation of clang-nvlink-wrapper tool in clang.
Add it to the release notes of clang. Fix a small MSVC
warning.

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

2 years ago[mlir][docs] Complement list of supported scf ops
Marius Brehler [Mon, 6 Sep 2021 05:51:36 +0000 (05:51 +0000)]
[mlir][docs] Complement list of supported scf ops

2 years ago[AArch64] Remove an uneeded !NeedsWinCFI check. NFC
Fangrui Song [Mon, 6 Sep 2021 04:02:56 +0000 (21:02 -0700)]
[AArch64] Remove an uneeded !NeedsWinCFI check. NFC

2 years ago[AArch64][GlobalISel] Use ZExtValue for zext(xor) when invert tb(n)z
guopeilin [Mon, 6 Sep 2021 03:11:23 +0000 (11:11 +0800)]
[AArch64][GlobalISel] Use ZExtValue for zext(xor) when invert tb(n)z

Currently, we use SExtValue to decide whether to invert tbz or tbnz.
However, for the case zext (xor x, c), we should use ZExt rather
than SExt otherwise we will generate totally opposite branches.

Reviewed By: paquette

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

2 years ago[gn build] Port 8ce2675b1363
LLVM GN Syncbot [Sun, 5 Sep 2021 19:38:22 +0000 (19:38 +0000)]
[gn build] Port 8ce2675b1363

2 years ago[libc++][compare] Implement three_way_comparable[_with] concepts
Ruslan Arutyunyan [Sun, 5 Sep 2021 03:16:18 +0000 (20:16 -0700)]
[libc++][compare] Implement three_way_comparable[_with] concepts

Implementation of `three_way_comparable` and `three_way_comparable_with` concepts from <compare> header.

Please note that I have temporarily removed `<compare>` header from `<utility>` due to cyclic dependency that prevents using `<concepts>` header in `<compare>` one.

I tried to quickly resolve those issues including applying suggestions from @cjdb and dive deeper by myself but the problem seems more complicated that we thought initially.

I am in progress to prepare the patch with resolving this cyclic dependency between headers but for now I decided to put all that I have to the review to unblock people that depend on that functionality. At first glance the patch with resolving cyclic dependency is not so small (unless I find the way to make it smaller and cleaner) so I don't want to mix everything to one review.

Reviewed By: ldionne, cjdb, #libc, Quuxplusone

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

2 years ago[Bazel] Add missing dependency after 650bbc56203c947bb85176c40ca9c7c7a91c3c57
Benjamin Kramer [Sun, 5 Sep 2021 19:13:03 +0000 (21:13 +0200)]
[Bazel] Add missing dependency after 650bbc56203c947bb85176c40ca9c7c7a91c3c57

2 years ago[test] Remove some legacy PM tests in llvm/test/Instrumentation/AddressSanitizer
Arthur Eubanks [Sun, 5 Sep 2021 19:02:31 +0000 (12:02 -0700)]
[test] Remove some legacy PM tests in llvm/test/Instrumentation/AddressSanitizer

2 years ago[test] Remove some legacy PM tests in llvm/test/Instrumentation
Arthur Eubanks [Sun, 5 Sep 2021 18:51:19 +0000 (11:51 -0700)]
[test] Remove some legacy PM tests in llvm/test/Instrumentation

2 years ago[test] Remove -loop-guard-widening legacy PM tests
Arthur Eubanks [Sun, 5 Sep 2021 18:36:21 +0000 (11:36 -0700)]
[test] Remove -loop-guard-widening legacy PM tests

2 years ago[clang-tidy] Drop unnecessary const from return types (NFC)
Kazu Hirata [Sun, 5 Sep 2021 15:37:27 +0000 (08:37 -0700)]
[clang-tidy] Drop unnecessary const from return types (NFC)

Identified with readability-const-return-type.

2 years ago[DAG] Remove oneuse check in select_cc setgt X, -1, C, ~C fold
David Green [Sun, 5 Sep 2021 15:18:31 +0000 (16:18 +0100)]
[DAG] Remove oneuse check in select_cc setgt X, -1, C, ~C fold

This appears to produce better code, even if the condition may need to
be replicated.

2 years ago[CostModel][X86] Add generic costs for vXi32 MUL -> v2Xi16 PMADDDW folds
Simon Pilgrim [Sun, 5 Sep 2021 15:08:03 +0000 (16:08 +0100)]
[CostModel][X86] Add generic costs for vXi32 MUL -> v2Xi16 PMADDDW folds

Based off the improved fold in D108522

This should eventually allow us to replace the SLM only cost patterns with generic versions.

2 years ago[CostModel][X86] Add vXi32 multiply pattern tests
Simon Pilgrim [Sat, 4 Sep 2021 14:44:41 +0000 (15:44 +0100)]
[CostModel][X86] Add vXi32 multiply pattern tests

Add tests for vXi32 multiplies where the operands have been extended from vXi8/vXi16

2 years ago[DAG] Fold select_cc setgt X, -1, C, ~C -> xor (ashr X, BW-1), C
David Green [Sun, 5 Sep 2021 15:04:01 +0000 (16:04 +0100)]
[DAG] Fold select_cc setgt X, -1, C, ~C -> xor (ashr X, BW-1), C

Given a select_cc producing a constant and a invertion of the constant
for a comparison more than zero, we can produce an xor with ashr
instead, which produces smaller code. The ashr either sets all bits or
clear all bits depending on if the value is negative. This is then xor'd
with the constant to optionally negate the value.
https://alive2.llvm.org/ce/z/DTFaBZ

This includes a OneUseCheck on the Cmp, which seems to make thinks a
little worse and will be removed in a followup.

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

2 years ago[DAG] Fold setcc eq with ashr to compare to zero.
David Green [Sun, 5 Sep 2021 13:06:47 +0000 (14:06 +0100)]
[DAG] Fold setcc eq with ashr to compare to zero.

Pulled out of D109149, this folds set_cc seteq (ashr X, BW-1), -1 ->
set_cc setlt X, 0 to prevent some regressions later on when folding
select_cc setgt X, -1, C, ~C -> xor (ashr X, BW-1), C

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

2 years ago[InstCombine] stpcpy(d,s) -> strcpy(d,s) if the result is not used
Dávid Bolvanský [Sun, 5 Sep 2021 10:12:07 +0000 (12:12 +0200)]
[InstCombine] stpcpy(d,s) -> strcpy(d,s) if the result is not used

2 years ago[DAG] Add tests for select_cc and setcc with constant patterns.
David Green [Sun, 5 Sep 2021 09:17:21 +0000 (10:17 +0100)]
[DAG] Add tests for select_cc and setcc with constant patterns.

2 years ago[libc][Obvious] Reorder CMakelists alphabetically.
Cheng Wang [Sun, 5 Sep 2021 02:38:31 +0000 (10:38 +0800)]
[libc][Obvious] Reorder CMakelists alphabetically.

2 years ago[libc][Obvious] Fix typos
Cheng Wang [Sat, 4 Sep 2021 12:14:54 +0000 (20:14 +0800)]
[libc][Obvious] Fix typos

2 years ago[OpenMP][OpenMPIRBuilder] Implement loop unrolling.
Michael Kruse [Sat, 4 Sep 2021 23:50:49 +0000 (18:50 -0500)]
[OpenMP][OpenMPIRBuilder] Implement loop unrolling.

Recommit of 707ce34b06190e275572c3c46843036db1bab6d1. Don't introduce a
dependency to the LLVMPasses component, instead register the required
passes individually.

Add methods for loop unrolling to the OpenMPIRBuilder class and use them in Clang if `-fopenmp-enable-irbuilder` is enabled. The unrolling methods are:

 * `unrollLoopFull`
 * `unrollLoopPartial`
 * `unrollLoopHeuristic`

`unrollLoopPartial` and `unrollLoopHeuristic` can use compiler heuristics to automatically determine the unroll factor. If possible, that is if no CanonicalLoopInfo is required to pass to another method, metadata for LLVM's LoopUnrollPass is added. Otherwise the unroll factor is determined using the same heurstics as user by LoopUnrollPass. Not requiring a CanonicalLoopInfo, especially with `unrollLoopHeuristic` allows greater flexibility.

With full unrolling and partial unrolling with known unroll factor, instead of duplicating instructions by the OpenMPIRBuilder, the full unroll is still delegated to the LoopUnrollPass. In case of partial unrolling the loop is first tiled using the existing `tileLoops` methods, then the inner loop fully unrolled using the same mechanism.

Reviewed By: jdoerfert, kiranchandramohan

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

2 years ago[test] Fixup tests with -analyze in llvm/test/Transforms
Arthur Eubanks [Sat, 4 Sep 2021 23:43:53 +0000 (16:43 -0700)]
[test] Fixup tests with -analyze in llvm/test/Transforms

2 years ago[M68k][test] Migrate the remaining fixup and relaxation tests
Min-Yih Hsu [Sat, 4 Sep 2021 23:06:33 +0000 (16:06 -0700)]
[M68k][test] Migrate the remaining fixup and relaxation tests

Migrate the tests regarding fixup and relaxation on branch and call
targets.
This patch wraps up the migration from `test/CodeGen/M68k/Encoding` to
`test/MC/M68k`.

2 years ago[test] Cleanup tests with -enable-new-pm in llvm/test/Analysis
Arthur Eubanks [Sat, 4 Sep 2021 23:06:10 +0000 (16:06 -0700)]
[test] Cleanup tests with -enable-new-pm in llvm/test/Analysis

2 years ago[test] Cleanup legacy PM tests in llvm/test/Analyis/ScalarEvolution
Arthur Eubanks [Sat, 4 Sep 2021 22:57:30 +0000 (15:57 -0700)]
[test] Cleanup legacy PM tests in llvm/test/Analyis/ScalarEvolution

2 years ago[test] Cleanup legacy PM tests in llvm/test/DebugInfo
Arthur Eubanks [Sat, 4 Sep 2021 22:52:43 +0000 (15:52 -0700)]
[test] Cleanup legacy PM tests in llvm/test/DebugInfo

2 years ago[SLP][Test] Add tests for PR47624 and PR49933
Anton Afanasyev [Sat, 4 Sep 2021 10:21:02 +0000 (13:21 +0300)]
[SLP][Test] Add tests for PR47624 and PR49933

Add tests monitoring issues fix. They should be fixed when
https://reviews.llvm.org/D57059 ("Initial support for the vectorization
of the non-power-of-2 vectors") is landed.

2 years ago[lld-macho] Initialize LTO backend with diagnostic handler
Jez Ng [Sat, 4 Sep 2021 21:40:07 +0000 (17:40 -0400)]
[lld-macho] Initialize LTO backend with diagnostic handler

Failing to do so results in `std::bad_function_call` being
thrown when a pass tries to emit a diagnostic.

I've copied the relevant test over from LLD-ELF's test suite.

Reviewed By: #lld-macho, thevinster

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

2 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.

2 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.

2 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

2 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.

2 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

2 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

2 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 $

2 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.

2 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

2 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.

2 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.

2 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.

2 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

2 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.

2 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.

2 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.

2 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

2 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.

2 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.

2 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.

2 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.

2 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

2 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

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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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

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

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

2 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.

2 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

2 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

2 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.

2 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

2 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.

2 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.

2 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>
2 years agoOpenBSD also needs execinfo
Brad Smith [Fri, 3 Sep 2021 21:31:26 +0000 (17:31 -0400)]
OpenBSD also needs execinfo

2 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

2 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

2 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

2 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

2 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

2 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

2 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

2 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.

2 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

2 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

2 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)

2 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.

2 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

2 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

2 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

2 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

2 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

2 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

2 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.

2 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

2 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

2 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