platform/upstream/llvm.git
17 months ago[RISCV] Use std::clamp (NFC)
Kazu Hirata [Sat, 28 Jan 2023 16:49:02 +0000 (08:49 -0800)]
[RISCV] Use std::clamp (NFC)

17 months ago[LSAN] Remove -fuse-ld=lld from HWASAN config
Kirill Stoimenov [Sat, 28 Jan 2023 15:57:21 +0000 (15:57 +0000)]
[LSAN] Remove -fuse-ld=lld from HWASAN config

I needed that to make -fsanitize-hwaddress-experimental-aliasing work, but it looks like the test pass without it also. This should fix https://lab.llvm.org/buildbot/#/builders/192 failures.

Reviewed By: kstoimenov

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

17 months agoRevert "[X86][ABI] Don't preserve return regs for preserve_all/preserve_most CCs"
Hans Wennborg [Sat, 28 Jan 2023 15:38:15 +0000 (16:38 +0100)]
Revert "[X86][ABI] Don't preserve return regs for preserve_all/preserve_most CCs"

This caused Chromium to crash, see comment on the code review.

> Currently both calling conventions preserve registers that are used to
> store a return value. This causes the returned value to be lost:
>
>   define i32 @bar() {
>     %1 = call preserve_mostcc i32 @foo()
>     ret i32 %1
>   }
>
>   define preserve_mostcc i32 @foo() {
>     ret i32 2
>     ; preserve_mostcc will restore %rax,
>     ; whatever it was before the call.
>   }
>
> This contradicts the current documentation (preserve_allcc "behaves
> identical to the `C` calling conventions on how arguments and return
> values are passed") and also breaks [[clang::preserve_most]].
>
> This change makes CSRs be preserved iff they are not used to store a
> return value (e.g. %rax for scalars, {%rax:%rdx} for __int128, %xmm0
> for double). For void functions no additional registers are
> preserved, i.e. the behaviour is backward compatible with existing
> code.
>
> Differential Revision: https://reviews.llvm.org/D141020

This reverts commit 0276fa89d7a4dbe73105c9148f947716b3d8f17f.

17 months agoFix Clang sphinx build
Aaron Ballman [Sat, 28 Jan 2023 13:56:22 +0000 (08:56 -0500)]
Fix Clang sphinx build

This addresses the issue found in:
https://lab.llvm.org/buildbot/#/builders/92/builds/39306

17 months agoAMDGPU: Convert fcopysign tests to generated checks and add cases
Matt Arsenault [Fri, 27 Jan 2023 00:25:17 +0000 (20:25 -0400)]
AMDGPU: Convert fcopysign tests to generated checks and add cases

17 months agoAMDGPU: Add fneg and select test
Matt Arsenault [Tue, 13 Dec 2022 18:26:25 +0000 (13:26 -0500)]
AMDGPU: Add fneg and select test

17 months ago[Clang][RISCV] Simplify RVV intrinsic policy suffix
eopXD [Wed, 18 Jan 2023 13:50:19 +0000 (05:50 -0800)]
[Clang][RISCV] Simplify RVV intrinsic policy suffix

This patch works towards the simplification proposal [0] of Nick
Knight. After this patch, we have reduced the hierarchy of intrinsics
from two sets (non-policy and policy) into a single set, with a general
assumption that policy behavior is agnostic unless specified.

[0] https://gist.github.com/nick-knight/6cb0b74b351a25323dfb1821d3a269b9

Pull Request: riscv-non-isa/rvv-intrinsic-doc#186.

Depends on D141796.

Reviewed By: craig.topper, kito-cheng

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

17 months ago[bazel] Adjust lsp-server-support include paths for 305d71853965
Benjamin Kramer [Sat, 28 Jan 2023 10:04:57 +0000 (11:04 +0100)]
[bazel] Adjust lsp-server-support include paths for 305d71853965

17 months ago[bazel] Add a dep from target asm parsers to :TargetParser
Benjamin Kramer [Sat, 28 Jan 2023 10:01:07 +0000 (11:01 +0100)]
[bazel] Add a dep from target asm parsers to :TargetParser

This is needed for the AArch64 asm parser after 9ea00fc74c3c

17 months ago[bazel][mlir] Remove references to SubElementInterfaces.
Chenguang Wang [Sat, 28 Jan 2023 09:58:55 +0000 (10:58 +0100)]
[bazel][mlir] Remove references to SubElementInterfaces.

It was removed in D142272.

This commit is manually verified with:

  bazel test --config=generic_clang @llvm-project//mlir/unittests:ir_tests

Reviewed By: bkramer

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

17 months ago[RISCV] Use llvm::bit_floor and std::clamp (NFC)
Kazu Hirata [Sat, 28 Jan 2023 08:49:38 +0000 (00:49 -0800)]
[RISCV] Use llvm::bit_floor and std::clamp (NFC)

17 months agoUse std::optional instead of llvm::Optional (NFC)
Kazu Hirata [Sat, 28 Jan 2023 08:45:19 +0000 (00:45 -0800)]
Use std::optional instead of llvm::Optional (NFC)

17 months ago[RISCV] Refine the (mul (zext.w X), C) -> mulhu isel heuristic.
Craig Topper [Sat, 28 Jan 2023 07:41:06 +0000 (23:41 -0800)]
[RISCV] Refine the (mul (zext.w X), C) -> mulhu isel heuristic.

We try to shift both X and C left by 32 to replace the zext.w
with a SLLI and use mulhu. If C is already a simm32, this likely
makes a constant that is more expensive to materialize.

17 months ago[Docs] Fix a statement wrt instruction alignment of 0
Shivam Gupta [Sat, 28 Jan 2023 05:01:33 +0000 (10:31 +0530)]
[Docs] Fix a statement wrt instruction alignment of 0

17 months agoRecommit "Reorder (shl (add/sub (shl x, C0), y), C1) -> (add/sub (shl x, C0 + C1...
Noah Goldstein [Fri, 27 Jan 2023 23:26:41 +0000 (17:26 -0600)]
Recommit "Reorder (shl (add/sub (shl x, C0), y), C1) -> (add/sub (shl x, C0 + C1), (shl y, C1))" 2nd Try

First time caused build failure:
    https://lab.llvm.org/buildbot/#/builders/183/builds/10447
but after investigating it seems to be unrelated. The same
test/build passed later with the original commit here:
    https://lab.llvm.org/buildbot/#/builders/183/builds/10448

This is just expanding the existing pattern that exists for AND/XOR/OR
and gets a bit more parallelism in from the instruction sequence.

Alive2:
Add  - https://alive2.llvm.org/ce/z/dSmPkV
Sub1 - https://alive2.llvm.org/ce/z/6rpi5V
Sub2 - https://alive2.llvm.org/ce/z/UfYeUd

Reviewed By: spatel

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

17 months agoRecommit "Add optimizations for icmp eq/ne (mul(X, Y), 0)" 2nd Try
Noah Goldstein [Fri, 27 Jan 2023 23:26:19 +0000 (17:26 -0600)]
Recommit "Add optimizations for icmp eq/ne (mul(X, Y), 0)" 2nd Try

First time caused build failure:
    https://lab.llvm.org/buildbot/#/builders/183/builds/10447
but after investigating it seems to be unrelated. The same
test/build passed later with the original commit here:
    https://lab.llvm.org/buildbot/#/builders/183/builds/10448

1. Add checks if X and/or Y are odd. The Odd values are unnecessary to
   the icmp: isZero(Odd * N) == isZero(N)

2. If neither X nor Y is known odd, then if X * Y cannot overflow AND
   if X and/or Y is non-zero, the non-zero values are unnecessary to the
   icmp.

Reviewed By: nikic

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

17 months ago[X86] Use llvm::bit_ceil (NFC)
Kazu Hirata [Sat, 28 Jan 2023 02:33:25 +0000 (18:33 -0800)]
[X86] Use llvm::bit_ceil (NFC)

The argument is known to be nonzero, so we can safely switch to
llvm::bit_ceil.

17 months agollvm-reduce: Add REQUIRES: default_triple to test
Matt Arsenault [Sat, 28 Jan 2023 02:14:05 +0000 (22:14 -0400)]
llvm-reduce: Add REQUIRES: default_triple to test

Allegedly fixes test failure if there are no targets built.

17 months agoLoopStrengthReduce: Convert AMDGPU tests to opaque pointers
Matt Arsenault [Sat, 28 Jan 2023 02:00:25 +0000 (22:00 -0400)]
LoopStrengthReduce: Convert AMDGPU tests to opaque pointers

17 months agoAMDGPU: Support atomicrmw uinc_wrap/udec_wrap
Matt Arsenault [Thu, 3 Nov 2022 06:42:58 +0000 (23:42 -0700)]
AMDGPU: Support atomicrmw uinc_wrap/udec_wrap

For now keep the exising intrinsics working.

17 months agoFix "not all control paths return a value" introduced by D142642
Mircea Trofin [Sat, 28 Jan 2023 01:58:20 +0000 (17:58 -0800)]
Fix "not all control paths return a value" introduced by D142642

17 months agoAdded a note that "%p" is also a Lit token and needs to be escaped.
Flash Sheridan [Sat, 28 Jan 2023 01:57:59 +0000 (17:57 -0800)]
Added a note that "%p" is also a Lit token and needs to be escaped.

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

17 months agoExplain code coverage with Lit in docs/SourceBasedCodeCoverage.rst
Flash Sheridan [Sat, 28 Jan 2023 01:51:18 +0000 (17:51 -0800)]
Explain code coverage with Lit in docs/SourceBasedCodeCoverage.rst

The documentation for code coverage in clang/docs/SourceBasedCodeCoverage.rst omits a couple of crucial steps when using it with Lit.
This patch should fix that.

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

17 months ago[mlir][NFC] Move the headers for lsp-server-support to include/
River Riddle [Sat, 28 Jan 2023 00:32:36 +0000 (16:32 -0800)]
[mlir][NFC] Move the headers for lsp-server-support to include/

This makes it a bit easier to share the functionality for building
language servers, and makes the API public. No real functional
change, as the API was already intended for this anyways.

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

17 months ago[AArch64] Fix crash for expandMOVImm
zhongyunde [Sat, 28 Jan 2023 01:09:10 +0000 (09:09 +0800)]
[AArch64] Fix crash for expandMOVImm

Fix https://github.com/llvm/llvm-project/issues/59892

Reviewed By: efriedma

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

17 months ago[flang] Catch out-of-range constant arguments to CHAR/ACHAR
Peter Klausler [Tue, 3 Jan 2023 18:09:37 +0000 (10:09 -0800)]
[flang] Catch out-of-range constant arguments to CHAR/ACHAR

When folding the intrinsic functions CHAR and ACHAR, emit an
error message if the argument is out of the valid range for the
kind of the result.

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

17 months ago[gn build] Port 5b8dc7c8a552
LLVM GN Syncbot [Sat, 28 Jan 2023 01:04:03 +0000 (01:04 +0000)]
[gn build] Port 5b8dc7c8a552

17 months ago[mlgo] Introduce an "InteractiveModelRunner"
Mircea Trofin [Thu, 26 Jan 2023 15:58:17 +0000 (07:58 -0800)]
[mlgo] Introduce an "InteractiveModelRunner"

This is a model runner for ML researchers using environments like
CompilerGym. In such environments, researchers host the compiler and
want to be able to observe the problem space (features) at each decision
step of some optimization pass, at which point the compiler is stopped,
waiting for the host makes a decision and provide an advice back to
the compiler, which then continues its normal operation, and so on.

The InteractiveModelRunner supports this scenario for the feature set
exposed by the compiler at a given time. It uses 2 files - ideally FIFO
pipes - one to pass data to the host, the other to get advices back from
the host. This means this scenario is supported with no special
dependencies. The file creation and deletion is the responsibility of
the host. Hooking up this model evaluator to a MLGO-ed pass is the
responsibilty of the pass author, and subsequent patches will do so for
the current set of mlgo passes, and offer an API to easily "just opt in"
by default when mlgo-ing a new pass.

The data protocol is that of the training logger: the host sees a training
log doled out observation by observation by reading from one of the
files, and passes back its advice as a serialized tensor (i.e. tensor value
memory dump) via the other file.

There are some differences wrt the log seen during training: the
interactive model doesn't currently include the outcome (because it should be
identical to the decision, and it's also not present in the "release"
mode); and partial rewards aren't currently communicated back.

The assumption - just like with the training logger - is that the host
is co-located, thus avoiding any endianness concerns. In a distributed
environment, it is up to the hosting infrastructure to intermediate
that.

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

17 months ago[flang] Portability warnings for an ambiguous ASSOCIATED() case
Peter Klausler [Wed, 11 Jan 2023 22:31:49 +0000 (14:31 -0800)]
[flang] Portability warnings for an ambiguous ASSOCIATED() case

The standard's specification for the ASSOCIATED() intrinsic function
describes its optional second argument (TARGET=) as being required
to be a valid target for a pointer assignment statement in which the
first argument (POINTER=) was the left-hand side.  Some Fortran compilers
apparently interpret this text as a requirement that the POINTER= argument
actually be a valid left-hand side to a pointer assignment statement,
and emit an error if it is not so.  This particularly affects the
use of an explicit NULL pointer as the first argument.

Such usage is well-defined, benign, useful, and supported by at least
two other compilers, so we should continue to accept it.  This patch
adds a portability warning and some documentation.

In order to implement the portability warning in the best way, the
special checks on calls to the ASSOCIATED() intrinsic function have
been moved from intrinsic processing to Semantics/check-calls.cpp,
whence they have access to semantics' toolchest.  Special checks for
other intrinsic functions might also migrate in the future in order
to keep them all in one place.

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

17 months ago[LSAN] Disable leak_check_before_thread_started for hwasan
Kirill Stoimenov [Sat, 28 Jan 2023 00:46:12 +0000 (00:46 +0000)]
[LSAN] Disable leak_check_before_thread_started for hwasan

17 months agoRevert "Reorder (shl (add/sub (shl x, C0), y), C1) -> (add/sub (shl x, C0 + C1),...
Noah Goldstein [Sat, 28 Jan 2023 00:44:45 +0000 (18:44 -0600)]
Revert "Reorder (shl (add/sub (shl x, C0), y), C1) -> (add/sub (shl x, C0 + C1), (shl y, C1))"

This reverts commit edd80befeeb92000800ded2a6f3dcdfd672d95ea.

Caused test failures in Clangd: https://lab.llvm.org/buildbot/#/builders/183/builds/10447
reverting while investigating.

17 months agoRevert "Add optimizations for icmp eq/ne (mul(X, Y), 0)"
Noah Goldstein [Sat, 28 Jan 2023 00:44:02 +0000 (18:44 -0600)]
Revert "Add optimizations for icmp eq/ne (mul(X, Y), 0)"

This reverts commit aa250ceb3ff15d55bb506b4bc8196f143133d8b5.

Caused test failures in Clangd: https://lab.llvm.org/buildbot/#/builders/183/builds/10447
reverting while investigating.

17 months ago[RISCV] Teach computeKnownBits that vsetvli returns <= 65536.
Craig Topper [Sat, 28 Jan 2023 00:39:54 +0000 (16:39 -0800)]
[RISCV] Teach computeKnownBits that vsetvli returns <= 65536.

Resolves a FIXME. We could do even better taking into account SEW/LMUL.

17 months ago[ValueTracking] Teach computeKnownBits about riscv.vsetvli.opt and riscv.vsetvlimax...
Craig Topper [Fri, 27 Jan 2023 23:52:31 +0000 (15:52 -0800)]
[ValueTracking] Teach computeKnownBits about riscv.vsetvli.opt and riscv.vsetvlimax.opt intrinsics.

These are like the intrinsic without opt, but don't have side effects.

Add missing test cases for riscv.vsetvlimax.

17 months agollvm-reduce: Parse file from the opened buffer instead of the file
Matt Arsenault [Fri, 27 Jan 2023 21:58:20 +0000 (17:58 -0400)]
llvm-reduce: Parse file from the opened buffer instead of the file

If this wasn't bitcode this was opening a second MemoryBuffer.

17 months agollvm-reduce: Use WithColor in another place
Matt Arsenault [Fri, 27 Jan 2023 18:32:07 +0000 (14:32 -0400)]
llvm-reduce: Use WithColor in another place

Use more consistently capitalized/colorized/punctuated error messages.

17 months agollvm-reduce: Use ThreadPool feature to wait for tasks to complete
Matt Arsenault [Fri, 27 Jan 2023 20:36:42 +0000 (16:36 -0400)]
llvm-reduce: Use ThreadPool feature to wait for tasks to complete

Don't use the hackier barrier I wrote using the task queue.

17 months agollvm-reduce: Use consistent type for reducer function
Matt Arsenault [Fri, 27 Jan 2023 18:47:18 +0000 (14:47 -0400)]
llvm-reduce: Use consistent type for reducer function

17 months ago[LSAN][HWASAN] Run LSAN tests with HWASAN enabled
Kirill Stoimenov [Fri, 27 Jan 2023 23:40:39 +0000 (23:40 +0000)]
[LSAN][HWASAN] Run LSAN tests with HWASAN enabled

A lot of tests are disabled by using UNSUPPORTED. The plan is to remove UNSUPPORTED for tests that are fixed.

Reviewed By: vitalybuka

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

17 months agoManual DWARF index: don't skip over -gmodules debug info
Adrian Prantl [Fri, 27 Jan 2023 00:42:31 +0000 (16:42 -0800)]
Manual DWARF index: don't skip over -gmodules debug info

This fixes a regression introduced by
https://reviews.llvm.org/D131437. The intention of the patch was to
avoid indexing DWO skeleton units, but it also skipped over full DWARF
compile units linked via a -gmodules DW_AT_dwo_name attribute. This
patch restores the functionality and adds a test for it.

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

17 months ago[flang] Fix shared library build
Peter Klausler [Fri, 27 Jan 2023 23:51:20 +0000 (15:51 -0800)]
[flang] Fix shared library build

A recent patch introduced a dependency upon Semantics from
Evaluate; fixing immediately.

17 months ago[BOLT][DWARF] Add logging for split dwarf
Alexander Yermolovich [Fri, 27 Jan 2023 23:49:01 +0000 (15:49 -0800)]
[BOLT][DWARF] Add logging for split dwarf

Added logging when bolt is processing binary with split dwarf.

Reviewed By: rafauler

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

17 months agoReorder (shl (add/sub (shl x, C0), y), C1) -> (add/sub (shl x, C0 + C1), (shl y,...
Noah Goldstein [Fri, 27 Jan 2023 23:26:41 +0000 (17:26 -0600)]
Reorder (shl (add/sub (shl x, C0), y), C1) -> (add/sub (shl x, C0 + C1), (shl y, C1))

This is just expanding the existing pattern that exists for AND/XOR/OR
and gets a bit more parallelism in from the instruction sequence.

Alive2:
Add  - https://alive2.llvm.org/ce/z/dSmPkV
Sub1 - https://alive2.llvm.org/ce/z/6rpi5V
Sub2 - https://alive2.llvm.org/ce/z/UfYeUd

Reviewed By: spatel

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

17 months agoAdd tests for reoredering (shift (add (shift x, C0), y), C1); NFC
Noah Goldstein [Fri, 27 Jan 2023 23:26:51 +0000 (17:26 -0600)]
Add tests for reoredering (shift (add (shift x, C0), y), C1); NFC

Reviewed By: spatel

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

17 months agoAdd optimizations for icmp eq/ne (mul(X, Y), 0)
Noah Goldstein [Fri, 27 Jan 2023 23:26:19 +0000 (17:26 -0600)]
Add optimizations for icmp eq/ne (mul(X, Y), 0)

1. Add checks if X and/or Y are odd. The Odd values are unnecessary to
   the icmp: isZero(Odd * N) == isZero(N)

2. If neither X nor Y is known odd, then if X * Y cannot overflow AND
   if X and/or Y is non-zero, the non-zero values are unnecessary to the
   icmp.

Reviewed By: nikic

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

17 months agoAdd tests for binops with conditions/assume constraints
Noah Goldstein [Fri, 27 Jan 2023 23:25:57 +0000 (17:25 -0600)]
Add tests for binops with conditions/assume constraints

Reviewed By: nikic

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

17 months ago[mlir] Promote the SubElementInterfaces to a core Attribute/Type construct
River Riddle [Sat, 21 Jan 2023 05:39:13 +0000 (21:39 -0800)]
[mlir] Promote the SubElementInterfaces to a core Attribute/Type construct

This commit restructures the sub element infrastructure to be a core part
of attributes and types, instead of being relegated to an interface. This
establishes sub element walking/replacement as something "always there",
which makes it easier to rely on for correctness/etc (which various bits of
infrastructure want, such as Symbols).

Attribute/Type now have `walk` and `replace` methods directly
accessible, which provide power API for interacting with sub elements. As
part of this, a new AttrTypeWalker class is introduced that supports caching
walked attributes/types, and a friendlier API (see the simplification of symbol
walking in SymbolTable.cpp).

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

17 months ago[lldb][Test] TestVSCode_completions.py: fix expected type strings
Michael Buch [Fri, 27 Jan 2023 23:21:49 +0000 (23:21 +0000)]
[lldb][Test] TestVSCode_completions.py: fix expected type strings

Fixes build failures following https://reviews.llvm.org/D141828

17 months ago[mlir][sparse] fixed typo
Aart Bik [Fri, 27 Jan 2023 22:29:31 +0000 (14:29 -0800)]
[mlir][sparse] fixed typo

Reviewed By: bixia

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

17 months ago[flang][parser] Diagnose an invalid space
Peter Klausler [Fri, 6 Jan 2023 01:04:10 +0000 (17:04 -0800)]
[flang][parser] Diagnose an invalid space

In free form, don't silently skip over an invalid space between
an underscore and a kind parameter.

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

17 months ago[flang] Correct procedure pointer (or dummy) compatibility check
Peter Klausler [Sun, 1 Jan 2023 15:35:37 +0000 (07:35 -0800)]
[flang] Correct procedure pointer (or dummy) compatibility check

Fix a subtle bug in procedure compatibility checking with base
derived types vs. their extensions to ensure that a procedure
expecting an extended type cannot be associated with a pointer
(or dummy procedure) to a procedure expecting a base type.

  subroutine s1(base); ... subroutine s2(extended)
  procedure(s1), pointer :: p
  p => s2 ! <- must be caught as an error

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

17 months agoReland "[lldb] Add support for DW_AT_default_value in template params"
Michael Buch [Sun, 15 Jan 2023 03:26:41 +0000 (03:26 +0000)]
Reland "[lldb] Add support for DW_AT_default_value in template params"

**Summary**

This patch makes LLDB understand the `DW_AT_default_value` on
template argument DIEs. As a result, type summaries will no
longer contain the defaulted template arguments, reducing
noise substantially. E.g.,

Before:
```
(lldb) v nested
(std::vector<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::allocator<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator <char> > > > > >) nested = size=0 {}
```

After:
```
(lldb) v nested
(std::vector<std::vector<std::basic_string<char> > >) nested = size=0 {}
```

See discussion in https://reviews.llvm.org/D140423

**Testing**

* Adjust API tests
* Added unit-test

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

17 months ago[flang] Prohibit multiple separate module procedure definitions
Peter Klausler [Fri, 30 Dec 2022 23:26:44 +0000 (15:26 -0800)]
[flang] Prohibit multiple separate module procedure definitions

Ensure that non-BIND(C) separate module procedures are not
defined more than once.

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

17 months ago[flang] Don't apply intrinsic assignment check for PURE subprograms to defined assignment
Peter Klausler [Thu, 29 Dec 2022 19:36:20 +0000 (11:36 -0800)]
[flang] Don't apply intrinsic assignment check for PURE subprograms to defined assignment

A semantic constraint on assignments in PURE subprograms (C1594) applies
only to an intrinsic assignment and should not be checked in the case of
a defined assignment.

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

17 months ago[lldb][test] Set minimum compiler_versions
Dave Lee [Tue, 24 Jan 2023 23:53:17 +0000 (15:53 -0800)]
[lldb][test] Set minimum compiler_versions

Set compiler_versions on these tests, as they fail if tested on lower compiler
versions versions.

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

17 months ago[flang] Catch obscure error in defined assignment
Peter Klausler [Sat, 31 Dec 2022 00:18:05 +0000 (16:18 -0800)]
[flang] Catch obscure error in defined assignment

A subroutine that implements a defined assignment cannot have
a dummy argument for its second operand (the RHS of the assignment)
with the POINTER or ALLOCATABLE attributes, since the RHS of
an assignment is always an expression.  This problem is flagged
as a fatal error in other compilers, so let's make it fatal here
as well.

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

17 months ago[NVPTX] Infer AS of pointers passed to kernels as integers.
Artem Belevich [Thu, 26 Jan 2023 21:28:31 +0000 (13:28 -0800)]
[NVPTX] Infer AS of pointers passed to kernels as integers.

When pointers are passed within aggregates, we sometimes end up with IR that
loads them as integers and the converts them back to pointers. Typically it's
due to a memcpy or SROA. E.g. https://godbolt.org/z/xM3n5daaa

Normally we treat all pointers passed to a CUDA kernel as global pointers and
the same treatment should be applied to the pointers we load/store as integers.

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

17 months ago[mlri][ExecutionEngine] Don't globaly set CMake prefixes to find HIP
Krzysztof Drewniak [Mon, 23 Jan 2023 16:33:43 +0000 (16:33 +0000)]
[mlri][ExecutionEngine] Don't globaly set CMake prefixes to find HIP

The HIP CMake files expect to find their own dependencies and don't
use or respect PATHS or HINTS, relying on CMAKE_PREFIX_PATH to contain
/opt/rocm and /opt/rocm/hip . This is not great for the rest of the
build. Therefore, copy the CMake prefix path, add the ROCm
directories, find HIP, and reset the path to its old value.

Reviewed By: arsenm

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

17 months ago[llvm-cov] Fix logic error in debuginfod lookup.
Daniel Thornburgh [Fri, 27 Jan 2023 20:23:35 +0000 (12:23 -0800)]
[llvm-cov] Fix logic error in debuginfod lookup.

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

17 months ago[libc] Add code for detecting NVIDIA GPUs as well
Joseph Huber [Fri, 27 Jan 2023 19:04:50 +0000 (13:04 -0600)]
[libc] Add code for detecting NVIDIA GPUs as well

Recently the `nvptx-arch` tool was added to address the lack of a
similar tool for detecting locally installed NVIDIA GPUs. This patch
adds similar functionality for the already existing `amdgpu-arch` tool
in libc. These will be used to run tests on the user's system in the
future. On a system with both GPUs installed we will just go with the
first GPU detected. In the future we may want to configure the tests to
run on both of them.

Reviewed By: sivachandra, lntue

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

17 months ago[libc] Do not install to the default triple in GPU mode
Joseph Huber [Fri, 27 Jan 2023 18:08:28 +0000 (12:08 -0600)]
[libc] Do not install to the default triple in GPU mode

Currently this logic causes the `libcgpu.a` to be installed to the
user's default triple. The GPU target isn't really true to this in a
cross-compiling sense so we should just default to the regular `/lib`
directory

Reviewed By: sivachandra, lntue

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

17 months ago[flang] Don't fold STORAGE_SIZE() on polymorphic argument
Peter Klausler [Fri, 20 Jan 2023 00:42:59 +0000 (16:42 -0800)]
[flang] Don't fold STORAGE_SIZE() on polymorphic argument

More generally, don't return a successful result from
Fortran::evaluate::DynamicType::MeasureSizeInBytes() when the
type is polymorphic.

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

17 months ago[libc] Use a prebuilt libc-hdrgen binary if available.
Siva Chandra Reddy [Tue, 10 Jan 2023 19:33:45 +0000 (19:33 +0000)]
[libc] Use a prebuilt libc-hdrgen binary if available.

This feature will primarily by used by the runtimes build. In the
runtimes build, we build libc-hdrgen once for the host and use it
to build the libc for other targets. So, the host libc-hdrgen is
like a prebuilt passed to the target builds.

Reviewed By: lntue

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

17 months agoRevert "[BranchRelaxation] Move faulting_op check into callee [nfc]"
Philip Reames [Fri, 27 Jan 2023 19:52:22 +0000 (11:52 -0800)]
Revert "[BranchRelaxation] Move faulting_op check into callee [nfc]"

This reverts commit c549da959b81902789a17918c5b95d4449e6fdfa.  Per buildbots, this was not NFC.

17 months ago[RISCV][InsertVSETVLI] Handle partially transparent instructions in PRE
Philip Reames [Fri, 27 Jan 2023 19:48:14 +0000 (11:48 -0800)]
[RISCV][InsertVSETVLI] Handle partially transparent instructions in PRE

The PRE implementation was being overly strict when checking to see if a vsetvli was removed in the current block. For instructions which don't use all the fields of VTYPE or VL, we can propagate a changed state past the first instruction with an SEW operand and remove a vsetvli later in the block. We do need to be careful now to ensure that the state convergences before the end of the block or we'd invalidate the cached data flow results.

Taking a step back, we're modeling the effect of the emitVSETVLIs pass which runs just after PRE. This is unfortunate, and makes me think we should probably reevaluate doing the PRE as a post-pass instead of as surgery in the data flow phases. Doing that requires us to get more aggressive about mutating user written vsetvlis which we've tried not to do up to now, but well, maybe it's time? Anyways, that's a thought for the future, not something I'm proposing doing now.

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

17 months ago[clang][deps] Fix modulemap file path for implementation of module
Ben Langmuir [Tue, 24 Jan 2023 21:21:11 +0000 (13:21 -0800)]
[clang][deps] Fix modulemap file path for implementation of module

Use the name "as requested" for the path of the implemented module's
modulemap file, just as we do for other modulemap file paths. This fixes
fatal errors with modules where we tried to find framework headers
relative to the wrong directory when imported by an implementation file
of the same module.

rdar://104619123

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

17 months ago[mlir][sparse] refactoring isAdmissibleTensorExp into codegen
Peiming Liu [Wed, 18 Jan 2023 18:19:32 +0000 (18:19 +0000)]
[mlir][sparse] refactoring isAdmissibleTensorExp into codegen

This patch moves some utils into CodegenEnv class, it should make the code easier to follow and it eliminates several indirect value assignment that use `ptr**`.

Reviewed By: aartbik

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

17 months ago[BranchRelaxation] Move faulting_op check into callee [nfc]
Philip Reames [Fri, 27 Jan 2023 19:23:53 +0000 (11:23 -0800)]
[BranchRelaxation] Move faulting_op check into callee [nfc]

Mostly to remove a special case from an upcoming patch.

17 months ago[SystemZ] Fix handling of vectors and their exposure of the vector ABI.
Jonas Paulsson [Tue, 10 Jan 2023 00:51:11 +0000 (18:51 -0600)]
[SystemZ] Fix handling of vectors and their exposure of the vector ABI.

- Global vector variables expose the vector ABI through their alignments only
  if they are >=16 bytes in size.

- Vectors passed between functions expose the vector ABI only if they are
  <=16 bytes in size.

LLVM test suite builds with gcc/clang now give the same gnu attributes emitted.

Reviewed By: Ulrich Weigand

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

17 months agoworkflows: Fix libclc tests
Tom Stellard [Fri, 27 Jan 2023 19:23:19 +0000 (11:23 -0800)]
workflows: Fix libclc tests

libclc requires using cmake files to detect the LLVM installation instead
of llvm-config so we need to update our cmake invocation.

Reviewed By: thieta

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

17 months agolibclc: Fix building against an llvm build directory
Tom Stellard [Fri, 27 Jan 2023 19:15:54 +0000 (11:15 -0800)]
libclc: Fix building against an llvm build directory

Reviewed By: thieta

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

17 months agoFix recursive error for constraints depending on itself incorrectly
Erich Keane [Fri, 27 Jan 2023 19:06:07 +0000 (11:06 -0800)]
Fix recursive error for constraints depending on itself incorrectly

Fixes: #60323

https://github.com/llvm/llvm-project/issues/60323

The problem is that we are profiling the 'Expr' components directly,
however when they contain an unresolved lookup, those canonicalize
identically.  The result was the two versions of calls to 'go' were
canonicalized identically.

This patch fixes this by ensuring we consider the declaration the
constraint is attached to, when possible.  When not, we skip the
diagnostic.

The result is that we are relaxing our diagnostic in some cases (Of
which I couldn't come up with a reproducer), such that we might see
overflows when evaluating constraints that depend on themselves in a way
that they are not attached to a declaration directly, such as if
they are nested requirements, though the hope is this won't be a
problem, since the 'parent' named constraint would catch this.  I'm
hopeful that the 'worst case' is that we catch recursion 'later' in the
process, instead of immediately.

17 months agoworkflows: Bump python version on Windows to try to fix lldb failure
Tom Stellard [Fri, 27 Jan 2023 19:06:18 +0000 (11:06 -0800)]
workflows: Bump python version on Windows to try to fix lldb failure

Reviewed By: thieta

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

17 months ago[clang-tidy] Fix warning in portability-simd-intrinsics
Piotr Zegar [Wed, 25 Jan 2023 18:00:33 +0000 (18:00 +0000)]
[clang-tidy] Fix warning in portability-simd-intrinsics

When portability-simd-intrinsics.Suggest were set to false,
produced warning were missing source location,
and due to that such warning coudn't be NOLINTed.

Added missing tests.

Fixes issues: https://github.com/llvm/llvm-project/issues/52831

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

17 months agolibclc: Set CMAKE_CXX_STANDARD to 17 to match llvm
Tom Stellard [Fri, 27 Jan 2023 18:50:01 +0000 (10:50 -0800)]
libclc: Set CMAKE_CXX_STANDARD to 17 to match llvm

Reviewed By: thieta

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

17 months ago[CMake] Include clang-bolt bootstrap target in BOLT-PGO.cmake
Amir Ayupov [Fri, 27 Jan 2023 17:48:13 +0000 (09:48 -0800)]
[CMake] Include clang-bolt bootstrap target in BOLT-PGO.cmake

Preemptively include clang-bolt target in BOLT-PGO CMake cache file,
in preparation of https://reviews.llvm.org/D139454 to avoid breaking
bolt-x86_64-ubuntu-clang-bolt-lto-pgo buildbot.

17 months ago[lldb] Make SBSection::GetSectionData call Section::GetSectionData.
Jorge Gorbe Moya [Thu, 26 Jan 2023 22:23:41 +0000 (14:23 -0800)]
[lldb] Make SBSection::GetSectionData call Section::GetSectionData.

`SBSection::GetSectionData` and `Section::GetSectionData` are
implemented differently, and the `SBSection` method doesn't handle
compressed sections correctly.

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

17 months ago[gn build] Enable check-bolt on Linux
Arthur Eubanks [Tue, 17 Jan 2023 01:47:12 +0000 (17:47 -0800)]
[gn build] Enable check-bolt on Linux

It builds but not all tests pass, mostly due to missing libbolt_rt_instr.a.

Reviewed By: thakis

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

17 months agoFix tsan problem where the per-thread shared_ptr() can be locked right before the...
Qiao Zhang [Fri, 27 Jan 2023 17:49:29 +0000 (18:49 +0100)]
Fix tsan problem where the per-thread shared_ptr() can be locked right before the cache is destroyed causing a race where it tries to remove an entry from a destroyed cache.

Reviewed By: rriddle

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

17 months agodisable-language-runtime-unwindplans desc rewrite to be searchable
Jason Molenda [Fri, 27 Jan 2023 17:39:31 +0000 (09:39 -0800)]
disable-language-runtime-unwindplans desc rewrite to be searchable

The description for disable-language-runtime-unwindplans did not
include likely search terms ("backtrace", "stack"), rewrite it
to include those so it is more easily discoverable with apropos.
The text is still not the clearest description of what a language
runtime is / what it might do, but this is better.

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

17 months agoDon't flag memory-only mach-o corefiles as invalid
Jason Molenda [Fri, 27 Jan 2023 17:37:34 +0000 (09:37 -0800)]
Don't flag memory-only mach-o corefiles as invalid

It is possible to have a memory-only mach-o corefile, with the
threads provided by an os-plugin thread provider, or a scripted
process, in Python.

Differential Revision: https://reviews.llvm.org/D142662
rdar://102579544

17 months ago[LinkerWrapper] Add support for --[no-]whole-archive into the linker wrapper
Joseph Huber [Fri, 27 Jan 2023 17:29:47 +0000 (11:29 -0600)]
[LinkerWrapper] Add support for --[no-]whole-archive into the linker wrapper

Summary:
This patch adds support for `--[no-]whole-archive` to the linker
wrapper. This allows us to bypass the symbol resolution logic that is
normally used for static archives. For multi-architecture binaries this
also allows us to build for every single member.

17 months ago[Verifier][WinEH] Check funclet tokens on intrinsic calls that may lower to function...
Stefan Gränitz [Fri, 27 Jan 2023 15:48:05 +0000 (16:48 +0100)]
[Verifier][WinEH] Check funclet tokens on intrinsic calls that may lower to function calls

WinEHPrepare requires funclet operand bundles ("tokens") on function calls from EH funclets to prevent them from getting removed as "implausible" calls. This includes calls to intrinsic functions that lower to function calls in the course of IR transformations (e.g. ObjC ARC runtime calls).

We can not detect such cases in WinEHPrepare itself, because at this point they mixed up with valid implausible calls. These must be removed to guarantee that the EH backend can assign unique colors and EH state numbers to all blocks.

This patch allows the IR Verifier to detect missing and dangling funclet tokens. Non-conforming IR becomes illegal and miscompilations are detected early. In order to find funclet pad instructions for funclets that extend over multiple blocks, we have to calculate EH funclet colors. As coloring can be expensive, it runs on-demand and results are cached per function.

Reviewed By: efriedma

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

17 months agoLift EHPersonalities from Analysis to IR (NFC)
Stefan Gränitz [Tue, 24 Jan 2023 11:29:53 +0000 (12:29 +0100)]
Lift EHPersonalities from Analysis to IR (NFC)

Computing EH-related information was only relevant for analysis passes so far. Lifting it to IR will allow the IR Verifier to calculate EH funclet coloring and validate funclet operand bundles in a follow-up step.

Reviewed By: rnk, compnerd

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

17 months ago[mlir][sparse] Implement BufferizableOpInterface for additional ops
Matthias Springer [Fri, 27 Jan 2023 16:49:26 +0000 (17:49 +0100)]
[mlir][sparse] Implement BufferizableOpInterface for additional ops

The handling of unknown ops will be tightened in a subsequent change. All sparse_tensor ops should implement BufferizableOpInterface, otherwise, they are treated as "unknown" and additional buffer allocs/copies may be inserted around them.

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

17 months ago[mlir][sparse][NFC] Disallow writing into sparse_tensor.to_... results
Matthias Springer [Fri, 27 Jan 2023 16:49:14 +0000 (17:49 +0100)]
[mlir][sparse][NFC] Disallow writing into sparse_tensor.to_... results

Writing into the memrefs returned by `sparse_tensor.to_values` etc. can cause additional copies during bufferization.

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

17 months ago[LinkerWrapper][NFC] Remove unused options
Joseph Huber [Fri, 27 Jan 2023 16:44:16 +0000 (10:44 -0600)]
[LinkerWrapper][NFC] Remove unused options

Summary:
These options are no longer used, we don't need to keep them.

17 months ago[lldb][CXXModuleHandler] Set TemplateArgument::IsDefaulted
Michael Buch [Fri, 27 Jan 2023 14:17:02 +0000 (14:17 +0000)]
[lldb][CXXModuleHandler] Set TemplateArgument::IsDefaulted

Since https://reviews.llvm.org/D141827 this field gets used
to print type names. Thus propagate it after importing TemplateArguments
from modules.

**Testing**

* Confirmed that this fixes the ongoing `import-std-module` test
  failures.

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

17 months ago[clang][ASTImporter] Propagate TemplateArgument::IsDefaulted during import
Michael Buch [Fri, 27 Jan 2023 14:09:48 +0000 (14:09 +0000)]
[clang][ASTImporter] Propagate TemplateArgument::IsDefaulted during import

With https://reviews.llvm.org/D141826 `TemplateArgument`s have an
additional field that indicates their defaulted-ness. This gets
used during debug-info generation and in the `clang::TypePrinter`.

This patch copies the field during the import process so consumers
of the ASTImporter can benefit from the other Clang components that
read the field.

**Testing**

* Added unit-test
* Checked that this fixes (in addition to a follow-up LLDB patch)
  fix current test failures in LLDB

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

17 months ago[mlir][NFC] GreedyPatternRewriteDriver: Merge region-based and multi-op-based drivers
Matthias Springer [Fri, 27 Jan 2023 16:25:55 +0000 (17:25 +0100)]
[mlir][NFC] GreedyPatternRewriteDriver: Merge region-based and multi-op-based drivers

Deduplicate large parts of the worklist processing (`GreedyPatternRewriteDriver::processWorklist`).

The new class hierarchy is as follows:
```
          GreedyPatternRewriteDriver (abstract)
                       ^
                       |
      -----------------------------------
      |                                 |
RegionPatternRewriteDriver         MultiOpPatternRewriteDriver
```

Also update the Markdown documentation.

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

17 months ago[flang] Add Count to simplified intrinsics
Sacha Ballantyne [Fri, 27 Jan 2023 15:31:42 +0000 (15:31 +0000)]
[flang] Add Count to simplified intrinsics

This patch adds a simplfiied version of count for the simplify intrinsics pass, allowing the function to be inlined.

This was done specifically to help improve performance for exchange2, and provides a ~12% performance increase.

Reviewed By: vzakhari, Leporacanthicus

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

17 months ago[gn] merge 650bbc56203c9
Nico Weber [Fri, 27 Jan 2023 16:26:55 +0000 (11:26 -0500)]
[gn] merge 650bbc56203c9

Needed to link e.g. LexTests after ca446037af0.

17 months agoCorrect the link to the latest C DR status page for C11 and C17
Aaron Ballman [Fri, 27 Jan 2023 16:17:42 +0000 (11:17 -0500)]
Correct the link to the latest C DR status page for C11 and C17

We were linking against:
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm

However, the latest DR page for the 400s is:
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm

17 months ago[libc][math] Implement asinhf function correctly rounded for all rounding modes.
Tue Ly [Fri, 27 Jan 2023 15:15:46 +0000 (10:15 -0500)]
[libc][math] Implement asinhf function correctly rounded for all rounding modes.

Implement asinhf function correctly rounded for all rounding modes.

Reviewed By: zimmermann6

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

17 months ago[libc++] Disables a test in clang-17.
Mark de Wever [Fri, 27 Jan 2023 16:01:55 +0000 (17:01 +0100)]
[libc++] Disables a test in clang-17.

This test already had issues and bumping main to 17 causes them to fail
again.

17 months ago[SCCP] Add test cases with switch on range containing undef.
Florian Hahn [Fri, 27 Jan 2023 16:02:29 +0000 (16:02 +0000)]
[SCCP] Add test cases with switch on range containing undef.

17 months agoStop diagnosing member and array access in offsetof as an extension
Aaron Ballman [Fri, 27 Jan 2023 16:01:12 +0000 (11:01 -0500)]
Stop diagnosing member and array access in offsetof as an extension

This was a mistake from e7300e75b51a7e7d4e81975b4be7a6c65f9a8286
(https://reviews.llvm.org/D133574) caused by us accidentally tracking
an older copy of the C DR list for DR496. The text in
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_496 makes
it clear that subobjects are allowed, which means member and array
access expressions are allowed.

This backs out the changes from the previous commit that relate to this
diagnostic.

17 months ago[gn] port a3b0dde4edb9 (llvm-cov -> Debuginfod dep)
Nico Weber [Fri, 27 Jan 2023 15:59:54 +0000 (10:59 -0500)]
[gn] port a3b0dde4edb9 (llvm-cov -> Debuginfod dep)

17 months agoRevert "[DAGCombine] fp_to_sint isSaturatingMinMax"
Samuel Parker [Fri, 27 Jan 2023 15:31:54 +0000 (15:31 +0000)]
Revert "[DAGCombine] fp_to_sint isSaturatingMinMax"

This reverts commit 85395af27241ab9c8d5763b8afcaa07f1bab26d5.

This is causing trouble with scalable vectors.

17 months ago[NFC][AArch64] Get extension strings directly from ArchInfo in target parser
Lucas Prates [Wed, 25 Jan 2023 12:15:00 +0000 (12:15 +0000)]
[NFC][AArch64] Get extension strings directly from ArchInfo in target parser

Reviewed By: tmatheson

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