platform/upstream/llvm.git
14 months ago[lldb/API] Introduce SBProcess::ForceScriptedState method
Med Ismail Bennani [Mon, 13 Mar 2023 22:34:29 +0000 (15:34 -0700)]
[lldb/API] Introduce SBProcess::ForceScriptedState method

This patch introduces a new method to the SBProcess API called
ForceScriptedState. As the name suggests, this affordance will allow the
user to alter the state of the scripted process programatically.

This is necessary to update the scripted process state when perform
interactive debugging.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
14 months ago[LegacyPM] Remove InjectTLIMappings and AssumeSimplify passes
Arthur Eubanks [Tue, 25 Apr 2023 21:34:24 +0000 (14:34 -0700)]
[LegacyPM] Remove InjectTLIMappings and AssumeSimplify passes

14 months ago[LV][NFC] Precommit test for a follow-up patch that introduces uniformity for a speci...
Vasileios Porpodas [Tue, 4 Apr 2023 20:02:05 +0000 (13:02 -0700)]
[LV][NFC] Precommit test for a follow-up patch that introduces uniformity for a specific VF.

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

14 months ago[NFC][StructuralHash] Use hash_code
Arthur Eubanks [Tue, 25 Apr 2023 21:11:49 +0000 (14:11 -0700)]
[NFC][StructuralHash] Use hash_code

14 months ago[clang] add diagnose when member function contains invalid default argument
Congcong Cai [Tue, 25 Apr 2023 21:08:28 +0000 (23:08 +0200)]
[clang] add diagnose when member function contains invalid default argument

Fixed: https://github.com/llvm/llvm-project/issues/62122
This change pointer to add diagnose message for this code.
```
struct S {
    static int F(int n = 0 ? 0) {
        return 0;
    }
};
```
For default parameter, we should set it as unparsed even if meeting
syntax error because it should be issued in real parser time instead of
set is as invalid directly without diagnose.

Reviewed By: rsmith

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

14 months ago[clang] Don't emit type tests for dllexport/import classes
Arthur Eubanks [Wed, 13 Jul 2022 22:51:15 +0000 (15:51 -0700)]
[clang] Don't emit type tests for dllexport/import classes

According to https://clang.llvm.org/docs/LTOVisibility.html, classes on
Windows with dllimport/export receive public LTO visibility and
therefore should not participate in WPD.

Reviewed By: pcc

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

14 months ago[SCEV] Do not plant SCEV checks unnecessarily
Paul Osmialowski [Tue, 25 Apr 2023 20:44:35 +0000 (21:44 +0100)]
[SCEV] Do not plant SCEV checks unnecessarily

The vectorisation analysis collects strides for loop invariant
pointers, which is wrong because they are not strided. We don't
need to generate SCEV checks (which are costly performancewise)
for such pointers, we just need to do the appropriate aliasing
checks.

This patch fixes the problem by changing getStrideFromPointer()
to treat loop invariant pointers as having no stride.

Originally proposed by David Sherwood with further suggestions
from Florian Hahn.

Reviewed By: fhahn

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

14 months agoRevert "[MLIR][python bindings] implement `replace_all_uses_with` on `PyValue`"
max [Tue, 25 Apr 2023 20:32:14 +0000 (15:32 -0500)]
Revert "[MLIR][python bindings] implement `replace_all_uses_with` on `PyValue`"

This reverts commit 3bab7cb089d92cc7025ebc57ef3a74d3ce94ecd8 because it breaks sanitizers.

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

14 months ago[test] A test case for D146958
Paul Osmialowski [Tue, 25 Apr 2023 20:33:01 +0000 (21:33 +0100)]
[test] A test case for D146958

This commit introduces a test for the change introduced by the
`[SCEV] Do not plant SCEV checks unnecessarily` commit,
D146958.

Reviewed By: fhahn, david-arm

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

14 months ago[ThinLTO] Reduce pipeline clang test to avoid churn from LLVM changes
Teresa Johnson [Tue, 25 Apr 2023 20:17:50 +0000 (13:17 -0700)]
[ThinLTO] Reduce pipeline clang test to avoid churn from LLVM changes

This test was added in D72538, along with multiple LLVM pipeline tests,
to ensure that distributed ThinLTO backends invoked via clang set up the
expected ThinLTO optimization pipeline. However, this introduces churn
to clang tests from LLVM pipeline changes (see recent comment in that
patch).

Since the full pipeline setup is tested by LLVM, I have changed this
test to simply look for a single pass that is only invoked during LTO
backends, to make sure that clang is provoking the an LTO backend
pipeline setup.

14 months ago[flang][openacc] Add initial support to lower assumed size array in data operand
Valentin Clement [Tue, 25 Apr 2023 20:26:48 +0000 (13:26 -0700)]
[flang][openacc] Add initial support to lower assumed size array in data operand

Add lowering for assumed size array in data clause to the newly
added data operand operations.

Depends on D148840

Reviewed By: razvanlupusoru

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

14 months ago[gn build] Port b42718dcecdd
LLVM GN Syncbot [Tue, 25 Apr 2023 20:18:23 +0000 (20:18 +0000)]
[gn build] Port b42718dcecdd

14 months agoFactor out split-dwarf test in Generic/empty.ll
Shubham Sandeep Rastogi [Mon, 24 Apr 2023 23:01:41 +0000 (16:01 -0700)]
Factor out split-dwarf test in Generic/empty.ll

In llvm/test/DebugInfo/Generic/empty.ll, there are two RUN lines. The
second one use the option "-split-dwarf-file=foo.dwo"

Since darwin doesn't support split dwarf, there is an assertion when
running the test:

"Assertion failed: (Section && "Cannot switch to a null section!"),
function switchSection, file llvm/lib/MC/MCStreamer.cpp, line 1238"

While there is an XFAIL for darwin in the test, It is not a good
practice to run a test on darwin which causes an assertion. This
patch is a small refactoring of the test so that the split-dwarf test
can be it's own file with an explicit elf triple.

Differential Review: https://reviews.llvm.org/D149106

14 months ago[LLDB][REPL] Destroy the repl instances correctly
walter erquinigo [Tue, 25 Apr 2023 19:46:34 +0000 (14:46 -0500)]
[LLDB][REPL] Destroy the repl instances correctly

This change ensures that the REPL map inside Target is destroyed correctly when `Target::Destroy()` is invoked. Not doing so results in the REPL not finishing its job when the debugger is initialized in REPL mode reading from a file. In my particular case, my REPL doesn't print the stdout of the last expression in the input file unless I include this change.

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

14 months agoPreserve the address space for llvm.used and llvm.compiler.used global variables...
Nawal Copty [Tue, 25 Apr 2023 19:45:33 +0000 (12:45 -0700)]
Preserve the address space for llvm.used and llvm.compiler.used global variables in GlobalOpt pass.

The llvm.used (or llvm.compiler.used) global variable is an array that contains a list of pointers to global variables and functions.

The GlobalOpt (Global Variable Optimizer) pass is not preserving the address space for llvm.used and llvm.compiler.used global variables.This patch updates the setUsedInitializer() function in GlobalOpt.cpp, so the address space is preserved.

Reviewed By: aeubanks

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

14 months agoRemove code only needed to detect a pre-4.0 API break.
Owen Anderson [Tue, 25 Apr 2023 05:23:38 +0000 (22:23 -0700)]
Remove code only needed to detect a pre-4.0 API break.

Updated with build fix for unit tests

Reviewed By: dexonsmith

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

14 months ago[SystemZ][z/OS] Create utility functions for converting between EBCDIC and UTF-8.
Neumann Hon [Tue, 25 Apr 2023 20:03:34 +0000 (16:03 -0400)]
[SystemZ][z/OS] Create utility functions for converting between EBCDIC and UTF-8.

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

14 months ago[RISCV] Add test case showing failure to fold (fadd (reduce -0.0, X), Y) due to one...
Craig Topper [Tue, 25 Apr 2023 19:52:00 +0000 (12:52 -0700)]
[RISCV] Add test case showing failure to fold (fadd (reduce -0.0, X), Y) due to one use check. NFC"

If the -0.0 has multiple uses we won't fold the reduction.

14 months ago[ConstraintElim] Port `mul nuw` for unsigned to `mul nsw` to signed.
Florian Hahn [Tue, 25 Apr 2023 19:34:14 +0000 (20:34 +0100)]
[ConstraintElim] Port `mul nuw` for unsigned to `mul nsw` to signed.

Add handling for `mul nsw` for signed systems based on the logic for
`mul nuw` for unsigned.

14 months ago[ConstraintElim] Split up test case to it easier for Alive2 to verify.
Florian Hahn [Tue, 25 Apr 2023 19:33:29 +0000 (20:33 +0100)]
[ConstraintElim] Split up test case to it easier for Alive2 to verify.

Split up larger test functions into 2 versions, one with the checks in
the then and one with the checks in the else block.

The original versions of the function caused timeouts even with larger
thresholds. The new versions verify very quickly.

14 months ago[MachO] Disable atexit()-based lowering when LTO'ing kernel/kext code
Julian Lettner [Fri, 21 Apr 2023 22:14:42 +0000 (15:14 -0700)]
[MachO] Disable atexit()-based lowering when LTO'ing kernel/kext code

The kernel and kext environments do not provide the `__cxa_atexit()`
function, so we can't use it for lowering global module destructors.

Unfortunately, just querying for "compiling for kernel/kext?" in the LTO
pipeline isn't possible (kernel/kext identifier isn't part of the triple
yet) so we need to pass down a CodeGen flag.

rdar://93536111

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

14 months ago[SCEV] Common code for computing trip count in a fixed type [NFC-ish]
Philip Reames [Tue, 25 Apr 2023 18:57:46 +0000 (11:57 -0700)]
[SCEV] Common code for computing trip count in a fixed type [NFC-ish]

This is a follow on to D147117 and D147355. In both cases, we were adding special cases to compute zext(BTC+1) instead of zext(BTC)+1 when the BTC+1 computation was known not to overflow.

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

14 months ago[ConstraintElim] Add tests for mul nsw and signed predicates.
Florian Hahn [Tue, 25 Apr 2023 18:51:23 +0000 (19:51 +0100)]
[ConstraintElim] Add tests for mul nsw and signed predicates.

14 months ago[libc] Fix including 'libc_errno.h' incorrectly
Joseph Huber [Tue, 25 Apr 2023 18:32:17 +0000 (13:32 -0500)]
[libc] Fix including 'libc_errno.h' incorrectly

Summary:
This causes problems when included. Fix this to hopefully get the bots
working again.

14 months ago[libc][fix] Add missing 'errno' header for the GPU libc
Joseph Huber [Tue, 25 Apr 2023 18:25:45 +0000 (13:25 -0500)]
[libc][fix] Add missing 'errno' header for the GPU libc

Summary:
The previous GPU `libc` patch added support for `atoi`. However, it
didn't also enable generating the errno header. This caused including it
to use the system's header which invariably will cause compiler
problems.

14 months ago[compiler-rt] [test] Add an .exe suffix for unit test executables on MinGW
Martin Storsjö [Sun, 23 Apr 2023 19:51:59 +0000 (22:51 +0300)]
[compiler-rt] [test] Add an .exe suffix for unit test executables on MinGW

Previously, an .exe suffix was only added for MSVC configurations.

In practice, an .exe suffix is added implicitly by MinGW toolchains
if the output is a suffixless file name. However this can cause lots
of subtle build system confusion, when it's not generating the file it
expected.

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

14 months ago[RISCV] Rename hasNonZeroAVL->isNonZeroAVL. NFC
Craig Topper [Tue, 25 Apr 2023 17:49:57 +0000 (10:49 -0700)]
[RISCV] Rename hasNonZeroAVL->isNonZeroAVL. NFC

The argument is the AVL itself, not some operation that has an AVL.
Thus "is" instead of "has" is a better name.

14 months ago[bazel] Fix libc target deps after 7090c102731192d5abafb7e0b2b49adb4912efae
Jorge Gorbe Moya [Tue, 25 Apr 2023 17:46:58 +0000 (10:46 -0700)]
[bazel] Fix libc target deps after 7090c102731192d5abafb7e0b2b49adb4912efae

14 months ago[libc] Ignore 'errno' on the GPU and support 'atoi'
Joseph Huber [Mon, 24 Apr 2023 23:28:54 +0000 (18:28 -0500)]
[libc] Ignore 'errno' on the GPU and support 'atoi'

The 'errno' value is most likely not useful on the GPU and it prevents
us from providing certain functions on the GPU that depend on it, like
`atoi`. This patch makes the necessary changes to support `errno` by
simple replacing it with a consumer class.

Supporting `errno` on the GPU is possible in some aspects. The first
approach would be to use a buffer of shared memory that has enough space
for all threads. Another option would be to change code generation to
support `thread_local` using `address_space(5)` memory allocated at
kernel launch. The former could look like the following, which could be
implemented in a later patch:

```
template <typename T>
using SharedBuffer = T[gpu::MAX_THREADS] [[clang::address_space(3)]];
template <typename T> struct ErrnoSetter {
  constexpr ErrnoSetter(SharedBuffer<T> &storage) : storage(storage) {}
  SharedBuffer<T> &storage;
  void operator=(const T &val) { storage[gpu::get_thread_id()] = val; }
};

static SharedBuffer<int> thread_local_buffer [[clang::loader_uninitialized]];
ErrnoSetter<int> __llvmlibc_internal_errno(thread_local_buffer);
```

Reviewed By: sivachandra

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

14 months ago[flang] Avoid dependency of runtime library on pthread for MinGW
Markus Mützel [Tue, 25 Apr 2023 17:09:20 +0000 (10:09 -0700)]
[flang] Avoid dependency of runtime library on pthread for MinGW

When building the Fortran runtime on MinGW, `clock_gettime` is currently used. That function is provided by the `pthread` library on that platform. That means that all programs that link `libFortranRuntime` also require to be linked with `pthread` on that platform.

There is already a code path (for MSVC) that doesn't use `clock_gettime` in the implementation of the Fortran library.
Use the same code path also on MinGW by undefining `CLOCKID`.

Reviewed By: vzakhari

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

14 months ago[flang] Account for .exe suffix in test/Driver/omp-driver-offload.f90.
Slava Zakharin [Tue, 25 Apr 2023 16:45:45 +0000 (09:45 -0700)]
[flang] Account for .exe suffix in test/Driver/omp-driver-offload.f90.

I believe this test started failing pre-commit testing after D148038.
For example:
https://buildkite.com/llvm-project/premerge-checks/builds/148654#0187b72b-7360-4c52-be94-93eefcb269f4
https://buildkite.com/llvm-project/premerge-checks/builds/148642#0187b691-15a7-44c4-ae23-c7e97ec67755

On Windows the .exe suffix is used for clang-offload-packager tool:
"c:\\program files\\llvm\\bin\\clang-offload-packager.exe" ...

At the same time, I believe I have seen this test sporadically fail before,
meaning that the .exe suffix is not added consistently. I am not sure
why this might be happening. I decided just to allow the suffix.

14 months ago[RISCV][NFC] Pull select->binop identities used in lowerSelect to a helper function
Alex Bradbury [Tue, 25 Apr 2023 16:53:12 +0000 (17:53 +0100)]
[RISCV][NFC] Pull select->binop identities used in lowerSelect to a helper function

This will allow reusing the same logic for a select combine.

14 months ago[docs] Update HowToReleaseLLVM documentation.
Tobias Hieta [Tue, 25 Apr 2023 07:54:33 +0000 (09:54 +0200)]
[docs] Update HowToReleaseLLVM documentation.

There was a bunch of references to bugzilla and other old
instructions in there. I have updated it to match the current
reality.

Reviewed By: tstellar

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

14 months ago[AArch64][SME] NFC: Fix comment in enum class
Cullen Rhodes [Tue, 25 Apr 2023 16:45:38 +0000 (16:45 +0000)]
[AArch64][SME] NFC: Fix comment in enum class

14 months ago[flang][runtime] Added Clang CMake modules include path.
Slava Zakharin [Mon, 24 Apr 2023 18:09:57 +0000 (11:09 -0700)]
[flang][runtime] Added Clang CMake modules include path.

Fortran runtime standalone build is broken after D140998
because of the missing CMake modules path. This is a fix.

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

14 months ago[DebugInfo] Treat empty metadata operands the same as undef operands
OCHyams [Tue, 25 Apr 2023 15:21:42 +0000 (16:21 +0100)]
[DebugInfo] Treat empty metadata operands the same as undef operands

A `ValueAsMetadata` may be replaced with nullptr for several reasons including
deleting values and value remapping a use-before-def. In the case of a
`MetadataAsValue` user, `handleChangedOperand` intercepts and replaces the
metadata with an empty tuple (`!{}`).

At the moment, an empty metadata operand in a debug intrinsics signals that it
can be deleted.

Given that we end up with empty metadata operands in circumstances where the
Value has been "lost" the current behaviour can lead to incorrect variable
locations. Instead, we should treat empty metadata as meaning "there is no
location for the variable" (the same as we currently treat undef operands).

This patch changes `isKillLocation` to take this into account.

Related to https://discourse.llvm.org/t/auto-undef-debug-uses-of-a-deleted-value

Reviewed By: StephenTozer

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

14 months agoFix codegen for initialization of global atomics
Aaron Ballman [Tue, 25 Apr 2023 15:29:22 +0000 (11:29 -0400)]
Fix codegen for initialization of global atomics

This amends 2e275e24355cb224981f9beb2b026a3169fc7232. That commit added
a null to pointer cast kind when determining whether the expression can
be a valid constant initializer, but failed to update the constant
expression evaluator to perform the evaluation. This commit updates the
constant expression evaluator to handle that cast kind.

14 months ago[DebugInfo] Replace UndefValue with PoisonValue in DIArgList::handleChangedOperand
OCHyams [Tue, 25 Apr 2023 14:39:31 +0000 (15:39 +0100)]
[DebugInfo] Replace UndefValue with PoisonValue in DIArgList::handleChangedOperand

This helps towards the effort to remove UndefValue from LLVM.

Related to https://discourse.llvm.org/t/auto-undef-debug-uses-of-a-deleted-value

Reviewed By: nlopes

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

14 months ago[mlir] ActionTracing: require ASSERTS for debugcounter test
Emilio Cota [Tue, 25 Apr 2023 14:26:02 +0000 (10:26 -0400)]
[mlir] ActionTracing: require ASSERTS for debugcounter test

While at it, fix some typos.

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

14 months ago[AMDGPU] Do not handle _SGPR SMEM instructions in SILoadStoreOptimizer
Jay Foad [Tue, 25 Apr 2023 09:26:46 +0000 (10:26 +0100)]
[AMDGPU] Do not handle _SGPR SMEM instructions in SILoadStoreOptimizer

After D147334 we never select _SGPR forms of SMEM instructions on
subtargets that also support the _SGPR_IMM form, so there is no need to
handle them here.

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

14 months agoDisable private mapping test for AMD GPU due to intermittent fails.
Doru Bercea [Tue, 25 Apr 2023 14:05:07 +0000 (10:05 -0400)]
Disable private mapping test for AMD GPU due to intermittent fails.

14 months ago[mlir][llvm][test] Move exception-related tests to their own file
Victor Perez [Mon, 24 Apr 2023 08:51:11 +0000 (09:51 +0100)]
[mlir][llvm][test] Move exception-related tests to their own file

Move mlir-translate exception-related tests from basic.ll to exception.ll.

Signed-off-by: Victor Perez <victor.perez@codeplay.com>
Differential Revision: https://reviews.llvm.org/D149043

14 months ago[InstSimplify] with logical ops: (X | Y) ? 0 : X --> 0
Zhongyunde [Tue, 25 Apr 2023 13:47:41 +0000 (21:47 +0800)]
[InstSimplify] with logical ops: (X | Y) ? 0 : X --> 0

Use simplifySelectWithICmpEq to handle the implied equalities from the icmp-or,
then both of ICMP_NE and ICMP_EQ will be addressed
  (X | Y) == 0 ?  X : 0 --> 0 (commuted 2 ways)
  (X | Y) != 0 ?  0 : X --> 0 (commuted 2 ways)
Fixes https://github.com/llvm/llvm-project/issues/62263

Reviewed By: nikic, RKSimon
Differential Revision: https://reviews.llvm.org/D148986

14 months agoReapply [InstSimplify] Support all instructions in simplifyWithOpReplaced()
Nikita Popov [Mon, 24 Apr 2023 13:22:20 +0000 (15:22 +0200)]
Reapply [InstSimplify] Support all instructions in simplifyWithOpReplaced()

Relative to the previous attempt, this includes a bailout for phi
nodes, whose arguments might refer to a previous cycle iteration.

We did not hit this before by a fortunate deficiency of the
ConstantFoldInstOperands() API, which doesn't handle phi nodes,
unlike ConstantFoldInstruction().

-----

Instead of hardcoding a few instruction kinds, use the generic
interface now that we have it.

The primary effect of this is that intrinsics are now supported.

It's worth noting that this is still limited in that it does not
support vectors, so we can't remove e.g. existing fshl special
cases.

14 months ago[tests] precommit tests for D148986
Zhongyunde [Tue, 25 Apr 2023 13:39:06 +0000 (21:39 +0800)]
[tests] precommit tests for D148986

Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D149115

14 months ago[InstSimplify] Add test for select op replacement in phi (NFC)
Nikita Popov [Tue, 25 Apr 2023 13:40:43 +0000 (15:40 +0200)]
[InstSimplify] Add test for select op replacement in phi (NFC)

14 months agoTableGen: Introduce `!range` operator for half-opened interval
NAKAMURA Takumi [Wed, 1 Mar 2023 22:16:44 +0000 (07:16 +0900)]
TableGen: Introduce `!range` operator for half-opened interval

`!range(a, b)` generates a list `[a,b)`. `a` is optional and `0` by default.

  - `!range(-1, 4)` generates `[-1, 0, 1, 2, 3]`
  - `!range(4)` generates `[0, 1, 2, 3]`
  - `!range(2, 2)` generates `[]<list<int>>`

`!range(list)` is equivalent to `!range(0, !size(list))`.

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

14 months agoReformat
NAKAMURA Takumi [Tue, 25 Apr 2023 13:35:33 +0000 (22:35 +0900)]
Reformat

14 months agoRevert "[DebugInfo] Print empty MDTuples wrapped in MetadataAsValue inline"
OCHyams [Tue, 25 Apr 2023 13:36:38 +0000 (14:36 +0100)]
Revert "[DebugInfo] Print empty MDTuples wrapped in MetadataAsValue inline"

This reverts commit 1e6fe677f8aa98518e05218affa16e468819f5ed (D140900).

Buildbot: https://lab.llvm.org/buildbot/#/builders/196/builds/29937

14 months ago[LoopVectorize] Convert test to opaque pointers (NFC)
Nikita Popov [Tue, 25 Apr 2023 13:20:36 +0000 (15:20 +0200)]
[LoopVectorize] Convert test to opaque pointers (NFC)

14 months ago[DebugInfo][CSInfo] Avoid crash when defining super-regs
Jeremy Morse [Tue, 25 Apr 2023 13:04:41 +0000 (14:04 +0100)]
[DebugInfo][CSInfo] Avoid crash when defining super-regs

In rare situations involving AVX intrinsics, it seems LLVM can be coaxed
into generating copies to arguments that look like this:

    $xmm0 = VMOVAPSrr $xmm1, implicit-def $ymm0
    CALL64 @something ymm0

This particular form of copy implicitly zeros the upper lanes of ymm0,
hence there's an implicit-def for the register in the copy. The X86
implementation of describeLoadedValue doesn't attempt to describe this sort
of copy which causes the generic implementation in
TargetInstrInfo::describeLoadedValue to fire an assertion saying it
expected the target hook to handle it.

Play it safe in the generic implementation and return the "no location /
value" return value, rather than asserting.

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

14 months ago[DebugInfo] Print empty MDTuples wrapped in MetadataAsValue inline
OCHyams [Tue, 25 Apr 2023 10:24:30 +0000 (11:24 +0100)]
[DebugInfo] Print empty MDTuples wrapped in MetadataAsValue inline

This improves the readability of debugging intrinsics. Instead of:

    call void @llvm.dbg.value(metadata !2, ...)
    !2 = !{}

We will see:

    call void @llvm.dbg.value(metadata !{}, ...)
    !2 = !{}

Note that we still get a numbered metadata entry for the node even if it's not
used elsewhere. This is to avoid adding more context to the print functions.

This is already legal IR - LLVM can parse and understand it - so there is no
need to update the parser.

The next patches in this stack will make such empty metadata operands more
common and semantically important.

Related to https://discourse.llvm.org/t/auto-undef-debug-uses-of-a-deleted-value

Reviewed By: StephenTozer

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

14 months ago[MC] Eagerly skip zero-sized .fill fragments
Benjamin Kramer [Tue, 25 Apr 2023 12:57:09 +0000 (14:57 +0200)]
[MC] Eagerly skip zero-sized .fill fragments

This doesn't change the output in any way, but we have a bunch of
emitFill for padding. When emitting an array of floats we'd end up with

DataFragment float1
FillFragment 0
DataFragment float2
FillFragment 0
... and so on

We never actually emit anything for those fills, neither in asm nor obj
emission mode, they just consume RAM for no reason.

14 months ago[AMDGPU] Move GCN-specific stuff out of AMDGPUISelLowering. NFC.
Jay Foad [Tue, 25 Apr 2023 11:07:00 +0000 (12:07 +0100)]
[AMDGPU] Move GCN-specific stuff out of AMDGPUISelLowering. NFC.

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

14 months ago[flang][hlfir] inline hlfir.transpose as hlfir.elemental
Tom Eccles [Tue, 25 Apr 2023 12:24:46 +0000 (12:24 +0000)]
[flang][hlfir] inline hlfir.transpose as hlfir.elemental

Inlining as a hlfir.elemental will allow the transpose to be inlined
into subsequent operations in some cases. For example,

y = TRANSPOSE(x)
z = y * 2

Will operate in a single loop without creating a temporary for the
TRANSPOSE (unlike the runtime call, which always allocates).

This is in a new SimplifyHLFIRIntriniscs pass. The intention is that some
day that pass might replace the FIR SimplifyIntrinsics pass.

Depends On: D149060

Reviewed By: jeanPerier, vzakhari

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

14 months ago[flang][hlfir] get constant extents when possible
Tom Eccles [Tue, 25 Apr 2023 12:24:08 +0000 (12:24 +0000)]
[flang][hlfir] get constant extents when possible

If we know the extent at compile time, it is better to generate an
arith.constant than hlfir.get_extent. This gives more information earlier
in compilation (before hflir.get_extent is lowered).

Reviewed By: jeanPerier

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

14 months ago[bazel] update build for MLIR test for c8d1388e6c8bd57299d5801f170719218f735c4c
Mikhail Goncharov [Tue, 25 Apr 2023 12:37:23 +0000 (14:37 +0200)]
[bazel] update build for MLIR test for c8d1388e6c8bd57299d5801f170719218f735c4c

14 months ago[SCEV] Regenerate test checks (NFC)
Nikita Popov [Tue, 25 Apr 2023 12:25:57 +0000 (14:25 +0200)]
[SCEV] Regenerate test checks (NFC)

I was very confused by this change while working on a patch --
turns out that it's pre-existing, and we currently just match the
"1" part of "13".

14 months ago[MergeICmps] Adapt to non-eq comparisons, bugfix
Zhongyunde [Tue, 25 Apr 2023 11:36:12 +0000 (19:36 +0800)]
[MergeICmps] Adapt to non-eq comparisons, bugfix

Fix the last runtime issue as some sequent comparisons need be spilted.
For the origin equal comparisons chain, the new spilted Icmp chain will
still be end with equal, while for the new not-equal comparisons chain,
the new spilted Icmp chain will still be end with equal, so should address
this carefully, see detail wih case partial_sequent_ne

Thanks for @aeubanks, @glandium and @ayzhao report the runtime issue
and carefully examine.
Fix https://github.com/llvm/llvm-project/issues/59740.

Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D141188

14 months ago[RISCV][NFC] Fix typo in comment in RISCVISelLowering
Alex Bradbury [Tue, 25 Apr 2023 11:38:04 +0000 (12:38 +0100)]
[RISCV][NFC] Fix typo in comment in RISCVISelLowering

SELECT_CC is expanded to SETT and SELECT.

14 months ago[compiler-rt][test] Add `--large-address-aware` link flag for MinGW
Alvin Wong [Sat, 22 Apr 2023 14:38:53 +0000 (22:38 +0800)]
[compiler-rt][test] Add `--large-address-aware` link flag for MinGW

The interception tests rely on the test binary being large address
aware. This has already been set for MSVC builds. Now we do the same for
MinGW.

This fixes the interception unit tests for i686-w64-windows-gnu target.

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

14 months ago[compiler-rt][asan] Add report on intercept fail to more places
Alvin Wong [Sat, 22 Apr 2023 11:33:53 +0000 (19:33 +0800)]
[compiler-rt][asan] Add report on intercept fail to more places

Use `ASAN_INTERCEPT_FUNC` instead of `INTERCEPT_FUNCTION` so it checks
the return value and reports a message if verbosity >= 1.

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

14 months ago[clangd] Add support TextDocumentEdit.
Haojian Wu [Wed, 19 Apr 2023 21:54:22 +0000 (23:54 +0200)]
[clangd] Add support TextDocumentEdit.

This is an initial patch to add TextDocumentEdit (versioned edits) support in
clangd, the scope is minimal:

- add and extend the corresponding protocol structures
- propagate the documentChanges for diagnostic codeactions (our motivated case)

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

14 months ago[LoopReroll] Convert tests to opaque pointers (NFC)
Nikita Popov [Tue, 25 Apr 2023 10:55:36 +0000 (12:55 +0200)]
[LoopReroll] Convert tests to opaque pointers (NFC)

14 months ago[LoopReroll] Regenerate test checks (NFC)
Nikita Popov [Tue, 25 Apr 2023 10:55:21 +0000 (12:55 +0200)]
[LoopReroll] Regenerate test checks (NFC)

14 months ago[SCEV] Support sub in and negative constants willNotOverflow
Max Kazantsev [Tue, 25 Apr 2023 09:40:37 +0000 (16:40 +0700)]
[SCEV] Support sub in and negative constants willNotOverflow

This lifts two TODOs from this function, allowing us to prove
no-overflow whether it happens through max int (up) or through
min int (down) for both and and sub.

Differential Revision: https://reviews.llvm.org/D148618
Reviewed By: dmakogon

14 months ago[LICM] Add additional "free instruction" tests (NFC)
Nikita Popov [Tue, 25 Apr 2023 08:51:25 +0000 (10:51 +0200)]
[LICM] Add additional "free instruction" tests (NFC)

14 months ago[SLP] Deduplicate loads subkey generator. NFCI
Luke Lau [Fri, 21 Apr 2023 13:50:35 +0000 (14:50 +0100)]
[SLP] Deduplicate loads subkey generator. NFCI

Reviewed By: ABataev

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

14 months ago[RISCV] Fix interleave crash on unary interleaves
Luke Lau [Tue, 18 Apr 2023 17:29:20 +0000 (18:29 +0100)]
[RISCV] Fix interleave crash on unary interleaves

We were crashing when lowering interleave shuffles like
(shuffle <0,3,1,4>, x:v4i8, y:v4i8)
Where it was technically an unary shuffle (both EvenSrc and OddSrc point
to the first operand), but the resulting extract_subvectors were out of
bounds.
This checks to make sure that the vectors being extracted are within
range.

Reviewed By: craig.topper

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

14 months ago[LICM] Remove redundant test (NFC)
Nikita Popov [Tue, 25 Apr 2023 08:07:30 +0000 (10:07 +0200)]
[LICM] Remove redundant test (NFC)

Drop the separate opaque pointers test now that the original one
uses opaque pointers as well.

14 months ago[LICM] Regenerate test checks (NFC)
Nikita Popov [Tue, 25 Apr 2023 08:06:39 +0000 (10:06 +0200)]
[LICM] Regenerate test checks (NFC)

14 months ago[LICM] Only forget loop/block dispositions
Nikita Popov [Tue, 25 Apr 2023 07:57:39 +0000 (09:57 +0200)]
[LICM] Only forget loop/block dispositions

As we are moving the instruction without changing its value, it
is sufficient to only invalidate the loop/block dispositions.
This is the same we do in LoopSink.

14 months ago[mlir][ArmSME] Add tests for Streaming SVE
Cullen Rhodes [Tue, 25 Apr 2023 07:38:09 +0000 (07:38 +0000)]
[mlir][ArmSME] Add tests for Streaming SVE

This patch adds a couple of tests for targeting Arm Streaming SVE (SSVE)
mode, part of the Arm Scalable Matrix Extension (SME).

SSVE is enabled in the backend at the function boundary by specifying
the `aarch64_pstate_sm_enabled` attribute, as documented here [1]. SSVE
can be targeted from MLIR by specifying this in the passthrough
attributes [2] and compiling with

  -mattr=+sme,+sve -force-streaming-compatible-sve

The passthrough will propagate to the backend where `smstart/smstop`
will be emitted around the call to the SSVE function.

The set of legal instructions changes in SSVE,
`-force-streaming-compatible-sve` avoids the use of NEON entirely and
instead lowers to (streaming-compatible) SVE. The behaviour this flag
predicates will be hooked up to the function attribute in the future
such that simply specifying this (should) lead to correct
code-generation.

Two tests are added:

  * A basic LLVMIR test verifying the attribute is passed through.
  * An integration test calling a SSVE function.

The integration test can be run with QEMU.

[1] https://llvm.org/docs/AArch64SME.html
[2] https://mlir.llvm.org/docs/Dialects/LLVM/#attribute-pass-through

Reviewed By: awarzynski, aartbik

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

14 months ago[ValueMapper] allow mapping ConstantTargetNone to its layout type
Bing1 Yu [Tue, 25 Apr 2023 07:47:33 +0000 (15:47 +0800)]
[ValueMapper] allow mapping ConstantTargetNone to its layout type

zeroinitializer is allowed for spirv TargetExtType.
This PR allows ValueMapper to map TargetExtType ConstantTargetNone to '0' constant of its layout type.

Reviewed By: jcranmer-intel

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

14 months ago[MLIR][doc] Fix the [TOC] tag in two doc
Mehdi Amini [Tue, 25 Apr 2023 07:08:20 +0000 (00:08 -0700)]
[MLIR][doc] Fix the [TOC] tag in two doc

Somehow it was escaped in these documents.

14 months ago[flang][runtime] Fix padding in CHARACTER(4) assignments.
Jean Perier [Tue, 25 Apr 2023 07:05:37 +0000 (09:05 +0200)]
[flang][runtime] Fix padding in CHARACTER(4) assignments.

One piece of pointer arithmetic was adding the number of bytes instead
of the number of characters. This caused failures in CHARACTER(KIND>1)
that required padding.
This was caught using HLFIR that currently uses the runtime for array
assignment where the current lowering does everything inline.

Reviewed By: vzakhari, klausler

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

14 months ago[flang][hlfir] Support fir.declare in AbstractResult pass
Jean Perier [Tue, 25 Apr 2023 07:03:55 +0000 (09:03 +0200)]
[flang][hlfir] Support fir.declare in AbstractResult pass

The AbstractResult pass replaces allocation of function result on the callee
side per an extra argument so that the allocation of the result can be
done on the caller stack.
It looks for the result allocation from the fir.return op, so it needs
to handle (in a transparent way) a fir.declare in the chain between the
allocation and the fir.return.

Reviewed By: vzakhari, clementval

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

14 months ago[flang][hlfir] Lower NULL(MOLD) to a variable
Jean Perier [Tue, 25 Apr 2023 07:02:18 +0000 (09:02 +0200)]
[flang][hlfir] Lower NULL(MOLD) to a variable

HLFIR lowering promotes intrinsic results lowered in memory to
hlfir.expr to underline their read-only aspect once they are created.
NULL(MOLD) should not be promoted to an hlfir.expr, it is the NULL
variable (we need to see it as an address).

Reviewed By: clementval

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

14 months ago[clang][Interp] Fix zero-init of float and pointer arrays
Timm Bäder [Mon, 24 Apr 2023 12:30:54 +0000 (14:30 +0200)]
[clang][Interp] Fix zero-init of float and pointer arrays

Our Zero opcode only exists for integer types. Use
visitZeroInitializer() here as well so it works for floats and pointers.

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

14 months ago[libc] Fix typos in documentation
Kazu Hirata [Tue, 25 Apr 2023 06:31:48 +0000 (23:31 -0700)]
[libc] Fix typos in documentation

14 months ago[Driver] Remove no-op -frewrite-map-file=
Fangrui Song [Tue, 25 Apr 2023 06:18:59 +0000 (23:18 -0700)]
[Driver] Remove no-op -frewrite-map-file=

This option has been a no-op since D99707.

14 months ago[clang] Modernize SkipBodyInfo (NFC)
Kazu Hirata [Tue, 25 Apr 2023 06:15:55 +0000 (23:15 -0700)]
[clang] Modernize SkipBodyInfo (NFC)

14 months ago[RISCV][NFC] skip non-RISCV target test riscv32-zihintntl.c
Piyou Chen [Tue, 25 Apr 2023 06:09:56 +0000 (23:09 -0700)]
[RISCV][NFC] skip non-RISCV target test riscv32-zihintntl.c

Reviewed By: kito-cheng

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

14 months ago[clang][Interp] PointerToBoolean casts
Timm Bäder [Sat, 22 Apr 2023 04:40:54 +0000 (06:40 +0200)]
[clang][Interp] PointerToBoolean casts

Just emit e != nullptr for these.

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

14 months ago[clang] Add test for CWG1821
Vlad Serebrennikov [Tue, 25 Apr 2023 06:03:14 +0000 (09:03 +0300)]
[clang] Add test for CWG1821

[[https://wg21.link/p1787 | P1787]]: My clarification in [[ http://lists.isocpp.org/core/2019/06/6614.php | “Where can namespace-scope functions and variables be redeclared?” ]] is applied, resolving CWG1821.
Wording: (If the declaration is not a friend declaration:) If the id-expression in a declarator-id is a qualified-id Q, let S be its lookup context; the declaration shall inhabit a namespace scope. ([dcl.meaning]/1)

Reviewed By: shafik, #clang-language-wg

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

14 months ago[Driver] Simplify handling of -mabi=vec-default -mabi=vec-extabi
Fangrui Song [Tue, 25 Apr 2023 05:59:54 +0000 (22:59 -0700)]
[Driver] Simplify handling of -mabi=vec-default -mabi=vec-extabi

And fix a minor issue that -mabi=vec-extabi -mabi=vec-default should not pass
"-bplugin_opt:-vec-extabi" to ld.

14 months agoRevert "Remove code only needed to detect a pre-4.0 API break."
Owen Anderson [Tue, 25 Apr 2023 05:52:18 +0000 (22:52 -0700)]
Revert "Remove code only needed to detect a pre-4.0 API break."

This reverts commit 17a3fbf2a3683f862de52e0058110eb8b356be56
due to build failures in llvm/unittests/ADT/IListTest.cpp

14 months agoRemove code only needed to detect a pre-4.0 API break.
Owen Anderson [Tue, 25 Apr 2023 05:23:38 +0000 (22:23 -0700)]
Remove code only needed to detect a pre-4.0 API break.

Reviewed By: dexonsmith

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

14 months ago[clang][AST][NFC] Turn some single-line comments into doc comments
Timm Bäder [Sun, 23 Apr 2023 08:08:44 +0000 (10:08 +0200)]
[clang][AST][NFC] Turn some single-line comments into doc comments

14 months ago[bazel][mlir] Fold :Observers and :BreakpointManagers into :Debug
Emilio Cota [Tue, 25 Apr 2023 04:53:03 +0000 (00:53 -0400)]
[bazel][mlir] Fold :Observers and :BreakpointManagers into :Debug

To avoid circular deps.

While at it, add missing dep on CAPIIR.

14 months ago[flang] Feature list plugin
Ethan Luis McDonough [Tue, 25 Apr 2023 04:35:19 +0000 (23:35 -0500)]
[flang] Feature list plugin

Plugin that counts the number of times each tree node occurs in a given program.  Used for test coverage.

Updated to fix build issues.

Reviewed By: jdoerfert

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

14 months ago[RISCV] Fix -Wdeprecated-declarations in RISCVInstrInfo.cpp (NFC)
Jie Fu [Tue, 25 Apr 2023 03:54:16 +0000 (11:54 +0800)]
[RISCV] Fix -Wdeprecated-declarations in RISCVInstrInfo.cpp (NFC)

/Users/jiefu/llvm-project/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp:2636:10: error: 'makeArrayRef<std::pair<llvm::MachineMemOperand::Flags, const char *>, 2UL>' is deprecated: Use deduction guide instead [-Werror,-Wdeprecated-declarations]
  return makeArrayRef(TargetFlags);
         ^~~~~~~~~~~~
         ArrayRef
/Users/jiefu/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:572:3: note: 'makeArrayRef<std::pair<llvm::MachineMemOperand::Flags, const char *>, 2UL>' has been explicitly marked deprecated here
  LLVM_DEPRECATED("Use deduction guide instead", "ArrayRef")
  ^
/Users/jiefu/llvm-project/llvm/include/llvm/Support/Compiler.h:143:50: note: expanded from macro 'LLVM_DEPRECATED'
                                                 ^
1 error generated.

14 months ago[mlir] detensorize: don't accidentally convert function entry blocks
Alex Zinenko [Sat, 22 Apr 2023 08:57:10 +0000 (08:57 +0000)]
[mlir] detensorize: don't accidentally convert function entry blocks

In the Linalg detensorize pass, dialect conversion could accidentally
trigger signature conversion of the function entry block after inlining
the body of a Linalg generic into it. Such a conversion is not desirable
because it would break the internal validity of the function op, that is
futhermore not supposed to be detensorized at the boundary. Mitigate
this by creating a dummy (empty) entry block so Linalg operations are
never inlined into it and the conversion is never triggered.

Closes #62249.

Reviewed By: silvas

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

14 months ago[gn build] Port 8a3950510f81
LLVM GN Syncbot [Tue, 25 Apr 2023 03:20:33 +0000 (03:20 +0000)]
[gn build] Port 8a3950510f81

14 months ago[RISCV] Support scalar/fix-length vector NTLH intrinsic with different domain
Piyou Chen [Tue, 25 Apr 2023 02:58:38 +0000 (19:58 -0700)]
[RISCV] Support scalar/fix-length vector NTLH intrinsic with different domain

This commit implements the two NTLH intrinsic functions.

```
type __riscv_ntl_load (type *ptr, int domain);
void __riscv_ntl_store (type *ptr, type val, int domain);

```

```
enum {
  __RISCV_NTLH_INNERMOST_PRIVATE = 2,
  __RISCV_NTLH_ALL_PRIVATE,
  __RISCV_NTLH_INNERMOST_SHARED,
  __RISCV_NTLH_ALL
};
```

We encode the non-temporal domain into MachineMemOperand flags.

1. Create the RISC-V built-in function with custom semantic checking.
2. Assume the domain argument is a compile time constant,
and make it as LLVM IR metadata (nontemp_node).
3. Encode domain value as two bits MachineMemOperand TargetMMOflag.
4. According to MachineMemOperand TargetMMOflag, select corrsponding ntlh instruction.

Currently, it supports scalar type and fixed-length vector type.

Reviewed By: craig.topper

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

14 months ago-Wframe-larger-than=: improve error with an invalid argument
Fangrui Song [Tue, 25 Apr 2023 03:11:21 +0000 (20:11 -0700)]
-Wframe-larger-than=: improve error with an invalid argument

Remove a FIXME. For simplicity, the error message for the missing argument case
has changed from err_drv_missing_argument to err_drv_invalid_argument_to_option,
which should be fine.

14 months agoValueTracking: Add ordered negative handling for fmul to computeKnownFPClass
Matt Arsenault [Mon, 17 Apr 2023 19:01:11 +0000 (15:01 -0400)]
ValueTracking: Add ordered negative handling for fmul to computeKnownFPClass

Port from the existing handling in cannotBeOrderedLessThanZero

14 months agoValueTracking: Handle fptrunc_round in computeKnownFPClass
Matt Arsenault [Sun, 9 Apr 2023 11:16:56 +0000 (07:16 -0400)]
ValueTracking: Handle fptrunc_round in computeKnownFPClass

14 months ago[bazel][mlir] Build Debug/BreakpointManagers only from a single target
Emilio Cota [Tue, 25 Apr 2023 02:11:22 +0000 (22:11 -0400)]
[bazel][mlir] Build Debug/BreakpointManagers only from a single target

When writing 5f2b0892d "[bazel][mlir] BreakpointManager fixes for 7f069f5",
I did not notice that 17c6de3f1 "[bazel] Fix bazel build for 7f069f5ef.."
had added Debug/BreakpointManagers globs to the Debug target. But these
are already being built in the "BreakpointManagers" target; remove them
from "Debug".

14 months ago[RISCV] Ensure extract_vector_elt has a single use in combineBinOpToReduce.
Craig Topper [Tue, 25 Apr 2023 01:11:05 +0000 (18:11 -0700)]
[RISCV] Ensure extract_vector_elt has a single use in combineBinOpToReduce.

Without this, the original reduction will not be removed and we'll
end up with a second reduction. Reductions are expensive operations so
we should avoid that.