platform/upstream/llvm.git
2 years ago[DWARFLinker] llvm::Optional => std::optional
Fangrui Song [Tue, 13 Dec 2022 10:14:09 +0000 (10:14 +0000)]
[DWARFLinker] llvm::Optional => std::optional

2 years ago[WindowsDriver] llvm::Optional => std::optional
Fangrui Song [Tue, 13 Dec 2022 10:06:57 +0000 (10:06 +0000)]
[WindowsDriver] llvm::Optional => std::optional

2 years agoLLParser: llvm::Optional => std::optional
Fangrui Song [Tue, 13 Dec 2022 10:04:35 +0000 (10:04 +0000)]
LLParser: llvm::Optional => std::optional

2 years agoReland "[compiler-rt][test] Heed COMPILER_RT_DEBUG when compiling unittests"
Rainer Orth [Tue, 13 Dec 2022 09:58:58 +0000 (10:58 +0100)]
Reland "[compiler-rt][test] Heed COMPILER_RT_DEBUG when compiling unittests"

When trying to debug some `compiler-rt` unittests, I initially had a hard
time because

- even in a `Debug` build one needs to set `COMPILER_RT_DEBUG` to get
  debugging info for some of the code and
- even so the unittests used a hardcoded `-O2` which often makes debugging
  impossible.

This patch addresses this by instead using `-O0` if `COMPILER_RT_DEBUG`.

Changes relative to the previous commit:

- Use `string(APPEND)` for `COMPILER_RT_TEST_COMPILER_CFLAGS`.
- Omit `-O3` from `COMPILER_RT_TEST_COMPILER_CFLAGS` in non-debug builds for now.
- Provide `__sanitizer::integral_constant<bool, true>::value` instantiation
  for `sanitizer_type_traits_test.cpp` in debug builds.
- Disable subtests of `tsan/tests/unit/tsan_trace_test.cpp` that deadlock
  in debug builds.
- `XFAIL` `tsan/Linux/check_memcpy.c` in debug builds.

Tested on `sparcv9-sun-solaris2.11`, `amd64-pc-solaris2.11`, and
`x86_64-pc-linux-gnu`.

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

2 years ago[InstCombine] Add additional foldAndOrOfICmpsWithConstEq() tests (NFC)
Nikita Popov [Tue, 13 Dec 2022 09:56:00 +0000 (10:56 +0100)]
[InstCombine] Add additional foldAndOrOfICmpsWithConstEq() tests (NFC)

Add logical variants of vector tests.

2 years agoRevert "[Assignment Tracking][13/*] Account for assignment tracking in SROA"
Krasimir Georgiev [Tue, 13 Dec 2022 09:54:26 +0000 (09:54 +0000)]
Revert "[Assignment Tracking][13/*] Account for assignment tracking in SROA"

This reverts commit 3bfba672afd52dfd5bde54dc8b67ec96275f9e15.

Temporary revert since this potentially causes
https://github.com/llvm/llvm-project/issues/59490.

2 years ago[mlir][scf] Fixes IndexSwitchOp verifier crash
Mehdi Amini [Tue, 13 Dec 2022 09:41:13 +0000 (09:41 +0000)]
[mlir][scf] Fixes IndexSwitchOp verifier crash

Fixes #59460

2 years agoRevert "[AArch64][GlobalISel] Lower formal arguments of AAPCS & ms_abi variadic funct...
Martin Storsjö [Tue, 13 Dec 2022 09:36:12 +0000 (11:36 +0200)]
Revert "[AArch64][GlobalISel] Lower formal arguments of AAPCS & ms_abi variadic functions."

This reverts commit 56fd846f370adf16bea333b12637038ea2f3c225.

This commit regressed handling of functions with floats as arguments,
reproducible e.g. like this:

$ cat test.c
double func(double f) {
    return f;
}
$ clang -target aarch64-windows -S -o - test.c -fno-asynchronous-unwind-tables
func:
sub sp, sp, #16
str x0, [sp, #8]
ldr d0, [sp, #8]
add sp, sp, #16
ret

2 years ago[InstCombine] Support logical ops in foldAndOrOfICmpEqZeroAndICmp()
Nikita Popov [Tue, 13 Dec 2022 09:02:46 +0000 (10:02 +0100)]
[InstCombine] Support logical ops in foldAndOrOfICmpEqZeroAndICmp()

If the and/or is logical and one of the operands only occurs on the
RHS, we need to freeze it: https://alive2.llvm.org/ce/z/vuMuE_

2 years ago[RS4GC] Turn lambda into static function. NFC.
Denis Antrushin [Wed, 23 Nov 2022 15:31:41 +0000 (22:31 +0700)]
[RS4GC] Turn lambda into static function. NFC.

Extract `rematerializeChain()` lambda into static function.
We'll need it in upcoming patch to RS4GC pass.
There is small interface change: now reversal of `ChainToBase` is
performed within this function, not outside.
Still this is non-functional change.

Reviewed By: skatkov

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

2 years ago[InstCombine] Add additional tests for foldAndOrOfICmpEqZeroAndICmp (NFC)
Nikita Popov [Tue, 13 Dec 2022 09:07:54 +0000 (10:07 +0100)]
[InstCombine] Add additional tests for foldAndOrOfICmpEqZeroAndICmp (NFC)

Adds logical variants of the commuted tests.

2 years ago[CodeGen] llvm::Optional => std::optional
Fangrui Song [Tue, 13 Dec 2022 09:06:36 +0000 (09:06 +0000)]
[CodeGen] llvm::Optional => std::optional

2 years ago[clangd] Fix some header guard names, NFC
Haojian Wu [Tue, 13 Dec 2022 08:55:58 +0000 (09:55 +0100)]
[clangd] Fix some header guard names, NFC

Per the LLVM code style, there should be no trailing `_` on the header
guard name.

2 years agoImplement CWG2631
Corentin Jabot [Sun, 23 Oct 2022 15:32:58 +0000 (17:32 +0200)]
Implement CWG2631

Implement https://cplusplus.github.io/CWG/issues/2631.html.

Immediate calls in default arguments and defaults members
are not evaluated.

Instead, we evaluate them when constructing a
`CXXDefaultArgExpr`/`BuildCXXDefaultInitExpr`.

The immediate calls are executed by doing a
transform on the initializing expression.

Note that lambdas are not considering subexpressions so
we do not need to transform them.

As a result of this patch, unused default member
initializers are not considered odr-used, and
errors about members binding to local variables
in an outer scope only surface at the point
where a constructor is defined.

Reviewed By: aaron.ballman, #clang-language-wg

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

2 years agoFix APFloat::toString on Float8E5M2 values.
Reed [Tue, 13 Dec 2022 08:50:02 +0000 (09:50 +0100)]
Fix APFloat::toString on Float8E5M2 values.

Before, an APInt with value 10 was created, whose width was the significand width. But 10 cannot fit in Float8E5M2's significand.

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

2 years ago[InstCombine] Handle logical op in simplifyRangeCheck() (PR59484)
Nikita Popov [Tue, 13 Dec 2022 08:41:28 +0000 (09:41 +0100)]
[InstCombine] Handle logical op in simplifyRangeCheck() (PR59484)

We need to freeze to avoid propagating a potentially poison
upper bound (https://alive2.llvm.org/ce/z/MsD38k).

This resolves the existing TODO in the code.

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

2 years agoAdd LLVMDialect as dependent for "llvm-legalize-for-export" pass
Mehdi Amini [Tue, 13 Dec 2022 08:48:32 +0000 (08:48 +0000)]
Add LLVMDialect as dependent for "llvm-legalize-for-export" pass

Fixes #59462

2 years ago[flang] Use input type when emboxing/reboxing polymorphic entities
Valentin Clement [Tue, 13 Dec 2022 08:44:01 +0000 (09:44 +0100)]
[flang] Use input type when emboxing/reboxing polymorphic entities

When emboxing an entity to a polymorphic box, use the input type to
compute the type code and element size as the box type is too generic.
When reboxing a polymorphic box, get this information from the input
box.

Reviewed By: jeanPerier

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

2 years ago[Transforms/Coroutines] llvm::Optional => std::optional
Fangrui Song [Tue, 13 Dec 2022 08:32:44 +0000 (08:32 +0000)]
[Transforms/Coroutines] llvm::Optional => std::optional

2 years ago[Transforms/InstCombine] llvm::Optional => std::optional
Fangrui Song [Tue, 13 Dec 2022 08:26:08 +0000 (08:26 +0000)]
[Transforms/InstCombine] llvm::Optional => std::optional

2 years ago[MemProf] llvm::Optional => std::optional
Fangrui Song [Tue, 13 Dec 2022 08:15:56 +0000 (08:15 +0000)]
[MemProf] llvm::Optional => std::optional

2 years agoRevert "[UpdateTestChecks] Match define for labels"
Nikita Popov [Tue, 13 Dec 2022 08:13:39 +0000 (09:13 +0100)]
Revert "[UpdateTestChecks] Match define for labels"

This reverts commit a888825aeef8d6592c6cf5f4e5854cc39af49633.

This changes the default output of UTC, and as such introduces
spurious changes whenever existing tests are regenerated.

I've indicated in https://reviews.llvm.org/D139006#3989954 how
this can be implemented without causing test churn.

2 years ago[Transforms/Scalar] llvm::Optional => std::optional
Fangrui Song [Tue, 13 Dec 2022 08:05:14 +0000 (08:05 +0000)]
[Transforms/Scalar] llvm::Optional => std::optional

2 years ago[Clang] Implement CWG2640 Allow more characters in an n-char sequence
Corentin Jabot [Mon, 28 Nov 2022 21:45:15 +0000 (22:45 +0100)]
[Clang] Implement CWG2640 Allow more characters in an n-char sequence

Reviewed By: #clang-language-wg, aaron.ballman, tahonermann

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

2 years ago[NFC][PowerPC] Add tests for 64-bit constants that require 5 instructions to materialize.
esmeyi [Tue, 13 Dec 2022 07:44:49 +0000 (02:44 -0500)]
[NFC][PowerPC] Add tests for 64-bit constants that require 5 instructions to materialize.

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

2 years agoApply clang-tidy fixes for readability-identifier-naming in AsyncToAsyncRuntime.cpp...
Mehdi Amini [Sat, 10 Dec 2022 10:28:26 +0000 (10:28 +0000)]
Apply clang-tidy fixes for readability-identifier-naming in AsyncToAsyncRuntime.cpp (NFC)

2 years agoApply clang-tidy fixes for performance-unnecessary-value-param in AsyncToAsyncRuntime...
Mehdi Amini [Sat, 10 Dec 2022 10:27:47 +0000 (10:27 +0000)]
Apply clang-tidy fixes for performance-unnecessary-value-param in AsyncToAsyncRuntime.cpp (NFC)

2 years agoRevert "[OpenMP][NFCI] Remove effectively dead code in clang and the runtime"
Johannes Doerfert [Tue, 13 Dec 2022 06:08:28 +0000 (22:08 -0800)]
Revert "[OpenMP][NFCI] Remove effectively dead code in clang and the runtime"

This reverts commit c1c8cbbf5f29257d084a23a2f6c4236c40b7afb9. One of the
tests seems to be flaky/non-deterministic.

2 years ago[Clang][NFC] Prevent lit tests from matching substrings in current path
Sameer Sahasrabuddhe [Tue, 13 Dec 2022 05:45:15 +0000 (11:15 +0530)]
[Clang][NFC] Prevent lit tests from matching substrings in current path

2 years ago[libc] Use correct type for atol
Alex Brachet [Tue, 13 Dec 2022 05:38:09 +0000 (05:38 +0000)]
[libc] Use correct type for atol

2 years ago[OpenMP][FIX] Ensure combing accesses does not violate invariants
Johannes Doerfert [Tue, 13 Dec 2022 03:38:19 +0000 (19:38 -0800)]
[OpenMP][FIX] Ensure combing accesses does not violate invariants

2 years ago[OpenMP][NFCI] Remove effectively dead code in clang and the runtime
Johannes Doerfert [Thu, 27 Oct 2022 23:53:17 +0000 (16:53 -0700)]
[OpenMP][NFCI] Remove effectively dead code in clang and the runtime

2 years ago[Attributor] Make non-side-effect inline asm be "no-call"
Johannes Doerfert [Tue, 4 Oct 2022 14:39:45 +0000 (07:39 -0700)]
[Attributor] Make non-side-effect inline asm be "no-call"

If we have inline asm with side effects we assume any function might be
called. For non-side-effect asm we now assume no function is called.

2 years ago[Sanitizers][CFG][arm64e] Fix test because -fsanitize-coverage=control-flow does...
Blue Gaston [Thu, 8 Dec 2022 20:02:14 +0000 (12:02 -0800)]
[Sanitizers][CFG][arm64e] Fix test because -fsanitize-coverage=control-flow does not sign BB entry

-fsanitize-coverage=control-flow does not sign entries into basic blocks on arm64e. This test compares a local pointer to a function [signed] with the basic block pointer. Because the entry into the
basic block is unsigned the addresses being compared are signed and unsigned, causing the path never to be taken.
This is a "bandaid" to get this test passing. We strip the signed bits from the pointer to the local functions so that the comparisons pass.
Filed radar: rdar://103042879 to note the behavior.

context: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp#L1068
    // blockaddress can not be used on function's entry block.
    if (&BB == &F.getEntryBlock())
      CFs.push_back((Constant *)IRB.CreatePointerCast(&F, IntptrPtrTy));
    else
      CFs.push_back((Constant *)IRB.CreatePointerCast(BlockAddress::get(&BB),
                                                      IntptrPtrTy));
BlockAddress::get is responsible for signing the pointer.

Because of:
https://reviews.llvm.org/D133157

rdar://103042879

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

2 years ago[IR][NFC] Adds Function::insertBasicBlockAt() to replace things like F->getBasicBlock...
Vasileios Porpodas [Mon, 12 Dec 2022 22:57:47 +0000 (14:57 -0800)]
[IR][NFC] Adds Function::insertBasicBlockAt() to replace things like F->getBasicBlockList().insert()

This is part of a series of patches that aim at making Function::getBasicBlockList() private.

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

2 years agoInstCombine: Fix metadata arguments blocking freeze combining
Matt Arsenault [Sun, 4 Dec 2022 16:36:11 +0000 (11:36 -0500)]
InstCombine: Fix metadata arguments blocking freeze combining

These are used for special arguments to intrinsics and don't make any
sense to consider for poisonness. Fixes not pushing freeze through
llvm.fptrunc.round.

92106641ae297c24877085e0357e8095aa7b43c9 made
isGuaranteedNotToBeUndefOrPoison return false for metadata arguments,
which doesn't entirely make sense. An alternate patch could switch
that to true, and try to filter out adding some pointless noundefs on
metadata arguments (I tried that, attributor breaks one case with a
llvm.dbg.value in it).

2 years agoValueTracking: Teach canCreateUndefOrPoison about FP ops
Matt Arsenault [Mon, 5 Dec 2022 03:55:57 +0000 (22:55 -0500)]
ValueTracking: Teach canCreateUndefOrPoison about FP ops

Probably could replace the switch by marking the intrinsic definitions
with NoUndef<RetIndex>.

2 years agoInstCombine: Add baseline tests for freeze with some FP ops
Matt Arsenault [Sun, 4 Dec 2022 00:55:15 +0000 (19:55 -0500)]
InstCombine: Add baseline tests for freeze with some FP ops

2 years ago[LoongArch] Add custom parser for atomic instructions' memory operand
wanglei [Tue, 13 Dec 2022 03:32:10 +0000 (11:32 +0800)]
[LoongArch] Add custom parser for atomic instructions' memory operand

In order to be compatible with the form of the atomic instruction in
GAS that accepts the fourth operand as 0 (i.e. `am* $rd, $rk, $rj, 0`),
we need to treat `$rj, 0` as one operand, but only print `$rj`.

For this, the number of result operands of inline assembly memory
operand `ZB` constraint is modified to 2 (reg + 0).

Restrictions on register usage in `am*` instructions have also been
adjusted. When `$rd` is equal to `$r0`, the instruction must be
considered legal, because of some special usage like `PseudoUNIMP`.

Reviewed By: SixWeining, xen0n

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

2 years agoObjCARC: Update tests to use opaque pointers
Matt Arsenault [Sat, 26 Nov 2022 18:02:48 +0000 (13:02 -0500)]
ObjCARC: Update tests to use opaque pointers

escape.ll needed a simple manual check line update.

contract-storestrong.ll:test12 is kind of contrived now. The comment
says it's for testing bitcasts of pointers, which don't really matter
anymore. Leaves identity ptr to ptr bitcasts (which I thought were
illegal).

2 years agoObjCARC: Try to fix faulty tests
Matt Arsenault [Sat, 26 Nov 2022 19:07:43 +0000 (14:07 -0500)]
ObjCARC: Try to fix faulty tests

These were trying to check if there was not an llvm.objc call before a
closing "}", which presumably was intended to match the end of the
function. Really this was matching the closing } in "bitcast {}* %self
to i8*", which can't be what anyone intended. This broke after
converting the test to opaque pointer deleted this bitcast.

There are in fact @llvm.obj calls remaining in the function, so this
may indicate the transform this was intended to check is actually
broken. In @"\01-[A z]" (great test name), the first retain call seems
to move down to the printf. The second case, @"\01-[Top0 _getX]", has
no change.

Change the checks to what's produced and add FIXMES. Also change the }
checks to match only at the start of the line for the function end.

2 years agoAMDGPU: Add sanity test if amdgcn.device.{init|fini} already exists
Matt Arsenault [Tue, 29 Nov 2022 15:26:00 +0000 (10:26 -0500)]
AMDGPU: Add sanity test if amdgcn.device.{init|fini} already exists

2 years agoInstSimplify: Add basic folding of llvm.is.fpclass intrinsic
Matt Arsenault [Fri, 11 Nov 2022 00:15:34 +0000 (16:15 -0800)]
InstSimplify: Add basic folding of llvm.is.fpclass intrinsic

Copied from the existing llvm.amdgcn.class handling; eventually I will
fold that to the generic intrinsic when legal. The tests should
probably move into an instsimplify only test.

2 years agoVerifier: Enforce value of llvm.is.fpclass test mask
Matt Arsenault [Sat, 10 Dec 2022 02:18:29 +0000 (21:18 -0500)]
Verifier: Enforce value of llvm.is.fpclass test mask

As requested in D137811

2 years ago[Coroutines] Don't mark the parameter attribute of resume function as noalias
Chuanqi Xu [Tue, 13 Dec 2022 02:09:59 +0000 (10:09 +0800)]
[Coroutines] Don't mark the parameter attribute of resume function as noalias

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

The root cause for the problem is that we marked the parameter of the
resume/destroy functions as noalias previously. But this is not true.

See https://github.com/llvm/llvm-project/issues/59221 for the details.
Long story short, for this C++ program
(https://compiler-explorer.com/z/6qGcozG93), the optimized frame will be
something like:

```
struct test_frame {
    void (*__resume_)(), // a function pointer points to the
`test.resume` function, which can be imaged as the test() function in
the example.
    ....
    struct a_frame {
          ...
          void **caller; // may points to test_frame at runtime.
    };
};
```

And the function a and function test looks just like:

```
define i32 @a(ptr noalias %alloc_8) {
  %alloc_8_16 = getelementptr ptr, ptr %alloc_8, i64 16
  store i32 42, ptr %alloc_8_16, align 8
  %alloc_8_8 = getelementptr ptr, ptr %alloc_8, i64 8
  %alloc = load ptr, ptr %alloc_8_8, align 8
  %p = load ptr, ptr %alloc, align 8
  %r = call i32 %p(ptr %alloc)
  ret i32 %r
}

define i32 @b(ptr %p) {
entry:
  %alloc = alloca [128 x i8], align 8
  %alloc_8 = getelementptr ptr, ptr %alloc, i64 8
  %alloc_8_8 = getelementptr ptr, ptr %alloc_8, i64 8
  store ptr %alloc, ptr %alloc_8_8, align 8
  store ptr %p, ptr %alloc, align 8
  %r = call i32 @a(ptr nonnull %alloc_8)
  ret i32 %r
}
```

Here inside the function `a`,  we can access the parameter `%alloc_8` by
`%alloc` and we pass `%alloc` to an unknown function. So it breaks the
assumption of `noalias` parameter.

Note that although only CoroElide optimization can put a frame inside
another frame directly, the following case is not valid too:

```
struct test_frame {
    ....
   void **a_frame; // may points to a_frame at runtime.
};

 struct a_frame {
    void **caller; // may points to test_frame at runtime.
};
```

Since the C++ language allows the programmer to get the address of
coroutine frames, we can't assume the above case wouldn't happen in the
source codes. So we can't set the parameter as noalias no matter if
CoroElide applies or not. And for other languages, it may be safe if
they don't allow the programmers to get the address of coroutine frames.

Reviewed By: nikic

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

2 years ago[NFC] Remove the instruction list from the arguments of llvm::ReplaceInstWithValue().
Vasileios Porpodas [Mon, 28 Nov 2022 22:53:24 +0000 (14:53 -0800)]
[NFC] Remove the instruction list from the arguments of llvm::ReplaceInstWithValue().

This is part of a series of cleanup patches towards making BasicBlock::getInstList() private.

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

2 years agoFix test on 32-bit targets.
Richard Smith [Tue, 13 Dec 2022 01:38:28 +0000 (17:38 -0800)]
Fix test on 32-bit targets.

2 years ago[mlir][Vector] Initial masking support in Linalg vectorizer
Diego Caballero [Thu, 24 Nov 2022 02:16:46 +0000 (02:16 +0000)]
[mlir][Vector] Initial masking support in Linalg vectorizer

This patch introduces the initial bits to support vector masking
using the `vector.mask` operation. Vectorization changes should be
NFC for non-masked cases. We can't test masked cases directly until
we extend the Transform dialect to support masking.

Reviewed By: nicolasvasilache

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

2 years ago[NFC][Codegen][X86] Revisit interleaved store codegen tests
Roman Lebedev [Tue, 13 Dec 2022 01:04:42 +0000 (04:04 +0300)]
[NFC][Codegen][X86] Revisit interleaved store codegen tests

This matches the coverage with the Costmodel tests,
adds stride 5/7/8, and improves AVX512 checks.

I *think* i've compressed check prefixes
as much as possible, but it's a bit hard to tell.
But hey, at one no longer has to fight against FileCheck+UTC :).

2 years ago[NFC][Codegen][X86] Add higher-VF interleaved load codegen tests that got lost
Roman Lebedev [Tue, 13 Dec 2022 01:23:34 +0000 (04:23 +0300)]
[NFC][Codegen][X86] Add higher-VF interleaved load codegen tests that got lost

2 years agoAdd missing check for constant evaluation of a comparison of a pointer
Richard Smith [Tue, 13 Dec 2022 00:39:14 +0000 (16:39 -0800)]
Add missing check for constant evaluation of a comparison of a pointer
to member naming a weak member to nullptr.

This fixes a miscompile where constant evaluation would incorrectly
determine that a weak member function pointer is never null.

In passing, also improve the diagnostics for constant evaluation of some
nearby cases.

2 years ago[PowerPC][NFC] Add test case for memset tail store
Ting Wang [Tue, 13 Dec 2022 01:07:23 +0000 (20:07 -0500)]
[PowerPC][NFC] Add test case for memset tail store

Add test case to show something can be improved.

Reviewed By: shchenz

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

2 years ago[mlir][sparse] Simplifying SparseTensorEncodingAttr function arguments
wren romano [Mon, 12 Dec 2022 23:17:01 +0000 (15:17 -0800)]
[mlir][sparse] Simplifying SparseTensorEncodingAttr function arguments

Since STEA isa Attribute, and that's just (a wrapper around) a pointer, the extra `const` and `&` aren't necessary for function arguments.

Reviewed By: aartbik

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

2 years ago[mlir][sparse] Replace vector.print with printMemref for some tests.
bixia1 [Wed, 7 Dec 2022 23:39:17 +0000 (15:39 -0800)]
[mlir][sparse] Replace vector.print with printMemref for some tests.

Reviewed By: aartbik

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

2 years ago[RISCV] Set ShouldSignExtI32Param in TargetLibraryInfo for riscv64.
Craig Topper [Tue, 13 Dec 2022 00:41:28 +0000 (16:41 -0800)]
[RISCV] Set ShouldSignExtI32Param in TargetLibraryInfo for riscv64.

riscv64 sign extends signed and unsigned i32 arguments like Mips.

Based on discussion here
https://discourse.llvm.org/t/can-we-preserve-signext-return-attribute-when-converting-memcmp-to-bcmp/67126

I'll work on returns next.

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

2 years ago[NFC][Codegen][X86] Revisit interleaved load codegen tests
Roman Lebedev [Mon, 12 Dec 2022 23:32:46 +0000 (02:32 +0300)]
[NFC][Codegen][X86] Revisit interleaved load codegen tests

This matches the coverage with the Costmodel tests,
adds stride 5/7/8, and improves AVX512 checks.

I *think* i've compressed check prefixes
as much as possible, but it's a bit hard to tell.
But hey, at one no longer has to fight against FileCheck+UTC :).

2 years ago[NFC][bazel] Run buildifier on all bzl/BUILD.bazel files
Jordan Rupprecht [Tue, 13 Dec 2022 00:30:51 +0000 (16:30 -0800)]
[NFC][bazel] Run buildifier on all bzl/BUILD.bazel files

2 years ago[NFC] Replaces: BB->getInstList().erase(I) with I->eraseFromParent().
Vasileios Porpodas [Tue, 29 Nov 2022 01:35:34 +0000 (17:35 -0800)]
[NFC] Replaces: BB->getInstList().erase(I) with I->eraseFromParent().

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

2 years ago[scudo] Optimize scudo test string allocation
Dominic Chen [Sat, 10 Dec 2022 01:22:38 +0000 (17:22 -0800)]
[scudo] Optimize scudo test string allocation

When the underlying vector becomes full, it resizes, remaps, and then copies over the old data. To avoid thes excess allocations, allow reservation from the backing vector.

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

2 years ago[FuzzMutate] InstModificationStrategy, add FastMath flags and exact flags to instruct...
Peter Rong [Thu, 8 Dec 2022 01:27:10 +0000 (17:27 -0800)]
[FuzzMutate] InstModificationStrategy, add FastMath flags and exact flags to instructions.

I think there are more attributes, flags we can add to `call`, functions declarations and global variables. Let's start with these two flags.

Reviewed By: arsenm

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

2 years ago[FuzzMutate] New InsertCFGStrategy
Peter Rong [Thu, 1 Dec 2022 01:27:01 +0000 (17:27 -0800)]
[FuzzMutate] New InsertCFGStrategy

Mutating CFG is hard as we have to maintain dominator relations.
We avoid this problem by inserting a CFG into a splitted block.

switch, ret, and br instructions are generated.

Reviewed By: arsenm

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

2 years ago[OpenMP] Refactoring: Move teams forking and serial region forking to separate functions.
Terry Wilmarth [Thu, 1 Dec 2022 15:13:48 +0000 (09:13 -0600)]
[OpenMP] Refactoring: Move teams forking and serial region forking to separate functions.

Code for serial parallel regions and teams construct have been moved
out of __kmp_fork_call and into separate functions.  This is to reduce
the size of the __kmp_fork_call function, and aid in debugging.

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

2 years ago[InstSimplify] try harder to propagate existing NaN values through FP folds
Sanjay Patel [Mon, 12 Dec 2022 22:48:22 +0000 (17:48 -0500)]
[InstSimplify] try harder to propagate existing NaN values through FP folds

Any undef element in a vector would trigger the whole constant
to be replaced with a canonical NaN. This propagates each
element when possible.

issue #59122

2 years ago[InstSimplify] add tests for vectors with NaN + partial undef; NFC
Sanjay Patel [Mon, 12 Dec 2022 22:19:43 +0000 (17:19 -0500)]
[InstSimplify] add tests for vectors with NaN + partial undef; NFC

issue #59122

2 years ago[RISCV] Make DemandedFields::usedVTYPE() const. NFC
Craig Topper [Mon, 12 Dec 2022 22:49:26 +0000 (14:49 -0800)]
[RISCV] Make DemandedFields::usedVTYPE() const. NFC

Noticed while reviewing D139877.

Reviewed By: reames

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

2 years ago[llvm-stress] Minor code improvements around vector types [nfc]
Philip Reames [Mon, 12 Dec 2022 22:41:49 +0000 (14:41 -0800)]
[llvm-stress] Minor code improvements around vector types [nfc]

2 years ago[RISCV][InsertVSETVLI] Reorder code to reduce a future diff [nfc]
Philip Reames [Mon, 12 Dec 2022 21:48:05 +0000 (13:48 -0800)]
[RISCV][InsertVSETVLI] Reorder code to reduce a future diff [nfc]

2 years ago[mlir][tosa] Refactor tosa.resize
Rob Suderman [Mon, 12 Dec 2022 22:17:58 +0000 (14:17 -0800)]
[mlir][tosa] Refactor tosa.resize

Moved to using helper lambdas to avoid code repetition. IR needed to be reordered to
accommodate which should be the only changes to the existing tests.

This changes the quantized test to target `i48` types to guarantee types are extended
correctly when necessary.

Reviewed By: jpienaar

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

2 years agoReapply "DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions""
David Blaikie [Thu, 8 Dec 2022 01:28:48 +0000 (01:28 +0000)]
Reapply "DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions""

This may be a breaking change for consumers if they're trying to detect
if code is C or C++, since it'll start using new codes that they may not
be ready to recognize, in which case they may fall back to non-C
handling.

This caused regressions due to PS4 having a different default for C
language version than other targets. Those tests were adapted to be
relaxed about which C version is used.

This reapplies commit 3c312e48f325c1b1ee11404ee6cfa08ee00037b0
Which was reverted by commit 6ab6085c77ef9bcdabf842342f63fba4291791a4.

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

2 years agoDelete sanitizer_common-based ('old') scudo: o7
Mitch Phillips [Mon, 12 Dec 2022 22:35:46 +0000 (14:35 -0800)]
Delete sanitizer_common-based ('old') scudo: o7

This has been on life support for a long time. Now that -fsanitize=scudo
is scudo_standalone, this can be removed.

Tests are sticking around for now to be reused for scudo_standalone
later on.

Reviewed By: vitalybuka

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

2 years agoDebugInfo: Test DW_AT_prototyped and generalize it to handle C11 and C17
David Blaikie [Mon, 12 Dec 2022 22:18:45 +0000 (22:18 +0000)]
DebugInfo: Test DW_AT_prototyped and generalize it to handle C11 and C17

2 years ago[flang] Preserve bound info for pointer assignments through derived types
Jonathon Penix [Thu, 1 Dec 2022 23:44:10 +0000 (15:44 -0800)]
[flang] Preserve bound info for pointer assignments through derived types

Doing a pointer assignment to another pointer which is a derived type component
could result in the bound information being lost, potentially leading to
incorrect array accesses. Fix this by trying to retain the bound info during
the assignment.

Fixes #57441

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

2 years ago[analyzer] Nullability: Enable analysis of non-inlined nullable objc properties.
Paul Pelzl [Mon, 12 Dec 2022 21:53:16 +0000 (13:53 -0800)]
[analyzer] Nullability: Enable analysis of non-inlined nullable objc properties.

The NullabilityChecker has a very early policy decision that non-inlined
property accesses will be inferred as returning nonnull, despite nullability
annotations to the contrary. This decision eliminates false positives related
to very common code patterns that look like this:

if (foo.prop) {
    [bar doStuffWithNonnull:foo.prop];
}

While this probably represents a correct nil-check, the analyzer can't
determine correctness without gaining visibility into the property
implementation.

Unfortunately, inferring nullable properties as nonnull comes at the cost of
significantly reduced code coverage. My goal here is to enable detection of
many property-related nullability violations without a large increase
in false positives.

The approach is to introduce a heuristic: after accessing the value of
a property, if the analyzer at any time proves that the property value is
nonnull (which would happen in particular due to a nil-check conditional),
then subsequent property accesses on that code path will be *inferred*
as nonnull. This captures the pattern described above, which I believe
to be the dominant source of false positives in real code.

https://reviews.llvm.org/D131655

2 years agoFix breakpoint-command.test when no script interpreter is compiled in.
Mitch Phillips [Mon, 12 Dec 2022 22:00:19 +0000 (14:00 -0800)]
Fix breakpoint-command.test when no script interpreter is compiled in.

My local build is with -DLLVM_ENABLE_PROJECTS=lldb, but I don't compile
with -DLLDB_ENABLE_PYTHON=True or -DLLDB_ENABLE_LUA=True. This results
in there being no script interpreter.

The test lldb/test/Shell/Breakpoint/breakpoint-command.test has an
implicit dependency on a script interpreter being available.

This patch makes that dependency clear. If you have a script
interpreter, the test gets run, otherwise it gets skipped. This means
that folks (like me) who naively use -DLLVM_ENABLE_PROJECTS=lldb can
continue to run check-all without breakages.

Reviewed By: JDevlieghere

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

2 years ago[NFC][Exegesis] Don't recompute opcode/reg names on each YAML write (-38% runtime)
Roman Lebedev [Mon, 12 Dec 2022 21:02:05 +0000 (00:02 +0300)]
[NFC][Exegesis] Don't recompute opcode/reg names on each YAML write (-38% runtime)

This reducer runtime of
```
$ ./bin/llvm-exegesis -mode=inverse_throughput --opcode-index=-1 --benchmarks-file=/dev/null --dump-object-to-disk=0 --measurements-print-progress --skip-measurements
```
from 3m44s to 2m17s, aka -38%.
But more importantly, we go from 400 *million* memory allocations
down to just 100 million, aka -75%.

But really, the big missing thing is doing everything in a single thread.
Sure, we can't do anything when measuring, but when we are not measuring,
we should just prepare (codegen) everything via all threads.
That should parallelize quite well.

2 years ago[NFC][InstCombine] fold-nested-selects: fix profitability check
Roman Lebedev [Mon, 12 Dec 2022 18:31:33 +0000 (21:31 +0300)]
[NFC][InstCombine] fold-nested-selects: fix profitability check

We'd check the cost of the wrong 'cond', after potentially skipping `not`.

2 years ago[GWP-ASan] Fix sanitizer backtrace util using wrong print.
Mitch Phillips [Mon, 12 Dec 2022 21:53:08 +0000 (13:53 -0800)]
[GWP-ASan] Fix sanitizer backtrace util using wrong print.

The sanitizer backtrace is used in tests, and calling StackTrace.Print()
means that it uses the sanitizer's Printf(), rather than GWP-ASan's
Printf(). In the current code, GWP-ASan's Printf() *is* the sanitizer
print, but this isn't guaranteed to be the case, and will change in an
upcoming patch.

Reviewed By: eugenis

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

2 years ago[OpenMP] Basic parse and sema support for modifiers in order clause
Chi Chun Chen [Mon, 12 Dec 2022 21:51:38 +0000 (15:51 -0600)]
[OpenMP] Basic parse and sema support for modifiers in order clause

This patch gives basic parsing and semantic support for "modifiers" of order clause introduced in OpenMP 5.1 ( section 2.11.3 )

Reviewed By: ABataev

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

2 years ago[flang] skip fast_math linker test on powerpc #3
Tom Eccles [Mon, 12 Dec 2022 21:46:35 +0000 (21:46 +0000)]
[flang] skip fast_math linker test on powerpc #3

Another attempt to skip the fast-math linker test on powerpc. The test
has to be skipped because there is no crtfastmath.o on powerpc.

Change recommended by Amy Kwan <amyk>.

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

2 years ago[NFC] Cleanup: Replaces BB->getInstList().insert() with I->insertAt().
Vasileios Porpodas [Mon, 28 Nov 2022 22:43:11 +0000 (14:43 -0800)]
[NFC] Cleanup: Replaces BB->getInstList().insert() with I->insertAt().

This is part of a series of cleanup patches towards making BasicBlock::getInstList() private.

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

2 years ago[libc] remove use after free in tests.
Michael Jones [Mon, 12 Dec 2022 21:21:41 +0000 (13:21 -0800)]
[libc] remove use after free in tests.

There were some tests added that attempted to access files after they
were closed to test errno behavior, this caused sanitizer issues. Those
portions of the tests have been disabled.

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

2 years agoRevert "[reland][Alignment][NFC] Remove access to deprecated GlobalObject::getAlignme...
Guillaume Chatelet [Mon, 12 Dec 2022 21:18:15 +0000 (21:18 +0000)]
Revert "[reland][Alignment][NFC] Remove access to deprecated GlobalObject::getAlignment from llvm"

This reverts commit 3bbfaee23d41c099547c652f87b252ab6e1f6c46.

2 years ago[mlir][CAPI] Add a simple MlirOpOperand API for MlirValue uses.
Mike Urbach [Tue, 6 Dec 2022 22:56:08 +0000 (15:56 -0700)]
[mlir][CAPI] Add a simple MlirOpOperand API for MlirValue uses.

This allows basic IR traversal via the C API, which is useful for
analyses in languages other than C++.

This starts by defining an MlirOpOperand struct to encapsulate a pair
of an owner operation and an operand number.

A new API is added for MlirValue, to return the first use of the Value
as an MlirOpOperand, or a "null" MlirOpOperand if there are no uses.

A couple APIs are added for MlirOpOperand. The first checks if an
MlirOpOperand is "null", by checking if its owner's pointer is
null. The second supports iteration along the use-def lists by
accepting an MlirOpOperand and returning the next use of the Value as
another MlirOpOperand, or a "null" MlirOpOperand if there are no more
uses.

Reviewed By: mehdi_amini

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

2 years ago[libc] move errno out of file internals
Michael Jones [Wed, 7 Dec 2022 21:25:22 +0000 (13:25 -0800)]
[libc] move errno out of file internals

Now errno is only set by the terminal entrypoints, and not the internal
implementations. This patch is part of the larger effort to not set
errno in libc internal code: https://github.com/llvm/llvm-project/issues/59278

Reviewed By: sivachandra

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

2 years ago[mlir][Transform] Make FuseIntoContainingOp support rank-reducing extract slices
Nicolas Vasilache [Mon, 12 Dec 2022 14:31:43 +0000 (06:31 -0800)]
[mlir][Transform] Make FuseIntoContainingOp support rank-reducing extract slices

This fixes an issue where rank-reducing + fusion would not interop properly.

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

2 years ago[CodeExtractor] Use scope reparenting helper to update loop dbg loc
Felipe de Azevedo Piovezan [Mon, 12 Dec 2022 17:00:49 +0000 (12:00 -0500)]
[CodeExtractor] Use scope reparenting helper to update loop dbg loc

Apply the same strategy from D139217 to loop debug locations.

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

2 years ago[CodeExtractor] Preserve entire scope of labels when moving them
Felipe de Azevedo Piovezan [Mon, 12 Dec 2022 16:23:37 +0000 (11:23 -0500)]
[CodeExtractor] Preserve entire scope of labels when moving them

When a dbg.label is moved into a new function, its corresponding scope
should be preserved, with the exception of the subprogram at the end of
the scope chain, which should now be the subprogram of the destination
function. See D139671.

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

2 years ago[CodeExtractor] Only rewrite scope of labels that were not inlined
Felipe de Azevedo Piovezan [Mon, 12 Dec 2022 15:22:44 +0000 (10:22 -0500)]
[CodeExtractor] Only rewrite scope of labels that were not inlined

dbg.labels that were inlined from other functions should have their
scope preserved upon outlining for the same reasons described in
D139669.

2 years ago[clangd] Add a missing header guard for InsertionPoint.h
Haojian Wu [Mon, 12 Dec 2022 20:25:04 +0000 (21:25 +0100)]
[clangd] Add a missing header guard for InsertionPoint.h

2 years ago[flang] disable fast_math test on powerpc
Tom Eccles [Mon, 12 Dec 2022 20:02:37 +0000 (20:02 +0000)]
[flang] disable fast_math test on powerpc

There seems not be any crtfastmath.o on powerpc.

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

2 years ago[mlir][LLVMIR target] Fix llvm.freeze builder to prevent crashes
Krzysztof Drewniak [Wed, 7 Dec 2022 21:05:58 +0000 (21:05 +0000)]
[mlir][LLVMIR target] Fix llvm.freeze builder to prevent crashes

The freeze builder did not assign the result of creating the freeze
operation to $res, which meant that when subsequent translations (such
as a sext) tried to use that result or query its type, mlir-translate
would crash.

This fixes the issue and adds a test for it.

Reviewed By: ftynse

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

2 years ago[mlir][arith][tosa] Use extended mul in 32-bit `tosa.apply_scale`
Jakub Kuderski [Mon, 12 Dec 2022 19:39:57 +0000 (14:39 -0500)]
[mlir][arith][tosa] Use extended mul in 32-bit `tosa.apply_scale`

To not introduce 64-bit types that may be difficult to handle for some
targets.

Reviewed By: rsuderman, antiagainst

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

2 years ago[Clang] Try to fix test on Windows (NFC)
Nikita Popov [Mon, 12 Dec 2022 19:35:29 +0000 (20:35 +0100)]
[Clang] Try to fix test on Windows (NFC)

Try to fix failure reported in
https://reviews.llvm.org/rG9466b49171dc#1154213 by making the
match more specific, as there are multiple dbg.declares that
could be matched.

2 years ago[mlgo] Use LLVM_HAVE_TFLITE instead of LLVM_HAVE_TF_API in C++ code (NFC)
Kazu Hirata [Mon, 12 Dec 2022 19:28:40 +0000 (11:28 -0800)]
[mlgo] Use LLVM_HAVE_TFLITE instead of LLVM_HAVE_TF_API in C++ code (NFC)

We use LLVM_HAVE_TFLITE as the key to enable the mlgo work these days,
and LLVM_HAVE_TF_API is defined whenever LLVM_HAVE_TF_API is defined.

I'm posting this patch because it's purely mechanical.

I'll post a follow-up patch to remove LLVM_HAVE_TF_API in non-C++
files, and that will not be as mechanical as this one.

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

2 years ago[mlgo] Remove TENSORFLOW_C_LIB_PATH
Kazu Hirata [Mon, 12 Dec 2022 19:28:38 +0000 (11:28 -0800)]
[mlgo] Remove TENSORFLOW_C_LIB_PATH

We use LLVM_HAVE_TFLITE as the key to enable the MLGO bits.  We do not
use the "else" clause.

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

2 years ago[ZOS] Convert tests to check 'target={{.*}}-zos{{.*}}'
Paul Robinson [Mon, 12 Dec 2022 19:24:02 +0000 (11:24 -0800)]
[ZOS] Convert tests to check 'target={{.*}}-zos{{.*}}'

Also add 'system-zos' as a lit feature and use it where needed.

Part of the project to eliminate special handling for triples in lit
expressions.

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

2 years ago[HWASAN][NFC] Renamed [g|s]et_requested_size to [G|S]etRequestedSize.
Kirill Stoimenov [Fri, 9 Dec 2022 18:53:54 +0000 (18:53 +0000)]
[HWASAN][NFC] Renamed [g|s]et_requested_size to [G|S]etRequestedSize.

Reviewed By: kda

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

2 years ago[COFF] Respect weak externals for mangled symbol searching
Shoaib Meenai [Sat, 10 Dec 2022 04:09:56 +0000 (20:09 -0800)]
[COFF] Respect weak externals for mangled symbol searching

We were previously ignoring weak externals during these searches (which
are used for the entry point, exports, and subsystem inference), which
differed from link.exe behavior. It also meant that we could get
different behavior when linking an object file directly vs. packaging it
into a static library, because static library symbol name directories
include weak externals.

Reviewed By: mstorsjo, yozhu

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

2 years ago[gn] port 988ab0048daf
Nico Weber [Mon, 12 Dec 2022 18:52:03 +0000 (13:52 -0500)]
[gn] port 988ab0048daf

2 years ago[lldb] Make ParseTemplateParameterInfos return false if there are no template params
Arthur Eubanks [Thu, 8 Dec 2022 18:01:01 +0000 (10:01 -0800)]
[lldb] Make ParseTemplateParameterInfos return false if there are no template params

This factors out the check from various callers.

Reviewed By: Michael137

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