platform/upstream/llvm.git
2 years ago[linalg] When removing noop linalg.generics, check that inserting a cast is valid
Benjamin Kramer [Mon, 28 Mar 2022 12:10:26 +0000 (14:10 +0200)]
[linalg] When removing noop linalg.generics, check that inserting a cast is valid

linalg.generic can also take scalars instead of tensors, which
tensor.cast doesn't support. We don't have an easy way to cast between
scalars and tensors so just keep the linalg.generic in those cases.

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

2 years ago[MC] Make MCAsmInfo::isAcceptableChar reflect MCAsmInfo::doesAllowAtInName
Eli Friedman [Fri, 25 Mar 2022 22:40:46 +0000 (15:40 -0700)]
[MC] Make MCAsmInfo::isAcceptableChar reflect MCAsmInfo::doesAllowAtInName

On targets which don't allow "@" in unquoted identifiers, make sure we
don't emit them; otherwise, we can't parse our own output.

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

2 years ago[NFC] clang-format sanitizer_interface_internal.h
Vitaly Buka [Tue, 29 Mar 2022 20:29:07 +0000 (13:29 -0700)]
[NFC] clang-format sanitizer_interface_internal.h

2 years agoNFC. Fixing warnings from adding DXContainer
Chris Bieneman [Tue, 29 Mar 2022 19:46:24 +0000 (14:46 -0500)]
NFC. Fixing warnings from adding DXContainer

Adds DXContainer to switch statements in Clang and LLDB to silence
warnings.

2 years agoAdd DXContainer
Chris Bieneman [Sat, 19 Mar 2022 19:33:39 +0000 (14:33 -0500)]
Add DXContainer

DXIL is wrapped in a container format defined by the DirectX 11
specification. Codebases differ in calling this format either DXBC or
DXILContainer.

Since eventually we want to add support for DXBC as a target
architecture and the format is used by DXBC and DXIL, I've termed it
DXContainer here.

Most of the changes in this patch are just adding cases to switch
statements to address warnings.

Reviewed By: pete

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

2 years ago[LV] Move code to place pointer induction increment to VPlan post-processing.
Florian Hahn [Tue, 29 Mar 2022 19:27:59 +0000 (20:27 +0100)]
[LV] Move code to place pointer induction increment to VPlan post-processing.

This patch moves the code to set the correct incoming block for the
backedge value to VPlan::execute.

When generating the phi node, the backedge value is temporarily added
using the pre-header as incoming block. The invalid phi node will be
fixed up during VPlan::execute after main VPlan code generation.
At the same time, the backedge value is also moved to the latch.

This change removes the requirement to create the latch block up-front
for VPWidenInductionPHIRecipe::execute, which in turn will enable
modeling the pre-header in VPlan.

Depends on D121617.

Reviewed By: Ayal

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

2 years ago[x86] consolidate tests and auto-gen complete check lines; NFC
Sanjay Patel [Tue, 29 Mar 2022 18:53:41 +0000 (14:53 -0400)]
[x86] consolidate tests and auto-gen complete check lines; NFC

The same test was duplicated in 2 files.

2 years ago[clang][DR] Test and mark DR1305 as complete
Markus Böck [Tue, 29 Mar 2022 18:45:41 +0000 (20:45 +0200)]
[clang][DR] Test and mark DR1305 as complete

DR: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1305

This DR has always been implemented in all clang versions as far back as I could go. This patch basically just adds a test with the needed comments to mark it as complete.

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

2 years ago[Clang][CodeGen]Remove anonymous tag locations
wangyihan [Tue, 29 Mar 2022 18:38:29 +0000 (11:38 -0700)]
[Clang][CodeGen]Remove anonymous tag locations

Remove anonymous tag locations, powered by 'PrintingPolicy',
@aaron.ballman once suggested removing this extra information in
https://reviews.llvm.org/D122248
struct:

  struct S {
    int a;
    struct /* Anonymous*/ {
      int x;
    } b;
    int c;
  };

Before:

  struct S {
    int a = 0
      struct S::(unnamed at ./builtin_dump_struct.c:20:3) {
        int x = 0
      }
    int c = 0
  }

After:

struct S {
  int a = 0
    struct S::(unnamed) {
      int x = 0
    }
  int c = 0
}

Differntial Revision: https://reviews.llvm.org/D122670

2 years agoNFC. Fixing rebase error
Chris Bieneman [Tue, 29 Mar 2022 17:57:49 +0000 (12:57 -0500)]
NFC. Fixing rebase error

Somehow managed to get a double-assignment in there. Thanks @erichkeane
for pointing it out!

2 years ago[AMDGPU] gfx940 VALU hazard recognizer
Stanislav Mekhanoshin [Wed, 23 Mar 2022 18:59:08 +0000 (11:59 -0700)]
[AMDGPU] gfx940 VALU hazard recognizer

Differntial Revision: https://reviews.llvm.org/D122339

2 years agoRevert "[Support/BLAKE3] Re-enable building with the simd-optimized implementations"
Mehdi Amini [Tue, 29 Mar 2022 17:39:05 +0000 (17:39 +0000)]
Revert "[Support/BLAKE3] Re-enable building with the simd-optimized implementations"

This reverts commit 23519d3000b4703f17e639534a38b4f221fa4f63.

This breaks the build with clang-5:

/usr/bin/clang-5.0 -DBUILD_EXAMPLES -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Support/BLAKE3 -Illvm/lib/Support/BLAKE3 -Iinclude -Illvm/include -fPIC -O3 -DNDEBUG -MD -MT lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/blake3_avx512_x86-64_unix.S.o -MF lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/blake3_avx512_x86-64_unix.S.o.d -o lib/Support/BLAKE3/CMakeFiles/LLVMSupportBlake3.dir/blake3_avx512_x86-64_unix.S.o -c llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S
...
llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S:54:9: error: instruction requires: AVX-512 ISA
        kmovw k1, r9d
        ^

2 years ago[ADT] add initializer list specialization for is_contained
Chris Bieneman [Mon, 28 Mar 2022 21:33:16 +0000 (16:33 -0500)]
[ADT] add initializer list specialization for is_contained

Adding an initializer list specialization for is_contained allows for
compile-time evaluation when called with a constant or runtime
evaluation for non-constant values.

This patch doesn't add any uses of this template, but that is coming in
a subsequent patch.

Reviewed By: pete

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

2 years ago[Clang][doc][NFC]Remove duplicate items in ReleaseNotes
wangyihan [Tue, 29 Mar 2022 17:30:34 +0000 (10:30 -0700)]
[Clang][doc][NFC]Remove duplicate items in ReleaseNotes

Remove duplicate items in ReleaseNotes for __builtin_dump_struct, the
code changes int patch https://reviews.llvm.org/D122248

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

2 years ago[clang][extract-api] Use correct language info from inputs
Zixu Wang [Fri, 25 Mar 2022 18:43:44 +0000 (11:43 -0700)]
[clang][extract-api] Use correct language info from inputs

The current way of getting the `clang::Language` from `LangOptions` does
not handle Objective-C correctly because `clang::Language::ObjC` does
not correspond to any `LangStandard`. This patch passes the correct
`Language` from the frontend input information.

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

2 years ago[MLIR][Presburger] Simplify std::{all,any}_of -> llvm::{all,any}_of (NFC)
Arjun P [Tue, 29 Mar 2022 16:57:14 +0000 (17:57 +0100)]
[MLIR][Presburger] Simplify std::{all,any}_of -> llvm::{all,any}_of (NFC)

Also simplify [](const F &f){ return f.foo(); } -> std::mem_fn(&F::foo)

2 years ago[llvm-pdbutil] Fix a crash due to Expected not checked before destruction
Zequan Wu [Mon, 28 Mar 2022 23:42:53 +0000 (16:42 -0700)]
[llvm-pdbutil] Fix a crash due to Expected not checked before destruction

Reviewed By: aganea

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

2 years ago[mlir][ods] Allow null to be passed as default-valued attributes
Mogball [Tue, 29 Mar 2022 16:54:41 +0000 (16:54 +0000)]
[mlir][ods] Allow null to be passed as default-valued attributes

Allow default-valued attributes to be passed as null to builders, which will not add the attribute if not present, so the default value will be returned by getters.

2 years ago[ELF] --emit-relocs: adjust offsets of .rel[a].eh_frame relocations
Fangrui Song [Tue, 29 Mar 2022 16:51:41 +0000 (09:51 -0700)]
[ELF] --emit-relocs: adjust offsets of .rel[a].eh_frame relocations

Two code paths may reach the EHFrame case in SectionBase::getOffset:

* .eh_frame reference
* relocation copy for --emit-relocs

The first may be used by clang_rt.crtbegin.o and GCC crtbeginT.o to get the
start address of the output .eh_frame. The relocation has an offset of 0 or
(x86-64 PC-relative leaq for clang_rt.crtbegin.o) -4. The current code just
returns `offset`, which handles this case well.

The second is related to InputSection::copyRelocations on .eh_frame (used by
--emit-relocs). .eh_frame pieces may be dropped due to GC/ICF, so we should
convert the input offset to the output offset. Use the same way as
MergeInputSection with a special case handling outSecOff==-1 for an invalid
piece (see eh-frame-marker.s).

This exposes an issue in mips64-eh-abs-reloc.s that we don't reliably
handle anyway. Just add --no-check-dynamic-relocations to paper over it.

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

2 years agoFix a test failure.
Aaron Ballman [Tue, 29 Mar 2022 16:26:38 +0000 (12:26 -0400)]
Fix a test failure.

This amends 3c84e4a0dbd08fc03bbcdd8354a984e0efcf7672 which had an
unsaved change when committed.

2 years ago[X86] combineCarryThroughADD - remove unused peek through of SEXT/AEXT nodes.
Simon Pilgrim [Tue, 29 Mar 2022 16:15:25 +0000 (17:15 +0100)]
[X86] combineCarryThroughADD - remove unused peek through of SEXT/AEXT nodes.

2 years ago[C11] Improve the diagnostic when accessing a member of an atomic struct
Aaron Ballman [Tue, 29 Mar 2022 16:13:54 +0000 (12:13 -0400)]
[C11] Improve the diagnostic when accessing a member of an atomic struct

Member access for an atomic structure or union is unconditional
undefined behavior (C11 6.5.2.3p5). However, we would issue a confusing
error message about the base expression not being a structure or union
type.

GCC issues a warning for this case. Clang now warns as well, but the
warning is defaulted to an error because the actual access is still
unsafe.

This fixes Issue 54563.

2 years ago[libomptarget] x86 offloading fails map_back_race.cpp intermittently
Ron Lieberman [Tue, 29 Mar 2022 14:53:27 +0000 (14:53 +0000)]
[libomptarget] x86 offloading fails map_back_race.cpp intermittently

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

2 years ago[lldb] Remove usages of case-insensitive c-string functions
Pavel Labath [Mon, 21 Mar 2022 13:52:22 +0000 (14:52 +0100)]
[lldb] Remove usages of case-insensitive c-string functions

They are not portable (which meant we had a hand-rolled implementation
for windows), and llvm::StringRef provides equivalent functionality.

2 years ago[clang-tidy] Fix test failing on 32-bit architectures due to missing `__int128_t`
Danny Mösch [Tue, 29 Mar 2022 15:58:05 +0000 (17:58 +0200)]
[clang-tidy] Fix test failing on 32-bit architectures due to missing `__int128_t`

This was caused by ff60af91ac0bbab12dd5ff5dc9b78bc1636f2d86. The reason for the failure is that
the type `__int128_t` is not available on 32-bit architectures. So just exclude the test case if
128-bit integers are not available.

2 years ago[ELF] --emit-relocs: fix missing STT_SECTION when the first input section is synthetic
Fangrui Song [Tue, 29 Mar 2022 15:56:21 +0000 (08:56 -0700)]
[ELF] --emit-relocs: fix missing STT_SECTION when the first input section is synthetic

addSectionSymbols suppresses the STT_SECTION symbol if the first input section
is non-SHF_MERGE synthetic. This is incorrect when the first input section is synthetic
while a non-synthetic input section exists:

* `.bss : { *(COMMON) *(.bss) }`
  (abc388ed3cf0ef7e617ebe243d3b0b32d29e69a5 regressed the case because
  COMMON symbols precede .bss in the absence of a linker script)
* Place a synthetic section in another section: `.data : { *(.got) *(.data) }`

For `%t/a1` in the new test emit-relocs-synthetic.s, ld.lld produces incorrect
relocations with symbol index 0.
```
0000000000000000 <_start>:
       0: 8b 05 33 00 00 00             movl    51(%rip), %eax          # 0x39 <bss>
                0000000000000002:  R_X86_64_PC32        *ABS*+0xd
       6: 8b 05 1c 00 00 00             movl    28(%rip), %eax          # 0x28 <common>
                0000000000000008:  R_X86_64_PC32        common-0x4
       c: 8b 05 06 00 00 00             movl    6(%rip), %eax           # 0x18
                000000000000000e:  R_X86_64_GOTPCRELX   *ABS*+0x4
```

Fix the issue by checking every input section.

Reviewed By: ikudrin

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

2 years ago[libc++] Use __builtin_expect and __builtin_assume in _LIBCPP_ASSERT
Louis Dionne [Thu, 24 Mar 2022 13:27:03 +0000 (09:27 -0400)]
[libc++] Use __builtin_expect and __builtin_assume in _LIBCPP_ASSERT

Since we expect the condition to be true most of the time, we might
as well tell the compiler. And when assertions are disabled, we
might as well tell the compiler that it's allowed to assume that
the condition holds.

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

2 years ago[libc++][NFC] Fix typo in comment
Louis Dionne [Tue, 29 Mar 2022 15:45:49 +0000 (11:45 -0400)]
[libc++][NFC] Fix typo in comment

2 years ago[InstCombine] Fold (ctpop(X) == 1) | (X == 0) into ctpop(X) < 2
Hirochika Matsumoto [Tue, 29 Mar 2022 14:51:59 +0000 (10:51 -0400)]
[InstCombine] Fold (ctpop(X) == 1) | (X == 0) into ctpop(X) < 2

https://alive2.llvm.org/ce/z/94yRMN

Fixes #54177

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

2 years ago[OpenMP] Regenerate the check lines for 2 tests
Johannes Doerfert [Mon, 21 Mar 2022 21:02:42 +0000 (16:02 -0500)]
[OpenMP] Regenerate the check lines for 2 tests

Somehow those check lines were mostly untested prefixes and the ones we
were looking for have been removed. Simple cleanup.

2 years ago[mlir][spirv] Mark SPV_UndefOp NoSideEffect
Ivan Butygin [Mon, 28 Mar 2022 08:09:00 +0000 (11:09 +0300)]
[mlir][spirv] Mark SPV_UndefOp NoSideEffect

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

2 years ago[InstCombine] Remove call to getPointerElementType()
Nikita Popov [Tue, 29 Mar 2022 14:51:55 +0000 (16:51 +0200)]
[InstCombine] Remove call to getPointerElementType()

This was erroneously re-introduced as part of
bb0b23174e4ab963df427393fbf21bddede499bf.

2 years ago[ADT] Flesh out HLSL raytracing environments
Chris Bieneman [Tue, 29 Mar 2022 14:42:57 +0000 (09:42 -0500)]
[ADT] Flesh out HLSL raytracing environments

Fleshing this out now allows me to rely on enum math to translate
values rather than having to translate the off cases.

I should have added this in the first pass, but wasn't thinking about
it.

2 years ago[demangler] Update node match calls
Nathan Sidwell [Tue, 29 Mar 2022 11:43:16 +0000 (04:43 -0700)]
[demangler] Update node match calls

Each demangler node's match function needs to call the provided
functor with constructor arguments.  That was omitted from D120905.
This adds the new Precedence argument where necessary (and a missing
boolean for a module node).

The two visitors need updating with a printer for that type, and this
adds a stub to cxa_demangle's version.  blaikie added one to llvm's.
I'll fill out those printers in a followup, rather than wait, so that
downstream consumers are unbroken.

2 years ago[libc++][libc++abi] Serialize the enable_assertions Lit parameter in the generated...
Louis Dionne [Mon, 28 Mar 2022 17:10:14 +0000 (13:10 -0400)]
[libc++][libc++abi] Serialize the enable_assertions Lit parameter in the generated config

This means that re-running with llvm-lit in that configuration will
work as expected. This also enables assertions in libc++abi in the
Generic-assertions CI job, which was disabled previously.

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

2 years ago[X86] Regenerate x86-interleaved-access.ll with AVX1OR2 common check-prefix to reduce...
Simon Pilgrim [Tue, 29 Mar 2022 11:24:46 +0000 (12:24 +0100)]
[X86] Regenerate x86-interleaved-access.ll with AVX1OR2 common check-prefix to reduce duplication

2 years agoClarify invariants of software pipelining hooks
Thomas Preud'homme [Tue, 29 Mar 2022 09:12:35 +0000 (10:12 +0100)]
Clarify invariants of software pipelining hooks

PowerPC backend relies on each pair of prologue/epilogue of a software
pipelined loop to correspond to a single iteration a the loop through
its use of the BDZ instruction to skip inner prologues/epilogues and
loop kernel. However the interface does not make it clear that it is a
valid way to check that the trip count is big enough to execute inner
prologues/epilogues and kernel loop.

The API also does not specify in which order of prologues the
createTripCountGreaterCondition() hook is being called. Knowing that it
starts with the last/innermost prologues can help recording some
information when createTripCountGreaterCondition() is first executed and
reuse it in setPreheader() or adjustTripCount().

This commit documents both aspects.

Reviewed By: jmolloy

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

2 years ago[mlir][vector][nfc] Rename index optimizations option
Javier Setoain [Thu, 24 Mar 2022 16:07:19 +0000 (16:07 +0000)]
[mlir][vector][nfc] Rename index optimizations option

We are using "enable-index-optimizations" and "indexOptimizations" as
names for an optimization that consists of using i32 for indices within
a vector. For instance, when building a vector comparison for mask
generation. The name is confusing and suggests a scope beyond these
vector indices.  This change makes the function of the option explicit
in its name.

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

2 years ago[doc] Rely on tblgen to dump supported options value when generating doc
serge-sans-paille [Mon, 28 Mar 2022 13:59:47 +0000 (15:59 +0200)]
[doc] Rely on tblgen to dump supported options value when generating doc

It was already the case for CLI help, also support it for rst output. As a side
effect remove redundant (and sometime inconsistent!) value help from HelpText in
clang/Driver/Options.td.

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

2 years ago[AMDGPU] Generate checks in atomic_optimizations_*.ll
Jay Foad [Tue, 29 Mar 2022 10:05:07 +0000 (11:05 +0100)]
[AMDGPU] Generate checks in atomic_optimizations_*.ll

This had already been done for some of these files but not all.

2 years ago[OpenCL] opencl-c.h: remove a/b/c/i/p/n/v arg names
Sven van Haastregt [Tue, 29 Mar 2022 09:16:27 +0000 (10:16 +0100)]
[OpenCL] opencl-c.h: remove a/b/c/i/p/n/v arg names

This simplifies completeness comparisons against OpenCLBuiltins.td and
also makes the header no longer "claim" any single-letter identifiers.

Continues the direction set out in D119560.

2 years ago[AArch64] Ensure fixed point fptoi_sat has correct saturation width
David Green [Tue, 29 Mar 2022 09:12:44 +0000 (10:12 +0100)]
[AArch64] Ensure fixed point fptoi_sat has correct saturation width

D113200 introduced an error where it was converting FP_TO_SI_SAT with
multiply to a fixed point floating point convert. The saturation
bitwidth needs to be equal to the floating point width, or else the
routine would truncate the result as opposed to saturating it.

Fixes #54601

2 years ago[ConstraintElimination] Move ConstraintInfo after ConstraintTy. (NFC)
Florian Hahn [Tue, 29 Mar 2022 08:59:03 +0000 (09:59 +0100)]
[ConstraintElimination] Move ConstraintInfo after ConstraintTy. (NFC)

Code movement to it slightly easier to use ConstraintTy & co in
ConstraintInfo directly, for follow-up patches.

2 years ago[NFC][libc] Disable benchmarks when the LLVM benchmark target is not available
Guillaume Chatelet [Fri, 25 Mar 2022 13:21:20 +0000 (13:21 +0000)]
[NFC][libc] Disable benchmarks when the LLVM benchmark target is not available

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

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

2 years ago[DAGCombine] add tests for bswap-shift optimization
Chenbing Zheng [Tue, 29 Mar 2022 08:34:52 +0000 (16:34 +0800)]
[DAGCombine] add tests for bswap-shift optimization

Reviewed By: RKSimon

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

2 years ago[MLIR][NFC] Remove dead FlatAffineConstraints constructor
Uday Bondhugula [Tue, 29 Mar 2022 07:18:54 +0000 (12:48 +0530)]
[MLIR][NFC] Remove dead FlatAffineConstraints constructor

NFC. Remove dead FlatAffineConstraints constructor.

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

2 years ago[CSKY] Add CSKYTargetObjectFile to support exception handling
Zi Xuan Wu [Tue, 29 Mar 2022 07:42:06 +0000 (15:42 +0800)]
[CSKY] Add CSKYTargetObjectFile to support exception handling

Initialize TargetLoweringObjectFileELF and EH header.

2 years ago[CSKY] Add missing codegen pattern for 16-bit instruction
Zi Xuan Wu [Tue, 29 Mar 2022 07:05:49 +0000 (15:05 +0800)]
[CSKY] Add missing codegen pattern for 16-bit instruction

In generic cpu model, there are only low 16 registers and little 32-bit instruction. CK801 is the cpu
family with least basic features like generic model.

Add test run and check for generic cpu model in original test case to cover basic LLVM IR functionality.

2 years ago[RISCV][NFC] Improve encoding/decoding tests for Zbb/Zbp/Zbt instructions
Liqin Weng [Tue, 29 Mar 2022 07:44:44 +0000 (15:44 +0800)]
[RISCV][NFC] Improve encoding/decoding tests for Zbb/Zbp/Zbt instructions

Reviewed By: benshi001

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

2 years ago[flang] prevent undefined behavior in character MAXLOC folding
Jean Perier [Mon, 28 Mar 2022 17:05:36 +0000 (19:05 +0200)]
[flang] prevent undefined behavior in character MAXLOC folding

When folding MAXLOC/MINLOC, the current element being compared was moved twice
in row in case it became the new extremum. With numeric and logical types, it
made no difference (std::move is a no-op for them), but for characters
where the string storage is actually moved, it caused the new extremum to
be set to the empty string, leading to wrong results.

Note: I could have left the first std::move relating to logical Findloc, but it
brings nothing and makes the code less auditable, so I also removed it.

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

2 years ago[RISCV][NFC] Remove redundant check and rename functions in some IR tests
Lian Wang [Tue, 22 Mar 2022 06:07:17 +0000 (06:07 +0000)]
[RISCV][NFC] Remove redundant check and rename functions in some IR tests

Reviewed By: frasercrmck

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

2 years ago[clang][DR] Test and mark DR1479 as complete
Markus Böck [Tue, 29 Mar 2022 07:28:17 +0000 (09:28 +0200)]
[clang][DR] Test and mark DR1479 as complete

DR: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1479

Clang has implemented this DR as far back as I could go on compiler explorer (3.0). This patch simply adds a test case and needed comments for the update script to mark it as complete.

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

2 years ago[Support/BLAKE3] Re-enable building with the simd-optimized implementations
Argyrios Kyrtzidis [Tue, 29 Mar 2022 04:00:58 +0000 (21:00 -0700)]
[Support/BLAKE3] Re-enable building with the simd-optimized implementations

2 years ago[LSR] Fixup canonicalization formula and its checker.
Serguei Katkov [Fri, 25 Mar 2022 03:19:01 +0000 (10:19 +0700)]
[LSR] Fixup canonicalization formula and its checker.

According to definition of canonical form, it is a canonical
if scale reg does not contain addrec for loop L then none of bases
should contain addrec for this loop.

The critical word here is "contains".

Current checker of canonical form checks not "containing" property
but "is". So it does not check whether it contains but whether it is.

Fix the checker and canonicalizing utility to follow definition.

Without this fix in the test attached the base formula looking as
reg((-1 * {0,+,8}<nuw><nsw><%bb2>)<nsw>) + 1*reg((8 * (%arg /u 8))<nuw>)
is considered as conanocial while base contains an addrec.
And modified formula we want to insert
reg({0,+,8}<nuw><nsw><%bb2>) + 1*reg((-8 * (%arg /u 8)))
is considered as not canonical.

Reviewed By: mkazantsev
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D122457

2 years agoCleanup includes: final pass
serge-sans-paille [Mon, 28 Mar 2022 12:10:26 +0000 (14:10 +0200)]
Cleanup includes: final pass

Cleanup a few extra files, this closes the work on libLLVM dependencies on my
side.

Impact on libLLVM preprocessed output: -35876 lines

Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup
Differential Revision: https://reviews.llvm.org/D122576

2 years ago[RISCV][test] Make PATH empty when testing --gcc-toolchain is multilib_riscv_elf_sdk
luxufan [Tue, 29 Mar 2022 03:03:33 +0000 (11:03 +0800)]
[RISCV][test] Make PATH empty when testing --gcc-toolchain is multilib_riscv_elf_sdk

Due to D79842, clang dirver would search possible tool name in both possible
locations, then moving to the next name. The gcc toolchain `llvm-project/clang/test/Driver/
Inputs/multilib_riscv_elf_sdk` don't have a `riscv64-unknown-elf-ld` executable in
`llvm-project/clang/test/Driver/Inputs/multilib_riscv_elf_sdk/bin/`. So when searching
`riscv64-unknown-elf-ld`, if there is a `riscv64-unknown-elf-ld` in `PATH`, the
test would fail.

This patch makes the `PATH` empty when testing it.

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

2 years ago[RISCV] Optimize LI+SLT to SLTI+XORI for immediates in specific range
Liqin Weng [Tue, 29 Mar 2022 06:46:17 +0000 (14:46 +0800)]
[RISCV] Optimize LI+SLT to SLTI+XORI for immediates in specific range

This transform will reduce one GPR.

Reviewed By: craig.topper, benshi001

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

2 years ago[gn build] Port 90cb325abda9
LLVM GN Syncbot [Tue, 29 Mar 2022 06:21:57 +0000 (06:21 +0000)]
[gn build] Port 90cb325abda9

2 years agoRevert "[misexpect] Re-implement MisExpect Diagnostics"
Paul Kirth [Tue, 29 Mar 2022 06:20:30 +0000 (06:20 +0000)]
Revert "[misexpect] Re-implement MisExpect Diagnostics"

This reverts commit 2add3fbd976d7b80a3a7fc14ef0deb9b1ca6beee.

2 years agoRevert "[docs][misexpect][NFC] Fix malformed table in docs"
Paul Kirth [Tue, 29 Mar 2022 06:19:53 +0000 (06:19 +0000)]
Revert "[docs][misexpect][NFC] Fix malformed table in docs"

This reverts commit a427e18896dee3cd00d5f565cfb9d7d2f26ebcec.

2 years ago[flang][OpenMP] Added parallel sections translation
Shraiysh Vaishay [Tue, 29 Mar 2022 05:12:45 +0000 (10:42 +0530)]
[flang][OpenMP] Added parallel sections translation

This patch adds translation for parallel sections from PFT to MLIR.

Reviewed By: kiranchandramohan, NimishMishra

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

2 years ago[clangd] Handle tabs in getIncrementalChangesAfterNewline()
Nathan Ridge [Mon, 28 Mar 2022 06:13:20 +0000 (02:13 -0400)]
[clangd] Handle tabs in getIncrementalChangesAfterNewline()

Tabs are not handled by columnWidthUTF8() (they are considered
non-printable) so require additional logic to handle.

Fixes https://github.com/clangd/clangd/issues/1074

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

2 years ago[OpenMP] The test does not have check lines
Johannes Doerfert [Tue, 29 Mar 2022 05:02:28 +0000 (00:02 -0500)]
[OpenMP] The test does not have check lines

2 years ago[scudo] Use template specialization on Quarantine to avoid zero-length array
Dominic Chen [Fri, 25 Mar 2022 23:44:31 +0000 (16:44 -0700)]
[scudo] Use template specialization on Quarantine to avoid zero-length array

Use a separate templated QuarantineBlocks class to avoid a zero-length array

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

2 years ago[OpenMP][FIX] Use clang++ for the C++ test case
Johannes Doerfert [Tue, 29 Mar 2022 04:14:00 +0000 (23:14 -0500)]
[OpenMP][FIX] Use clang++ for the C++ test case

2 years ago[Driver][AVR] Emit proper warnings for different options
Ben Shi [Tue, 29 Mar 2022 04:05:05 +0000 (12:05 +0800)]
[Driver][AVR] Emit proper warnings for different options

Reviewed By: MaskRay

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

2 years ago[RISCV] Pull APInt/computeKnonwbits specifics out of computeGREVOrGORC. NFC
Craig Topper [Tue, 29 Mar 2022 02:31:20 +0000 (19:31 -0700)]
[RISCV] Pull APInt/computeKnonwbits specifics out of computeGREVOrGORC. NFC

This function now takes a uint64_t instead of an APInt. The caller
is responsible for masking the shift amount, extracting and inserting
into the KnownBits APInts, and inverting to compute zeros.

This is less code and cleaner division of responsibilities.

2 years ago[OpenMP][FIX] Avoid races in the handling of to be deleted mapping entries
Johannes Doerfert [Wed, 2 Mar 2022 19:46:01 +0000 (13:46 -0600)]
[OpenMP][FIX] Avoid races in the handling of to be deleted mapping entries

If we decided to delete a mapping entry we did not act on it right away
but first issued and waited for memory copies. In the meantime some
other thread might reuse the entry. While there was some logic to avoid
colliding on the actual "deletion" part, there were two races happening:

1) The data transfer back of the thread deleting the entry and
   the data transfer back of the thread taking over the entry raced.
2) The update to the shadow map happened regardless if the entry was
   actually reused by another thread which left the shadow map in a
   inconsistent state.

To fix both issues we will now update the shadow map and delete the
entry only if we are sure the thread is responsible for deletion, hence
no other thread took over the entry and reused it. We also wait for a
potential former data transfer from the device to finish before we issue
another one that would race with it.

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

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

2 years ago[OpenMP][NFC] Add missing virtual destructor to silence warning
Johannes Doerfert [Fri, 25 Mar 2022 21:07:57 +0000 (16:07 -0500)]
[OpenMP][NFC] Add missing virtual destructor to silence warning

2 years ago[X86][regcall] Support passing / returning structures
Phoebe Wang [Tue, 29 Mar 2022 01:41:31 +0000 (09:41 +0800)]
[X86][regcall] Support passing / returning structures

Currently, the regcall calling conversion in Clang doesn't match with
ICC when passing / returning structures. https://godbolt.org/z/axxKMKrW7

This patch tries to fix the problem to match with ICC.

Reviewed By: LuoYuanke

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

2 years agoRevert D122459 "[ELF] --emit-relocs: adjust offsets of .rel[a].eh_frame relocations"
Fangrui Song [Tue, 29 Mar 2022 03:26:21 +0000 (20:26 -0700)]
Revert D122459 "[ELF] --emit-relocs: adjust offsets of .rel[a].eh_frame relocations"

This reverts commit 6faba31e0d88ce71e87567ddb51d2444524b8a81.

It may cause "offset is outside the section".

2 years ago[memcpyopt] Common code into performCallSlotOptzn [NFC]
Philip Reames [Tue, 29 Mar 2022 03:06:22 +0000 (20:06 -0700)]
[memcpyopt] Common code into performCallSlotOptzn [NFC]

We have the same code repeated in both callers, sink it into callee.

The motivation here isn't just code style, we can also defer the relatively expensive aliasing checks until the cheap structural preconditions have been validated.  (e.g. Don't bother aliasing if src is not an alloca.)  This helps compile time significantly.

2 years ago[slp] Delete dead scalar instructions feeding vectorized instructions
Philip Reames [Tue, 29 Mar 2022 02:28:13 +0000 (19:28 -0700)]
[slp] Delete dead scalar instructions feeding vectorized instructions

If we vectorize a e.g. store, we leave around a bunch of getelementptrs for the individual scalar stores which we removed. We can go ahead and delete them as well.

This is purely for test output quality and readability. It should have no effect in any sane pipeline.

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

2 years ago[mlir] Fix leak in case of failed parse
Jacques Pienaar [Tue, 29 Mar 2022 03:04:31 +0000 (20:04 -0700)]
[mlir] Fix leak in case of failed parse

A Block is optionally allocated & leaks in case of failed parse. Inline the
function and ensure Block gets freed unless parse is successful.

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

2 years ago[AArch64][GlobalISel] Add new MOVI pattern for fp constants
zhongyunde [Tue, 29 Mar 2022 00:39:23 +0000 (08:39 +0800)]
[AArch64][GlobalISel] Add new MOVI pattern for fp constants

GlobalISel is used in option -O0, so add MOVI pattern for it,
which is done similar in gcc.(https://godbolt.org/z/8j6fzG3h6)

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

Reviewed By: dmgreen, paquette

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

2 years agoEliminate gcc7 compiler warnings
long.chen [Tue, 29 Mar 2022 02:55:37 +0000 (19:55 -0700)]
Eliminate gcc7 compiler warnings

we will get warning:```parameter ‘op’ set but not used``` when template function with empty template parameter list.

Reviewed By: jpienaar

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

2 years ago[libcxx] random_device, specify optimal entropy properties for all OS's using arc4ran...
Brad Smith [Tue, 29 Mar 2022 02:27:28 +0000 (22:27 -0400)]
[libcxx] random_device, specify optimal entropy properties for all OS's using arc4random()

Reviewed By: ldionne

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

2 years agoRevert "[scudo] Use template specialization on Quarantine to avoid zero-length array"
Dominic Chen [Tue, 29 Mar 2022 02:08:55 +0000 (19:08 -0700)]
Revert "[scudo] Use template specialization on Quarantine to avoid zero-length array"

This reverts commit 7dda44c189d74ec0a1bbe7dfff7c4d5f6b0e96d4.

2 years ago[RISCV] [NFC] add some tests for overloaded intrinsics of FP16
Chenbing Zheng [Tue, 29 Mar 2022 01:55:06 +0000 (09:55 +0800)]
[RISCV] [NFC] add some tests for overloaded intrinsics of FP16

Reviewed By: craig.topper

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

2 years ago[Attributor][OpenMP] Add assumption for non-call assembly instructions
Johannes Doerfert [Sat, 11 Sep 2021 23:34:47 +0000 (18:34 -0500)]
[Attributor][OpenMP] Add assumption for non-call assembly instructions

Inline assembly is scary but we need to support it for the OpenMP GPU
device runtime. The new assumption expresses the fact that it may not
have call semantics, that is, it will not call another function but
simply perform an operation or side-effect. This is important for
reachability in the presence of inline assembly.

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

2 years ago[InstCombineCalls] Optimize call of bitcast even w/ parameter attributes
Johannes Doerfert [Mon, 14 Feb 2022 23:12:34 +0000 (17:12 -0600)]
[InstCombineCalls] Optimize call of bitcast even w/ parameter attributes

Before we gave up if a call through bitcast had parameter attributes.
Interestingly, we allowed attributes for the return value already. We
now handle both the same way, namely, we drop the ones that are
incompatible with the new type and keep the rest. This cannot cause
"more UB" than initially present.

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

2 years ago[NFC][CodeGen] Add a setTargetDAGCombine use ArrayRef
Shao-Ce SUN [Mon, 28 Mar 2022 18:31:39 +0000 (02:31 +0800)]
[NFC][CodeGen] Add a setTargetDAGCombine use ArrayRef

Reviewed By: arsenm

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

2 years ago[AArch64] Allow .variant_pcs before the symbol is registered
Fangrui Song [Tue, 29 Mar 2022 00:52:27 +0000 (17:52 -0700)]
[AArch64] Allow .variant_pcs before the symbol is registered

glibc sysdeps/aarch64/tst-vpcs-mod.S has something like:
```
.variant_pcs    vpcs_call
.global vpcs_call
```

This is supported by GNU as but leads to an error in MC. Use getOrCreateSymbol
to support a not-yet-registered symbol: call `registerSymbol` to ensure the
symbol exists even if there is no binding directive/label, to match GNU as.

While here, improve tests to check (1) a local symbol can get
STO_AARCH64_VARIANT_PCS (2) undefined .variant_pcs (3) an alias does not
inherit STO_AARCH64_VARIANT_PCS.

Reviewed By: efriedma

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

2 years ago[docs][misexpect][NFC] Fix malformed table in docs
Paul Kirth [Mon, 28 Mar 2022 23:50:51 +0000 (23:50 +0000)]
[docs][misexpect][NFC] Fix malformed table in docs

Reviewed By: abrachet

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

2 years ago[RISCV] Add computeKnownBits support for RISCVISD::GORC.
Craig Topper [Mon, 28 Mar 2022 23:44:57 +0000 (16:44 -0700)]
[RISCV] Add computeKnownBits support for RISCVISD::GORC.

Reviewed By: luismarques

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

2 years ago[Driver] Make -moutline-atomics default for aarch64-fuchsia targets
Roland McGrath [Mon, 28 Mar 2022 21:05:23 +0000 (14:05 -0700)]
[Driver] Make -moutline-atomics default for aarch64-fuchsia targets

This makes Fuchsia consistent with Linux on AArch64.

Reviewed By: abrachet

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

2 years ago[libc] Set rtlib to compiler-rt in integration tests.
Siva Chandra Reddy [Mon, 28 Mar 2022 21:11:08 +0000 (21:11 +0000)]
[libc] Set rtlib to compiler-rt in integration tests.

The clang driver to picks up compiler runtime files using full paths.
Without this, at least for aarch64, the driver tries to pick up the
compiler runtime files from the working directory.

Reviewed By: michaelrj

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

2 years ago[gn build] Port 2add3fbd976d
LLVM GN Syncbot [Mon, 28 Mar 2022 23:38:54 +0000 (23:38 +0000)]
[gn build] Port 2add3fbd976d

2 years ago[scudo] Use cast on calls to __builtin_umul_overflow/__builtin_umull_overflow
Dominic Chen [Wed, 16 Mar 2022 20:40:58 +0000 (13:40 -0700)]
[scudo] Use cast on calls to __builtin_umul_overflow/__builtin_umull_overflow

Platforms may define uintptr_t differently, so perform an explicit cast

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

2 years ago[scudo] Use template specialization on Quarantine to avoid zero-length array
Dominic Chen [Fri, 25 Mar 2022 23:44:31 +0000 (16:44 -0700)]
[scudo] Use template specialization on Quarantine to avoid zero-length array

Use a separate templated QuarantineBlocks class to avoid a zero-length array

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

2 years ago[misexpect] Re-implement MisExpect Diagnostics
Paul Kirth [Sat, 19 Mar 2022 00:54:23 +0000 (00:54 +0000)]
[misexpect] Re-implement MisExpect Diagnostics

Reimplements MisExpect diagnostics from D66324 to reconstruct its
original checking methodology only using MD_prof branch_weights
metadata.

New checks rely on 2 invariants:

1) For frontend instrumentation, MD_prof branch_weights will always be
   populated before llvm.expect intrinsics are lowered.

2) for IR and sample profiling, llvm.expect intrinsics will always be
   lowered before branch_weights are populated from the IR profiles.

These invariants allow the checking to assume how the existing branch
weights are populated depending on the profiling method used, and emit
the correct diagnostics. If these invariants are ever invalidated, the
MisExpect related checks would need to be updated, potentially by
re-introducing MD_misexpect metadata, and ensuring it always will be
transformed the same way as branch_weights in other optimization passes.

Frontend based profiling is now enabled without using LLVM Args, by
introducing a new CodeGen option, and checking if the -Wmisexpect flag
has been passed on the command line.

Reviewed By: tejohnson

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

2 years agoSilence compiler warning after the addition of HLSL to Clang
Benjamin Kramer [Mon, 28 Mar 2022 23:21:52 +0000 (01:21 +0200)]
Silence compiler warning after the addition of HLSL to Clang

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:472:16: warning: enumeration value 'HLSL' not handled in switch [-Wswitch]
    switch (IK.getLanguage()) {
               ^

2 years ago[ELF] --emit-relocs: adjust offsets of .rel[a].eh_frame relocations
Fangrui Song [Mon, 28 Mar 2022 23:23:13 +0000 (16:23 -0700)]
[ELF] --emit-relocs: adjust offsets of .rel[a].eh_frame relocations

.eh_frame pieces may be dropped due to GC/ICF. When --emit-relocs adds
relocations against .eh_frame, the offsets need to be adjusted. Use the same
way as MergeInputSection with a special case handling outSecOff==-1 for an
invalid piece (see eh-frame-marker.s).

This exposes an issue in mips64-eh-abs-reloc.s that we don't reliably
handle anyway. Just add --no-check-dynamic-relocations to paper over it.

Original patch by Ayrton Muñoz

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

2 years agoRevert 29fada4a3d3db309f11f7fa7a0c61cd4021e9947
Alina Sbirlea [Mon, 28 Mar 2022 23:16:07 +0000 (16:16 -0700)]
Revert 29fada4a3d3db309f11f7fa7a0c61cd4021e9947

Seeing a test failure with asan in Halide generated code, reverting
while I investigate.

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

2 years ago[ELF][test] Refactor some .eh_frame tests
Fangrui Song [Mon, 28 Mar 2022 22:55:46 +0000 (15:55 -0700)]
[ELF][test] Refactor some .eh_frame tests

* Improve eh-frame-merge.s
* Delete invalid .eh_frame+5 test in ehframe-relocation.s

2 years ago[mlir] Update Vector dialect to prefixed accessors.
Jacques Pienaar [Mon, 28 Mar 2022 22:44:40 +0000 (15:44 -0700)]
[mlir] Update Vector dialect to prefixed accessors.

Been >2 weeks since flipped to Both, following update procedure and
flipping to prefixed.

2 years ago[Clang] Implement __builtin_source_location.
James Y Knight [Mon, 28 Mar 2022 22:27:18 +0000 (18:27 -0400)]
[Clang] Implement __builtin_source_location.

This builtin returns the address of a global instance of the
`std::source_location::__impl` type, which must be defined (with an
appropriate shape) before calling the builtin.

It will be used to implement std::source_location in libc++ in a
future change. The builtin is compatible with GCC's implementation,
and libstdc++'s usage. An intentional divergence is that GCC declares
the builtin's return type to be `const void*` (for
ease-of-implementation reasons), while Clang uses the actual type,
`const std::source_location::__impl*`.

In order to support this new functionality, I've also added a new
'UnnamedGlobalConstantDecl'. This artificial Decl is modeled after
MSGuidDecl, and is used to represent a generic concept of an lvalue
constant with global scope, deduplicated by its value. It's possible
that MSGuidDecl itself, or some of the other similar sorts of things
in Clang might be able to be refactored onto this more-generic
concept, but there's enough special-case weirdness in MSGuidDecl that
I gave up attempting to share code there, at least for now.

Finally, for compatibility with libstdc++'s <source_location> header,
I've added a second exception to the "cannot cast from void* to T* in
constant evaluation" rule. This seems a bit distasteful, but feels
like the best available option.

Reviewers: aaron.ballman, erichkeane

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

2 years ago[mlir] Update the Builtin dialect to use prefixed accessors
Jacques Pienaar [Mon, 28 Mar 2022 22:20:48 +0000 (15:20 -0700)]
[mlir] Update the Builtin dialect to use prefixed accessors

Been >2 weeks since flipped to Both, following update procedure and
flipping to prefixed.

2 years ago[Bazel] Update zlib to 1.2.12
Geoffrey Martin-Noble [Mon, 28 Mar 2022 21:48:18 +0000 (14:48 -0700)]
[Bazel] Update zlib to 1.2.12

There's a vulnerability in 1.2.11:
https://twitter.com/taviso/status/1508438583484452866

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

2 years ago[attributes] Generalize attribute 'enforce_tcb' to Objective-C methods.
Pierre d'Herbemont [Mon, 28 Mar 2022 20:24:02 +0000 (13:24 -0700)]
[attributes] Generalize attribute 'enforce_tcb' to Objective-C methods.

Calling an ObjC method from a C function marked with the 'enforce_tcb'
attribute did not produce a warning. Now it does, and on top of that
Objective-C methods can participate in TCBs themselves.

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