platform/upstream/llvm.git
2 years agostop llvm-reduce from introducing undefs
John Regehr [Tue, 21 Jun 2022 23:30:52 +0000 (17:30 -0600)]
stop llvm-reduce from introducing undefs

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

2 years ago[mlir][linalg] move isElementwise() to Linalg/Utils (NFC)
Okwan Kwon [Wed, 22 Jun 2022 22:59:53 +0000 (15:59 -0700)]
[mlir][linalg] move isElementwise() to Linalg/Utils (NFC)

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

2 years ago[ASan][Darwin] XFAIL test; atos does not show line numbers for globals
Julian Lettner [Thu, 23 Jun 2022 01:19:31 +0000 (18:19 -0700)]
[ASan][Darwin] XFAIL test; atos does not show line numbers for globals

atos currently doesn't show source line numbers for global variables, so
global-location.cpp is failing after we switched from ASan-specific
metadata to normal symbolication.

See:
https://reviews.llvm.org/D127552

2 years agoAMDGPU: Add missing implicit uses in tests
Matt Arsenault [Fri, 17 Jun 2022 22:24:28 +0000 (18:24 -0400)]
AMDGPU: Add missing implicit uses in tests

These tests were deleting the copy instruction, defeating
the purpose of having it.

2 years agoAMDGPU: Fix invalid liveness after si-optimize-exec-masking-pre-ra
Matt Arsenault [Fri, 10 Jun 2022 19:07:39 +0000 (15:07 -0400)]
AMDGPU: Fix invalid liveness after si-optimize-exec-masking-pre-ra

This was leaving behind a use at the deleted instruction which the
verifier would fail during allocation.

2 years agoInlineSpiller: Don't fold spills into undef reads
Matt Arsenault [Wed, 15 Jun 2022 21:04:05 +0000 (17:04 -0400)]
InlineSpiller: Don't fold spills into undef reads

This was producing a load into a dead register which was a verifier
error.

2 years ago[OpenMP] Add handling cases when filter(tid) appears with default(none)
Fazlay Rabbi [Thu, 23 Jun 2022 00:10:31 +0000 (17:10 -0700)]
[OpenMP] Add handling cases when filter(tid) appears with default(none)

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

2 years ago[SampleProfile][Inline] Annotate sample profile inline remarks with link phase (preli...
Mingming Liu [Wed, 1 Jun 2022 22:21:59 +0000 (15:21 -0700)]
[SampleProfile][Inline] Annotate sample profile inline remarks with link phase (prelink/postlink) information.

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

2 years ago[SVE] Make ISD::SPLAT_VECTOR a legal operation.
Paul Walker [Thu, 24 Feb 2022 18:40:23 +0000 (18:40 +0000)]
[SVE] Make ISD::SPLAT_VECTOR a legal operation.

The implication of this patch being AArch64ISD::DUP no longer
supports scalable vectors.

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

2 years ago[mlir][vulkan-runner] fix VK_ERROR_INCOMPATIBLE_DRIVER error
jackalcooper [Tue, 21 Jun 2022 16:28:36 +0000 (12:28 -0400)]
[mlir][vulkan-runner] fix VK_ERROR_INCOMPATIBLE_DRIVER error

On macOS, Vulkan is emulated by MoltenVK. Some extra flags are
required for "building robust and portable Vulkan based
applications that are good citizens in the Vulkan ecosystem".

More information:
https://vulkan.lunarg.com/doc/sdk/1.3.216.0/mac/getting_started.html

Reviewed By: antiagainst

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

2 years ago[libc++] Implement P0154R1 (Hardware inference size)
Nikolas Klauser [Wed, 22 Jun 2022 19:10:57 +0000 (21:10 +0200)]
[libc++] Implement P0154R1 (Hardware inference size)

`__GCC_CONSTRUCTIVE_SIZE` and `__GCC_DESTRUCTIVE_SIZE` are available since GCC 12. I'm assuming clang will also implement these for compatability with libstdc++.

Reviewed By: ldionne, #libc

Spies: h-vetinari, libcxx-commits, arichardson

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

2 years ago[libc++] Simplify the visibility attributes
Nikolas Klauser [Wed, 22 Jun 2022 09:14:04 +0000 (11:14 +0200)]
[libc++] Simplify the visibility attributes

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

2 years ago[ELF][test] Clean up thinlto*
Fangrui Song [Wed, 22 Jun 2022 23:19:17 +0000 (16:19 -0700)]
[ELF][test] Clean up thinlto*

2 years ago[MTE] [HWASan] Use LoopInfo for reachability queries.
Florian Mayer [Wed, 15 Jun 2022 22:31:05 +0000 (15:31 -0700)]
[MTE] [HWASan] Use LoopInfo for reachability queries.

The reachability queries default to "reachable" after exploring too many
basic blocks. LoopInfo helps it skip over the whole loop.

Reviewed By: eugenis

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

2 years ago[lldb/Fuzzer] Add command interpreter fuzzer for LLDB
Chelsea Cassanova [Tue, 21 Jun 2022 18:11:27 +0000 (14:11 -0400)]
[lldb/Fuzzer] Add command interpreter fuzzer for LLDB

This adds a command interpreter fuzzer to LLDB's fuzzing library.
The input data from the fuzzer is used as input for the command
interpreter.
Input data for the fuzzer is guided by a dictionary of keywords used in
LLDB, such as "breakpoint", "target" and others.

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

2 years agoFix a misspell. NFC
Adrian Tong [Wed, 22 Jun 2022 21:22:45 +0000 (21:22 +0000)]
Fix a misspell. NFC

2 years ago[StructurizeCFG] Improve basic block ordering
Brendon Cahoon [Wed, 6 Apr 2022 14:05:56 +0000 (09:05 -0500)]
[StructurizeCFG] Improve basic block ordering

StructurizeCFG linearizes the successors of branching basic block
by adding Flow blocks to record the true/false path for branches
and back edges. This patch reduces the number of Phi values needed
to capture the control flow path by improving the basic block
ordering.

Previously, StructurizeCFG adds loop exit blocks outside of the
loop. StructurizeCFG sets a boolean value to indicate the path
taken, and all exit block live values extend to after the loop.
For loops with a large number of exits blocks, this creates a
huge number of values that are maintained, which increases
compilation time and register pressure. This is problem
especially with ASAN, which adds early exits to blocks with
unreachable instructions for each instrumented check in the loop.

In specific cases, this patch reduces the number of values needed
after the loop by moving the exit block into the loop. This is
done for blocks that have a single predecessor and single successor
by moving the block to appear just after the predecessor.

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

2 years ago[lldb] Fix off-by-one error in the AppleObjCRuntimeV2 utility function
Jonas Devlieghere [Wed, 22 Jun 2022 20:46:00 +0000 (13:46 -0700)]
[lldb] Fix off-by-one error in the AppleObjCRuntimeV2 utility function

Fix an off-by-one error in the utility function used to extract the
dynamic class info. This resulted in a buffer overflow in the inferior
which interrupted our utility function.

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

2 years ago[lldb] Return the correct utility function in AppleObjCRuntimeV2
Jonas Devlieghere [Wed, 22 Jun 2022 20:39:56 +0000 (13:39 -0700)]
[lldb] Return the correct utility function in AppleObjCRuntimeV2

A copy/paste error in GetClassInfoUtilityFunction resulted in the wrong
utility function being returned: copyRealizedClassList instead of
getRealizedClassList_trylock.

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

2 years ago[UnifyLoopExits] Reduce number of guard blocks
Brendon Cahoon [Wed, 6 Apr 2022 01:53:46 +0000 (20:53 -0500)]
[UnifyLoopExits] Reduce number of guard blocks

UnifyLoopExits creates a single exit, a control flow hub, for
loops with multiple exits. There is an input to the block for
each loop exiting block and an output from the block for each
loop exit block. Multiple checks, or guard blocks, are needed
to branch to the correct exit block.

For large loops with lots of exit blocks, all the extra guard
blocks cause problems for StructurizeCFG and subsequent passes.
This patch reduces the number of guard blocks needed when the
exit blocks branch to a common block (e.g., an unreachable
block). The guard blocks are reduced by changing the inputs
and outputs of the control flow hub. The inputs are the exit
blocks and the outputs are the common block.

Reducing the guard blocks enables StructurizeCFG to reorder the
basic blocks in the CFG to reduce the values that exit a loop
with multiple exits. This reduces the compile-time of
StructurizeCFG and also reduces register pressure.

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

2 years agoRevert "[Attributor] Ensure to use the proper liveness AA"
Evgenii Stepanov [Wed, 22 Jun 2022 18:19:56 +0000 (11:19 -0700)]
Revert "[Attributor] Ensure to use the proper liveness AA"

Reason: memory leaks

This reverts commit 083010312aa4a0ba0cd5299bd3b039af8fb6d58f.

2 years ago[clang-tidy][docs] Fix a couple of missed cases from 6e566bc5523
Nathan James [Wed, 22 Jun 2022 20:37:16 +0000 (21:37 +0100)]
[clang-tidy][docs] Fix a couple of missed cases from 6e566bc5523

A few of the checks had documentation URLs that weren't updated in the aforementioned commit.

2 years ago[flang] Capture result interface of functions called in internal procedures
Valentin Clement [Wed, 22 Jun 2022 20:32:21 +0000 (22:32 +0200)]
[flang] Capture result interface of functions called in internal procedures

Character and array results are allocated on the caller side. This
require evaluating the result interface on the call site. When calling
such functions inside an internal procedure, it is possible that the
interface is defined in the host, in which case the lengths/bounds of
the function results must be captured so that they are available in
the internal function to emit the call.

To handle this case, extend the PFT symbol visit to visit the bounds and length
parameters of functions called in the internal procedure parse tree.

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

Reviewed By: klausler

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[clang-tidy][docs] Reorganise release notes
Nathan James [Wed, 22 Jun 2022 20:21:24 +0000 (21:21 +0100)]
[clang-tidy][docs] Reorganise release notes

2 years agoFix a bug with "process continue -b" when no breakpoints are
Jim Ingham [Wed, 22 Jun 2022 19:16:24 +0000 (12:16 -0700)]
Fix a bug with "process continue -b" when no breakpoints are
passed.  I was passing the empty list of breakponts to the
VerifyBreakpointList routine, but that treats empty as "choose
the default breakpoint" which we don't want here.

2 years ago[mlir][Linalg] SplitReduction implementation without tensor::ExpandShapeOp
Nicolas Vasilache [Tue, 21 Jun 2022 12:11:29 +0000 (05:11 -0700)]
[mlir][Linalg] SplitReduction implementation without tensor::ExpandShapeOp

This revision proposes a different implementation of the SplitReductoin transformation that does
not rely on tensor::ExpandShapeOp.

Previously, a dimension `[k]` would be split into `[k][kk]` via an ExpandShapeOp.
Instead, this revision proposes to rewrite `[k]` into `[factor * k + kk]`.

There are different tradeoffs involved  but the proposed implementation is more general because
the affine rewrite is well-defined. In particular, it works naturally with `?` parallel dimensions and
non-trivial indexing maps.

A further rewrite of `[factor * k + kk]` + ExpandShapeOp is possible as a followup.

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

2 years agoRename GCCBuiltin into ClangBuiltin
Guillaume Gomez [Wed, 22 Jun 2022 18:48:31 +0000 (19:48 +0100)]
Rename GCCBuiltin into ClangBuiltin

This patch is needed because developers expect "GCCBuiltin" items to be the GCC intrinsics equivalent and not the Clang internals.

Reviewed By: #libc_abi, RKSimon, xbolva00

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

2 years ago[flang] Remove some auto
Valentin Clement [Wed, 22 Jun 2022 18:47:48 +0000 (20:47 +0200)]
[flang] Remove some auto

This patch replaces some `auto` with proper type. This was done in fir-dev
but not upstreamed yet.

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

Reviewed By: klausler

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

2 years ago[flang] Handle BINC(C) variables and add TODO for corner cases
Valentin Clement [Wed, 22 Jun 2022 18:46:30 +0000 (20:46 +0200)]
[flang] Handle BINC(C) variables and add TODO for corner cases

- BIND(C) was ignored in lowering for objects (it can be used on
module and common blocks): use the bind name as the fir.global name.

- When an procedure is declared BIND(C) indirectly via an interface,
  it should have a BIND(C) name. This was not the case because
  GetBindName()/bindingName() return nothing in this case: detect this
  case in mangler.cpp and use the symbol name.

Add TODOs for corner cases:

- BIND(C) module variables may be initialized on the C side. This does
  not fit well with the current linkage strategy. Add a TODO until this
  is revisited.

- BIND(C) internal procedures should not have a binding label (see
  Fortran 2018 section 18.10.2 point 2), yet we currently lower them as
  if they were BIND(C) external procedure.
  I think this and the indirect interface case should really be
  handled by symbol.GetBindName instead of adding more logic in
  lowering to deal with this case: add a TODO.

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

Reviewed By: klausler

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[libc++] Clarify std::function release note
Joe Loser [Wed, 22 Jun 2022 17:25:43 +0000 (11:25 -0600)]
[libc++] Clarify std::function release note

Replace "This option it" with "This option" to make the sentence read a bit
clearer.

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

2 years ago[MTE] [HWASan] Support diamond lifetimes.
Florian Mayer [Tue, 14 Jun 2022 22:41:27 +0000 (15:41 -0700)]
[MTE] [HWASan] Support diamond lifetimes.

We were overly conservative and required a ret statement to be dominated
completely be a single lifetime.end marker. This is quite restrictive
and leads to two problems:

* limits coverage of use-after-scope, as we degenerate to
  use-after-return;
* increases stack usage in programs, as we have to remove all lifetime
  markers if we degenerate to use-after-return, which prevents
  reuse of stack slots by the stack coloring algorithm.

Reviewed By: eugenis

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

2 years ago[trace] Add an option to dump instructions in json and to a file
Walter Erquinigo [Sat, 18 Jun 2022 22:44:37 +0000 (15:44 -0700)]
[trace] Add an option to dump instructions in json and to a file

In order to provide simple scripting support on top of instruction traces, a simple solution is to enhance the `dump instructions` command and allow printing in json and directly to a file. The format is verbose and not space efficient, but it's not supposed to be used for really large traces, in which case the TraceCursor API is the way to go.

- add a -j option for printing the dump in json
- add a -J option for pretty printing the json output
- add a -F option for specifying an output file
- add a -a option for dumping all the instructions available starting at the initial point configured with the other flags
- add tests for all cases
- refactored the instruction dumper and abstracted the actual "printing" logic. There are two writer implementations: CLI and JSON. This made the dumper itself much more readable and maintanable

sample output:

```
(lldb) thread trace dump instructions  -t -a --id 100 -J
[
  {
    "id": 100,
    "tsc": "43591204528448966"
    "loadAddress": "0x407a91",
    "module": "a.out",
    "symbol": "void std::deque<Foo, std::allocator<Foo>>::_M_push_back_aux<Foo>(Foo&&)",
    "mnemonic": "movq",
    "source": "/usr/include/c++/8/bits/deque.tcc",
    "line": 492,
    "column": 30
  },
  ...
```

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

2 years ago[clang-tidy] Organize test files into subdirectories by module (NFC)
Richard [Fri, 17 Jun 2022 01:02:47 +0000 (19:02 -0600)]
[clang-tidy] Organize test files into subdirectories by module (NFC)

Eliminate clutter by reorganizing the Lit test files for clang-tidy:
- Move checkers/<module>-* to checkers/<module>/*.
- Move module specific inputs from Inputs to <module>/Inputs.  Remove
  any module prefix from the file or subdirectory name as they are no
  longer needed.
- Introduce a Lit substitution %clang_tidy_headers for the system
  headers in checkers/Inputs/Headers and use this throughout.  This
  avoids referencing system headers through a relative path to the
  parent directory and makes it clear that these fake system headers are
  shared among all modules.
- Update add_new_check.py to follow the above conventions when creating
  the boiler plate test files for a new check.
- Update Contributing.rst to describe per-module Inputs directory and
  fix link to test source code.

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

2 years ago[LLDB] Handle DIE with DW_AT_low_pc and empty ranges
Alexander Yermolovich [Wed, 22 Jun 2022 17:52:19 +0000 (10:52 -0700)]
[LLDB] Handle DIE with DW_AT_low_pc and empty ranges

The case comes out of how BOLT handles transformation of
DW_AT_low_pc/DW_AT_high_pc into DW_AT_low_pc/DW_AT_high_pc
with latter being 0.

Reviewed By: clayborg

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

2 years ago[NFC] [HWASan] Remove indirection for getting analyses.
Florian Mayer [Wed, 15 Jun 2022 22:54:12 +0000 (15:54 -0700)]
[NFC] [HWASan] Remove indirection for getting analyses.

This was necessary for code reuse between the old and new passmanager.
With the old pass-manager gone, this is no longer necessary.

Reviewed By: eugenis, myhsu

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

2 years ago[Support/BLAKE3] Fix error in prior commit, apply `-mavx512vl` for `blake3_avx512_x86...
Argyrios Kyrtzidis [Wed, 22 Jun 2022 17:49:31 +0000 (10:49 -0700)]
[Support/BLAKE3] Fix error in prior commit, apply `-mavx512vl` for `blake3_avx512_x86-64_unix.S` when including it

2 years ago[lldb] Second attempt at fixing command-target-create-resolve-exe.test on the buildbot
Alvin Wong [Wed, 22 Jun 2022 17:48:01 +0000 (20:48 +0300)]
[lldb] Second attempt at fixing command-target-create-resolve-exe.test on the buildbot

2 years ago[libc++][NFC] Merges unused functions in callers.
Mark de Wever [Tue, 14 Jun 2022 15:47:51 +0000 (17:47 +0200)]
[libc++][NFC] Merges unused functions in callers.

This is a follow up based on a request of @jloser in D127594.

As drive-by qualified the function calls in the <bit> header.

Reviewed By: #libc, EricWF

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

2 years ago[LinkerWrapper][NFC] Change interface to use a StringRef to TempFiles
Joseph Huber [Wed, 22 Jun 2022 15:17:14 +0000 (11:17 -0400)]
[LinkerWrapper][NFC] Change interface to use a StringRef to TempFiles

Summary:
Currently we use temporary files to write the intermediate results to.
However, these are stored as regular strings and we do a few unnecessary
copies and conversions of them. This patch simply replaces these strings
with a reference to the filename stored in the list of temporary files.
The temporary files will stay alive during the whole linking phase and
have stable pointers, so we should be able to cheaply pass references to
them rather than copying them every time.

2 years ago[Support] Change TrackingStatistic and NoopStatistic to use uint64_t instead of unsigned.
Mingming Liu [Fri, 17 Jun 2022 15:49:04 +0000 (08:49 -0700)]
[Support] Change TrackingStatistic and NoopStatistic to use uint64_t instead of unsigned.

Binary size of `clang` is trivial; namely, numerical value doesn't
change when measured in MiB, and `.data` section increases from 139Ki to
173 Ki.

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

2 years ago[MLIR] Fix top-level comment (NFC)
lorenzo chelini [Wed, 22 Jun 2022 17:04:40 +0000 (19:04 +0200)]
[MLIR] Fix top-level comment (NFC)

2 years ago[Symbolize] Parse multi-line markup elements.
Daniel Thornburgh [Fri, 29 Apr 2022 19:09:19 +0000 (19:09 +0000)]
[Symbolize] Parse multi-line markup elements.

This allows registering certain tags as possibly beginning multi-line
elements in the symbolizer markup parser. The parser is kept agnostic to
how lines are delimited; it reports the entire contents, including line
endings, once the end of element marker is reached.

Reviewed By: peter.smith

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

2 years agoAdd a "-b" option to "process continue" to run to a set of breakpoints,
Jim Ingham [Wed, 8 Jun 2022 01:03:23 +0000 (18:03 -0700)]
Add a "-b" option to "process continue" to run to a set of breakpoints,
temporarily ignoring the others.

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

2 years ago[iwyu] Handle regressions in libLLVM header include
serge-sans-paille [Wed, 22 Jun 2022 14:20:21 +0000 (16:20 +0200)]
[iwyu] Handle regressions in libLLVM header include

Running iwyu-diff on LLVM codebase since fb67d683db46dfd88da09d99 detected a few
regressions, fixing them.

The impact on preprocessed output is negligible: -4k lines.

2 years ago[clang-tidy] Fix documentation (NFC)
Richard [Wed, 22 Jun 2022 16:46:27 +0000 (10:46 -0600)]
[clang-tidy] Fix documentation (NFC)

The documentation files were reorganized into subdirectories, but a new
check was added concurrently and wasn't rebased correctly before
submitting.  Sort the new clang-tidy checks by check name and fix the
indentation of bugprone-unchecked-optional-access.

2 years ago[libc++] Reduces std::to_chars instantiations.
Mark de Wever [Mon, 20 Jun 2022 16:28:34 +0000 (18:28 +0200)]
[libc++] Reduces std::to_chars instantiations.

Instead of instantiating all functions called by std::to_chars for the
integral types only instantiate them for 32 and 64 bit integral types.
This results in a smaller binary when using different types.

In an example using the types: signed char, short, int, long, long long,
unsigned char, unsigned short, unsigned int, unsigned long, and
unsigned long long this saved 2792 bytes of code size. For libc++.so.1
is saves 688 bytes of code size (64-bit Linux).

This was discovered while investigating a solution for #52709.

Reviewed By: #libc, ldionne

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

2 years ago[mlir][sparse] fix typo in CHECK test
Aart Bik [Tue, 21 Jun 2022 23:03:25 +0000 (16:03 -0700)]
[mlir][sparse] fix typo in CHECK test

Thanks Peiming for reporting!

Reviewed By: Peiming

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

2 years ago[mlir][sparse] accept sparse reshape (expand/collapse)
Aart Bik [Tue, 21 Jun 2022 23:47:44 +0000 (16:47 -0700)]
[mlir][sparse] accept sparse reshape (expand/collapse)

This revision makes sure we accept sparse tensors as arguments
of the expand/collapse reshaping operations in the tensor dialect.
Note that the actual lowering to runnable IR is still TBD.

Reviewed By: springerm

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

2 years ago[MLIR][Presburger] introduce SlowMPInt, an auto-resizing APInt for fully correct...
Arjun P [Wed, 22 Jun 2022 16:29:46 +0000 (18:29 +0200)]
[MLIR][Presburger] introduce SlowMPInt, an auto-resizing APInt for fully correct signed integer computations

The Presburger library currently uses int64_t throughout for its integers.
This runs the risk of silently producing incorrect results when overflows occur.
Fixing this issue requires some sort of multiprecision integer
that transparently supports aribtrary arithmetic computations.

The class SlowMPInt provides this functionality, and is intended to be used
as the slow path fallback for a more optimized upcoming class, MPInt, that optimizes
for the Presburger library's workloads.

Reviewed By: ftynse

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

2 years ago[LSR] Don't allow zero quotient as scale ref. PR56160
Max Kazantsev [Wed, 22 Jun 2022 13:48:47 +0000 (20:48 +0700)]
[LSR] Don't allow zero quotient as scale ref. PR56160

Scale reg should never be zero, so when the quotient is zero, we
cannot assign it there. Limit this transform to avoid this situation.

Differential Revision: https://reviews.llvm.org/D128339
Reviewed By: eopXD

2 years ago[RISCV] Add RISCVISD opcodes for the rest of get*Addr.
Craig Topper [Wed, 22 Jun 2022 16:00:15 +0000 (09:00 -0700)]
[RISCV] Add RISCVISD opcodes for the rest of get*Addr.

This adds RISCVISD opccodes for LA, LA_TLS_IE, and LA_TLS_GD to
remove creation of MachineSDNodes form get*Addr. This makes the
code consistent with the previous patches that added RISCVISD::HI,
ADD_LO, LLA, and TPREL_ADD.

Reviewed By: asb

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

2 years ago[libc++][CI] Use GCC 12 labels.
Mark de Wever [Wed, 22 Jun 2022 16:11:19 +0000 (18:11 +0200)]
[libc++][CI] Use GCC 12 labels.

2 years ago[DirectX] Support opaque ptr for ValueAsMetadata in DXILBitcodeWriter
Xiang Li [Tue, 14 Jun 2022 00:15:56 +0000 (17:15 -0700)]
[DirectX] Support opaque ptr for ValueAsMetadata in DXILBitcodeWriter

When writeValueAsMetadata for GlobalVariable and Function, write TypedPointerType for ValueType and FunctionType.

Reviewed By: bogner

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

2 years ago[flang] Add semantic check for C1520
Peixin Qiao [Wed, 22 Jun 2022 16:04:24 +0000 (00:04 +0800)]
[flang] Add semantic check for C1520

As Fortran 2018 C1520, if proc-language-binding-spec with NAME= is
specified, then proc-decl-list shall contain exactly one proc-decl,
which shall neither have the POINTER attribute nor be a dummy procedure.
Add this check.

Reviewed By: klausler

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

2 years ago[flang][Driver] Refine _when_ driver diagnostics are formatted
Peixin Qiao [Wed, 22 Jun 2022 15:56:34 +0000 (23:56 +0800)]
[flang][Driver] Refine _when_ driver diagnostics are formatted

This patch refines //when// driver diagnostics are formatted so that
`flang-new` and `flang-new -fc1` behave consistently with `clang` and
`clang -cc1`, respectively. This change only applies to driver diagnostics.
Scanning, parsing and semantic diagnostics are separate and not covered here.

**NEW BEHAVIOUR**
To illustrate the new behaviour, consider the following input file:
```! file.f90
program m
  integer :: i = k
end
```
In the following invocations, "error: Semantic errors in file.f90" _will be_
formatted:
```
$ flang-new file.f90
error: Semantic errors in file.f90
./file.f90:2:18: error: Must be a constant value
    integer :: i = k
$ flang-new -fc1 -fcolor-diagnostics file.f90
error: Semantic errors in file.f90
./file.f90:2:18: error: Must be a constant value
    integer :: i = k
```

However, in the following invocations, "error: Semantic errors in file.f90"
_will not be_ formatted:
```
$ flang-new -fno-color-diagnostics file.f90
error: Semantic errors in file.f90
./file.f90:2:18: error: Must be a constant value
    integer :: i = k
$ flang-new -fc1 file.f90
error: Semantic errors in file.f90
./file.f90:2:18: error: Must be a constant value
    integer :: i = k
```

Before this change, none of the above would be formatted. Note also that the
default behaviour in `flang-new` is different to `flang-new -fc1` (this is
consistent with Clang).

**NOTES ON IMPLEMENTATION**
Note that the diagnostic options are parsed in `createAndPopulateDiagOpt`s in
driver.cpp. That's where the driver's `DiagnosticEngine` options are set. Like
most command-line compiler driver options, these flags are "claimed" in
Flang.cpp (i.e.  when creating a frontend driver invocation) by calling
`getLastArg` rather than in driver.cpp.

In Clang's Options.td, `defm color_diagnostics` is replaced with two separate
definitions: `def fcolor_diagnostics` and def fno_color_diagnostics`. That's
because originally `color_diagnostics` derived from `OptInCC1FFlag`, which is a
multiclass for opt-in options in CC1. In order to preserve the current
behaviour in `clang -cc1` (i.e. to keep `-fno-color-diagnostics` unavailable in
`clang -cc1`) and to implement similar behaviour in `flang-new -fc1`, we can't
re-use `OptInCC1FFlag`.

Formatting is only available in consoles that support it and will normally mean that
the message is printed in bold + color.

Co-authored-by: Andrzej Warzynski <andrzej.warzynski@arm.com>
Reviewed By: rovka

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

2 years ago[NFC][flang] Add the test case for D125371
Peixin Qiao [Wed, 22 Jun 2022 15:53:38 +0000 (23:53 +0800)]
[NFC][flang] Add the test case for D125371

This adds the test case with portability warning preparing for D125804,
which supports checking for portability warnings in test_errors.py.

Reviewed By: ekieri

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

2 years ago[lldb] Tentative attempt to fix command-target-create-resolve-exe.test on buildbot
Martin Storsjö [Wed, 22 Jun 2022 15:48:04 +0000 (18:48 +0300)]
[lldb] Tentative attempt to fix command-target-create-resolve-exe.test on buildbot

This test does succeed in my local test environment though, but
fails on the buildbot.

2 years ago[OpenMP][libomp] Hold old __kmp_threads arrays until library shutdown
Jonathan Peyton [Thu, 5 May 2022 14:15:41 +0000 (09:15 -0500)]
[OpenMP][libomp] Hold old __kmp_threads arrays until library shutdown

When many nested teams are formed, __kmp_threads may be reallocated
to accommodate new threads. This reallocation causes a data
race when another existing team's thread simultaneously references
__kmp_threads. This patch keeps the old thread arrays around until library
shutdown so these lingering references can complete without issue and
access to __kmp_threads remains a simple array reference.

Fixes: https://github.com/llvm/llvm-project/issues/54708
Differential Revision: https://reviews.llvm.org/D125013

2 years ago[X86PreAMXConfig] Use IRBuilder to insert instructions (NFC)
Nikita Popov [Wed, 22 Jun 2022 15:25:35 +0000 (17:25 +0200)]
[X86PreAMXConfig] Use IRBuilder to insert instructions (NFC)

Use an IRBuilder to insert instructions in preWriteTileCfg().
While here, also remove some unnecessary bool return values.

There are some test changes because the IRBuilder folds
"trunc i16 8 to i8" to "i8 8", and that has knock-on effects on
instruction naming.

I ran into this when converting tests to opaque pointers and
noticed that this pass introduces unnecessary "bitcast ptr to ptr"
instructions.

2 years ago[libc++] Fixes GCC-12 build.
Mark de Wever [Wed, 22 Jun 2022 15:26:17 +0000 (17:26 +0200)]
[libc++] Fixes GCC-12 build.

2 years ago[X86] Regenerate test checks (NFC)
Nikita Popov [Wed, 22 Jun 2022 15:00:10 +0000 (17:00 +0200)]
[X86] Regenerate test checks (NFC)

This runs the test through -instnamer and generates test checks
using update_test_checks.py. (The previous comment indicated that
update_llc_test_checks.py was used, but I rather doubt that.)

This relies on the non-determinism fix from
fbb72530fe80a95678a7d643d7a3f5ee8d693c93,
the previous check lines have apparently been written to accomodate
that non-determinism.

2 years ago[X86PreAMXConfig] Use MapVector to fix non-determinism
Nikita Popov [Wed, 22 Jun 2022 14:56:43 +0000 (16:56 +0200)]
[X86PreAMXConfig] Use MapVector to fix non-determinism

We generate code by iterating over this map, so make sure that the
order is deterministic.

2 years agoRevert "[NFC] Remove dead code"
Guillaume Chatelet [Wed, 22 Jun 2022 14:55:47 +0000 (14:55 +0000)]
Revert "[NFC] Remove dead code"

This reverts commit 8ba2cbff70f2c49a8926451c59cc260d67b706cf.

2 years ago[X86] Name instructions in test (NFC)
Nikita Popov [Wed, 22 Jun 2022 14:43:21 +0000 (16:43 +0200)]
[X86] Name instructions in test (NFC)

Run the test through -instnamer, to make it easier to modify.

2 years ago[gn build] Port c3574ef739fb slightly better
Nico Weber [Wed, 22 Jun 2022 14:44:07 +0000 (10:44 -0400)]
[gn build] Port c3574ef739fb slightly better

The name of the host binary changed from make_confusable_table to
make-confusable-table, so match that.

2 years agoReland "[gn build] (manually) port b94db7ed7eaf (Confusables.inc)"
Nico Weber [Fri, 3 Jun 2022 11:49:28 +0000 (07:49 -0400)]
Reland "[gn build] (manually) port b94db7ed7eaf (Confusables.inc)"

b94db7ed7eaf relanded in c3574ef739fb.

This relands commit 180bae08a04d4dc, rebased across the new version of
commit c3574ef739fb, and rebased across 10f7255d32b690.

2 years ago[clang-tidy] Confusable identifiers detection
serge-sans-paille [Fri, 15 Oct 2021 13:20:22 +0000 (15:20 +0200)]
[clang-tidy] Confusable identifiers detection

Detect identifiers that are confusable using a variant of Unicode definition

        http://www.unicode.org/reports/tr39/#Confusable_Detection

and have conflicting scopes.

This a recommit (with portability and feature fixes) of b94db7ed7eaf4a3b21f600653a09c55cab77b79f

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

2 years ago[lldb] Add setting to override PE/COFF ABI by module name
Alvin Wong [Wed, 22 Jun 2022 13:16:04 +0000 (16:16 +0300)]
[lldb] Add setting to override PE/COFF ABI by module name

The setting `plugin.object-file.pe-coff.module-abi` is a string-to-enum
map that allows specifying an ABI to a module name. For example:

    ucrtbase.dll=msvc
    libstdc++-6.dll=gnu

This allows for debugging a process which mixes both modules built using
the MSVC ABI and modules built using the MinGW ABI.

Depends on D127048

Reviewed By: DavidSpickett

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

2 years ago[lldb][windows] Fix crash on getting nested exception
Alvin Wong [Wed, 22 Jun 2022 13:15:34 +0000 (16:15 +0300)]
[lldb][windows] Fix crash on getting nested exception

LLDB tries to follow `EXCEPTION_RECORD::ExceptionRecord` to follow the
nested exception chain. In practice this code just causes Access
Violation whenever there is a nested exception. Since there does not
appear to be any code in LLDB that is actually using the nested
exceptions, this change just removes the crashing code and adds a
comment for future reference.

Fixes https://github.com/mstorsjo/llvm-mingw/issues/292

Reviewed By: DavidSpickett

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

2 years ago[lldb] Resolve exe location for `target create`
Alvin Wong [Wed, 22 Jun 2022 13:13:57 +0000 (16:13 +0300)]
[lldb] Resolve exe location for `target create`

This fixes an issue that, when you start lldb or use `target create`
with a program name which is on $PATH, or not specify the .exe suffix of
a program in the working directory on Windows, you get a confusing
error, for example:

    (lldb) target create notepad
    error: 'C:\WINDOWS\SYSTEM32\notepad.exe' doesn't contain any 'host'
    platform architectures: i686, x86_64, i386, i386

Fixes https://github.com/mstorsjo/llvm-mingw/issues/265

Reviewed By: DavidSpickett

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

2 years ago[lldb] Fix reading i686-windows executables with GNU environment
Martin Storsjö [Tue, 21 Jun 2022 12:31:32 +0000 (15:31 +0300)]
[lldb] Fix reading i686-windows executables with GNU environment

25c8a061c5739677d2fc0af29a8cc9520207b923 / D127048 added an option
for setting the ABI to GNU.

When an object file is loaded, there's only minimal verification
done for the architecture spec set for it, if the object file only
provides one.

However, for i386 object files, the PECOFF object file plugin
provides two architectures, i386-pc-windows and i686-pc-windows.
This picks a totally different codepath in
TargetList::CreateTargetInternal, where it's treated as a fat
binary. This goes through more verifications to see if the
architectures provided by the object file matches what the
platform plugin supports.

The PlatformWindows() constructor explicitly adds the
"i386-pc-windows" and "i686-pc-windows" architectures (even when
running on other architectures), which allows this "fat binary
verification" to succeed for the i386 object files that provide
two architectures.

However, after that commit, if the object file is advertised with
the different environment (either when lldb is built in a mingw
environment, or if that setting is set), the fat binary validation
won't accept the file any longer.

Update ArchSpec::IsEqualTo with more logic for the Windows use
cases; mismatching vendors is not an issue (they don't have any
practical effect on Windows), and GNU and MSVC environments are
compatible to the point that PlatformWindows can handle object
files for both environments/ABIs.

As a separate path forward, one could also consider to stop returning
two architecture specs from ObjectFilePECOFF::GetModuleSpecifications
for i386 files.

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

2 years agoClang AttributeReference: emit entries for "Undocumented" attributes.
James Y Knight [Wed, 22 Jun 2022 13:41:59 +0000 (09:41 -0400)]
Clang AttributeReference: emit entries for "Undocumented" attributes.

Almost all attributes currently marked `Undocumented` are user-facing
attributes which _ought_ to be documented, but nobody has written it
yet. This change ensures that we at least acknowledge that these
attributes exist in the documentation, even if we have no description
of their semantics.

A new category, `InternalOnly` has been added for those few attributes
which are not user-facing, and should remain omitted from the docs.

2 years ago[Alignment] Use Align for MaxKernArgAlign
Guillaume Chatelet [Sat, 18 Jun 2022 11:36:02 +0000 (11:36 +0000)]
[Alignment] Use Align for MaxKernArgAlign

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

2 years ago[LinkerWrapper] Fix calls to deleted Error constructor on older compilers
Joseph Huber [Wed, 22 Jun 2022 13:37:54 +0000 (09:37 -0400)]
[LinkerWrapper] Fix calls to deleted Error constructor on older compilers

Summary:
A recent patch added some new code paths to the linker wrapper. Older
compilers seem to have problems with returning errors wrapped in
an Excepted type without explicitly moving them. This caused failures in
some of the buildbots. This patch fixes that.

2 years ago[X86] Migrate more tests to opaque pointers (NFC)
Nikita Popov [Wed, 22 Jun 2022 12:51:00 +0000 (14:51 +0200)]
[X86] Migrate more tests to opaque pointers (NFC)

Migrate some more tests that required manual fixups (e.g. due to
phi nodes), but have no codegen changes.

Also tweak some more tests that had leftover no-op constant
expressions.

2 years ago[flang] Add FIR tests missing from fir-dev
Valentin Clement [Wed, 22 Jun 2022 13:34:29 +0000 (15:34 +0200)]
[flang] Add FIR tests missing from fir-dev

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

Reviewed By: jeanPerier, PeteSteinfeld

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Kiran Chandramohan <kiran.chandramohan@arm.com>
2 years ago[NFC] Remove dead code
Guillaume Chatelet [Wed, 22 Jun 2022 13:33:40 +0000 (13:33 +0000)]
[NFC] Remove dead code

2 years ago[ConstraintElimination] Transfer info from SGE to unsigned system.
Florian Hahn [Wed, 22 Jun 2022 13:27:59 +0000 (15:27 +0200)]
[ConstraintElimination] Transfer info from SGE to unsigned system.

This patch adds a new transferToOtherSystem helper that tries to
transfer information from signed predicates to the unsigned system and
vice versa.

The initial version adds A >=u B for A >=s B && B >=s 0

https://alive2.llvm.org/ce/z/8b6F9i

2 years ago[Clang] Allow multiple comma separated arguments to `--offload-arch=`
Joseph Huber [Mon, 20 Jun 2022 14:17:40 +0000 (10:17 -0400)]
[Clang] Allow multiple comma separated arguments to `--offload-arch=`

This patch updates the `--[no-]offload-arch` command line arguments to
allow the user to pass in many architectures in a single argument rather
than specifying it multiple times. This means that the following command
line,
```
clang foo.cu --offload-arch=sm_70 --offload-arch=sm_80
```
can become:
```
clang foo.cu --offload-arch=sm_70,sm_80
```

Reviewed By: ye-luo

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

2 years ago[LinkerWrapper] Rework the linker wrapper and use owning binaries
Joseph Huber [Mon, 6 Jun 2022 15:36:45 +0000 (11:36 -0400)]
[LinkerWrapper] Rework the linker wrapper and use owning binaries

The linker wrapper currently eagerly extracts all identified offloading
binaries to a file. This isn't ideal because we will soon open these
files again to examine their symbols for LTO and other things.
Additionally, we may not use every extracted file in the case of static
libraries. This would be very noisy in the case of static libraries that
may contain code for several targets not participating in the current
link.

Recent changes allow us to treat an Offloading binary as a standard
binary class. So that allows us to use an OwningBinary to model the
file. Now we keep it in memory and only write it once we know which
files will be participating in the final link job. This also reworks a
lot of the structure around how we handle this by removing the old
DeviceFile class.

The main benefit from this is that the following doesn't output 32+ files and
instead will only output a single temp file for the linked module.
```
$ clang input.c -fopenmp --offload-arch=sm_70 -foffload-lto -save-temps
```

Reviewed By: JonChesterfield

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

2 years ago[X86] Name instructions in test (NFC)
Nikita Popov [Wed, 22 Jun 2022 13:16:37 +0000 (15:16 +0200)]
[X86] Name instructions in test (NFC)

Run the test through -instnamer, which makes it simpler to modify
it.

2 years ago[NFC] Remove dead code
Guillaume Chatelet [Wed, 22 Jun 2022 13:11:30 +0000 (13:11 +0000)]
[NFC] Remove dead code

2 years ago[lldb] Remove an outdated comment. NFC.
Martin Storsjö [Mon, 20 Jun 2022 21:21:00 +0000 (00:21 +0300)]
[lldb] Remove an outdated comment. NFC.

This comment became outdated in 053eb35651906e693906fad6c695fce11415ade7
(but was moved along); that commit moved the code and the comment
to a separate function, with a separate local variable
`num_of_bytes_read`. On error, the possibly garbage value is never
copied back to the caller's reference, thus the comment is no longer
relevant (and slightly confusing as is).

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

2 years agoDon't treat invalid parameters as being unused
Aaron Ballman [Wed, 22 Jun 2022 12:06:08 +0000 (08:06 -0400)]
Don't treat invalid parameters as being unused

The misc-unused-parameters check would trigger false positive warnings
about the parameter being unused when the parameter declaration was
invalid. No longer issue the warning in that case on the assumption
that most parameters are used in practice, so the extra diagnostic is
most likely a false positive.

Fixes #56152

2 years ago[NVPTX] Keep metadata attached to module-scope variables
Igor Kudrin [Wed, 22 Jun 2022 12:51:29 +0000 (05:51 -0700)]
[NVPTX] Keep metadata attached to module-scope variables

This helps to preserve the debug information of global variables.

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

2 years ago[DAG] SelectionDAG::GetDemandedBits - don't recurse back into GetDemandedBits
Simon Pilgrim [Wed, 22 Jun 2022 11:07:27 +0000 (12:07 +0100)]
[DAG] SelectionDAG::GetDemandedBits - don't recurse back into GetDemandedBits

Another minor cleanup as we work toward removing GetDemandedBits entirely - call SimplifyMultipleUseDemandedBits directly.

2 years ago[X86] Migrate tests to use opaque pointers (NFC)
Nikita Popov [Wed, 22 Jun 2022 12:33:12 +0000 (14:33 +0200)]
[X86] Migrate tests to use opaque pointers (NFC)

Test updates were performed using:
https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34

These are only the test updates where the test passed without
further modification (which is almost all of them, as the backend
is largely pointer-type agnostic).

2 years agoRe-land [libc] Apply no-builtin everywhere, remove unnecessary flags
Guillaume Chatelet [Wed, 22 Jun 2022 12:21:25 +0000 (12:21 +0000)]
Re-land [libc] Apply no-builtin everywhere, remove unnecessary flags

This is a reland of D126773 / b2a9ea4420127d10b18ae648b16757665f8bbd7c.

The removal of `-mllvm -combiner-global-alias-analysis` has landed separately
in D128051 / 7b73f53790f3db9ee589dc26a05a481a5e9e6915.

And the removal of `-mllvm --tail-merge-threshold=0` is scheduled for
removal in a subsequent patch.

2 years ago[Tests] Remove unnecessary bitcasts from opaque pointer tests (NFC)
Nikita Popov [Wed, 22 Jun 2022 12:06:12 +0000 (14:06 +0200)]
[Tests] Remove unnecessary bitcasts from opaque pointer tests (NFC)

Previously left these behind due to the required instruction
renumbering, drop them now. This more accurately represents
opaque pointer input IR.

Also drop duplicate opaque pointer check lines in one SROA test.

2 years ago[AlignmentFromAssumptions] Migrate tests to opaque pointers (NFC)
Nikita Popov [Wed, 22 Jun 2022 11:02:18 +0000 (13:02 +0200)]
[AlignmentFromAssumptions] Migrate tests to opaque pointers (NFC)

Tests were updated with (without manual fixup):
https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34

2 years ago[libc][mem*] Introduce Sized/Backends for new mem framework
Guillaume Chatelet [Tue, 14 Jun 2022 11:34:13 +0000 (11:34 +0000)]
[libc][mem*] Introduce Sized/Backends for new mem framework

This patch is a subpart of D125768 intented to make the review easier.

The `SizedOp` struct represents operations to be performed on a certain number of bytes.
It is responsible for breaking them down into platform types and forwarded to the `Backend`.

The `Backend` struct represents a lower level abstraction that works only on types (`uint8_t`, `__m128i`, ...).
It is similar to instruction selection.

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

2 years ago[AddDiscriminators] Migrate tests to opaque pointers (NFC)
Nikita Popov [Wed, 22 Jun 2022 10:47:12 +0000 (12:47 +0200)]
[AddDiscriminators] Migrate tests to opaque pointers (NFC)

Update performed using:
https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34

memcpy-discriminator.ll was fixed up to use named instructions
and drop the no longer needed bitcasts.

2 years ago[AggressiveInstCombine] Update tests to use opaque pointers (NFC)
Nikita Popov [Wed, 22 Jun 2022 10:27:21 +0000 (12:27 +0200)]
[AggressiveInstCombine] Update tests to use opaque pointers (NFC)

Update performed using (without manual fixup):
https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34

2 years ago[ADCE] Update tests to use opaque pointers (NFC)
Nikita Popov [Wed, 22 Jun 2022 10:24:43 +0000 (12:24 +0200)]
[ADCE] Update tests to use opaque pointers (NFC)

Update performed using:
https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34

This time without any manual fixup.

2 years ago[XCOFF] write the real source file name in C_FILE symbol.
esmeyi [Wed, 22 Jun 2022 10:23:36 +0000 (06:23 -0400)]
[XCOFF] write the real source file name in C_FILE symbol.

The symbol table starts with all the C_FILE symbols.

Reviewed By: shchenz

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

2 years ago[ARM] Fix MVE gather/scatter merged gep offsets
David Green [Wed, 22 Jun 2022 10:04:22 +0000 (11:04 +0100)]
[ARM] Fix MVE gather/scatter merged gep offsets

This fixes the combining of constant vector GEP operands in the
optimization of MVE gather/scatter addresses, when opaque pointers are
enabled. As opaque pointers reduce the number of bitcasts between geps,
more can be folded than before. This can cause problems if the index
types are now different between the two geps.

This fixes that by making sure each constant is scaled appropriately,
which has the effect of transforming the geps to have a scale of 1,
changing [r0, q0, uxtw #1] gathers to [r0, q0] with a larger q0. This
helps use a simpler instruction that doesn't need the extra uxtw.

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

2 years ago[X86] Don't run O2 pipeline in codegen test (NFC)
Nikita Popov [Wed, 22 Jun 2022 09:36:38 +0000 (11:36 +0200)]
[X86] Don't run O2 pipeline in codegen test (NFC)

Regenerate the test with current O2 result and only run CGP.

2 years ago[AArch64][SME] Add some SME PSTATE setting/query intrinsics
David Sherwood [Thu, 16 Jun 2022 10:46:15 +0000 (11:46 +0100)]
[AArch64][SME] Add some SME PSTATE setting/query intrinsics

This patch adds support for:

* Querying the PSTATE.SM state with @llvm.aarch64.sme.get.pstatesm
* Reading/writing the TPIDR2 register with new
@llvm.aarch64.sme.get.tpidr2 and @llvm.aarch64.sme.set.tpidr2
intrinsics.

Tests added here:

  CodeGen/AArch64/sme-get-pstatesm.ll
  CodeGen/AArch64/sme-read-write-tpidr2.ll

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

2 years ago[libc++] fix views::all hard error on lvalue move only views instead of SFINAE
Hui Xie [Wed, 22 Jun 2022 08:24:09 +0000 (09:24 +0100)]
[libc++] fix views::all hard error on lvalue move only views instead of SFINAE

For an lvalue reference to a move only view x, views::all(x) gives hard error because the expression inside noexcept is not well formed and it is not SFINAE friendly.

Given a move only view type `V`, and a concept

```
template <class R>
concept can_all = requires {
    std::views::all(std::declval<R>());
};
```

The expression `can_all<V&>` returns
libstdc++: false
msvc stl : false
libc++   : error: static_cast from 'V' to 'typename decay<decltype((std::forward<V &>(__t)))>::type' (aka 'V') uses deleted function
      noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t))))

The standard spec has its own problem, the spec says it is expression equivalent to `decay-copy(E)` but the spec of `decay-copy` does not have any constraint, which means the expression `decay-copy(declval<V&>())` is well-formed and the concept `can_all<V&>` should return true and should error when instantiating the function body of decay-copy. This is clearly wrong behaviour in the spec and we will probably create an LWG issue. But the libc++'s behaviour is clearly not correct. The `noexcept` is an "extension" in libc++ which is not in the spec, but the expression inside `noexpect` triggers hard error, which is not right.

Reviewed By: #libc, ldionne, var-const

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

2 years ago[SCCP] Don't mark edges feasible when resolving undefs
Nikita Popov [Fri, 3 Jun 2022 09:42:07 +0000 (11:42 +0200)]
[SCCP] Don't mark edges feasible when resolving undefs

As branch on undef is immediate undefined behavior, there is no need
to mark one of the edges as feasible. We can leave all the edges
non-feasible. In IPSCCP, we can replace the branch with an unreachable
terminator.

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