platform/upstream/llvm.git
13 months agoFix "[compiler-rt] Allow 3 simultaneous interceptors on Linux"
Marco Elver [Wed, 7 Jun 2023 07:17:43 +0000 (09:17 +0200)]
Fix "[compiler-rt] Allow 3 simultaneous interceptors on Linux"

No need to "error" on unsupported architectures, since we technically
only care where the macro is used. If the macro is undefined, and used,
the compiler will producer an error anyway.

This fixes build on Windows, where none of these macros should be used.

13 months ago[compiler-rt] Allow 3 simultaneous interceptors on Linux
Marco Elver [Tue, 30 May 2023 17:27:59 +0000 (19:27 +0200)]
[compiler-rt] Allow 3 simultaneous interceptors on Linux

Rework Linux (and *BSD) interceptors to allow for up to 3 (2 for *BSD)
simultaneous interceptors. See code comments for details.

The main motivation is to support new sampling sanitizers (in the spirit
of GWP-ASan), that have to intercept few functions. Unfortunately, the
reality is that there are user interceptors that exist in the wild.

To support foreign user interceptors, foreign dynamic analysis
interceptors, and compiler-rt interceptors all at the same time,
including any combination of them, this change enables up to 3
interceptors on Linux (2 on *BSD).

Reviewed By: dvyukov, MaskRay, vitalybuka

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

13 months ago[mlir][linalg] Add option to pad Linalg ops to a specified multiple
Matthias Springer [Wed, 7 Jun 2023 06:43:58 +0000 (08:43 +0200)]
[mlir][linalg] Add option to pad Linalg ops to a specified multiple

A multiple (int64_t) can optionally be specified for every padding dimension.

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

13 months ago[mlir][linalg][NFC] Simplify padOperandToSmallestStaticBoundingBox
Matthias Springer [Wed, 7 Jun 2023 06:43:21 +0000 (08:43 +0200)]
[mlir][linalg][NFC] Simplify padOperandToSmallestStaticBoundingBox

The implementation is based on `ValueBoundsOpInterface` to compute upper bounds for tensor dim sizes. It is not necessary to skip over certain ops and reify shape dims; `ValueBoundsOpInterface` already takes care of that.

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

13 months ago[LoopIdiom] Freeze BitPos if !isGuaranteedNotToBeUndefOrPoison
luxufan [Wed, 7 Jun 2023 06:01:59 +0000 (14:01 +0800)]
[LoopIdiom] Freeze BitPos if !isGuaranteedNotToBeUndefOrPoison

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

Reviewed By: nikic

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

13 months ago[CodeGen] Disable default copy assignment operator for struct VectorInfo
Bing1 Yu [Wed, 7 Jun 2023 06:32:36 +0000 (14:32 +0800)]
[CodeGen] Disable default copy assignment operator for struct VectorInfo

struct VectorInfo manages resources such as dynamically allocated memory, it's generally a good practice to either implement a custom copy constructor or disable the default one

Reviewed By: kazu

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

13 months ago[CodeGen] Disable default copy ctor and copy assignment operator for class Array
Bing1 Yu [Wed, 7 Jun 2023 06:31:42 +0000 (14:31 +0800)]
[CodeGen] Disable default copy ctor and copy assignment operator for class Array

class Array manages resources such as dynamically allocated memory, it's generally a good practice to either implement a custom copy constructor or disable the default one.

Reviewed By: pengfei

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

13 months ago[CodeGen] Disable default copy ctor and copy assignment operator for VLIWPacketizerList
Bing1 Yu [Wed, 7 Jun 2023 06:30:48 +0000 (14:30 +0800)]
[CodeGen] Disable default copy ctor and copy assignment operator for VLIWPacketizerList

Reviewed By: pengfei

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

13 months ago[CodeGen] Disable default copy ctor and copy assignment operator for class Scoreboard
Bing1 Yu [Wed, 7 Jun 2023 06:29:48 +0000 (14:29 +0800)]
[CodeGen] Disable default copy ctor and copy assignment operator for class Scoreboard

Reviewed By: pengfei

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

13 months ago[CodeGen] Disable default copy ctor and copy assignment operator for InterferenceCache
Bing1 Yu [Wed, 7 Jun 2023 06:28:39 +0000 (14:28 +0800)]
[CodeGen] Disable default copy ctor and copy assignment operator for InterferenceCache

Reviewed By: pengfei

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

13 months ago[CodeGen] Disable default copy ctor and copy assignment operator for class Circuits
Bing1 Yu [Wed, 7 Jun 2023 06:27:49 +0000 (14:27 +0800)]
[CodeGen] Disable default copy ctor and copy assignment operator for class Circuits

Reviewed By: aprantl

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

13 months ago[CodeGen] Disable default copy ctor and copy assignment operator for VLIWResourceModel
Bing1 Yu [Wed, 7 Jun 2023 06:26:37 +0000 (14:26 +0800)]
[CodeGen] Disable default copy ctor and copy assignment operator for VLIWResourceModel

Reviewed By: JamesNagurne

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

13 months ago[RISCV] Fix sched class for MC layer version of vmsgt.vx.
Craig Topper [Wed, 7 Jun 2023 06:21:23 +0000 (23:21 -0700)]
[RISCV] Fix sched class for MC layer version of vmsgt.vx.

13 months agoSet isRequired true for CFGViewer/CFGPrinter passes
Wenju He [Wed, 7 Jun 2023 06:12:22 +0000 (14:12 +0800)]
Set isRequired true for CFGViewer/CFGPrinter passes

This PR allows function's cfg to be viewed/printed even if the function
has optnone attribute.

Reviewed By: MaskRay

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

13 months ago[RISCV] Fix sched class for MC layer version of vrsub.vx.
Craig Topper [Wed, 7 Jun 2023 05:52:27 +0000 (22:52 -0700)]
[RISCV] Fix sched class for MC layer version of vrsub.vx.

13 months ago[LoongArch] Define `ual` feature and override `allowsMisalignedMemoryAccesses`
Weining Lu [Wed, 7 Jun 2023 03:20:30 +0000 (11:20 +0800)]
[LoongArch] Define `ual` feature and override `allowsMisalignedMemoryAccesses`

Some CPUs do not allow memory accesses to be unaligned, e.g. 2k1000la
who uses the la264 core on which misaligned access will trigger an
exception.

In this patch, a backend feature called `ual` is defined to decribe
whether the CPU supports unaligned memroy accesses. And this feature
can be toggled by clang options `-m[no-]unaligned-access` or the
aliases `-m[no-]strict-align`. When this feature is on,
`allowsMisalignedMemoryAccesses` sets the speed number to 1 and returns
true that allows the codegen to generate unaligned memory access insns.

Clang options `-m[no-]unaligned-access` are moved from `m_arm_Features_Group`
to `m_Group` because now more than one targets use them. And a test
is added to show that they remain unused on a target that does not
support them. In addition, to keep compatible with gcc, a new alias
`-mno-strict-align` is added which is equal to `-munaligned-access`.

The feature name `ual` is consistent with linux kernel [1] and the
output of `lscpu` or `/proc/cpuinfo` [2].

There is an `LLT` variant of `allowsMisalignedMemoryAccesses`, but
seems that curently it is only used in GlobalISel which LoongArch
doesn't support yet. So this variant is not implemented in this patch.

[1]: https://github.com/torvalds/linux/blob/master/arch/loongarch/include/asm/cpu.h#L77
[2]: https://github.com/torvalds/linux/blob/master/arch/loongarch/kernel/proc.c#L75

Reviewed By: xen0n

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

13 months ago[RISCV] Split scheduler classes for vector min/max from compares.
Craig Topper [Wed, 7 Jun 2023 05:25:22 +0000 (22:25 -0700)]
[RISCV] Split scheduler classes for vector min/max from compares.

Compares write a mask result. Min/max write a full result. This
makes them sufficiently different to have their own classes.

Reviewed By: pcwang-thead

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

13 months ago[libc] Fix undefined behavior of left shifting signed integer in exp2f.cpp.
Tue Ly [Wed, 7 Jun 2023 04:32:27 +0000 (00:32 -0400)]
[libc] Fix undefined behavior of left shifting signed integer in exp2f.cpp.

Fix undefined behavior of left shifting signed integer in exp2f.cpp.

Reviewed By: sivachandra

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

13 months ago[NFC][Driver] Change Multilib flag representation
Michael Platings [Tue, 6 Jun 2023 13:03:54 +0000 (14:03 +0100)]
[NFC][Driver] Change Multilib flag representation

This new representation means that a valid command line option may
potentially be used directly as a multilib flag without any translation.

To indicate that a flag is required not to be present, its first
character is replaced with '!', which is intended for consistency with
the logical not operator in many programming languages.

Reviewed By: simon_tatham

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

13 months ago[NFC][Driver] Change MultilibBuilder interface
Michael Platings [Wed, 24 May 2023 14:20:01 +0000 (15:20 +0100)]
[NFC][Driver] Change MultilibBuilder interface

Decouple the interface of the MultilibBuilder flag method from how flags
are stored internally. Likewise change the addMultilibFlag function.

Currently a multilib flag like "-fexceptions" means a multilib is
*incompatible* with the -fexceptions command line option, which is
counter-intuitive. This change is a step towards changing this scheme.

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

13 months ago[ValueTracking] Implied conditions for lshr
Joshua Cao [Wed, 7 Jun 2023 03:27:24 +0000 (20:27 -0700)]
[ValueTracking] Implied conditions for lshr

`V1 >> V2 u<= V1` for any V1, V2

This works for lshr and any div's that are changed to lshr's

This fixes issues in clang and rustc:
https://github.com/llvm/llvm-project/issues/62441
https://github.com/rust-lang/rust/issues/110971

Reviewed By: goldstein.w.n

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

13 months ago[InstSimplify] Add tests for shl implied conditions
Joshua Cao [Wed, 7 Jun 2023 03:26:28 +0000 (20:26 -0700)]
[InstSimplify] Add tests for shl implied conditions

13 months ago[M68k,MSP430,VE,Xtensa] Migrate to new encodeInstruction that uses SmallVectorImpl...
Fangrui Song [Wed, 7 Jun 2023 04:02:51 +0000 (21:02 -0700)]
[M68k,MSP430,VE,Xtensa] Migrate to new encodeInstruction that uses SmallVectorImpl<char>. NFC

13 months ago[flang][hlfir] Enable assignments with allocatable components.
Slava Zakharin [Tue, 6 Jun 2023 23:12:49 +0000 (16:12 -0700)]
[flang][hlfir] Enable assignments with allocatable components.

The TODO was left there to verify that Assign() runtime handles
overlaps of allocatable components. It did not, and this change-set
fixes it. Note that the same Assign() issue can be reproduced
without HLFIR. In the following example the LHS would be reallocated
before value of RHS (essentially, the same memory) is read:
```
program main
  type t1
     integer, allocatable :: a(:)
  end type t1
  type(t1) :: x, y
  allocate(x%a(10))
  do i =1,10
     x%a(i) = 2*i
  end do
  x = x
  print *, x%a
  deallocate(x%a)
end program main
```

The test's output would be incorrect (though, this depends on the memory
reuse by malloc):
0 0 0 0 10 12 14 16 18 20

It is very hard to add a Flang unittest exploiting derived types.

Reviewed By: klausler

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

13 months ago[Hexagon,Lanai,LoongArch,Sparc] Migrate to new encodeInstruction that uses SmallVecto...
Fangrui Song [Wed, 7 Jun 2023 03:21:00 +0000 (20:21 -0700)]
[Hexagon,Lanai,LoongArch,Sparc] Migrate to new encodeInstruction that uses SmallVectorImpl<char>. NFC

13 months ago[LoongArch] Define the LAELF v20230519 relocs
WANG Xuerui [Wed, 7 Jun 2023 03:16:02 +0000 (11:16 +0800)]
[LoongArch] Define the LAELF v20230519 relocs

The LoongArch ELF psABI document has changed location and versioning
scheme; this revision is v2.10 in the old scheme. Notably this revision
brings initial capability of linker relaxation to LoongArch.

Reviewed By: SixWeining, MaskRay

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

13 months ago[LICM] [Coroutines] Don't hoist threadlocals within presplit coroutines
Chuanqi Xu [Wed, 7 Jun 2023 02:16:19 +0000 (10:16 +0800)]
[LICM] [Coroutines] Don't hoist threadlocals within presplit coroutines

Close https://github.com/llvm/llvm-project/issues/63022

This is the following of https://reviews.llvm.org/D135550, which is
discussed in
https://discourse.llvm.org/t/rfc-unify-memory-effect-attributes/65579.
In my imagination, we could fix the issue fundamentally after we
introduces new memory kind thread id. But I am not very sure if we can
fix the issue fundamentally in time.

Besides that, I think the correctness is the most important. So it
should not be bad to land this given it is innocent.

Reviewed By: nikic

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

13 months ago[AMDGPU][IGLP]: Add rules to SchedGroups
Jeffrey Byrnes [Fri, 28 Apr 2023 14:40:00 +0000 (07:40 -0700)]
[AMDGPU][IGLP]: Add rules to SchedGroups

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

Change-Id: Icd7aaaa0b257a25713c22ead0813777cef7d5859

13 months ago[gn build] Port 1794532bb942
LLVM GN Syncbot [Wed, 7 Jun 2023 02:14:26 +0000 (02:14 +0000)]
[gn build] Port 1794532bb942

13 months ago[InstrProf] Move BPFunctionNode test to ProfileDataTests
Ellis Hoag [Wed, 7 Jun 2023 01:04:11 +0000 (18:04 -0700)]
[InstrProf] Move BPFunctionNode test to ProfileDataTests

In https://reviews.llvm.org/D147812 I created
`BalancedPartitioningTest.cpp` and inadvertently drastically increased the
number of files needed to compile `SupportTests`. Instead lets move the
`BPFunctionNode` test to `unittests/ProfileData` so we can remove the
extra dependency.

Reviewed By: thakis

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

13 months ago[Coroutines] [LICM] Precommit test for D151774
Chuanqi Xu [Wed, 7 Jun 2023 02:10:17 +0000 (10:10 +0800)]
[Coroutines] [LICM] Precommit test for D151774

This is required in the review.

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

13 months ago[RISCV] Remove overly restrictive assert from negateFMAOpcode.
Craig Topper [Wed, 7 Jun 2023 01:34:15 +0000 (18:34 -0700)]
[RISCV] Remove overly restrictive assert from negateFMAOpcode.

It's possible that both multiplicands are being negated. This won't
change the opcode, but we can delete the two negates. Allow this
case to get through negateFMAOpcode.

I think D152260 will also fix this test case, but in the future
it may be possible for an fneg to appear after we've already converted
to RISCVISD opcodes in which case D152260 won't help.

Reviewed By: fakepaper56

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

13 months ago[NFC] Remove unneeded semicolon after function definition
Jim Lin [Tue, 6 Jun 2023 02:24:18 +0000 (10:24 +0800)]
[NFC] Remove unneeded semicolon after function definition

13 months ago[RISCV] Fix UBSan failure on signed integer overflow.
Craig Topper [Wed, 7 Jun 2023 01:27:33 +0000 (18:27 -0700)]
[RISCV] Fix UBSan failure on signed integer overflow.

13 months agoRevert "[TypePromotion] Don't treat bitcast as a Source"
Paul Kirth [Wed, 7 Jun 2023 00:45:49 +0000 (00:45 +0000)]
Revert "[TypePromotion] Don't treat bitcast as a Source"

This reverts commit 27aea17fe061f9778bb1e8ff5fdf9fc0fb03abe1.
For details, see: https://reviews.llvm.org/D152112

Fuchsia CI failure: https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/clang-linux-arm64/b8779118297575483793/overview

13 months ago[gn build] Port 44268271f61e
LLVM GN Syncbot [Wed, 7 Jun 2023 00:45:47 +0000 (00:45 +0000)]
[gn build] Port 44268271f61e

13 months ago[lldb/test] Fix target-label.test on Fuchsia
Med Ismail Bennani [Wed, 7 Jun 2023 00:40:41 +0000 (17:40 -0700)]
[lldb/test] Fix target-label.test on Fuchsia

This shell test also checks some SBAPI functionalities and thus requires
python support.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
13 months agoRevert "Revert "[RISCV] Add special case to selectImm for constants that can be creat...
Florian Mayer [Wed, 7 Jun 2023 00:39:05 +0000 (17:39 -0700)]
Revert "Revert "[RISCV] Add special case to selectImm for constants that can be created with (ADD (SLLI C, 32), C).""

Revert broke even more stuff.

This reverts commit d5fbec30939f2c9f82475cf42c638619514b5c67.

13 months agoRevert "[RISCV] Add special case to selectImm for constants that can be created with...
Florian Mayer [Wed, 7 Jun 2023 00:30:07 +0000 (17:30 -0700)]
Revert "[RISCV] Add special case to selectImm for constants that can be created with (ADD (SLLI C, 32), C)."

Triggers UBSan error.

This reverts commit 58b2d652af49ee9d9ff2af6edd7f67f23b26bfee.

13 months agoRevert "[Sanitizers] Remove BuildId from sanitizers stacktrace on
Florian Mayer [Wed, 7 Jun 2023 00:25:55 +0000 (17:25 -0700)]
Revert "[Sanitizers] Remove BuildId from sanitizers stacktrace on

Breaks tests.

This reverts commit fdb1a891b64c27522a2386a8025f8ad5c7e02bfb.

13 months ago[scudo] Enable MTE in Trusty
Marco Nelissen [Wed, 7 Jun 2023 00:15:02 +0000 (00:15 +0000)]
[scudo] Enable MTE in Trusty

Trusty now has MTE support.
Back-ported from https://r.android.com/2332745.

Reviewed By: Chia-hungDuan

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

13 months ago[gn build] Port 1117b9a284aa
Nico Weber [Tue, 6 Jun 2023 23:57:23 +0000 (19:57 -0400)]
[gn build] Port 1117b9a284aa

13 months ago[Sanitizers] Remove BuildId from sanitizers stacktrace on Darwin
usama hameed [Tue, 6 Jun 2023 22:53:18 +0000 (15:53 -0700)]
[Sanitizers] Remove BuildId from sanitizers stacktrace on Darwin

On Darwin, we do not want to show the BuildId appended at the end of stack
frames in Sanitizers. The BuildId/UUID can be seen by using the
print_module_map=1 sanitizer option.

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

rdar://108324403

13 months ago[Fuchsia] Add llvm-strings to Fuchsia clang build.
Haowei Wu [Tue, 6 Jun 2023 23:09:33 +0000 (16:09 -0700)]
[Fuchsia] Add llvm-strings to Fuchsia clang build.

This patch adds 'llvm-strings' to Fuchsia clang build.

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

13 months ago[mlir][sparse][gpu] add sm8.0+ tensor core 2:4 sparsity support
Kun Wu [Tue, 6 Jun 2023 23:12:45 +0000 (23:12 +0000)]
[mlir][sparse][gpu] add sm8.0+ tensor core 2:4 sparsity support

Reviewed By: aartbik

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

13 months ago[lldb] Disable some tests on windows
Med Ismail Bennani [Tue, 6 Jun 2023 23:05:26 +0000 (16:05 -0700)]
[lldb] Disable some tests on windows

This patch skips both `test_completion_target_create_from_root_dir`
introduced in `e896612` and  `target-label.test` introduced in `1e82b20`
since I don't have a windows machine to try to accomodate the filesystem
path style differences for these tests to pass.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
13 months agoRevert "Reland [compiler-rt][CMake] Properly set COMPILER_RT_HAS_LLD"
Arthur Eubanks [Tue, 6 Jun 2023 22:59:26 +0000 (15:59 -0700)]
Revert "Reland [compiler-rt][CMake] Properly set COMPILER_RT_HAS_LLD"

This reverts commit fffa05a2bcb548d5189e8c2e52d2ed2e7ebb2498.

This seems to cause hwasan tests to run in environments it didn't run in before.

13 months ago[BOLT][NFC] Fix debug messages
Amir Ayupov [Tue, 6 Jun 2023 22:49:00 +0000 (15:49 -0700)]
[BOLT][NFC] Fix debug messages

Fix debug printing, making it easier to compare two debug logs side by side:
- `BinaryFunction::addRelocation`: print function name instead of `this` ptr,
- `DataAggregator::doTrace`: remove duplicated function name.

Reviewed By: #bolt, maksfb

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

13 months ago[lldb] Fix "NameError: name 'self' is not defined" when using crashlog -c
Jonas Devlieghere [Tue, 6 Jun 2023 22:18:14 +0000 (15:18 -0700)]
[lldb] Fix "NameError: name 'self' is not defined" when using crashlog -c

This fixes a regression introduced by 27f27d15f6c9 that results in a
NameError: (name 'self' is not defined) when using crashlog with the -c
option.

rdar://110007391

13 months ago[Driver] Change some Separate CC1 options to use the Joined = form
Fangrui Song [Tue, 6 Jun 2023 22:12:45 +0000 (15:12 -0700)]
[Driver] Change some Separate CC1 options to use the Joined = form

13 months agoclang/HIP: Inline frexp/frexpf implementations
Matt Arsenault [Tue, 22 Nov 2022 05:42:55 +0000 (00:42 -0500)]
clang/HIP: Inline frexp/frexpf implementations

Don't bother calling ocml. This stops setting the
appropriate fast math flags, and requires this junk
for passing to a private pointer.

13 months agoFix LLVM Sphinx build; NFC
Aaron Ballman [Tue, 6 Jun 2023 21:29:15 +0000 (17:29 -0400)]
Fix LLVM Sphinx build; NFC

Addresses the issue found by:
https://lab.llvm.org/buildbot/#/builders/30/builds/35968

13 months ago[RISCV] Use const reference when looping over RISCVMatInt::InstSeq. NFC
Craig Topper [Tue, 6 Jun 2023 21:27:28 +0000 (14:27 -0700)]
[RISCV] Use const reference when looping over RISCVMatInt::InstSeq. NFC

13 months ago[NVPTX] Adapt tests to make them usable with CUDA-12.x
Artem Belevich [Mon, 5 Jun 2023 20:45:47 +0000 (13:45 -0700)]
[NVPTX] Adapt tests to make them usable with CUDA-12.x

CUDA-12 no longer supports 32-bit compilation.

Tests agnostic to 32/64 compilation mode are switched to use nvptx64.
Tests that do care about it have 32-bit ptxas compilation disabled with cuda-12+.

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

13 months agoLangRef: Try to fix sphinx bot error
Matt Arsenault [Tue, 6 Jun 2023 21:18:31 +0000 (17:18 -0400)]
LangRef: Try to fix sphinx bot error

13 months agoValueTracking: Add baseline test for ldexp computeKnownFPClass
Matt Arsenault [Fri, 28 Apr 2023 17:50:20 +0000 (13:50 -0400)]
ValueTracking: Add baseline test for ldexp computeKnownFPClass

13 months ago[test] Restore x86-registered-target in Driver/as-warnings.c
Fangrui Song [Tue, 6 Jun 2023 21:08:49 +0000 (14:08 -0700)]
[test] Restore x86-registered-target in Driver/as-warnings.c

64666d46c0bb0575e62525a5b867569b32850116 incorrectly removed REQUIRES.
2 RUN lines do need x86-registered-target.

13 months agoclang: Start emitting intrinsic for __builtin_ldexp*
Matt Arsenault [Sun, 30 Apr 2023 14:19:57 +0000 (10:19 -0400)]
clang: Start emitting intrinsic for __builtin_ldexp*

Also introduce __builtin_ldexpf16.

13 months agoIR: Add llvm.ldexp and llvm.experimental.constrained.ldexp intrinsics
Matt Arsenault [Thu, 27 Apr 2023 02:02:42 +0000 (22:02 -0400)]
IR: Add llvm.ldexp and llvm.experimental.constrained.ldexp intrinsics

AMDGPU has native instructions and target intrinsics for this, but
these really should be subject to legalization and generic
optimizations. This will enable legalization of f16->f32 on targets
without f16 support.

Implement a somewhat horrible inline expansion for targets without
libcall support. This could be better if we could introduce control
flow (GlobalISel version not yet implemented). Support for strictfp
legalization is less complete but works for the simple cases.

13 months agoAMDGPU/GlobalISel: Fix broken / copy paste error in sext_inreg test
Matt Arsenault [Tue, 6 Jun 2023 21:00:37 +0000 (17:00 -0400)]
AMDGPU/GlobalISel: Fix broken / copy paste error in sext_inreg test

13 months ago[libc++] Refactor __less
Nikolas Klauser [Tue, 6 Jun 2023 20:57:45 +0000 (13:57 -0700)]
[libc++] Refactor __less

This simplifies the usage of `__less` by making the class not depend on the types compared, but instead the `operator()`. We can't remove the template completely because we explicitly instantiate `std::__sort` with `__less<T>`.

Reviewed By: ldionne, #libc

Spies: arichardson, EricWF, libcxx-commits, mgrang

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

13 months ago[Driver] Change some Separate CC1 options to use the Joined = form
Fangrui Song [Tue, 6 Jun 2023 20:50:04 +0000 (13:50 -0700)]
[Driver] Change some Separate CC1 options to use the Joined = form

-f{constexpr,macro,template}-backtrace-limit=, -fspell-checking-limit=, -ftemplate-depth=

13 months ago[profi][NFC] Get rid of afdo_detail::TypeMap
Amir Ayupov [Tue, 6 Jun 2023 20:41:43 +0000 (13:41 -0700)]
[profi][NFC] Get rid of afdo_detail::TypeMap

Parametrize SampleProfileInference and SampleProfileLoaderBaseImpl by function
type (Function/MachineFunction) instead of block type
(BasicBlock/MachineBasicBlock). Move out specializations to appropriate
locations.

This change makes it possible to use GraphTraits instead of a custom TypeMap and
make SampleProfileInference not dependent on LLVM types, paving the way for
generalizing SampleProfileInference interfaces to BOLT IR types
(BinaryFunction/BinaryBasicBlock) in stale profile matching (D144500).

Reviewed By: hoy

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

13 months ago[bazel] Port 44268271f61e46636619623d52013c3be3e272c0
Benjamin Kramer [Tue, 6 Jun 2023 20:47:30 +0000 (22:47 +0200)]
[bazel] Port 44268271f61e46636619623d52013c3be3e272c0

13 months ago[bazel] Port 1117b9a284aa6e4b1f3cbde31825605bd07a2384
Benjamin Kramer [Tue, 6 Jun 2023 20:47:17 +0000 (22:47 +0200)]
[bazel] Port 1117b9a284aa6e4b1f3cbde31825605bd07a2384

13 months ago[libc++] Disable int128_t and ship filesystem on MSVC by default
Louis Dionne [Thu, 29 Sep 2022 21:44:39 +0000 (17:44 -0400)]
[libc++] Disable int128_t and ship filesystem on MSVC by default

Back in 2020 [1], we went very close to enabling Filesystem on MSVC
by disabling int128_t, but decided to wait because MSVC support
for int128_t was supposed to come shortly after. Since it's not
there yet, I propose turning off int128_t support by default on MSVC.
This will make <filesystem> available by default on MSVC, and most
importantly will open the possibility for changing
LIBCXX_ENABLE_FILESYSTEM to mean "the system doesn't have support
for a filesystem" instead of simply "don't build the std::filesystem
library", which is what I'm really after with this change.

In a way, this is a resurection of D91139.

[1]: https://reviews.llvm.org/D91139#2429595

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

13 months ago[RISCV] Use PACK in RISCVMatInt for constants that have the same lower and upper...
Craig Topper [Tue, 6 Jun 2023 20:30:33 +0000 (13:30 -0700)]
[RISCV] Use PACK in RISCVMatInt for constants that have the same lower and upper 32 bits.

This requires Zbkb.

Reviewed By: reames

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

13 months ago[libc++] Use Lit annotations for all .gen.py tests
Louis Dionne [Wed, 31 May 2023 18:02:23 +0000 (11:02 -0700)]
[libc++] Use Lit annotations for all .gen.py tests

Instead of guarding header tests using #ifdefs inside the tests,
use Lit markup to mark all the tests as unsupported. This is simpler
but also provides better feedback about which tests are being run
when running the test suite.

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

13 months ago[RISCV] Add early out to generateInstSeq when the initial sequence is 1 or 2 instruct...
Craig Topper [Tue, 6 Jun 2023 20:23:17 +0000 (13:23 -0700)]
[RISCV] Add early out to generateInstSeq when the initial sequence is 1 or 2 instructions.

This avoids checking the size of the sequence repeatedly for each
special case. Especially on RV32 where none of the special cases
apply.

Reviewed By: reames

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

13 months ago[NFC][lld][COFF] Rename findFile* methods
Arthur Eubanks [Tue, 6 Jun 2023 18:11:52 +0000 (11:11 -0700)]
[NFC][lld][COFF] Rename findFile* methods

findFile returns null if we've already seen the file, make that clearer.

Reviewed By: mstorsjo

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

13 months ago[InstCombine] Remove deadcode in `(icmp SignTest(shl/shr X))`; NFC
Noah Goldstein [Tue, 6 Jun 2023 19:07:30 +0000 (14:07 -0500)]
[InstCombine] Remove deadcode in `(icmp SignTest(shl/shr X))`; NFC

This is dead as of: D145341

Reviewed By: nikic

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

13 months ago[KnownBits] Factor out and improve the lowbit computation for {u,s}div
Noah Goldstein [Tue, 6 Jun 2023 19:06:39 +0000 (14:06 -0500)]
[KnownBits] Factor out and improve the lowbit computation for {u,s}div

There are some new cases if the division is `exact`:
    1: If `TZ(LHS) == TZ(RHS)` then the result is always Odd
    2: If `TZ(LHS) > TZ(RHS)` then the `TZ(LHS)-TZ(RHS)` bits of the
       result are zero.
Proofs: https://alive2.llvm.org/ce/z/3rAZqF

As well, return zero in known poison cases to be consistent rather
than just working about the bits we are changing.

Reviewed By: nikic

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

13 months ago[KnownBits] Return `0` for poison {s,u}div inputs
Noah Goldstein [Thu, 25 May 2023 17:10:31 +0000 (12:10 -0500)]
[KnownBits] Return `0` for poison {s,u}div inputs

It seems consistent to always return zero for known poison rather than
varying the value. We do the same elsewhere.

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

13 months ago[KnownBits] Cleanup some misspelling / logic in {u,s}div
Noah Goldstein [Sun, 28 May 2023 16:20:44 +0000 (11:20 -0500)]
[KnownBits] Cleanup some misspelling / logic in {u,s}div

Chronically misspelled 'denominator' as 'denuminator' and a few other
cases.

On the logic side, no longer require `RHS` to be strictly positive in
`sdiv`. This in turn means we need to handle a possible zero `denom`
in the APInt division.

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

13 months ago[AArch64][SVE] Add one-use-check to EitherVSelectOrPassthruPatFrags
David Green [Tue, 6 Jun 2023 20:10:32 +0000 (21:10 +0100)]
[AArch64][SVE] Add one-use-check to EitherVSelectOrPassthruPatFrags

As pointed out in D149968 vselect predicate patterns could do with a one-use
check to prevent multiple operations being created. This updates the
EitherVSelectOrPassthruPatFrags pattern frags used in creating predicates
min/max.

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

13 months ago[ELF] Add PT_RISCV_ATTRIBUTES program header
Fangrui Song [Tue, 6 Jun 2023 20:06:21 +0000 (13:06 -0700)]
[ELF] Add PT_RISCV_ATTRIBUTES program header

Close https://github.com/llvm/llvm-project/issues/63084

Unlike AArch32, RISC-V defines PT_RISCV_ATTRIBUTES to include the
SHT_RISCV_ATTRIBUTES section. There is no real-world use case yet.

We place PT_RISCV_ATTRIBUTES after PT_GNU_STACK, similar to PT_ARM_EXIDX. GNU ld
places PT_RISCV_ATTRIBUTES earlier, but the placement should not matter.

Link: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/71
Reviewed By: asb

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

13 months ago[lldb] Remove __FUNCTION__ from log messages in lldbHost (NFC)
Jonas Devlieghere [Tue, 6 Jun 2023 19:25:41 +0000 (12:25 -0700)]
[lldb] Remove __FUNCTION__ from log messages in lldbHost (NFC)

LLDB's logging infrastructure supports prepending log messages with the
name of the file and function that generates the log (see help log
enable). Therefore it's unnecessary to include the current __FUNCTION__
in the log message itself. This patch removes __FUNCTION__ from log
messages in the Host library.

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

13 months ago[AMDGPU] Replace std::pair with VOPDCombineInfo in VOPD combine. NFC.
Stanislav Mekhanoshin [Tue, 6 Jun 2023 19:20:39 +0000 (12:20 -0700)]
[AMDGPU] Replace std::pair with VOPDCombineInfo in VOPD combine. NFC.

The future patch will carry additional info there.

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

13 months ago[GVN] Improve PRE on load instructions
Guozhi Wei [Tue, 6 Jun 2023 19:45:34 +0000 (19:45 +0000)]
[GVN] Improve PRE on load instructions

This patch implements the enhancement proposed by
https://github.com/llvm/llvm-project/issues/59312.

Suppose we have following code

   v0 = load %addr
   br %LoadBB

LoadBB:
   v1 = load %addr
   ...

PredBB:
   ...
   br %cond, label %LoadBB, label %SuccBB

SuccBB:
   v2 = load %addr
   ...

Instruction v1 in LoadBB is partially redundant, edge (PredBB, LoadBB) is a
critical edge. SuccBB is another successor of PredBB, it contains another load
v2 which is identical to v1. Current GVN splits the critical edge
(PredBB, LoadBB) and inserts a new load in it. A better method is move the load
of v2 into PredBB, then v1 can be changed to a PHI instruction.

If there are two or more similar predecessors, like the test case in the bug
entry, current GVN simply gives up because otherwise it needs to split multiple
critical edges. But we can move all loads in successor blocks into predecessors.

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

13 months ago[InstrProf] Fix warning about converting double to float
Ellis Hoag [Tue, 6 Jun 2023 19:29:03 +0000 (12:29 -0700)]
[InstrProf] Fix warning about converting double to float

In https://reviews.llvm.org/D147812 I introduced the class
`BalancedPartitioning` and it seemed to trigger a warning in flang

```
C:\Users\buildbot-worker\minipc-ryzen-win\flang-x86_64-windows\llvm-project\llvm\include\llvm/Support/BalancedPartitioning.h(89): warning C4305: 'initializing': truncation from 'double' to 'float'
```

For good measure, I converted all double literals to floats. This should
be a NFC.

13 months ago[libc][Docs] Add support for the printing functions
Joseph Huber [Tue, 6 Jun 2023 19:32:58 +0000 (14:32 -0500)]
[libc][Docs] Add support for the printing functions

13 months ago[mlir][sparse][gpu] add AoS COO support to cuSPARSE
Aart Bik [Tue, 6 Jun 2023 17:56:58 +0000 (10:56 -0700)]
[mlir][sparse][gpu] add AoS COO support to cuSPARSE

Even though this feature was deprecated in release 11.2,
any library before this version still supports the feature,
which is why we are making it available under a macro.

Reviewed By: K-Wu

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

13 months ago[libc] Replace use of `asm` in the GPU code with LIBC_INLINE_ASM
Joseph Huber [Tue, 6 Jun 2023 18:22:15 +0000 (13:22 -0500)]
[libc] Replace use of `asm` in the GPU code with LIBC_INLINE_ASM

We should more consistently use inline assembly using the LIBC wrappers.
It's much safer to mark all of these volatile as well.

Reviewed By: lntue

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

13 months ago[lldb] Support file and function names in LLDB_LOGF macro
Jonas Devlieghere [Tue, 6 Jun 2023 17:37:12 +0000 (10:37 -0700)]
[lldb] Support file and function names in LLDB_LOGF macro

LLDB's logging machinery supports prepending log messages with the name
of the file and function that generates the log. However, currently this
functionality is limited to the LLDB_LOG macro. I meant to do this as a
follow up to D65128 but never got around to it.

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

13 months ago[RISCV] Don't persist invalid feature state on .option arch error
Jessica Clarke [Tue, 6 Jun 2023 19:14:20 +0000 (20:14 +0100)]
[RISCV] Don't persist invalid feature state on .option arch error

Otherwise subsequent .option arch, +foo directives (but not -, since
those have their own separate validation) fail the parseFeatureBits
check, leading to cascading errors.

Reviewed By: luismarques, MaskRay

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

13 months ago[BOLT] stale profile matching [part 1 out of 2]
spupyrev [Thu, 16 Feb 2023 18:52:04 +0000 (10:52 -0800)]
[BOLT] stale profile matching [part 1 out of 2]

BOLT often has to deal with profiles collected on binaries built from several
revisions behind release. As a result, a certain percentage of functions is
considered stale and not optimized. This diff adds an ability to match profile
to functions that are not 100% binary identical, which increases the
optimization coverage and boosts the performance of applications.

The algorithm consists of two phases: matching and inference:
- At the matching phase, we try to "guess" as many block and jump counts from
  the stale profile as possible. To this end, the content of each basic block
  is hashed and stored in the (yaml) profile. When BOLT optimizes a binary,
  it computes block hashes and identifies the corresponding entries in the
  stale profile. It yields a partial profile for every CFG in the binary.
- At the inference phase, we employ a network flow-based algorithm (profi) to
  reconstruct "realistic" block and jump counts from the partial profile
  generated at the first stage. In practice, we don't always produce proper
  profile data but the majority (e.g., >90%) of CFGs get the correct counts.

This is a first part of the change; the next stacked diff extends the block hashing
and provides perf evaluation numbers.

Reviewed By: maksfb

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

13 months ago[clang][TypePrinter] Add option to skip over elaborated types
Eric Li [Tue, 2 May 2023 17:59:46 +0000 (13:59 -0400)]
[clang][TypePrinter] Add option to skip over elaborated types

Elaborated types are sugar that represent how the type was spelled in
the original source. When printing a type outside of that original
context, the qualifiers as saved in the elaborated type will be
incorrect. Additionally, their existence also inhibits the use of
`PrintingCallbacks::isScopeVisible` as a customization point.

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

13 months ago[Driver][test] Remove unneeded some REQUIRES:
Fangrui Song [Tue, 6 Jun 2023 19:01:22 +0000 (12:01 -0700)]
[Driver][test] Remove unneeded some REQUIRES:

to decrease the number of unsupported tests on other platforms.

13 months ago[InstrProf] Use BalancedPartitioning to order temporal profiling trace data
Ellis Hoag [Tue, 6 Jun 2023 18:43:36 +0000 (11:43 -0700)]
[InstrProf] Use BalancedPartitioning to order temporal profiling trace data

In [0] we described an algorithm called //BalancedPartitioning// (bp) to consume function traces [1] and compute a function order that reduces the number of page faults during startup.

This patch adds the `order` command to the `llvm-profdata` tool which uses bp to output a function order that can be passed to the linker via `--symbol-ordering-file=`.

Special thanks to Sergey Pupyrev and Julian Mestre for designing this balanced partitioning algorithm.

[0] https://discourse.llvm.org/t/rfc-temporal-profiling-extension-for-irpgo/68068
[1] https://reviews.llvm.org/D147287

Reviewed By: spupyrev

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

13 months ago[RISCV] Add special case to selectImm for constants that can be created with (ADD...
Craig Topper [Tue, 6 Jun 2023 18:59:12 +0000 (11:59 -0700)]
[RISCV] Add special case to selectImm for constants that can be created with (ADD (SLLI C, 32), C).

Where C is a simm32.

This costs an extra temporary register, but avoids a constant pool.

Reviewed By: reames

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

13 months ago[flang] Set "undefined" NEXTREC=n variable to 0 rather than random garbage
Peter Klausler [Tue, 6 Jun 2023 18:37:52 +0000 (11:37 -0700)]
[flang] Set "undefined" NEXTREC=n variable to 0 rather than random garbage

12.10.2.17 defines that a INQUIRE statement's NEXTREC=n output value
for a unit that is not connected for direct access becomes undefined,
but the current I/O runtime can fail in a confusing manner by trying
to return uninitialized stack garbage.

Reported on Slack by Tarun Prabhu as an intermittent failure in
the gfortran regression test inquire_pre.f90.

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

13 months ago[AArch64] Regenerate tests with missing immediate hex asm comments
Simon Pilgrim [Tue, 6 Jun 2023 18:41:29 +0000 (19:41 +0100)]
[AArch64] Regenerate tests with missing immediate hex asm comments

Reduces diff in a future commit

13 months ago[mlir][Toy] Remove unnecessary transpose from chapter 1 example
Andrey Portnoy [Tue, 6 Jun 2023 18:19:53 +0000 (11:19 -0700)]
[mlir][Toy] Remove unnecessary transpose from chapter 1 example

The call to 'multiply_transpose' in the initialization of the variable 'f' was
intended to have a shape mismatch. However the variable 'a' has shape <2, 3> and
the variable 'c' has shape <3, 2>, so the arguments 'transpose(a)' and 'c' have
in fact compatible shapes (<3, 2> both), the opposite of what is wanted here.
This commit removes the transpose so that arguments 'a' and 'c' have
incompatible shapes <2, 3> and <3, 2>, respectively.

Reviewed By: mehdi_amini

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

13 months ago[mlir] Convert quantized dialect bytecode to generated.
Jacques Pienaar [Tue, 6 Jun 2023 18:16:07 +0000 (11:16 -0700)]
[mlir] Convert quantized dialect bytecode to generated.

Serves as rather self-contained documentation for using the generator
from https://reviews.llvm.org/D144820.

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

13 months agoRe-apply "Revert "[DebugInfo] Add error checking around data extraction in DWARFAbbre...
Alex Langford [Tue, 6 Jun 2023 18:00:42 +0000 (11:00 -0700)]
Re-apply "Revert "[DebugInfo] Add error checking around data extraction in DWARFAbbreviationDeclaration::extract""

This reverts commit 11d61c079d4b4927efea42a38a27d4586887b764 to re-apply
6836a47b7e6b57927664ec6ec750ae37bb951129 with modifications.

Specifically, the errors in DWARFAbbreviationDeclaration::extract needed
to be moved as they are returned to ensure the right Error constructor
is selected.

13 months ago[lld][COFF] Don't handle an input file multiple times when retrying
Arthur Eubanks [Mon, 5 Jun 2023 21:32:55 +0000 (14:32 -0700)]
[lld][COFF] Don't handle an input file multiple times when retrying

Follow up to D151815.

Or else we properly handle the first instance of a file, then error out on the second instance of the same file.

Reviewed By: rnk

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

13 months agoRevert "[DebugInfo] Add error checking around data extraction in DWARFAbbreviationDec...
Alex Langford [Tue, 6 Jun 2023 17:58:51 +0000 (10:58 -0700)]
Revert "[DebugInfo] Add error checking around data extraction in DWARFAbbreviationDeclaration::extract"

This reverts commit 6836a47b7e6b57927664ec6ec750ae37bb951129.
This breaks some bots, need to investigate.

13 months ago[lldb/Commands] Fix disk completion from root directory
Med Ismail Bennani [Mon, 5 Jun 2023 20:19:44 +0000 (13:19 -0700)]
[lldb/Commands] Fix disk completion from root directory

This patch should fix path completion starting from the root directory.

To do so, this patch adds a special case when setting the search
directory when the completion buffer points to the root directory.

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

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
13 months ago[lldb/crashlog] Expand crash report file path before parsing
Med Ismail Bennani [Fri, 2 Jun 2023 17:39:41 +0000 (10:39 -0700)]
[lldb/crashlog] Expand crash report file path before parsing

This patch should fix a crash in the opening a crash report that was
passed with a relative path.

This patch expands the crash report path before parsing it and raises a
`FileNotFoundError` exception if the file doesn't exist.

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

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
13 months ago[lldb/Commands] Add support to auto-completion for user commands
Med Ismail Bennani [Tue, 6 Jun 2023 17:24:48 +0000 (10:24 -0700)]
[lldb/Commands] Add support to auto-completion for user commands

This patch should allow the user to set specific auto-completion type
for their custom commands.

To do so, we had to hoist the `CompletionType` enum so the user can
access it and add a new completion type flag to the CommandScriptAdd
Command Object.

So now, the user can specify which completion type will be used with
their custom command, when they register it.

This also makes the `crashlog` custom commands use disk-file completion
type, to browse through the user file system and load the report.

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

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>