platform/upstream/llvm.git
2 years agoRevert "Revert "[Libomptarget] Add checks for AMDGPU TargetID using new image info""
Saiyedul Islam [Mon, 25 Jul 2022 13:32:26 +0000 (08:32 -0500)]
Revert "Revert "[Libomptarget] Add checks for AMDGPU TargetID using new image info""

This reverts commit 8cbf4a386b6740180fe48aaebbd1ca9f8ee14367.

2 years ago[C++20][Modules] Update ADL to handle basic.lookup.argdep p4 [P1815R2 part 1]
Iain Sandoe [Wed, 6 Jul 2022 06:40:01 +0000 (07:40 +0100)]
[C++20][Modules] Update ADL to handle basic.lookup.argdep p4 [P1815R2 part 1]

This includes the revised provisions of [basic.lookup.argdep] p4

1. ADL is amended to handle p 4.3 where functions in trasitively imported modules may
become visible when they are exported in the same namespace as a visible type.

2. If a function is in a different modular TU, and has internal-linkage, we invalidate
its entry in an overload set.

[basic.lookup.argdep] p5 ex 2 now passes.

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

2 years ago[Sema] Merge C++20 concept definitions from different modules in same TU
Ilya Biryukov [Mon, 25 Jul 2022 10:42:42 +0000 (12:42 +0200)]
[Sema] Merge C++20 concept definitions from different modules in same TU

Currently the C++20 concepts are only merged in `ASTReader`, i.e. when
coming from different TU. This can causes ambiguious reference errors when
trying to access the same concept that should otherwise be merged.

Please see the added test for an example.

Note that we currently use `ASTContext::isSameEntity` to check for ODR
violations. However, it will not check that concept requirements match.
The same issue holds for mering concepts from different TUs, I added a
FIXME and filed a GH issue to track this:
https://github.com/llvm/llvm-project/issues/56310

Reviewed By: ChuanqiXu

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

2 years ago[LoongArch] Parse LoongArch base ABI in ObjectYAML and llvm-readobj
Weining Lu [Mon, 25 Jul 2022 09:24:25 +0000 (17:24 +0800)]
[LoongArch] Parse LoongArch base ABI in ObjectYAML and llvm-readobj

LoongArch e_flags definition:
https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html#_e_flags_identifies_abi_type_and_version

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

2 years ago[lldb][ARM/AArch64] Use sys/uio.h instead of socket.h in native register context
David Spickett [Mon, 25 Jul 2022 10:55:45 +0000 (10:55 +0000)]
[lldb][ARM/AArch64] Use sys/uio.h instead of socket.h in native register context

We only want iovec and uio.h is just that without a lot
of other stuff. Saves me wondering why this code might
want to open sockets.

https://pubs.opengroup.org/onlinepubs/007904975/basedefs/sys/uio.h.html

2 years ago[AArch64] Combine setcc (iN (bitcast (vNi1 X))) with vecreduce_or
Cullen Rhodes [Mon, 25 Jul 2022 11:57:27 +0000 (11:57 +0000)]
[AArch64] Combine setcc (iN (bitcast (vNi1 X))) with vecreduce_or

Reviewed By: paulwalker-arm

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

2 years ago[AArch64][NFC] Add test case for setcc (iN bitcast (vNi1 X)), (iN 0), (eq|ne)
Cullen Rhodes [Mon, 25 Jul 2022 11:54:15 +0000 (11:54 +0000)]
[AArch64][NFC] Add test case for setcc (iN bitcast (vNi1 X)), (iN 0), (eq|ne)

To be combined to 'setcc (iN (zext (i1 (vecreduce_or (vNi1 X))))), 0, (eq|ne)'
in follow on patch.

Reviewed By: peterwaller-arm

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

2 years ago[SystemZ][z/OS] Open YAML text files as text
Abhina Sreeskantharajan [Mon, 25 Jul 2022 12:06:16 +0000 (08:06 -0400)]
[SystemZ][z/OS] Open YAML text files as text

This patch sets the YAML file as text instead of binary.

Reviewed By: MaskRay

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

2 years ago[flang] Support lowering intrinsic `selected_real_kind` for variables
Peixin Qiao [Mon, 25 Jul 2022 11:36:14 +0000 (19:36 +0800)]
[flang] Support lowering intrinsic `selected_real_kind` for variables

As Fortran 2018 16.9.170, the argument of `selected_real_kind` is integer
scalar, and result is default integer scalar. The constant expression in
this intrinsic has been supported by folding the constant expression.
This supports lowering this intrinsic for variables using runtime.

Reviewed By: Jean Perier

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

2 years ago[ValueTracking] Fix unused variable warning in release builds. NFC
Benjamin Kramer [Mon, 25 Jul 2022 11:28:32 +0000 (13:28 +0200)]
[ValueTracking] Fix unused variable warning in release builds. NFC

2 years agoRewording "static_assert" diagnostics
Muhammad Usman Shahid [Mon, 25 Jul 2022 11:22:54 +0000 (07:22 -0400)]
Rewording "static_assert" diagnostics

This patch rewords the static assert diagnostic output. Failing a
_Static_assert in C should not report that static_assert failed. This
changes the wording to be more like GCC and uses "static assertion"
when possible instead of hard coding the name. This also changes some
instances of 'static_assert' to instead be based on the token in the
source code.

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

2 years agoSwitch from XFAIL to UNSUPPORTED; NFC
Aaron Ballman [Mon, 25 Jul 2022 11:18:48 +0000 (07:18 -0400)]
Switch from XFAIL to UNSUPPORTED; NFC

This test is currently marked as XFAIL for Windows, but running the
test with a debug build of clang-repl.exe crashes with a modal system
dialog. This switches the test to UNSUPPORTED instead. This makes the
test behavior less onerous for those of us doing Debug builds, at the
expense of a minor bit of coverage if the test were ever to start
passing unexpectedly on Windows (which seems like an unlikely event).

2 years ago[C++20][Modules] Add a testcase for [basic.link] p10 [NFC].
Iain Sandoe [Mon, 25 Jul 2022 09:50:16 +0000 (10:50 +0100)]
[C++20][Modules] Add a testcase for [basic.link] p10 [NFC].

This adds a testcase based on example 2 from the basic.link section of the
standard.

2 years ago[pseudo] Eliminate multiple-specified-types ambiguities using guards
Sam McCall [Fri, 22 Jul 2022 09:28:51 +0000 (11:28 +0200)]
[pseudo] Eliminate multiple-specified-types ambiguities using guards

Motivating case: `foo bar;` is not a declaration of nothing with `foo` and `bar`
both types.

This is a common and critical ambiguity, clangd/AST.cpp has 20% fewer
ambiguous nodes (1674->1332) after this change.

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

2 years ago[mlir][tensor][bufferize][NFC] Remove duplicate code
Matthias Springer [Mon, 25 Jul 2022 10:29:01 +0000 (12:29 +0200)]
[mlir][tensor][bufferize][NFC] Remove duplicate code

InsertSliceOp and ParallelInsertSliceOp are very similar and can share some of the bufferization analysis code.

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

2 years agoRevert "[Libomptarget] Add checks for AMDGPU TargetID using new image info"
Saiyedul Islam [Mon, 25 Jul 2022 10:32:59 +0000 (05:32 -0500)]
Revert "[Libomptarget] Add checks for AMDGPU TargetID using new image info"

This reverts commit 471f2abc62d96b3ef97e13f4f7be2d386fc9f75f.

2 years ago[mlir][tensor][bufferize] Fix deallocation of GenerateOp/FromElementsOp
Matthias Springer [Mon, 25 Jul 2022 10:24:24 +0000 (12:24 +0200)]
[mlir][tensor][bufferize] Fix deallocation of GenerateOp/FromElementsOp

Both ops allocate a buffer. There were cases in which the buffer was not deallocated.

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

2 years ago[mlir] Transform dialect: separate dependent and generated dialects
Alex Zinenko [Thu, 21 Jul 2022 17:16:13 +0000 (17:16 +0000)]
[mlir] Transform dialect: separate dependent and generated dialects

In the Transform dialect extensions, provide the separate mechanism to
declare dependent dialects (the dialects the transform IR depends on)
and the generated dialects (the dialects the payload IR may be
transformed into). This allows the Transform dialect clients that are
only constructing the transform IR to avoid loading the dialects
relevant for the payload IR along with the Transform dialect itself,
thus decreasing the build/link time.

Reviewed By: springerm

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

2 years ago[C++20] [Modules] Make the linkage consistent for class template and its
Chuanqi Xu [Mon, 25 Jul 2022 09:43:52 +0000 (17:43 +0800)]
[C++20] [Modules] Make the linkage consistent for class template and its
specialization

Previously in D120397, we've handled the linkage for function template
and its specialization. But we forgot to handle it for class templates
and their specialization. So we make it in the patch with the similar
approach.

2 years agoAMDGPU: Turn off force init 16 input SGPRS for pal
David Stuttard [Tue, 12 Jul 2022 15:12:51 +0000 (16:12 +0100)]
AMDGPU: Turn off force init 16 input SGPRS for pal

Pal uses a different mechanism for user sgprs.

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

2 years ago[Libomptarget] Add checks for AMDGPU TargetID using new image info
Saiyedul Islam [Fri, 22 Jul 2022 14:43:15 +0000 (09:43 -0500)]
[Libomptarget] Add checks for AMDGPU TargetID using new image info

This patch extends the is_valid_binary routine to also check if the
binary's target ID matches the one parsed from the system's runtime
environment.
This should allow us to only use the binary whose compute capability
matches, allowing us to support basic multi-architecture binaries for
AMDGPU.
It also handles compatibility testing of target IDs of the image and
the enviornment.

Depends on D127432

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

2 years ago[mlir][tensor][bufferize] Load dependent dialects
Matthias Springer [Mon, 25 Jul 2022 09:30:22 +0000 (11:30 +0200)]
[mlir][tensor][bufferize] Load dependent dialects

Load dialects that will be generated by the extension. (Except for BufferizationDialect and MemrefDialect which are loaded already.)

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

2 years ago[RISCV] Scalarize binop followed by extractelement.
jacquesguan [Tue, 12 Jul 2022 06:12:23 +0000 (14:12 +0800)]
[RISCV] Scalarize binop followed by extractelement.

This patch adds shouldScalarizeBinop to RISCV target in order to convert an extract element of a vector binary operation into an extract element followed by a scalar binary operation.

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

2 years ago[DebugInfo] Avoid ptrtoint expression in generic test
Nikita Popov [Mon, 25 Jul 2022 09:18:01 +0000 (11:18 +0200)]
[DebugInfo] Avoid ptrtoint expression in generic test

After D130366 the ptrtoint expression this used results in an
error on 32-bit targets (the IR was already invalid previously,
but only produced the error with -filetype=obj).

Tweak the IR so it is correct for both 32-bit and 64-bit targets,
and can thus continue working as a generic test.

2 years ago[mlir][sparse][nfc] Fix memory leak in sparse sampled matmul integration test
Rajas Vanjape [Sat, 23 Jul 2022 16:55:17 +0000 (16:55 +0000)]
[mlir][sparse][nfc] Fix memory leak in sparse sampled matmul integration test

https://reviews.llvm.org/D130023 added a memory leak in sparse_sampled_matmul.mlir
This diff fixes the memory leak.

Testing: Ran integration tests after building with -DLLVM_USE_SANITIZER=Address flag.

Reviewed By: springerm

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

2 years ago[mlir] Apply ClangTidyPerformance findings (NFC)
Adrian Kuegel [Mon, 25 Jul 2022 08:49:14 +0000 (10:49 +0200)]
[mlir] Apply ClangTidyPerformance findings (NFC)

2 years ago[CMake] Copy folder without permissions
Sebastian Neubauer [Fri, 22 Jul 2022 09:31:20 +0000 (11:31 +0200)]
[CMake] Copy folder without permissions

Copying the folder keeps the original permissions by default. This
creates problems when the source folder is read-only, e.g. in a
packaging environment.
Then, the copied folder in the build directory is read-only as well.
Later on, other files are copied into that directory (in the build
tree), failing when the directory is read-only.

Fix that problem by copying the folder without keeping the original
permissions.

Follow-up to D130254.

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

2 years agotsan: prevent pathological slowdown for spurious races
Dmitry Vyukov [Thu, 21 Jul 2022 13:48:19 +0000 (15:48 +0200)]
tsan: prevent pathological slowdown for spurious races

Prevent the following pathological behavior:
Since memory access handling is not synchronized with DoReset,
a thread running concurrently with DoReset can leave a bogus shadow value
that will be later falsely detected as a race. For such false races
RestoreStack will return false and we will not report it.
However, consider that a thread leaves a whole lot of such bogus values
and these values are later read by a whole lot of threads.
This will cause massive amounts of ReportRace calls and lots of
serialization. In very pathological cases the resulting slowdown
can be >100x. This is very unlikely, but it was presumably observed
in practice: https://github.com/google/sanitizers/issues/1552
If this happens, previous access sid+epoch will be the same for all of
these false races b/c if the thread will try to increment epoch, it will
notice that DoReset has happened and will stop producing bogus shadow
values. So, last_spurious_race is used to remember the last sid+epoch
for which RestoreStack returned false. Then it is used to filter out
races with the same sid+epoch very early and quickly.
It is of course possible that multiple threads left multiple bogus shadow
values and all of them are read by lots of threads at the same time.
In such case last_spurious_race will only be able to deduplicate a few
races from one thread, then few from another and so on. An alternative
would be to hold an array of such sid+epoch, but we consider such scenario
as even less likely.
Note: this can lead to some rare false negatives as well:
1. When a legit access with the same sid+epoch participates in a race
as the "previous" memory access, it will be wrongly filtered out.
2. When RestoreStack returns false for a legit memory access because it
was already evicted from the thread trace, we will still remember it in
last_spurious_race. Then if there is another racing memory access from
the same thread that happened in the same epoch, but was stored in the
next thread trace part (which is still preserved in the thread trace),
we will also wrongly filter it out while RestoreStack would actually
succeed for that second memory access.

Reviewed By: melver

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

2 years agotsan: remove tracking of racy addresses
Dmitry Vyukov [Thu, 21 Jul 2022 09:52:17 +0000 (11:52 +0200)]
tsan: remove tracking of racy addresses

We used to deduplicate based on the race address to prevent lots
of repeated reports about the same race.

But now we clear the shadow for the racy address in DoReportRace:

  // This prevents trapping on this address in future.
  for (uptr i = 0; i < kShadowCnt; i++)
    StoreShadow(&shadow_mem[i], i == 0 ? Shadow::kRodata : Shadow::kEmpty);

It should have the same effect of not reporting duplicates
(and actually better because it's automatically reset when the memory is reallocated).

So drop the address deduplication code. Both simpler and faster.

Reviewed By: melver

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

2 years ago[clang][ASTImporter] Improved handling of functions with auto return type.
Balázs Kéri [Mon, 25 Jul 2022 07:30:37 +0000 (09:30 +0200)]
[clang][ASTImporter] Improved handling of functions with auto return type.

Avoid a crash if a function is imported that has auto return type that
references to a template with an expression-type of argument that
references into the function's body.
Fixes issue #56047

Reviewed By: martong

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

2 years ago[mlir][Math] Add constant folder for ExpOp.
jacquesguan [Fri, 22 Jul 2022 00:46:05 +0000 (08:46 +0800)]
[mlir][Math] Add constant folder for ExpOp.

This patch adds constant folder for ExpOp which only supports single and double precision floating-point.

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

2 years ago[ELF] --reproduce: support --export-dynamic-symbol-list
Fangrui Song [Mon, 25 Jul 2022 08:20:32 +0000 (01:20 -0700)]
[ELF] --reproduce: support --export-dynamic-symbol-list

2 years ago[llvm][FileCheck] Fix unit tests failures with EXPENSIVE_CHECKS
David Spickett [Thu, 21 Jul 2022 15:36:52 +0000 (15:36 +0000)]
[llvm][FileCheck] Fix unit tests failures with EXPENSIVE_CHECKS

EXPENSIVE_CHECKS enables _GLIBCXX_DEBUG, which makes std::sort
check that the compare function is implemented correctly.

To do this it calls it with the first item as both sides.
Which trips the assert here because we think they're
2 capture ranges that overlap, when it's just the same range twice.

Check up front for the two sides being the same item
(same address, not just ==).

Reviewed By: kazu

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

2 years ago[AsmPrinter] Reject ptrtoint to larger size in lowerConstant()
Nikita Popov [Fri, 22 Jul 2022 14:10:37 +0000 (16:10 +0200)]
[AsmPrinter] Reject ptrtoint to larger size in lowerConstant()

When using a ptrtoint to a size larger than the pointer width in a
global initializer, we currently create a ptr & low_bit_mask style
MCExpr, which will later result in a relocation error during object
file emission.

This patch rejects the constant expression already during
lowerConstant(), which results in a much clearer error message
that references the constant expression at fault.

This fixes https://github.com/llvm/llvm-project/issues/56400,
for certain definitions of "fix".

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

2 years ago[ELF] Simplify --build-id/--color-diagnostics with AliasArgs. NFC
Fangrui Song [Mon, 25 Jul 2022 08:14:53 +0000 (01:14 -0700)]
[ELF] Simplify --build-id/--color-diagnostics with AliasArgs. NFC

2 years ago[AArch64] Add f16 fpimm patterns
Rosie Sumpter [Wed, 20 Jul 2022 12:53:59 +0000 (13:53 +0100)]
[AArch64] Add f16 fpimm patterns

This patch recognizes f16 immediates as legal and adds the necessary
patterns. This allows the fadda folding introduced in 05d424d16563
to be applied to the f16 cases.

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

2 years ago[pseudo] Fix minor errors in module grammar
Sam McCall [Mon, 25 Jul 2022 08:00:05 +0000 (10:00 +0200)]
[pseudo] Fix minor errors in module grammar

2 years ago[NFC][GVN] Put phi-translation of 'add' behind a switch
Peter Waller [Thu, 21 Jul 2022 19:33:24 +0000 (20:33 +0100)]
[NFC][GVN] Put phi-translation of 'add' behind a switch

The code in this `#if 0` block appears to be a net benefit. Put it
behind a switch defaulting to off to support experimentation and as a
request for comment.

The codegen impact of enabling this that I'm currently persuing is that
it allows PRE to take place more frequently, particularly in loops with
second order recurrences.

Preliminary experimental data:

Across LNT on AArch64, 54 benchmarks are sped up by >1%, and 42 are
regressed by >1%, the geomean (exec_time_enabled / exec_time_disabled)
of these 96 "1% or greater significance" benchmarks is 0.991. For the
full set of 770 benchmarks it's 0.998.

There are two benchmarks which experience a >30% speedup, and the worst
slowdown is ~12%, and for every benchmark with a slowdown there is a
benckmark which is sped up by a greater factor.

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

2 years ago[flang] Use X->foo() instead of X.getValue().foo() (NFC)
Kazu Hirata [Mon, 25 Jul 2022 07:55:06 +0000 (00:55 -0700)]
[flang] Use X->foo() instead of X.getValue().foo() (NFC)

Flang C++ Style Guide tells us to use *X when the reference is
protected by a presense test.  However, (*X).foo() is a little harder
to read, especially when X is a complicated expression.

This patch slightly deviates from the guide (but retains the spirit)
by using X->foo() instead.

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

2 years ago[flang] Use value instead of getValue (NFC)
Kazu Hirata [Mon, 25 Jul 2022 07:55:05 +0000 (00:55 -0700)]
[flang] Use value instead of getValue (NFC)

Flang C++ Style Guide tells us to use x.value() when no presence test
is obviously protecting the reference.  Since a failure in EXPECT_TRUE
doesn't terminate a given test, I don't count it as "protection" here.

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

2 years ago[Docs] Update GEP docs for opaque pointers
Nikita Popov [Fri, 22 Jul 2022 12:36:27 +0000 (14:36 +0200)]
[Docs] Update GEP docs for opaque pointers

Update the GEP FAQ to use opaque pointers. This requires more than
a syntactic change in some place, because some of the concerns just
don't make sense anymore (trying to index past a ptr member in a
struct for example).

This also fixes uses of incorrect syntax to declare or reference
globals.

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

2 years ago[LangRef] Update for opaque pointers (NFC)
Nikita Popov [Fri, 22 Jul 2022 12:58:07 +0000 (14:58 +0200)]
[LangRef] Update for opaque pointers (NFC)

Update LangRef examples to use opaque pointers in most places.
I've retained typed pointers in a few cases where opaque pointers
don't make much sense, e.g. pointer to pointer bitcasts.

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

2 years ago[llvm-objcopy] Simplify --compress-debug-sections handling with AliasArgs. NFC
Fangrui Song [Mon, 25 Jul 2022 07:31:00 +0000 (00:31 -0700)]
[llvm-objcopy] Simplify --compress-debug-sections handling with AliasArgs. NFC

2 years ago[clang][analyzer] Added partial wide character support to CStringChecker
Balázs Kéri [Mon, 25 Jul 2022 06:30:00 +0000 (08:30 +0200)]
[clang][analyzer] Added partial wide character support to CStringChecker

Support for functions wmemcpy, wcslen, wcsnlen is added to the checker.
Documentation and tests are updated and extended with the new functions.

Reviewed By: martong

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

2 years ago[AArch64][SVE] Add patterns to select masked add/sub instructions
Cullen Rhodes [Mon, 25 Jul 2022 06:37:57 +0000 (06:37 +0000)]
[AArch64][SVE] Add patterns to select masked add/sub instructions

When lowering add(a, select(mask, b, splat(0))) the sel instruction can
be removed by using predicated add/sub instructions.

Reviewed By: paulwalker-arm

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

2 years ago[AArch64][SVE] NFC: Add tests for masked add/sub patterns (D129751)
Cullen Rhodes [Mon, 25 Jul 2022 07:13:13 +0000 (07:13 +0000)]
[AArch64][SVE] NFC: Add tests for masked add/sub patterns (D129751)

2 years ago[llvm-objcopy] Remove getDecompressedSizeAndAlignment. NFC
Fangrui Song [Mon, 25 Jul 2022 07:06:36 +0000 (00:06 -0700)]
[llvm-objcopy] Remove getDecompressedSizeAndAlignment. NFC

2 years ago[SCEV][NFC][CT] Cheaper handling of guards in isBasicBlockEntryGuardedByCond
Max Kazantsev [Mon, 25 Jul 2022 04:56:01 +0000 (11:56 +0700)]
[SCEV][NFC][CT] Cheaper handling of guards in isBasicBlockEntryGuardedByCond

Handle guards uniformly with assumes, rather than iterating through all
block instructions in attempt to find them.

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

2 years ago[Hexagon] Remove isLateInstrFeedsEarlyInstr (NFC)
Kazu Hirata [Mon, 25 Jul 2022 05:55:14 +0000 (22:55 -0700)]
[Hexagon] Remove isLateInstrFeedsEarlyInstr (NFC)

The last use was removed on May 3, 2017 in commit
2af5037d34dd81c8ff2dcc3ee5d3f000c2ec1a01.

This patch also removes isLateResultInstr and isEarlySourceInstr as
they become dead once we remove isLateInstrFeedsEarlyInstr.

2 years agoRemove redundaunt override specifiers (NFC)
Kazu Hirata [Mon, 25 Jul 2022 05:28:11 +0000 (22:28 -0700)]
Remove redundaunt override specifiers (NFC)

Identified with modernize-use-override.

2 years ago[llvm-objcopy] --compress-debug-sections: fix uninitialized ch_reserved for Elf64_Chdr
Fangrui Song [Mon, 25 Jul 2022 05:19:00 +0000 (22:19 -0700)]
[llvm-objcopy] --compress-debug-sections: fix uninitialized ch_reserved for Elf64_Chdr

ch_reserved is uninitialized and the output is not deterministic. Fix it.
Rewrite and improve compress-debug-sections-zlib.test.

2 years ago[clang] Remove redundant virtual specifies (NFC)
Kazu Hirata [Mon, 25 Jul 2022 05:02:58 +0000 (22:02 -0700)]
[clang] Remove redundant virtual specifies (NFC)

Identified with modernize-use-override.

2 years ago[llvm] Remove redundaunt virtual specifiers (NFC)
Kazu Hirata [Mon, 25 Jul 2022 04:50:35 +0000 (21:50 -0700)]
[llvm] Remove redundaunt virtual specifiers (NFC)

Identified with modernize-use-override.

2 years ago[clang] Remove unused forward declarations (NFC)
Kazu Hirata [Mon, 25 Jul 2022 03:51:06 +0000 (20:51 -0700)]
[clang] Remove unused forward declarations (NFC)

2 years ago[clang] better error message for while loops outside of control flow
inclyc [Tue, 12 Jul 2022 16:12:12 +0000 (00:12 +0800)]
[clang] better error message for while loops outside of control flow

report an error when encountering 'while' token parsing declarator

```
clang/test/Parser/while-loop-outside-function.c:3:1: error: while loop outside of a function
while // expected-error {{while loop outside of a function}}
^
clang/test/Parser/while-loop-outside-function.c:7:1: error: while loop outside of a function
while // expected-error {{while loop outside of a function}}
^
```

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

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

2 years ago[mlir][Arithmetic] Fix printing larger integer attributes in arith.const
Marius Hillenbrand [Mon, 25 Jul 2022 03:07:31 +0000 (08:37 +0530)]
[mlir][Arithmetic] Fix printing larger integer attributes in arith.const

For arith.constant operations of integer type, the operation generates
result names that include the value of the constant (i.e., the
IntegerAttr that defines the constant's value). That code currently
assumes integer widths of 64 bits or less and hits an assert with wider
constants or would create truncated and potentially ambiguous names when
built with assertions disabled.

To enable printing arith.constant ops for arbitrarily wide integer
types, change to use the IntegerAttr's function getValue() when
generating result names.

Also, add a regression test.

Reviewed By: bondhugula

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

2 years ago[llvm-objcopy] Remove remnant .zdebug code
Fangrui Song [Mon, 25 Jul 2022 01:52:15 +0000 (18:52 -0700)]
[llvm-objcopy] Remove remnant .zdebug code

2 years ago[Reassociate][NFC] Consistent checking for FastMathFlags suitability
Warren Ristow [Mon, 25 Jul 2022 00:44:30 +0000 (17:44 -0700)]
[Reassociate][NFC] Consistent checking for FastMathFlags suitability

In D129523, it was noted that the approach to check whether a value can
have FastMathFlags was done in different ways, and they should be made
consistent.  This patch makes minor changes to fix that.

Reviewed By: spatel

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

2 years agoUse llvm::less_first and llvm::less_second (NFC)
Kazu Hirata [Sun, 24 Jul 2022 23:21:29 +0000 (16:21 -0700)]
Use llvm::less_first and llvm::less_second (NFC)

2 years ago[NFC] Add parentheses in MathExtra.h
Amaury Séchet [Sun, 24 Jul 2022 22:02:59 +0000 (22:02 +0000)]
[NFC] Add parentheses in MathExtra.h

The code used to cause a warning:
  llvm/include/llvm/Support/MathExtras.h:751:39: warning: suggest parentheses around ‘-’ in operand of ‘&’ [-Wparentheses]
    751 |   assert(Align != 0 && (Align & Align - 1) == 0 &&
        |

2 years agoUse any_of (NFC)
Kazu Hirata [Sun, 24 Jul 2022 21:48:11 +0000 (14:48 -0700)]
Use any_of (NFC)

2 years ago[Hexagon] Remove unused declaration CanReturnSmallStruct (NFC)
Kazu Hirata [Sun, 24 Jul 2022 21:48:09 +0000 (14:48 -0700)]
[Hexagon] Remove unused declaration CanReturnSmallStruct (NFC)

The declaration was introduced without a corresponding definition on
Dec 12, 2011 in commit 1213a7a57fdcb6c875b3f79103fc96d3e9d30b40.

2 years ago[Hexagon] Remove unused declaration SelectZeroExtend (NFC)
Kazu Hirata [Sun, 24 Jul 2022 21:48:08 +0000 (14:48 -0700)]
[Hexagon] Remove unused declaration SelectZeroExtend (NFC)

The corresponding definition was removed on Jan 23, 2018 in commit
3780a0e1fae463e9195ae3fc2ba8424608310d8a.

2 years ago[IPO] Use range-based for loops (NFC)
Kazu Hirata [Sun, 24 Jul 2022 21:48:06 +0000 (14:48 -0700)]
[IPO] Use range-based for loops (NFC)

2 years ago[ValueTracking] allow vector types in isImpliedCondition()
Sanjay Patel [Sun, 24 Jul 2022 21:05:40 +0000 (17:05 -0400)]
[ValueTracking] allow vector types in isImpliedCondition()

The matching of constants assumed integers, but we can handle
splat vector constants seamlessly with m_APInt.

2 years ago[ValueTracking] add test for isImpliedCondition with vector types; NFC
Sanjay Patel [Sun, 24 Jul 2022 20:58:04 +0000 (16:58 -0400)]
[ValueTracking] add test for isImpliedCondition with vector types; NFC

2 years ago[PhaseOrdering] add explanatory comment for test; NFC
Sanjay Patel [Fri, 22 Jul 2022 20:09:29 +0000 (16:09 -0400)]
[PhaseOrdering] add explanatory comment for test; NFC

This note was going to be added in D129650, but we
solved the problem by reverting another patch, and
I missed transferring the comment.

2 years ago[gn build] Port b7aa9c4ac8e7
LLVM GN Syncbot [Sun, 24 Jul 2022 20:22:32 +0000 (20:22 +0000)]
[gn build] Port b7aa9c4ac8e7

2 years ago[libc++] Granularize some more type_traits
Nikolas Klauser [Sun, 24 Jul 2022 14:03:12 +0000 (16:03 +0200)]
[libc++] Granularize some more type_traits

Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny

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

2 years ago[CodeGen] Remove a redundant void (NFC)
Kazu Hirata [Sun, 24 Jul 2022 19:27:14 +0000 (12:27 -0700)]
[CodeGen] Remove a redundant void (NFC)

Identified with modernize-redundant-void-arg.

2 years ago[ExecutionEngine] Fix a header guard (NFC)
Kazu Hirata [Sun, 24 Jul 2022 19:27:12 +0000 (12:27 -0700)]
[ExecutionEngine] Fix a header guard (NFC)

Identified with llvm-header-guard.

2 years agoRemove redundant string initialization (NFC)
Kazu Hirata [Sun, 24 Jul 2022 19:27:11 +0000 (12:27 -0700)]
Remove redundant string initialization (NFC)

Identified with readability-redundant-string-init.

2 years ago[lldb] Remove redundant member initialization (NFC)
Kazu Hirata [Sun, 24 Jul 2022 19:27:09 +0000 (12:27 -0700)]
[lldb] Remove redundant member initialization (NFC)

Identified with readability-redundant-member-init.

2 years ago[lldb] Use nullptr instead of NULL (NFC)
Kazu Hirata [Sun, 24 Jul 2022 19:27:08 +0000 (12:27 -0700)]
[lldb] Use nullptr instead of NULL (NFC)

Identified with modernize-use-nullptr.

2 years ago[lldb] Use true instead of 0 (NFC)
Kazu Hirata [Sun, 24 Jul 2022 19:27:06 +0000 (12:27 -0700)]
[lldb] Use true instead of 0 (NFC)

Identified with modernize-use-bool-literals.

2 years ago[llvm] Remove unused forward declarations (NFC)
Kazu Hirata [Sun, 24 Jul 2022 19:27:05 +0000 (12:27 -0700)]
[llvm] Remove unused forward declarations (NFC)

2 years ago[ELF] Optimize some non-constant alignTo with alignToPowerOf2. NFC
Fangrui Song [Sun, 24 Jul 2022 18:20:49 +0000 (11:20 -0700)]
[ELF] Optimize some non-constant alignTo with alignToPowerOf2. NFC

My x86-64 lld executable is 2KiB smaller. .eh_frame writing gets faster as there
were lots of divisions.

2 years ago[gn build] Port 46ae26e7eb70
LLVM GN Syncbot [Sun, 24 Jul 2022 17:43:27 +0000 (17:43 +0000)]
[gn build] Port 46ae26e7eb70

2 years ago[Driver] Enable some sanitizers on FreeBSD AArch64
Andrew Turner [Sun, 24 Jul 2022 17:41:21 +0000 (10:41 -0700)]
[Driver] Enable some sanitizers on FreeBSD AArch64

They have been ported and tested to work on AArch64
(see D125883, D125758, and D125873).

Reviewed By: dim, MaskRay

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

2 years ago[clang-tidy] implement new check 'misc-const-correctness' to add 'const' to unmodifie...
Jonas Toth [Sun, 24 Jul 2022 17:35:52 +0000 (19:35 +0200)]
[clang-tidy] implement new check 'misc-const-correctness' to add 'const' to unmodified variables

This patch connects the check for const-correctness with the new general
utility to add `const` to variables.
The code-transformation is only done, if the detected variable for const-ness
is not part of a group-declaration.

The check allows to control multiple facets of adding `const`, e.g. if pointers themself should be
marked as `const` if they are not changed.

Reviewed By: njames93

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

2 years ago[compiler-rt][CMake] Enable TF intrinsics on powerpc32 Linux
Khem Raj [Sun, 24 Jul 2022 17:17:22 +0000 (10:17 -0700)]
[compiler-rt][CMake] Enable TF intrinsics on powerpc32 Linux

clang generates calls to these intrinsics when used for ppc32/linux, when using libgcc this works ok but when using compiler-rt for rtlib it fails with missing intrinsic symbols. also see [1]

[1] https://lists.llvm.org/pipermail/llvm-dev/2014-May/072784.html

Reviewed By: MaskRay, glaubitz

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

2 years ago[X86] Autogenerate atomic tests. NFC
Amaury Séchet [Sun, 24 Jul 2022 16:38:58 +0000 (16:38 +0000)]
[X86] Autogenerate atomic tests. NFC

2 years agoRegAllocGreedy: Fix subranges when rematerializing dead subreg defs
Matt Arsenault [Wed, 15 Jun 2022 01:18:21 +0000 (21:18 -0400)]
RegAllocGreedy: Fix subranges when rematerializing dead subreg defs

This would create a new interval missing the subrange and hit this
verifier error:

*** Bad machine code: Live interval for subreg operand has no subranges ***
- function:    test_remat_subreg_def
- basic block: %bb.0  (0xa568758) [0B;128B)
- instruction: 32B dead undef %4.sub0:vreg_64 = V_MOV_B32_e32 2, implicit $exec

2 years ago[X86] Autogenerate cfguard-x86-64-vectorcall.ll. NFC
Amaury Séchet [Sun, 24 Jul 2022 15:45:51 +0000 (15:45 +0000)]
[X86] Autogenerate cfguard-x86-64-vectorcall.ll. NFC

2 years agoAMDGPU: Fix broken test checks
Matt Arsenault [Sat, 23 Jul 2022 19:07:03 +0000 (15:07 -0400)]
AMDGPU: Fix broken test checks

2 years ago[DAG] visitSMUL_LOHI/visitUMUL_LOHI - ensure we canonicalize constants to the RHS
Simon Pilgrim [Sun, 24 Jul 2022 15:09:52 +0000 (16:09 +0100)]
[DAG] visitSMUL_LOHI/visitUMUL_LOHI - ensure we canonicalize constants to the RHS

2 years ago[X86] Autogenerate some of the fp128 tests. NFC
Amaury Séchet [Sun, 24 Jul 2022 14:32:36 +0000 (14:32 +0000)]
[X86] Autogenerate some of the fp128 tests. NFC

2 years ago[DAG] getNode - assert that SMUL_LOHI/UMUL_LOHI nodes have the correct ops + types
Simon Pilgrim [Sun, 24 Jul 2022 14:23:13 +0000 (15:23 +0100)]
[DAG] getNode - assert that SMUL_LOHI/UMUL_LOHI nodes have the correct ops + types

2 years ago[X86] Regenerate hoist-and-by-const-from-lshr-in-eqcmp-zero.ll with common SSE2 prefix
Simon Pilgrim [Sun, 24 Jul 2022 13:48:18 +0000 (14:48 +0100)]
[X86] Regenerate hoist-and-by-const-from-lshr-in-eqcmp-zero.ll with common SSE2 prefix

2 years ago[Clang] Add missing paper revisions in the release notes [NFC]
Corentin Jabot [Sun, 24 Jul 2022 14:24:11 +0000 (16:24 +0200)]
[Clang] Add missing paper revisions in the release notes [NFC]

2 years ago[clang] Fix incorrect constant folding of `if consteval`
Corentin Jabot [Sun, 24 Jul 2022 06:55:49 +0000 (08:55 +0200)]
[clang] Fix incorrect constant folding of `if consteval`

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

`if consteval` was evaluated incorrectly when in a
non-constant context that could be constant-folded.

Reviewed By: aaron.ballman

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

2 years ago[Clang] De-deprecate volatile compound operations
Corentin Jabot [Sat, 23 Jul 2022 12:38:48 +0000 (14:38 +0200)]
[Clang] De-deprecate volatile compound operations

As per P2327R1,

|=, &= and ^= are no longer deprecated in all languages mode.

Reviewed By: aaron.ballman

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

2 years agoFix crash in ObjC codegen introduced with 5ab6ee75994d645725264e757d67bbb1c96fb2b6
David Chisnall [Sun, 24 Jul 2022 10:56:12 +0000 (11:56 +0100)]
Fix crash in ObjC codegen introduced with 5ab6ee75994d645725264e757d67bbb1c96fb2b6

5ab6ee75994d645725264e757d67bbb1c96fb2b6 assumed that if `RValue::isScalar()` returns true then `RValue::getScalarVal` will return a valid value.  This is not the case when the return value is `void` and so void message returns would crash if they hit this path.  This is triggered only for cases where the nil-handling path needs to do something non-trivial (destroy arguments that should be consumed by the callee).

Reviewed By: triplef

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

2 years ago[DAG] MaskedVectorIsZero - don't bother with (-1).isSubsetOf mask check. NFC.
Simon Pilgrim [Sun, 24 Jul 2022 12:12:21 +0000 (13:12 +0100)]
[DAG] MaskedVectorIsZero - don't bother with (-1).isSubsetOf mask check. NFC.

Just use KnownBits::isZero() to ensure all the bits are known zero.

2 years ago[DAG] SimplifyMultipleUseDemandedBits - early-out for any scalable vector types
Simon Pilgrim [Sun, 24 Jul 2022 11:59:43 +0000 (12:59 +0100)]
[DAG] SimplifyMultipleUseDemandedBits - early-out for any scalable vector types

Noticed while working to remove SelectionDAG::GetDemandedBits - we were relying on the callers to have already bailed for scalable vectors

2 years ago[DAG] SimplifyDemandedVectorElts - if every and/mul element-pair has a zero/undef...
Simon Pilgrim [Sun, 24 Jul 2022 11:00:31 +0000 (12:00 +0100)]
[DAG] SimplifyDemandedVectorElts - if every and/mul element-pair has a zero/undef then just constant fold to zero

2 years ago[X86] combineAndnp - remove unused variable. NFC.
Simon Pilgrim [Sun, 24 Jul 2022 10:32:44 +0000 (11:32 +0100)]
[X86] combineAndnp - remove unused variable. NFC.

2 years ago[X86][SSE] Enable X86ISD::ANDNP constant folding
Simon Pilgrim [Sun, 24 Jul 2022 10:07:34 +0000 (11:07 +0100)]
[X86][SSE] Enable X86ISD::ANDNP constant folding

2 years ago[X86] Don't assume an AND/ANDNP element is undef/undemanded just because one element...
Simon Pilgrim [Sun, 24 Jul 2022 09:53:38 +0000 (10:53 +0100)]
[X86] Don't assume an AND/ANDNP element is undef/undemanded just because one element is undef

For mask ops like these, the other operand's corresponding element might be zero (result = zero) - so we must demand all the bits and that element.

This appears to be what D128570 was trying to fix - both sides of the funnel shift mask of the vXi64 (legalized to v2Xi32) were incorrectly simplifying the upper 32-bit halves to undef, resulting in bad folds later on.

I intend to address the test case regressions, but this close to the release branch I'd prefer to get a fix in first.

2 years ago[MC] Remove unused renameELFSection
Fangrui Song [Sun, 24 Jul 2022 08:23:07 +0000 (01:23 -0700)]
[MC] Remove unused renameELFSection