platform/upstream/llvm.git
13 months ago[mlir] teach expensive-checks transform mode about empty handle
Alex Zinenko [Fri, 26 May 2023 13:07:13 +0000 (13:07 +0000)]
[mlir] teach expensive-checks transform mode about empty handle

The transform dialect interpreter features the expensive-checks mode
that acts as an embedded sanitizer to track use-after-consume of
transform handles. Its logic is based on the relations between payload
operations, which made it silently ignore empty handles that are
consumed. Also catch and report this case because the remaining code may
hit an assertion on attempting to access a consumed handle (that is
removed from the mapping).

Reviewed By: nicolasvasilache

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

13 months ago[lldb] Improve error message when evaluating expression when not stopped
Jonas Devlieghere [Fri, 26 May 2023 15:48:02 +0000 (08:48 -0700)]
[lldb] Improve error message when evaluating expression when not stopped

When trying to run an expression after a process has existed, you
currently are shown the following error message:

  (lldb) p strlen("")
  error: Can't make a function caller while the process is running

This error is wrong and pretty uninformative. After this patch, the
following error message is shown:

  (lldb) p strlen("")
  error: unable to evaluate expression while the process is exited: the
  process must be stopped because the expression might require
  allocating memory.

rdar://109731325

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

13 months ago[Clang] Convert some tests to opaque pointers (NFC)
Nikita Popov [Fri, 26 May 2023 14:58:48 +0000 (16:58 +0200)]
[Clang] Convert some tests to opaque pointers (NFC)

13 months ago[FastISel] Implement translation of entry_value dbg.value intrinsics
Felipe de Azevedo Piovezan [Wed, 24 May 2023 11:53:26 +0000 (07:53 -0400)]
[FastISel] Implement translation of entry_value dbg.value intrinsics

For dbg.value intrinsics targeting an llvm::Argument address whose expression
starts with an entry value, we lower this to a DEBUG_VALUE targeting the livein
physical register corresponding to that Argument.

Depends on D151332

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

13 months ago[gn build] Port 8d0412ce9d48
LLVM GN Syncbot [Fri, 26 May 2023 15:12:00 +0000 (15:12 +0000)]
[gn build] Port 8d0412ce9d48

13 months ago[RISCV] Revise test coverage for shuffle/insert idiom which become v(f)slide1ups
Philip Reames [Fri, 26 May 2023 14:59:08 +0000 (07:59 -0700)]
[RISCV] Revise test coverage for shuffle/insert idiom which become v(f)slide1ups

This fixes a couple mistakes in 0f64d4f877.  In particular, I'd not included a negative test where the slideup didn't write the entire VL, and had gotten all of my 4 element vector shuffle masks incorrect so they didn't match.  Also, add a test with swapped operands for completeness.

The transform is in D151468.

13 months ago[gn] attempt to port fe2f0ab37c33
Nico Weber [Fri, 26 May 2023 15:05:57 +0000 (11:05 -0400)]
[gn] attempt to port fe2f0ab37c33

13 months ago[InstCombine] Remove instructions in dead blocks during combining
Nikita Popov [Wed, 24 May 2023 14:47:15 +0000 (16:47 +0200)]
[InstCombine] Remove instructions in dead blocks during combining

We already do this during initial worklist population. Doing this
as part of primary combining allows us to remove instructions in
blocks that were rendered dead by condition folding within the
same instcombine iteration.

13 months ago[ValueTracking] Avoid optimizing away condition in test (NFC)
Nikita Popov [Fri, 26 May 2023 14:37:38 +0000 (16:37 +0200)]
[ValueTracking] Avoid optimizing away condition in test (NFC)

This is not what we're interested in testing, and it allows to
essentially optimize away the entire function with more powerful
optimization.

13 months ago[RISCV] Fix typo VLUpperBound to VLEN in SiFive7. NFC.
Michael Maitland [Thu, 25 May 2023 21:53:56 +0000 (14:53 -0700)]
[RISCV] Fix typo VLUpperBound to VLEN in SiFive7. NFC.

The scheduler models said VLUpperBound which was a typo and should have
said VLEN. This is a purley cosmetic fix.

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

13 months ago[libc] Adapt includes after 25174976e19b2ef916bb94f4613662646c95cd46
Krasimir Georgiev [Fri, 26 May 2023 14:25:50 +0000 (14:25 +0000)]
[libc] Adapt includes after 25174976e19b2ef916bb94f4613662646c95cd46

13 months ago[AArch64] merge scaled and unscaled zero narrow stores.
Zain Jaffal [Fri, 19 May 2023 14:24:30 +0000 (15:24 +0100)]
[AArch64] merge scaled and unscaled zero narrow stores.

This patch fixes a crash when a sclaed and unscaled zero stores are merged.

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

13 months ago[InstCombine] Optimize compares with multiple selects as operands
Tejas Joshi [Fri, 26 May 2023 14:02:22 +0000 (16:02 +0200)]
[InstCombine] Optimize compares with multiple selects as operands

In case of a comparison with two select instructions having the same
condition, check whether one of the resulting branches can be simplified.
If so, just compare the other branch and select the appropriate result.
For example:

    %tmp1 = select i1 %cmp, i32 %y, i32 %x
    %tmp2 = select i1 %cmp, i32 %z, i32 %x
    %cmp2 = icmp slt i32 %tmp2, %tmp1

The icmp will result false for the false value of selects and the result
will depend upon the comparison of true values of selects if %cmp is
true. Thus, transform this into:

    %cmp = icmp slt i32 %y, %z
    %sel = select i1 %cond, i1 %cmp, i1 false

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

13 months ago[Clang] Correctly handle generic lambda used as default template argument.
Corentin Jabot [Wed, 24 May 2023 16:11:40 +0000 (18:11 +0200)]
[Clang] Correctly handle generic lambda used as default template argument.

Adjust the template pparameter depth when parsing default
template arguments as they may introduce generic lambda whose parameters
are not substituted at the same depth.

Fixes #62611

Reviewed By: erichkeane, #clang-language-wg

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

13 months ago[InstCombine] Add tests for icmp of select fold (NFC)
Tejas Joshi [Fri, 26 May 2023 14:00:28 +0000 (16:00 +0200)]
[InstCombine] Add tests for icmp of select fold (NFC)

For D150360.

13 months ago[InstCombine] Handle undef when pruning unreachable code
Nikita Popov [Thu, 25 May 2023 14:52:16 +0000 (16:52 +0200)]
[InstCombine] Handle undef when pruning unreachable code

If the branch condition is undef, then behavior is undefined and
neither of the successors are live.

This is to ensure that optimization quality does not decrease
when a constant gets replaced with undef/poison in this context.

13 months ago[ValueTracking] Avoid UB in test (NFC)
Nikita Popov [Fri, 26 May 2023 13:54:51 +0000 (15:54 +0200)]
[ValueTracking] Avoid UB in test (NFC)

Don't use br undef, as it is UB.

13 months ago[X86] fold select to mask instructions.
Luo, Yuanke [Fri, 26 May 2023 05:28:59 +0000 (13:28 +0800)]
[X86] fold select to mask instructions.

When avx512 is available the lhs operand of select instruction can be
folded with mask instruction, while the rhs operand can't. This patch is
to commute the lhs and rhs of the select instruction to create the
opportunity of folding.

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

13 months ago[InstCombine] Add additional tests for unreachable code (NFC)
Nikita Popov [Fri, 26 May 2023 13:47:50 +0000 (15:47 +0200)]
[InstCombine] Add additional tests for unreachable code (NFC)

13 months ago[LLDB] Explicitly declare constructor in `PersistentExpressionState`
Laszlo Kindrat [Thu, 25 May 2023 21:13:28 +0000 (17:13 -0400)]
[LLDB] Explicitly declare constructor in `PersistentExpressionState`

It seems that when trying to link the lldb library explicitly, the inlined default constructor cannot find the vtable for the class. This patch fixes this by explicitly declaring a default constructor in `PersistentExpressionState`, and providing the definition in the source file.

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

13 months ago[NFC] refactor code
Luo, Yuanke [Fri, 26 May 2023 13:04:04 +0000 (21:04 +0800)]
[NFC] refactor code

Split the NFC patch from D151535. Refactor canCombineAsMaskOperation to
take 1 input operand.

13 months ago[InstCombine] Add test for missing assume handling multi-use demanded bits (NFC)
Nikita Popov [Fri, 26 May 2023 12:59:36 +0000 (14:59 +0200)]
[InstCombine] Add test for missing assume handling multi-use demanded bits (NFC)

Works if the assume is on a root value or an operation that does
not support multi-use demanded bits.

13 months ago[InstCombine] Use KnownBits::shl() in SimplifyDemandedBits()
Nikita Popov [Fri, 26 May 2023 12:39:57 +0000 (14:39 +0200)]
[InstCombine] Use KnownBits::shl() in SimplifyDemandedBits()

It is more precise than the custom logic we had. This came up when
trying to enforce a consistency assertion with computeKnownBits().

13 months ago[KnownBits] Partially synchronize shift implementations (NFC)
Nikita Popov [Fri, 26 May 2023 12:03:12 +0000 (14:03 +0200)]
[KnownBits] Partially synchronize shift implementations (NFC)

And remove some bits of effectively dead code.

13 months ago[mlir] Make sure mlir-opt is in the list of substituted tools
Benjamin Kramer [Fri, 26 May 2023 11:57:09 +0000 (13:57 +0200)]
[mlir] Make sure mlir-opt is in the list of substituted tools

otherwise it gets picked up from $PATH, which is not always working
properly.

13 months ago[KnownBits] Add fast-path for shl with unknown shift amount (NFC)
Nikita Popov [Fri, 26 May 2023 10:09:44 +0000 (12:09 +0200)]
[KnownBits] Add fast-path for shl with unknown shift amount (NFC)

We currently don't call into KnownBits::shl() from ValueTracking
if the shift amount is unknown. If we do try to do so, we get
significant compile-time regressions, because evaluating all 64
shift amounts if quite expensive, and mostly pointless in this case.
Add a fast-path for the case where the shift amount is the full
[0, BitWidth-1] range. This primarily requires a more accurate
estimate of the max shift amount, to avoid taking the fast-path in
too many cases.

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

13 months ago[bazel][libc] Add another missing dependency
Benjamin Kramer [Fri, 26 May 2023 11:11:48 +0000 (13:11 +0200)]
[bazel][libc] Add another missing dependency

13 months ago[FastISel][NFC] Remove repeated calls to get{Variable,Expr}
Felipe de Azevedo Piovezan [Wed, 24 May 2023 11:13:17 +0000 (07:13 -0400)]
[FastISel][NFC] Remove repeated calls to get{Variable,Expr}

This will make it easy to reuse these values in subsequent commits.

Depends on D151331

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

13 months ago[FastISel][NFC] Refactor if/else chain into early returns
Felipe de Azevedo Piovezan [Wed, 24 May 2023 11:01:11 +0000 (07:01 -0400)]
[FastISel][NFC] Refactor if/else chain into early returns

This will make it easier to add more cases in a subsequent commit and also
better conforms to the coding guidelines.

Depends on D151330

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

13 months ago[SelectionDAGBuilder] Handle entry_value dbg.value intrinsics
Felipe de Azevedo Piovezan [Tue, 23 May 2023 17:52:01 +0000 (13:52 -0400)]
[SelectionDAGBuilder] Handle entry_value dbg.value intrinsics

Summary:
DbgValue intrinsics whose expression is an entry_value and whose address is
described an llvm::Argument must be lowered to the corresponding livein physical
register for that Argument.

Depends on D151329

Reviewers: aprantl

Subscribers:

13 months ago[IRTranslator] Implement translation of entry_value dbg.value intrinsics
Felipe de Azevedo Piovezan [Tue, 23 May 2023 15:48:11 +0000 (11:48 -0400)]
[IRTranslator] Implement translation of entry_value dbg.value intrinsics

For dbg.value intrinsics targeting an llvm::Argument address whose expression
starts with an entry value, we lower this to a DEBUG_VALUE targeting the livein
physical register corresponding to that Argument.

Depends on D151328

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

13 months ago[RISCV] Support '.option arch' directive
luxufan [Fri, 26 May 2023 03:48:28 +0000 (11:48 +0800)]
[RISCV] Support '.option arch' directive

The proposal of '.option arch' directive is https://github.com/riscv-non-isa/riscv-asm-manual/pull/67

Note: For '.option arch, +/-' directive, version number is not yet supported.

Reviewed By: luismarques, craig.topper

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

13 months ago[Utils] Added the ability to print the pass number and IR after it is triggered
dbakunevich [Thu, 11 May 2023 09:30:07 +0000 (16:30 +0700)]
[Utils] Added the ability to print the pass number and IR after it is triggered

As part of this patch, 2 options have been added:
print-pass-numbers and print-after-pass-number.

1) The print-pass-numbers option allows to print the pass names and their ordinals.
   The output of the option looks like this:
                Running pass ORDINAL PASS_NAME

2) The print-after-pass-number option allows to print IR after pass with the number
   which reported by print-passes-names.

Reviewed By: apilipenko, aeubanks

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

13 months ago[bazel][libc] Add file missing for 25174976e19b2ef916bb94f4613662646c95cd46
Benjamin Kramer [Fri, 26 May 2023 10:24:36 +0000 (12:24 +0200)]
[bazel][libc] Add file missing for 25174976e19b2ef916bb94f4613662646c95cd46

13 months ago[bazel][libc] Adjust for 4f1fe19df385445fabde47998affca50c7f1bc1e
Benjamin Kramer [Fri, 26 May 2023 10:14:50 +0000 (12:14 +0200)]
[bazel][libc] Adjust for 4f1fe19df385445fabde47998affca50c7f1bc1e

This also required a build rule for error_to_string, so add that too.

13 months ago[bazel] Run buildifier on libc BUILD. NFC.
Benjamin Kramer [Fri, 26 May 2023 10:14:24 +0000 (12:14 +0200)]
[bazel] Run buildifier on libc BUILD. NFC.

13 months ago[Remarks] Retain all remarks by default, add option to drop without DL.
Florian Hahn [Fri, 26 May 2023 10:01:18 +0000 (11:01 +0100)]
[Remarks] Retain all remarks by default, add option to drop without DL.

At the moment, dsymutil drops all remarks without debug location.

There are many cases where debug location may be missing for remarks,
mostly due LLVM not preserving debug locations. When using bitstream
remarks for statistical analysis, those missed remarks mean we get an
incomplete picture.

The patch flips the default to keeping all remarks and leaving it to
tools that display remarks to filter out remarks without debug locations
as needed.

The new --remarks-drop-without-debug flag can be used to drop remarks
without debug locations, i.e. restore the previous behavior.

Reviewed By: thegameg

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

13 months ago[mlir][tensor] Fix one-shot bufferization of tensor.reshape.
Ingo Müller [Fri, 26 May 2023 09:39:22 +0000 (09:39 +0000)]
[mlir][tensor] Fix one-shot bufferization of tensor.reshape.

I believe that the previous implementation did not work on any input. It
called getMemRefType with `layout = {}`, presumably with the intention
to create a MemrefType with identity layout. However, the implementation
of that function returns a MemrefType with *unknown* layout if it is
provided with a default-constructed layout attribute. This patch uses
getMemRefTypeWithStaticIdentityLayout instead, with has identical
behavior except for the case of a default-constructed layout, which it
passes on as-is to the MemrefType.

This problem did not surface in the test because tensor.reshape was not
tested with -one-shot-bufferize. This patch introduces a test copied
from the tests for -tesnor-bufferize adapted in as follows: since the
test is run with "bufferize-function-boundaries", a tensor that is
passed into the function is bufferized into a memref with unknown
layout, which wouldn't be a valid intput for memref.reshape, so the
tests now uses a tensor constructed with arith.constant inside of the
function.

Reviewed By: springerm

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

13 months ago[clang-format][doc] Fix a typo introduced in 9aab0db13fb6d
Owen Pan [Fri, 26 May 2023 09:10:38 +0000 (02:10 -0700)]
[clang-format][doc] Fix a typo introduced in 9aab0db13fb6d

13 months ago[clang-format][doc] Fix contradiction in SortIncludes description
Mike Matthews [Fri, 26 May 2023 08:53:25 +0000 (01:53 -0700)]
[clang-format][doc] Fix contradiction in SortIncludes description

Fixes #62033.

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

13 months ago[clangd] Remove inline Specifier for DefineOutline Tweak
Brian Gluzman [Fri, 26 May 2023 08:41:18 +0000 (10:41 +0200)]
[clangd] Remove inline Specifier for DefineOutline Tweak

`inline` specifiers should be removed from from the function declaration and
the newly-created implementation.

For example, take the following (working) code:
```cpp
// foo.hpp
struct A {
  inline void foo() { std::cout << "hello world\n" << std::flush; }
};

// foo.cpp
#include "foo.hpp"

// main.cpp
#include "foo.hpp"

int main() {
  A a;
  a.foo();
  return 0;
}

// compile: clang++ -std=c++20 main.cpp foo.cpp -o main
```

After applying the tweak:
```
// foo.hpp
struct A {
  inline void foo();
};

// foo.cpp
#include "foo.hpp"

inline void A::foo() { std::cout << "hello world\n" << std::flush; }

// main.cpp
#include "foo.hpp"

int main() {
  A a;
  a.foo();
  return 0;
}

// compile: clang++ -std=c++20 main.cpp foo.cpp -o main
```

We get a link error, as expected:
```
/usr/bin/ld: /tmp/main-4c5d99.o: in function `main':
main.cpp:(.text+0x14): undefined reference to `A::foo()'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

This revision removes these specifiers from both the header and the source file. This was identified in Github issue llvm/llvm-project#61295.

Reviewed By: kadircet

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

13 months ago[RISCV] Don't scalarize vector stores if volatile
Luke Lau [Thu, 25 May 2023 21:16:45 +0000 (22:16 +0100)]
[RISCV] Don't scalarize vector stores if volatile

As noted by @reames in https://reviews.llvm.org/D151211#4373404, we shouldn't
scalarize vector stores of constants if the store is volatile, or vector copies
if either the store or load are volatile.

Reviewed By: reames

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

13 months ago[mlir] Move casting calls from methods to function calls
Tres Popp [Fri, 26 May 2023 08:17:47 +0000 (10:17 +0200)]
[mlir] Move casting calls from methods to function calls

The MLIR classes Type/Attribute/Operation/Op/Value support
cast/dyn_cast/isa/dyn_cast_or_null functionality through llvm's doCast
functionality in addition to defining methods with the same name.
This change begins the migration of uses of the method to the
corresponding function call as has been decided as more consistent.

Note that there still exist classes that only define methods directly,
such as AffineExpr, and this does not include work currently to support
a functional cast/isa call.

Context:
- https://mlir.llvm.org/deprecation/ at "Use the free function variants
  for dyn_cast/cast/isa/…"
- Original discussion at https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443

Implementation:
This patch updates all remaining uses of the deprecated functionality in
mlir/. This was done with clang-tidy as described below and further
modifications to GPUBase.td and OpenMPOpsInterfaces.td.

Steps are described per line, as comments are removed by git:
0. Retrieve the change from the following to build clang-tidy with an
   additional check:
   main...tpopp:llvm-project:tidy-cast-check
1. Build clang-tidy
2. Run clang-tidy over your entire codebase while disabling all checks
   and enabling the one relevant one. Run on all header files also.
3. Delete .inc files that were also modified, so the next build rebuilds
   them to a pure state.

```
ninja -C $BUILD_DIR clang-tidy

run-clang-tidy -clang-tidy-binary=$BUILD_DIR/bin/clang-tidy -checks='-*,misc-cast-functions'\
               -header-filter=mlir/ mlir/* -fix

rm -rf $BUILD_DIR/tools/mlir/**/*.inc
```

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

13 months ago[Clang][RISCV] Add test coverage for typedef of RVV intrinsic data types under riscv_...
eopXD [Fri, 26 May 2023 08:26:31 +0000 (01:26 -0700)]
[Clang][RISCV] Add test coverage for typedef of RVV intrinsic data types under riscv_vector.h. NFC

Signed-off by: eop Chen <eop.chen@sifive.com>

13 months ago[AMDGPU] Silence gcc warning [NFC]
Mikael Holmen [Fri, 26 May 2023 08:17:59 +0000 (10:17 +0200)]
[AMDGPU] Silence gcc warning [NFC]

Without the fix gcc complains with
 ../lib/Target/AMDGPU/SIWholeQuadMode.cpp:1543: warning: enumeral and non-enumeral type in conditional expression [-Wextra]
  1542 |     unsigned CopyOp = MI->getOperand(1).isReg()
       |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1543 |                           ? AMDGPU::COPY
       |                           ~~~~~~~~~~~~~~
  1544 |                           : TII->getMovOpcode(TRI->getRegClassForOperandReg(
       |                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1545 |                                 *MRI, MI->getOperand(0)));
       |

13 months ago[ASAN] Support memory checks on vp.gather/scatter.
Yeting Kuo [Wed, 26 Apr 2023 04:55:50 +0000 (12:55 +0800)]
[ASAN] Support memory checks on vp.gather/scatter.

The patch supports vp.gather/scatter by allowing addresses being pointer vectors.
And then we just need to check each active pointer element of those pointer vectors.

Reviewed By: reames

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

13 months ago[clangd] Implement configs to stop clangd produce a certain semantic tokens
Qingyuan Zheng [Fri, 26 May 2023 07:15:10 +0000 (03:15 -0400)]
[clangd] Implement configs to stop clangd produce a certain semantic tokens

This patch introduces the following configurations to .clangd:

```
SemanticTokens:
    DisabledKinds: [ ... ]
    DisabledModifiers: [ ... ]
```

Based on the config, clangd would stop producing a certain type of semantic tokens from the source file.

Fixes https://github.com/clangd/clangd/discussions/1598

Reviewed By: nridge

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

13 months ago[Clang][RISCV] Add description for test case . NFC
eopXD [Fri, 26 May 2023 07:22:34 +0000 (00:22 -0700)]
[Clang][RISCV] Add description for test case . NFC

13 months ago[AMDGPU] 4-align SGPR triples
Jay Foad [Thu, 25 May 2023 15:18:25 +0000 (16:18 +0100)]
[AMDGPU] 4-align SGPR triples

Previously SGPR triples like s[3:5] were aligned on a 3-SGPR boundary
which has no basis in hardware.

Aligning them on a 4-SGPR boundary is at least justified by the
architecture reference guide which says: "Quad-alignment of SGPRs is
required for operation on more than 64-bits".

Currently there are no instructions that take SGPR triples as operands
so the issue is latent.

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

13 months ago[AMDGPU] Add pass to rewrite partially used virtual superregisters after RenameIndepe...
Valery Pykhtin [Fri, 9 Dec 2022 16:34:22 +0000 (17:34 +0100)]
[AMDGPU] Add pass to rewrite partially used virtual superregisters after RenameIndependentSubregs pass with registers of minimal size.

The main purpose of this is to simplify register pressure tracking as after the pass there is no need
to track subreg liveness anymore.

On the other hand this pass creates more possibilites for the subreg unaware code, as many of the subregs
becomes ordinary registers.

Intersting sideeffect: spill-vgpr.ll has lost a lot of spills.

Reviewed By: #amdgpu, arsenm

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

13 months ago[CSKY] Add missing relocation type for FK_Data_4 Fixup
Zi Xuan Wu (Zeson) [Fri, 26 May 2023 03:08:35 +0000 (11:08 +0800)]
[CSKY] Add missing relocation type for FK_Data_4 Fixup

13 months ago[CodeGen] Remove unused declaration EmitMoveFromReturnSlot
Kazu Hirata [Fri, 26 May 2023 06:52:09 +0000 (23:52 -0700)]
[CodeGen] Remove unused declaration EmitMoveFromReturnSlot

The corresponding function definition was removed by:

  commit 56e5a2e13e3048fc2ff39029cde406d9f4eb55f3
  Author: George Burgess IV <george.burgess.iv@gmail.com>
  Date:   Sat Mar 10 01:11:17 2018 +0000

13 months ago[RISCV] Custom lower vector llvm.is.fpclass to vfclass.v
LiaoChunyu [Fri, 26 May 2023 06:19:45 +0000 (14:19 +0800)]
[RISCV] Custom lower vector llvm.is.fpclass to vfclass.v

After D149063.
This patch adds support for both scalable and fixed-length vector.

Reviewed By: craig.topper

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

13 months ago[CodeGen] Remove unused member variable NextBlockInfo
Kazu Hirata [Fri, 26 May 2023 06:41:34 +0000 (23:41 -0700)]
[CodeGen] Remove unused member variable NextBlockInfo

The last use was removed by:

  commit c9a52de0026093327daedda7ea2eead8b64657b4
  Author: Akira Hatanaka <ahatanaka@apple.com>
  Date:   Wed Jun 3 16:41:50 2020 -0700

13 months ago[RISCV] Regenerate missing test checks
Fraser Cormack [Fri, 26 May 2023 06:20:01 +0000 (07:20 +0100)]
[RISCV] Regenerate missing test checks

Codegen was different between RV32 and RV64 so the single unified CHECK
was skipping these functions.

13 months ago[lit][NFC] Remove docs for nonexistent parameter
Fraser Cormack [Fri, 26 May 2023 06:02:20 +0000 (07:02 +0100)]
[lit][NFC] Remove docs for nonexistent parameter

13 months ago[lit][NFC] Remove double space after full stop/period
Fraser Cormack [Fri, 26 May 2023 06:01:09 +0000 (07:01 +0100)]
[lit][NFC] Remove double space after full stop/period

13 months ago[lit][NFC] Fix a couple of typos
Fraser Cormack [Fri, 26 May 2023 05:59:24 +0000 (06:59 +0100)]
[lit][NFC] Fix a couple of typos

13 months ago[clang] Remove unused declaration IgnoreLinkageSpecDecls
Kazu Hirata [Fri, 26 May 2023 06:31:17 +0000 (23:31 -0700)]
[clang] Remove unused declaration IgnoreLinkageSpecDecls

The declaration and its corresponding function definition were removed
once by:

  commit 02093906fa0fd5bacc61b2189ea643c78cd02509
  Author: Nathan Sidwell <nathan@acm.org>
  Date:   Mon Feb 14 10:19:04 2022 -0800

However, the declaration was added back without a corresponding
function definition a few days later by:

  commit 18ead23385a4e0e6421d658591b1ee6a1c592b53
  Author: Peter Collingbourne <peter@pcc.me.uk>
  Date:   Thu Feb 17 11:23:33 2022 -0800

This is most likely a rebasing error.

13 months ago[libc] Make ErrnoSetterMatcher handle logging floating point values.
Siva Chandra Reddy [Mon, 15 May 2023 22:12:26 +0000 (22:12 +0000)]
[libc] Make ErrnoSetterMatcher handle logging floating point values.

Along the way, couple of additional things have been done:

1. Move `ErrnoSetterMatcher.h` to `test/UnitTest` as all other matchers live
   there now.
2. `ErrnoSetterMatcher` ignores matching `errno` on GPUs.

Reviewed By: jhuber6

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

13 months ago[flang][hlfir] Only canonicalize forall_index if it can be erased
Jean Perier [Fri, 26 May 2023 06:21:49 +0000 (08:21 +0200)]
[flang][hlfir] Only canonicalize forall_index if it can be erased

It seems the canonicalization was not correct: it cannot return that
it failed if it did modify the IR.
This was exposed by a new MLIR sanity check added in
https://reviews.llvm.org/D144552.
I am not sure it is legit to return success if the operation being
canonicalized is not modified either. So only remove the loads if
they are the only uses of the forall_index.

Should fix (intermittent?) bot failures like
https://lab.llvm.org/buildbot/#/builders/179/builds/6251
since the new MLIR check was added.

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

13 months ago[AMDGPUCodegenPrepare] Add NewPM Support
Anshil Gandhi [Wed, 24 May 2023 16:37:07 +0000 (09:37 -0700)]
[AMDGPUCodegenPrepare] Add NewPM Support

Reviewed By: arsenm

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

13 months ago[NFC][Py Reformat] Reformat version-check.py in .github dir
Tobias Hieta [Fri, 26 May 2023 06:11:06 +0000 (08:11 +0200)]
[NFC][Py Reformat] Reformat version-check.py in .github dir

13 months ago[NFC] Add mlir python reformat SHA to .git-blame-ignore-revs
Tobias Hieta [Fri, 26 May 2023 06:06:03 +0000 (08:06 +0200)]
[NFC] Add mlir python reformat SHA to .git-blame-ignore-revs

13 months ago[NFC][Py Reformat] Reformat python files in mlir subdir
Tobias Hieta [Wed, 17 May 2023 14:53:39 +0000 (16:53 +0200)]
[NFC][Py Reformat] Reformat python files in mlir subdir

This is an ongoing series of commits that are reformatting our
Python code.

Reformatting is done with `black`.

If you end up having problems merging this commit because you
have made changes to a python file, the best way to handle that
is to run git checkout --ours <yourfile> and then reformat it
with black.

If you run into any problems, post to discourse about it and
we will try to help.

RFC Thread below:

https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style

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

13 months ago[clang] Modernize SourceLocation (NFC)
Kazu Hirata [Fri, 26 May 2023 05:56:08 +0000 (22:56 -0700)]
[clang] Modernize SourceLocation (NFC)

13 months ago[clang-tody] Fix typos in documentation
Kazu Hirata [Fri, 26 May 2023 05:56:06 +0000 (22:56 -0700)]
[clang-tody] Fix typos in documentation

13 months ago[mlir] Update cast/isa method calls to function calls
Tres Popp [Thu, 25 May 2023 14:35:45 +0000 (16:35 +0200)]
[mlir] Update cast/isa method calls to function calls

This updates the rest (at implementation) of MLIR's use of cast/isa
method calls where function calls are possible and automatic refactoring
is not. These changes occured in .td files or in macros.

Context:
- https://mlir.llvm.org/deprecation/ at "Use the free function variants for dyn_cast/cast/isa/…"
- Original discussion at https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443

13 months ago[mlir] Move tblgen code generation to use functional forms of cast/isa
Tres Popp [Thu, 25 May 2023 13:56:16 +0000 (15:56 +0200)]
[mlir] Move tblgen code generation to use functional forms of cast/isa

Summary:
The method forms are deprecated. This updates the rest of the tblgen
uses of methods where a function call is available.

Context:
- https://mlir.llvm.org/deprecation/ at "Use the free function variants for dyn_cast/cast/isa/…"
- Original discussion at https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443

Reviewers: rriddle

13 months ago[mlir] Add CastInfo for mlir classes subclassing from PointerUnion
Tres Popp [Tue, 23 May 2023 09:52:31 +0000 (11:52 +0200)]
[mlir] Add CastInfo for mlir classes subclassing from PointerUnion

This is required to use the function variants of cast/isa/dyn_cast/etc
on them.

Context:
- https://mlir.llvm.org/deprecation/ at "Use the free function variants for dyn_cast/cast/isa/…"
- Original discussion at https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443

13 months ago[flang] Fix an unused variable warning
Kazu Hirata [Fri, 26 May 2023 05:36:48 +0000 (22:36 -0700)]
[flang] Fix an unused variable warning

This patch fixes:

  flang/lib/Optimizer/HLFIR/Transforms/LowerHLFIROrderedAssignments.cpp:911:10:
  error: unused variable 'inserted' [-Werror,-Wunused-variable]

13 months ago[libc++] Fix C++26 transitive includes list
Nikolas Klauser [Fri, 26 May 2023 05:31:40 +0000 (22:31 -0700)]
[libc++] Fix C++26 transitive includes list

Reviewed By: vitalybuka

Spies: vitalybuka, libcxx-commits

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

13 months ago[X86] Add test for select folding.
Luo, Yuanke [Fri, 26 May 2023 03:47:55 +0000 (11:47 +0800)]
[X86] Add test for select folding.

When avx512 is available the lhs operand of select instruction can be
folded with mask instruction, while the rhs operand can't.

13 months agoFix link to the TOSA spec in the dialect doc (NFC)
Mehdi Amini [Fri, 26 May 2023 04:50:39 +0000 (21:50 -0700)]
Fix link to the TOSA spec in the dialect doc (NFC)

13 months ago[ELF] findAllByVersion: optimize a find('@') with hasVersionSuffix. NFC
Fangrui Song [Fri, 26 May 2023 04:23:23 +0000 (21:23 -0700)]
[ELF] findAllByVersion: optimize a find('@') with hasVersionSuffix. NFC

13 months agoRevert "[MLIR] Add native Bytecode support for properties"
Mehdi Amini [Fri, 26 May 2023 03:58:53 +0000 (20:58 -0700)]
Revert "[MLIR] Add native Bytecode support for properties"

This reverts commit ca5a12fd69d4acf70c08f797cbffd714dd548348
and follow-up fixes:

df34c288c428eb4b867c8075def48b3d1727d60b
07dc906883af660780cf6d0cc1044f7e74dab83e
ab80ad0095083fda062c23ac90df84c40b4332c8
837d1ce0dc8eec5b17255291b3462e6296cb369b

The first commit was incomplete and broken, I'll prepare a new version
later, in the meantime pull this work out of tree.

13 months ago[fuzzer] Platfom specific version of PageSize
Vitaly Buka [Fri, 26 May 2023 03:58:52 +0000 (20:58 -0700)]
[fuzzer] Platfom specific version of PageSize

13 months agoBump the MLIR bytecode current revision (version 5) to match the implementation
Mehdi Amini [Fri, 26 May 2023 03:39:26 +0000 (20:39 -0700)]
Bump the MLIR bytecode current revision (version 5) to match the implementation

13 months agoFix MLIR Bytecode backward deployment
Mehdi Amini [Fri, 26 May 2023 03:38:32 +0000 (20:38 -0700)]
Fix MLIR Bytecode backward deployment

The condition for guarding the properties section was reversed.

13 months agoFix MLIR back-deployment to version < 5 ; properties section should not be emitted.
Eugene Burmako [Fri, 26 May 2023 03:17:00 +0000 (20:17 -0700)]
Fix MLIR back-deployment to version < 5 ; properties section should not be emitted.

This was an oversight in the development of bytecode version 5, which was
caught by downstream StableHLO compatibility tests.

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

13 months ago[fuzzer] Don't hard-code page size in FuzzerUtil.h
zhanglimin [Fri, 26 May 2023 02:59:39 +0000 (19:59 -0700)]
[fuzzer] Don't hard-code page size in FuzzerUtil.h

Don't hard code the page in FuzzerUtil.h, this breaks on
e.g. LoongArch which defaults to a 16KiB page size.

Reviewed By: #sanitizers, vitalybuka

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

13 months ago[NFC][CLANG] Fix static code analyzer concerns
Manna, Soumi [Fri, 26 May 2023 03:00:19 +0000 (20:00 -0700)]
[NFC][CLANG] Fix static code analyzer concerns

Reported by Static Code Analyzer Tool:

Inside "CGExprConstant.cpp" file, VisitObjCEncodeExpr() returns null value which is dereferenced without checking.

This patch adds an assert.

Reviewed By: erichkeane

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

13 months agoTestStackCoreScriptedProcess.py is timing out, skip it
Jason Molenda [Fri, 26 May 2023 02:12:04 +0000 (19:12 -0700)]
TestStackCoreScriptedProcess.py is timing out, skip it

The x86_64 macOS CI bot is failing because this test
times out.  It was marked as expectedFail earlier today,
but that's not considered a fail so the CI runs are
red.  Skipping it on Darwin for now until Ismail can
look into it.

13 months ago[Clang] Simplify test `clang/test/OpenMP/bug59160.c`
Shilei Tian [Fri, 26 May 2023 02:12:16 +0000 (22:12 -0400)]
[Clang] Simplify test `clang/test/OpenMP/bug59160.c`

13 months agoFix test by marking it x86 specific
David Blaikie [Fri, 26 May 2023 02:07:08 +0000 (02:07 +0000)]
Fix test by marking it x86 specific

13 months ago[mlir] Fix non-const lvalue reference to type 'uint64_t' cannot bind to type 'size_t...
Jie Fu [Fri, 26 May 2023 02:02:21 +0000 (10:02 +0800)]
[mlir] Fix non-const lvalue reference to type 'uint64_t' cannot bind to type 'size_t' error (NFC)

/Users/jiefu/llvm-project/mlir/lib/Bytecode/Reader/BytecodeReader.cpp:1007:39: error: non-const lvalue reference to type 'uint64_t' (aka 'unsigned long long') cannot bind to a value of unrelated type 'size_t' (aka 'unsigned long')
    if (failed(propReader.parseVarInt(count)))
                                      ^~~~~
/Users/jiefu/llvm-project/mlir/lib/Bytecode/Reader/BytecodeReader.cpp:191:39: note: passing argument to parameter 'result' here
  LogicalResult parseVarInt(uint64_t &result) {
                                      ^
/Users/jiefu/llvm-project/mlir/lib/Bytecode/Reader/BytecodeReader.cpp:1033:41: error: non-const lvalue reference to type 'uint64_t' (aka 'unsigned long long') cannot bind to a value of unrelated type 'size_t' (aka 'unsigned long')
    if (failed(dialectReader.readVarInt(propertiesIdx)))
                                        ^~~~~~~~~~~~~
/Users/jiefu/llvm-project/mlir/lib/Bytecode/Reader/BytecodeReader.cpp:926:38: note: passing argument to parameter 'result' here
  LogicalResult readVarInt(uint64_t &result) override {
                                     ^
2 errors generated.

/Users/jiefu/llvm-project/mlir/lib/Bytecode/Reader/BytecodeReader.cpp:1033:41: error: non-const lvalue reference to type 'uint64_t' (aka 'unsigned long long') cannot bind to a value of unrelated type 'size_t' (aka 'unsigned long')
    if (failed(dialectReader.readVarInt(propertiesIdx)))
                                        ^~~~~~~~~~~~~
/Users/jiefu/llvm-project/mlir/lib/Bytecode/Reader/BytecodeReader.cpp:926:38: note: passing argument to parameter 'result' here
  LogicalResult readVarInt(uint64_t &result) override {
                                     ^
1 error generated.

13 months agoRevert "[fuzzer] Don't hard-code page size in FuzzerUtil.h"
Jason Molenda [Fri, 26 May 2023 01:05:10 +0000 (18:05 -0700)]
Revert "[fuzzer] Don't hard-code page size in FuzzerUtil.h"

This reverts commit a2b677e8153758997a9043360cf51333eecc3c44.

reverting

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

because <sys/auxv.h> and getauxval() are not available on macOS;
this change is breaking the mac CI bots.

13 months agollvm-symbolizer: access the base address from the skeleton CU, not the split unit
David Blaikie [Fri, 26 May 2023 00:59:40 +0000 (00:59 +0000)]
llvm-symbolizer: access the base address from the skeleton CU, not the split unit

In Split DWARF, if the unit had a non-trivial base address (a real
low_pc, rather than one with fixed value 0) then computing addresses
needs to access that base address to add to any base address-relative
values. But the code was trying to access the base address in the split
unit, when it's actually in the skeleton unit. So delegate to the
skeleton if it's available.

Fixes #62941

13 months ago[Clang] Fix test case issue introduced by D141627
Shilei Tian [Fri, 26 May 2023 00:40:57 +0000 (20:40 -0400)]
[Clang] Fix test case issue introduced by D141627

13 months ago[sanitizer] Implement __sanitizer_get_allocated_size_fast
Jin Xin Ng [Wed, 24 May 2023 00:04:53 +0000 (00:04 +0000)]
[sanitizer] Implement __sanitizer_get_allocated_size_fast

The primary motivation for this change is to allow FreeHooks to obtain
the allocated size of the pointer being freed in a fast, efficient manner.

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

13 months ago[Clang][OpenMP] Fix the issue that list items in `has_device_addr` are still mapped...
Shilei Tian [Fri, 26 May 2023 00:18:47 +0000 (20:18 -0400)]
[Clang][OpenMP] Fix the issue that list items in `has_device_addr` are still mapped to the target device

This patch fixes the issue that list items in `has_device_addr` are still mapped
to the target device because front end emits map type `OMP_MAP_TO`.

Fix #59160.

Reviewed By: jyu2

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

13 months agoRevert "[libc] Enable hermetic floating point tests"
Joseph Huber [Fri, 26 May 2023 00:15:02 +0000 (19:15 -0500)]
Revert "[libc] Enable hermetic floating point tests"

This passed locally but unfortauntely it seems some tests are not ready
to be made hermetic. Revert for now until we can investigate
specifically which tests are failing and mark those as `UNIT_TEST_ONLY`.

This reverts commit 417ea79e792a87d53f5ac4f5388af4b25aa04d7d.

13 months ago[libc] Enable hermetic floating point tests
Joseph Huber [Wed, 24 May 2023 23:07:39 +0000 (18:07 -0500)]
[libc] Enable hermetic floating point tests

This patch enables us to run the floating point tests as hermetic.
Importantly we now use the internal versions of the `fesetround` and
`fegetround` functions.

Reviewed By: michaelrj

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

13 months ago[mlir][tosa] Add type checking traits to the appropriate ops
TatWai Chong [Thu, 25 May 2023 23:47:23 +0000 (23:47 +0000)]
[mlir][tosa] Add type checking traits to the appropriate ops

Add the trait `SameOperandsAndResultElementType` and
`SameOperandsElementType` to verify ops that are known
to have the same input and output type rather than generate
an invalid tosa IR with mixed data types like:

  "tosa.add"(%0, %1) : (tensor<nxbf16>, tensor<nxf32>) -> tensor<nxf32>

Thus apply tosa.cast prior if needed.

Change-Id: Ie866b84e371e3b571ec04f7abb090c216dd39c33

Reviewed By: jpienaar

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

13 months ago[Clang][Attribute] Improve the AST/diagnoses fidelity of alignas and _Alignas
yronglin [Thu, 25 May 2023 23:40:51 +0000 (07:40 +0800)]
[Clang][Attribute] Improve the AST/diagnoses fidelity of alignas and _Alignas

- Fix diagnoses when the argument to `alignas` or `_Alignas` is an incomplete type.

Before:
```
./alignas.cpp:1:15: error: invalid application of 'alignof' to an incomplete type 'void'
class alignas(void) Foo {};
             ~^~~~~
1 error generated.
```
Now:
```
./alignas.cpp:1:15: error: invalid application of 'alignas' to an incomplete type 'void'
class alignas(void) Foo {};
             ~^~~~~
1 error generated.
```

- Improve the AST fidelity of `alignas` and `_Alignas` attribute.

Before:
```
AlignedAttr 0x13f07f278 <col:7> alignas
    `-ConstantExpr 0x13f07f258 <col:15, col:21> 'unsigned long'
      |-value: Int 8
      `-UnaryExprOrTypeTraitExpr 0x13f07f118 <col:15, col:21> 'unsigned long' alignof 'void *'
```

Now:
```
AlignedAttr 0x14288c608 <col:7> alignas 'void *'
```

Reviewed By: erichkeane

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

13 months ago[fuzzer] Don't hard-code page size in FuzzerUtil.h
zhanglimin [Thu, 25 May 2023 23:10:42 +0000 (16:10 -0700)]
[fuzzer] Don't hard-code page size in FuzzerUtil.h

Don't hard code the page in FuzzerUtil.h, this breaks on
e.g. LoongArch which defaults to a 16KiB page size.

Reviewed By: #sanitizers, vitalybuka

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

13 months ago[tosa] Improve inferred shapes of TOSA operations
Spenser Bauman [Thu, 25 May 2023 23:06:50 +0000 (16:06 -0700)]
[tosa] Improve inferred shapes of TOSA operations

The TosaInferShapes pass avoids updating the shapes of tensor operators
when the consumers are not TOSA operations, limiting the efficacy of
TosaInferShapes when the IR is a mix of TOSA and other operations.
This change attempts to update the result shapes when the consumers
themselves have reasonable type/shape inference methods.

Reviewed By: eric-k256

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

13 months ago[libc][darwin] Add OSUtil for darwin arm64 target so that unit tests can be run.
Tue Ly [Wed, 24 May 2023 21:26:55 +0000 (17:26 -0400)]
[libc][darwin] Add OSUtil for darwin arm64 target so that unit tests can be run.

Currently unit tests cannot be run on macOS due to missing OSUtil.

Reviewed By: michaelrj

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

13 months ago[libc][doc] Update math function status page to show more targets.
Tue Ly [Thu, 25 May 2023 19:54:00 +0000 (15:54 -0400)]
[libc][doc] Update math function status page to show more targets.

Show availability of math functions on each target.

Reviewed By: jeffbailey

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

13 months ago[mlir][sparse][gpu] end to end test for matmul
Aart Bik [Thu, 25 May 2023 21:30:58 +0000 (14:30 -0700)]
[mlir][sparse][gpu] end to end test for matmul

(1) minor bug fix in copy back [always nice to run stuff ;-)]
(2) run with and without lib (even though some fall back to CPU)

Reviewed By: wrengr

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