platform/upstream/llvm.git
2 years ago[DebugInfo] Fix end_sequence of debug_line in LTO Object
Kyungwoo Lee [Mon, 15 Nov 2021 04:18:36 +0000 (20:18 -0800)]
[DebugInfo] Fix end_sequence of debug_line in LTO Object

In a LTO build, the `end_sequence` in debug_line table for each compile unit (CU) points the end of text section which merged all CUs. The `end_sequence` needs to point to the end of each CU's range. This bug often causes invalid `debug_line` table in the final `.dSYM` binary for MachO after running `dsymutil` which tries to compensate an out-of-range address of `end_sequence`.
The fix is to sync the line table termination with the range operations that are already maintained in DwarfDebug. When CU or section changes, or nodebug functions appear or module is finished, the prior pending line table is terminated using the last range label. In the MC path where no range is tracked, the old logic is conservatively used to end the line table using the section end symbol.

Reviewed By: dblaikie

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

2 years ago[msan] Fix test with GLIBC 2.34
Vitaly Buka [Mon, 15 Nov 2021 04:15:45 +0000 (20:15 -0800)]
[msan] Fix test with GLIBC 2.34

PTHREAD_STACK_MIN is not a constexpr

2 years ago[llvm] Use range-based for loops with instructions (NFC)
Kazu Hirata [Mon, 15 Nov 2021 03:40:48 +0000 (19:40 -0800)]
[llvm] Use range-based for loops with instructions (NFC)

2 years ago[llvm] Use isa instead of dyn_cast (NFC)
Kazu Hirata [Mon, 15 Nov 2021 03:40:46 +0000 (19:40 -0800)]
[llvm] Use isa instead of dyn_cast (NFC)

2 years ago[AMDGPU] Remove selectStoreIntrinsic (NFC)
Kazu Hirata [Mon, 15 Nov 2021 03:40:44 +0000 (19:40 -0800)]
[AMDGPU] Remove selectStoreIntrinsic (NFC)

The last use was removed on Jan 13, 2020 in commit
533d650e947a2f7216a315aeb8c79ac1d4740e5f.

2 years ago[NFC] Use Optional<ProfileCount> to model invalid counts
Mircea Trofin [Sun, 14 Nov 2021 06:03:10 +0000 (22:03 -0800)]
[NFC] Use Optional<ProfileCount> to model invalid counts

ProfileCount could model invalid values, but a user had no indication
that the getCount method could return bogus data. Optional<ProfileCount>
addresses that, because the user must dereference the optional. In
addition, the patch removes concept duplication.

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

2 years ago[PowerPC] guard update form prepare with non-const increment with option
Chen Zheng [Tue, 9 Nov 2021 09:47:48 +0000 (09:47 +0000)]
[PowerPC] guard update form prepare with non-const increment with option

Reviewed By: jsji

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

2 years ago[NFC] Trim trailing whitespace in *.rst
Shao-Ce SUN [Mon, 15 Nov 2021 01:17:08 +0000 (09:17 +0800)]
[NFC] Trim trailing whitespace in *.rst

2 years ago[sanitizer] Disable test incompartible with recert GLIBC
Vitaly Buka [Mon, 15 Nov 2021 00:21:07 +0000 (16:21 -0800)]
[sanitizer] Disable test incompartible with recert GLIBC

2 years ago[llvm-jitlink] Add an explicit -debugger-support option.
Lang Hames [Sun, 14 Nov 2021 23:42:45 +0000 (15:42 -0800)]
[llvm-jitlink] Add an explicit -debugger-support option.

Commit 69be352a196 restricted the MachO debugger support testcase to run on
Darwin only, but we still need to disable debugger support by default for
other noexec tests.

This patch introduces a -debugger-support option to llvm-jitlink that is
on-by-default when executing code, and off-by-default for noexec tests. This
should prevent regression tests from trying (and failing) to set up MachO
debugging support when running on non-Darwin platforms.

to explicitly enable/disable support.

2 years agoRevert "[clang] retain type sugar in auto / template argument deduction"
Matheus Izvekov [Sun, 14 Nov 2021 23:29:05 +0000 (00:29 +0100)]
Revert "[clang] retain type sugar in auto / template argument deduction"

This reverts commit 4d8fff477e024698facd89741cc6cf996708d598.

2 years ago[mlir][ods] AttrOrTypeDef format: parse types
Mogball [Sun, 14 Nov 2021 23:01:59 +0000 (23:01 +0000)]
[mlir][ods] AttrOrTypeDef format: parse types

Add template specialization to `FieldParser` for parsing types.

Reviewed By: mehdi_amini

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

2 years ago[mlir][ods] Fix unused uniqued attr constraint
Mogball [Sun, 14 Nov 2021 23:23:14 +0000 (23:23 +0000)]
[mlir][ods] Fix unused uniqued attr constraint

Derived attributes' constraints are no longer uniqued - derived
attributes' verifiers are not automatically generated.

2 years ago[gn build] Port 69be352a1961
LLVM GN Syncbot [Sun, 14 Nov 2021 22:53:50 +0000 (22:53 +0000)]
[gn build] Port 69be352a1961

2 years agoReapply "[ORC] Initial MachO debugging support (via GDB JIT debug.." with fixes.
Lang Hames [Sun, 14 Nov 2021 17:34:14 +0000 (09:34 -0800)]
Reapply "[ORC] Initial MachO debugging support (via GDB JIT debug.." with fixes.

This reapplies e1933a0488a50eb939210808fc895d374570d891 (which was reverted in
f55ba3525eb19baed7d3f23638cbbd880246a370 due to bot failures, e.g.
https://lab.llvm.org/buildbot/#/builders/117/builds/2768).

The bot failures were due to a missing symbol error: We use the input object's
mangling to decide how to mangle the debug-info registration function name. This
caused lookup of the registration function to fail when the input object
mangling didn't match the host mangling.

Disbaling the test on non-Darwin platforms is the easiest short-term solution.
I have filed https://llvm.org/PR52503 with a proposed longer term solution.

2 years agoUse std::make_unique instead of `new` to reinitalize a unique_ptr (NFC)
Mehdi Amini [Sun, 14 Nov 2021 22:28:54 +0000 (22:28 +0000)]
Use std::make_unique instead of `new` to reinitalize a unique_ptr (NFC)

Fix a clang-tidy warning.

2 years ago[LoopVectorize] Add PR41179 test case
Simon Pilgrim [Sun, 14 Nov 2021 21:53:24 +0000 (21:53 +0000)]
[LoopVectorize] Add PR41179 test case

2 years agoFollow-up to D77598: Simplify API by passing template parameters only when used/to...
David Blaikie [Sun, 14 Nov 2021 19:15:05 +0000 (11:15 -0800)]
Follow-up to D77598: Simplify API by passing template parameters only when used/to imply "TemplOverloaded/overloadable"

These arguments were redundant, and other parts of D77598 did rely on
the presence/absence of template parameters to imply whether types
should be included for the argument (like
clang::printTemplateArgumentList) so do that here too.

2 years ago[X86] Add getPack helper
Simon Pilgrim [Sun, 14 Nov 2021 21:27:15 +0000 (21:27 +0000)]
[X86] Add getPack helper

This helper provides a more complete approach for lowering to X86ISD::PACKSS/PACKUS nodes - testing for existing suitable sign/zero extension before recreating it.

It also optionally packs the upper half instead of the lower half.

2 years ago[llvm-reduce] Remove unnecessary loop.
Florian Hahn [Sat, 13 Nov 2021 20:05:58 +0000 (20:05 +0000)]
[llvm-reduce] Remove unnecessary loop.

After cd8aa234fdd2, there's no need to collect a vector of basic blocks
to keep first. Remove the first loop.

2 years ago[sanitizer] Fix test with GLIBC 2.34
Vitaly Buka [Sun, 14 Nov 2021 19:30:13 +0000 (11:30 -0800)]
[sanitizer] Fix test with GLIBC 2.34

2 years ago[SPARC] Zero-extend the operands when doing UMULO on 64-bit integers
Koakuma [Sun, 14 Nov 2021 18:56:41 +0000 (19:56 +0100)]
[SPARC] Zero-extend the operands when doing UMULO on 64-bit integers

On SPARC, S/UMULO operation on 64-bit integers works by extending the value to 128-bit, then doing a multiplication and checking the upper half of the result.
This makes UMULO works correctly by putting a zero in the upper half rather than doing a sign extension.

Reviewed By: LemonBoy

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

2 years ago[mlir] FlatAffineConstraint parsing for unit tests
Christian Ulmann [Sun, 14 Nov 2021 18:19:19 +0000 (23:49 +0530)]
[mlir] FlatAffineConstraint parsing for unit tests

This patch adds functionality to parse FlatAffineConstraints from a
StringRef with the intention to be used for unit tests. This should
make the construction of FlatAffineConstraints easier for testing
purposes.

The patch contains an example usage of the functionality in a unit test that
uses FlatAffineConstraints.

Reviewed By: bondhugula

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

2 years ago[clang] Use isa instead of dyn_cast (NFC)
Kazu Hirata [Sun, 14 Nov 2021 17:32:40 +0000 (09:32 -0800)]
[clang] Use isa instead of dyn_cast (NFC)

2 years ago[llvm] Use range-based for loops with User::operands (NFC)
Kazu Hirata [Sun, 14 Nov 2021 17:32:38 +0000 (09:32 -0800)]
[llvm] Use range-based for loops with User::operands (NFC)

2 years ago[llvm] Use range-based for loops with CallBase::args (NFC)
Kazu Hirata [Sun, 14 Nov 2021 17:32:36 +0000 (09:32 -0800)]
[llvm] Use range-based for loops with CallBase::args (NFC)

2 years ago[NFC][X86][Costmodel] Improve test coverage for {i16,i32,i64}->i8 vector trunc
Roman Lebedev [Sun, 14 Nov 2021 17:24:27 +0000 (20:24 +0300)]
[NFC][X86][Costmodel] Improve test coverage for {i16,i32,i64}->i8 vector trunc

2 years ago[NFC][X86][Costmodel] Improve test coverage for i8->{i16,i32,i64} vector *ext
Roman Lebedev [Sun, 14 Nov 2021 17:16:11 +0000 (20:16 +0300)]
[NFC][X86][Costmodel] Improve test coverage for i8->{i16,i32,i64} vector *ext

2 years ago[X86][Costmodel] `getReplicationShuffleCost()`: promote 16 bit-wide elements to 32...
Roman Lebedev [Sun, 14 Nov 2021 16:53:01 +0000 (19:53 +0300)]
[X86][Costmodel] `getReplicationShuffleCost()`: promote 16 bit-wide elements to 32 bit when no AVX512BW

The basic idea is simple, if we don't have native shuffle for this element type,
then we must have native shuffle for wider element type,
so promote, replicate, demote.

I believe, asking `getCastInstrCost(Instruction::Trunc` is correct semantically,
case in point `trunc <32 x i32> to <32 x i8>` aka 2 * ZMM will naively result in
2 * XMM, that then will be packed into 1 * YMM,
and it should count the cost of said packing,
not just the truncations.

Reviewed By: RKSimon

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

2 years ago[NFC][TTI] `getReplicationShuffleCost()`: s/Replicated/Dst/
Roman Lebedev [Sun, 14 Nov 2021 16:56:10 +0000 (19:56 +0300)]
[NFC][TTI] `getReplicationShuffleCost()`: s/Replicated/Dst/

'Replicated' is mouthful and somewhat ambigious,
while 'destination' is pretty self-explanatory.

2 years ago[InstCombine] add tests for or-xor logic fold; NFC
Mehrnoosh Heidarpour [Sun, 14 Nov 2021 16:06:07 +0000 (11:06 -0500)]
[InstCombine] add tests for or-xor logic fold; NFC

Baseline tests for D113783

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

2 years ago[IR] Define ptrauth intrinsics.
Ahmed Bougacha [Mon, 27 Sep 2021 15:00:00 +0000 (08:00 -0700)]
[IR] Define ptrauth intrinsics.

This defines the new `@llvm.ptrauth.` pointer authentication intrinsics:
sign, auth, strip, blend, and sign_generic, documented in PointerAuth.md.

Pointer Authentication is a mechanism by which certain pointers are
signed.  When a pointer gets signed, a cryptographic hash of its value
and other values (pepper and salt) is stored in unused bits of that
pointer.

Before the pointer is used, it needs to be authenticated, i.e., have its
signature checked.  This prevents pointer values of unknown origin from
being used to replace the signed pointer value.

sign and auth provide the core operations.  strip removes the ptrauth
bits from a signed pointer without checking them.  sign_generic allows
signing non-pointer values.  Finally, blend combines salt values
("discriminators") to derive more targeted and less reusable ones.

In later patches, we implement primary backend support for these
intrinsics using the AArch64 PAuth feature, and build on that to
implement the arm64e Darwin ABI and ELF PAuth ABI Extension in clang.

For more details, see the docs page, as well as our llvm-dev RFC:
  http://lists.llvm.org/pipermail/llvm-dev/2019-October/136091.html
or our 2019 Developers' Meeting talk.

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

2 years ago[X86][Costmodel] `trunc v8i64 to v16i16/v32i16` can appear after legalization, cost...
Roman Lebedev [Sun, 14 Nov 2021 15:41:38 +0000 (18:41 +0300)]
[X86][Costmodel] `trunc v8i64 to v16i16/v32i16` can appear after legalization, cost is same as for `trunc v8i64 to v8i16`

Same as D113842, but for i64

Reviewed By: RKSimon

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

2 years ago[X86][Costmodel] `trunc v16i32 to v32i16` can appear after legalization, cost is...
Roman Lebedev [Sun, 14 Nov 2021 15:41:37 +0000 (18:41 +0300)]
[X86][Costmodel] `trunc v16i32 to v32i16` can appear after legalization, cost is same as for `trunc v16i32 to v16i16`

This was noticed in D113609, hopefully it unblocks that patch.
There are likely other similar problems.

Reviewed By: RKSimon

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

2 years ago[NFC][InlineFunction] Renamed some vars to conform to coding style
Mircea Trofin [Sun, 14 Nov 2021 06:29:38 +0000 (22:29 -0800)]
[NFC][InlineFunction] Renamed some vars to conform to coding style

2 years ago[DAGCombiner] match inverted/swapped patterns for vselect of mask of signbit
Sanjay Patel [Sun, 14 Nov 2021 14:25:00 +0000 (09:25 -0500)]
[DAGCombiner] match inverted/swapped patterns for vselect of mask of signbit

This was noted as a follow-up to D113212 / D113426:
4fc1fc4005f7
7e30404c3b6c
11522cfcad6b

https://alive2.llvm.org/ce/z/e4o96b

The canonicalization rules for these IR patterns are complicated,
and we were not matching the expected forms in 2 out of the 3
cases. We can make codegen more robust by matching the swapped
forms (and that will also work if these patterns are created late).

2 years ago[clang-format][c++2b] support removal of the space between auto and {} in P0849R8
mydeveloperday [Sun, 14 Nov 2021 14:12:42 +0000 (14:12 +0000)]
[clang-format][c++2b] support removal of the space between auto and {} in P0849R8

Looks like the work of {D113393} requires manual clang-formatting intervention.
Removal of the space between `auto` and `{}`

Reviewed By: HazardyKnusperkeks, Quuxplusone

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

2 years ago[X86] Widen 128/256-bit VPTERNLOG patterns to 512-bit on non-VLX targets
Simon Pilgrim [Sun, 14 Nov 2021 13:40:53 +0000 (13:40 +0000)]
[X86] Widen 128/256-bit VPTERNLOG patterns to 512-bit on non-VLX targets

Similar to what we've done for other ops, this patch widens VPTERNLOG to a 512-bit op for non-VLX targets.

Fixes regressions in D113192

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

2 years ago[NFC][X86][Costmodel] Improve test coverage for {i32,i64}->i16 vector *ext
Roman Lebedev [Sun, 14 Nov 2021 13:07:30 +0000 (16:07 +0300)]
[NFC][X86][Costmodel] Improve test coverage for {i32,i64}->i16 vector *ext

See https://reviews.llvm.org/D113609 - some of these costs seem wrong.

2 years ago[NFC][X86][Costmodel] Improve test coverage for i16->{i32,i64} vector *ext
Roman Lebedev [Sun, 14 Nov 2021 12:47:52 +0000 (15:47 +0300)]
[NFC][X86][Costmodel] Improve test coverage for i16->{i32,i64} vector *ext

2 years ago[NFC][SROA] Revisit test coverage in non-capturing-call.ll
Roman Lebedev [Sun, 14 Nov 2021 12:29:32 +0000 (15:29 +0300)]
[NFC][SROA] Revisit test coverage in non-capturing-call.ll

2 years ago[TypePromotion] Extend TypePromotion::isSafeWrap
David Green [Sun, 14 Nov 2021 11:18:31 +0000 (11:18 +0000)]
[TypePromotion] Extend TypePromotion::isSafeWrap

This modifies the preconditions of TypePromotion's isSafeWrap
method, to allow it to work from all constants from the ICmp.
Using the code:
  %a = add %x, C1
  %c = icmp ult %a, C2

According to Alive, we can prove that is equivalent to
icmp ult (add zext(%x), sext(C1)), zext(C2)  given
C1 <=s 0 and C1 >s C2.
https://alive2.llvm.org/ce/z/CECYZB
Which is similar to what is already present. We can also
prove icmp ult (add zext(%x), sext(C1)), sext(C2) given
C1 <=s 0 and C1 <=s C2.
https://alive2.llvm.org/ce/z/KKgyeL

The PrepareWrappingAdds method was removed, and the
constants are now altered to sext or zext directly as
required by the above methods.

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

2 years ago[DwarfCompileUnit] getOrCreateCommonBlock(): check for existing entity first. NFCI
Kristina Bessonova [Tue, 2 Nov 2021 18:37:48 +0000 (20:37 +0200)]
[DwarfCompileUnit] getOrCreateCommonBlock(): check for existing entity first. NFCI

For global variables and common blocks there is no way to create entities
through getOrCreateContextDIE(), so no need to obtain the context first.

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

2 years ago[DwarfCompileUnit] getOrCreateGlobalVariableDIE(): remove outdated comment. NFC
Kristina Bessonova [Sun, 14 Nov 2021 08:56:44 +0000 (10:56 +0200)]
[DwarfCompileUnit] getOrCreateGlobalVariableDIE(): remove outdated comment. NFC

2 years ago[sanitizer] Another try to fix the test with GLIBC 2.34
Vitaly Buka [Sat, 13 Nov 2021 22:47:27 +0000 (14:47 -0800)]
[sanitizer] Another try to fix the test with GLIBC 2.34

2 years ago[gn build] Port f55ba3525eb1
LLVM GN Syncbot [Sun, 14 Nov 2021 08:26:05 +0000 (08:26 +0000)]
[gn build] Port f55ba3525eb1

2 years agoRevert "[ORC] Initial MachO debugging support (via GDB JIT debug..."
Lang Hames [Sun, 14 Nov 2021 08:14:39 +0000 (00:14 -0800)]
Revert "[ORC] Initial MachO debugging support (via GDB JIT debug..."

This reverts commit e1933a0488a50eb939210808fc895d374570d891 until I can look
into bot failures.

2 years ago[llvm] Use GetElementPtrInst::indices (NFC)
Kazu Hirata [Sun, 14 Nov 2021 05:43:28 +0000 (21:43 -0800)]
[llvm] Use GetElementPtrInst::indices (NFC)

2 years ago[sanitizer][aarch64] fix clone system call's inline assembly
hyeongyu kim [Sun, 14 Nov 2021 00:45:40 +0000 (09:45 +0900)]
[sanitizer][aarch64] fix clone system call's inline assembly

Return value of the system call was not returned normally.
It was discussed at https://reviews.llvm.org/D105169.

2 years ago[sanitizer] Fix test for GLIBC 2.31
Vitaly Buka [Sat, 13 Nov 2021 22:24:50 +0000 (14:24 -0800)]
[sanitizer] Fix test for GLIBC 2.31

Newer GLIBC uses sysconf to get SIGSTKSZ.

2 years ago[gn build] Port e1933a0488a5
LLVM GN Syncbot [Sat, 13 Nov 2021 21:44:00 +0000 (21:44 +0000)]
[gn build] Port e1933a0488a5

2 years ago[ORC] Initial MachO debugging support (via GDB JIT debug registration interface)
Lang Hames [Thu, 11 Nov 2021 23:19:21 +0000 (15:19 -0800)]
[ORC] Initial MachO debugging support (via GDB JIT debug registration interface)

This commit adds a new plugin, GDBJITDebugInfoRegistrationPlugin, that checks
for objects containing debug info and registers any debug info found via the
GDB JIT registration API.

To enable this registration without redundantly representing non-debug sections
this plugin synthesizes a new embedded object within a section of the LinkGraph.
An allocation action is used to make the registration call.

Currently MachO only. ELF users can still use the DebugObjectManagerPlugin. The
two are likely to be merged in the near future.

2 years ago[GVN][NFC] Remove redundant check
ksyx [Sat, 13 Nov 2021 20:59:43 +0000 (15:59 -0500)]
[GVN][NFC] Remove redundant check

The if-check above deleted part guarantees that StoreOffset <= LoadOffset
and that StoreOffset + StoreSize >= LoadOffset + LoadSize, and given that
LoadOffset + LoadSize > LoadOffset when LoadSize > 0. Thus, this shows
StoreOffset + StoreSize > LoadOffset is guaranteed given LoadSize > 0,
while it could be meaningless to have a type with nonpositive size, so that
the check could be removed.

Part of revision D100179
Reviewed By: nikic

2 years agoreland: [VFS] Use original path when falling back to external FS
Keith Smiley [Sat, 13 Nov 2021 18:13:38 +0000 (10:13 -0800)]
reland: [VFS] Use original path when falling back to external FS

This reverts commit f0cf544d6f6fe6cbca4c07772998272d6bb433d8.

Just a small change to fix:

```
/home/buildbot/as-builder-4/llvm-clang-x86_64-expensive-checks-ubuntu/llvm-project/llvm/lib/Support/VirtualFileSystem.cpp: In static member function ‘static llvm::ErrorOr<std::unique_ptr<llvm::vfs::File> > llvm::vfs::File::getWithPath(llvm::ErrorOr<std::unique_ptr<llvm::vfs::File> >, const llvm::Twine&)’:
/home/buildbot/as-builder-4/llvm-clang-x86_64-expensive-checks-ubuntu/llvm-project/llvm/lib/Support/VirtualFileSystem.cpp:2084:10: error: could not convert ‘F’ from ‘std::unique_ptr<llvm::vfs::File>’ to ‘llvm::ErrorOr<std::unique_ptr<llvm::vfs::File> >’
   return F;
          ^
```

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

2 years agoFix some clang-tidy reports in MLIR (NFC)
Mehdi Amini [Sat, 13 Nov 2021 20:01:12 +0000 (20:01 +0000)]
Fix some clang-tidy reports in MLIR (NFC)

Mostly replace uses of `container.size()` with `container.empty()` in
conditionals when applicable.

2 years ago[mlir][ods] Fix incorrect name in comment (NFC)
Mogball [Sat, 13 Nov 2021 20:06:48 +0000 (20:06 +0000)]
[mlir][ods] Fix incorrect name in comment (NFC)

2 years ago[clangd] Fix function-arg-placeholder suppression with macros.
Sam McCall [Fri, 12 Nov 2021 14:03:23 +0000 (15:03 +0100)]
[clangd] Fix function-arg-placeholder suppression with macros.

While here, unhide function-arg-placeholders flag. It's reasonable to want and
maybe we should consider making it default.

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

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

2 years ago[ARM/AArch64] Move REQUIRES after update_cc_test_checks line. NFC
David Green [Sat, 13 Nov 2021 19:09:01 +0000 (19:09 +0000)]
[ARM/AArch64] Move REQUIRES after update_cc_test_checks line. NFC

c17d9b4b125e5561925aa added REQUIRES lines to a lot of Arm and AArch64
test, but added them to the very beginning, before the existing
update_cc_test_checks lines. This just moves them later so as to not
mess up the existing ordering when the checks are regenerated.

2 years agoRevert "[VFS] Use original path when falling back to external FS"
Keith Smiley [Sat, 13 Nov 2021 18:11:25 +0000 (10:11 -0800)]
Revert "[VFS] Use original path when falling back to external FS"

```
/work/omp-vega20-0/openmp-offload-amdgpu-runtime/llvm.src/llvm/lib/Support/VirtualFileSystem.cpp: In static member function 'static llvm::ErrorOr<std::unique_ptr<llvm::vfs::File> > llvm::vfs::File::getWithPath(llvm::ErrorOr<std::unique_ptr<llvm::vfs::File> >, const llvm::Twine&)':
/work/omp-vega20-0/openmp-offload-amdgpu-runtime/llvm.src/llvm/lib/Support/VirtualFileSystem.cpp:2084:10: error: could not convert 'F' from 'std::unique_ptr<llvm::vfs::File>' to 'llvm::ErrorOr<std::unique_ptr<llvm::vfs::File> >'
   return F;
          ^
```

This reverts commit c972175649f4bb50d40d911659a04d5620ce6fe0.

2 years ago[libc++][NFC] Fixes code alignment.
Mark de Wever [Sat, 13 Nov 2021 18:08:50 +0000 (19:08 +0100)]
[libc++][NFC] Fixes code alignment.

D112904 fixed some code alignment issues, but it seems only line was
omitted. (Found while resolving merge conflicts for my own patches.)

2 years ago[VFS] Use original path when falling back to external FS
Keith Smiley [Sat, 13 Nov 2021 17:34:30 +0000 (09:34 -0800)]
[VFS] Use original path when falling back to external FS

This is a follow up to 0be9ca7c0f9a733f846bb6bc4e8e36d46b518162 to make
paths in the case of falling back to the external file system use the
original format, preserving relative paths, and allow the external
filesystem to canonicalize them if needed.

Reviewed By: dexonsmith

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

2 years agoRevert "[lldb] Fix that the embedded Python REPL crashes if it receives SIGINT"
Raphael Isemann [Sat, 13 Nov 2021 17:18:20 +0000 (18:18 +0100)]
Revert "[lldb] Fix that the embedded Python REPL crashes if it receives SIGINT"

This reverts commit cef1e07cc6d00b5b429d77133201e1f404a8023c.

It broke the windows bot.

2 years agoAMDGPU: Regenerate test checks
Matt Arsenault [Sat, 13 Nov 2021 16:32:28 +0000 (11:32 -0500)]
AMDGPU: Regenerate test checks

Regenerate with -NEXT checks to make a future diff clearer.

2 years ago[PowerPC] Use SDNode::uses (NFC)
Kazu Hirata [Sat, 13 Nov 2021 16:34:22 +0000 (08:34 -0800)]
[PowerPC] Use SDNode::uses (NFC)

2 years ago[DebugInfo][test] Simplify/improve a few tests using --impicit-check-not=DW_TAG. NFC
Kristina Bessonova [Sat, 13 Nov 2021 15:31:54 +0000 (17:31 +0200)]
[DebugInfo][test] Simplify/improve a few tests using --impicit-check-not=DW_TAG. NFC

This patch rewrites checks in a few debug info tests to avoid using
'CHECK-NOT: {{DW_TAG|NULL}}'. It proposes `--impicit-check-not=DW_TAG`
instead, as it makes the checks clearer, and easier to analyze and update.

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

2 years ago[clang-format] [PR52228] clang-format csharp inconsistant nested namespace indentation
mydeveloperday [Sat, 13 Nov 2021 14:13:51 +0000 (14:13 +0000)]
[clang-format] [PR52228] clang-format csharp inconsistant nested namespace indentation

https://bugs.llvm.org/show_bug.cgi?id=52228

For multilevel namespaces in C# get their content indented when NamespaceIndentation: None is set, where as single level namespaces are formatted correctly.

Reviewed By: HazardyKnusperkeks, jbcoe

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

2 years ago[X86] Add getAVX512Node helper. NFC.
Simon Pilgrim [Sat, 13 Nov 2021 13:59:42 +0000 (13:59 +0000)]
[X86] Add getAVX512Node helper. NFC.

For AVX512 targets without VLX, we have to widen 128/256-bit vectors to 512-bits to use some specific AVX512 instructions (or some other instructions with predicates etc.).

I've pulled out the widening code from LowerFunnelShift into the helper function, so we can convert some other widening patterns in the future.

2 years ago[SCEV] Update SCEVLoopGuardRewriter to hold reference to map. (NFC)
Florian Hahn [Sat, 13 Nov 2021 09:39:14 +0000 (09:39 +0000)]
[SCEV] Update SCEVLoopGuardRewriter to hold reference to map. (NFC)

SCEVLoopGuardRewriter doesn't need to copy the rewrite map. It can just
hold a const reference instead, to avoid an unnecessary copy.

2 years agotsan: mmap shadow stack
Dmitry Vyukov [Fri, 12 Nov 2021 18:28:39 +0000 (19:28 +0100)]
tsan: mmap shadow stack

We used to mmap C++ shadow stack as part of the trace region
before ed7f3f5bc9 ("tsan: move shadow stack into ThreadState"),
which moved the shadow stack into TLS. This started causing
timeouts and OOMs on some of our internal tests that repeatedly
create and destroy thousands of threads.
Allocate C++ shadow stack with mmap and small pages again.
This prevents the observed timeouts and OOMs.
But we now need to be more careful with interceptors that
run after thread finalization because FuncEntry/Exit and
TraceAddEvent all need the shadow stack.

Reviewed By: vitalybuka

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

2 years agoRevert "[sanitizer] Fix test linking"
Vitaly Buka [Sat, 13 Nov 2021 07:40:30 +0000 (23:40 -0800)]
Revert "[sanitizer] Fix test linking"

This reverts commit afafa883a4757d88d869d1abb6bf7e11022fd521.

-pthread was not the fix. Symbols removed from GLIBC 2.34
Fixed with e60b3fcefa62311a93a9f7c8589a1da5f25b1ba9.

2 years ago[sanitizer] Don't test __pthread_mutex_lock with GLIBC 2.34
Vitaly Buka [Sat, 13 Nov 2021 07:38:59 +0000 (23:38 -0800)]
[sanitizer] Don't test __pthread_mutex_lock with GLIBC 2.34

2 years ago[X86] Promote f16 STRICT_FROUND to f32 and call libc.
Craig Topper [Sat, 13 Nov 2021 05:36:56 +0000 (21:36 -0800)]
[X86] Promote f16 STRICT_FROUND to f32 and call libc.

Reviewed By: pengfei

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

2 years ago[JITLink][MachO] Fix "find-symbol-by-address" logic.
Lang Hames [Sat, 13 Nov 2021 04:37:07 +0000 (20:37 -0800)]
[JITLink][MachO] Fix "find-symbol-by-address" logic.

Only search within the requested section, and allow one-past-then-end addresses.

This is needed to support section-end-address references to sections with no
symbols in them.

2 years ago[Target] Use SDNode::uses (NFC)
Kazu Hirata [Sat, 13 Nov 2021 05:23:04 +0000 (21:23 -0800)]
[Target] Use SDNode::uses (NFC)

2 years agoSupport: Pass wrapped Error's error code through FileError
Duncan P. N. Exon Smith [Tue, 14 Sep 2021 19:13:19 +0000 (15:13 -0400)]
Support: Pass wrapped Error's error code through FileError

Change FileError to pass through the error code from the Error it wraps.
This allows APIs that return ECError to transition to FileError without
changing returned std::error_code.

This was extracted from https://reviews.llvm.org/D109345.

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

2 years agoADT: Fix const-correctness of iterator facade
Duncan P. N. Exon Smith [Fri, 12 Nov 2021 01:46:27 +0000 (17:46 -0800)]
ADT: Fix const-correctness of iterator facade

Fix the const-ness of `iterator_facade_base::operator->` and
`iterator_facade_base::operator[]`. This is a follow-up to
1b651be0465de70cfa22ce4f715d3501a4dcffc1, which fixed const-ness of
various iterator adaptors.

Iterators, like the pointers that they generalize, have two types of
`const`.

  - The `const` qualifier on members indicates whether the iterator
    itself can be changed. This is analagous to `int *const`.
  - The `const` qualifier on return values of `operator*()`,
    `operator[]()`, and `operator->()` controls whether the the
    pointed-to value can be changed. This is analogous to `const int*`.

If an iterator facade returns a handle to its own state, then T (and
PointerT and ReferenceT) should usually be const-qualified. Otherwise,
if clients are expected to modify the state itself, the field can be
declared mutable or a const_cast can be used.

2 years agoSupport: Make VarStreamArrayIterator iterate over const values
Duncan P. N. Exon Smith [Fri, 12 Nov 2021 03:14:03 +0000 (19:14 -0800)]
Support: Make VarStreamArrayIterator iterate over const values

VarStreamArrayIterator returns a reference to a just-computed internal
value. Change it to iterate over `const ValueType` to avoid allowing
clients to mutate the internal state, and to drop the
non-`const`-qualified operator*().

The removed operator*() was from 175d70ee5c2f03f6 to get
iterator_facade_base::operator->() working, and this fixes the root
cause instead: setting `T` to `const ValueType` causes
iterator_facade_base to infer `PointerT` as `const ValueType*`.

Ironically, this is the last blocker for removing the const-incorrect
overload of `iterator_facade_base::operator->()`, whose presence
triggered adding the workaround in the first place :).

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

2 years agotest/ExecutionEngine: Clean up lit.local.cfg
Tom Stellard [Fri, 12 Nov 2021 21:31:40 +0000 (13:31 -0800)]
test/ExecutionEngine: Clean up lit.local.cfg

Switch to using config.root.native_target to determine if tests are
supported.  This is a canonical form of the arch from the target
triple.

Reviewed By: lhames, DavidSpickett

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

2 years ago[lld-macho] Fix warning
Keith Smiley [Sat, 13 Nov 2021 03:25:37 +0000 (19:25 -0800)]
[lld-macho] Fix warning

```
/Users/ksmiley/dev/llvm-project/lld/MachO/Symbols.cpp:43:27: warning: field 'external' will be initialized after field 'weakDefCanBeHidden' [-Wreorder-ctor]
      weakDef(isWeakDef), external(isExternal),
                          ^
1 warning generated.
```

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

2 years ago[llvm-obcopy][MachO] Add error for MH_PRELOAD
Keith Smiley [Sat, 13 Nov 2021 01:24:26 +0000 (17:24 -0800)]
[llvm-obcopy][MachO] Add error for MH_PRELOAD

Previously this would crash. Fixes https://bugs.llvm.org/show_bug.cgi?id=51877

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

2 years ago[lld-macho] Allow exporting weak_def_can_be_hidden(AKA "autohide") symbols
Vy Nguyen [Tue, 9 Nov 2021 00:50:34 +0000 (19:50 -0500)]
[lld-macho] Allow exporting weak_def_can_be_hidden(AKA "autohide") symbols

autohide symbols behaves similarly to private_extern symbols.
However, LD64 allows exporting autohide symbols. LLD currently does not.
This patch allows LLD to export them.

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

2 years ago[clang] retain type sugar in auto / template argument deduction
Matheus Izvekov [Fri, 12 Nov 2021 23:40:18 +0000 (00:40 +0100)]
[clang] retain type sugar in auto / template argument deduction

This implements the following changes:
* AutoType retains sugared deduced-as-type.
* Template argument deduction machinery analyses the sugared type all the way
down. It would previously lose the sugar on first recursion.
* Undeduced AutoType will be properly canonicalized, including the constraint
template arguments.
* Remove the decltype node created from the decltype(auto) deduction.

As a result, we start seeing sugared types in a lot more test cases,
including some which showed very unfriendly `type-parameter-*-*` types.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Reviewed By: rsmith

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

2 years ago[X86][ABI] Change the alignment of f80 in 32-bit calling convention to meet with...
Phoebe Wang [Sat, 13 Nov 2021 01:24:05 +0000 (09:24 +0800)]
[X86][ABI] Change the alignment of f80 in 32-bit calling convention to meet with different data layout

Reviewed By: RKSimon

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

2 years ago[asan] More leaks in test
Vitaly Buka [Sat, 13 Nov 2021 01:56:19 +0000 (17:56 -0800)]
[asan] More leaks in test

It fails to detect a single leak with GLIBC 2.34.

2 years ago[lld-macho] Parallelize scanning the symbol tables in export/unexport-ing.
Vy Nguyen [Sat, 13 Nov 2021 01:26:30 +0000 (20:26 -0500)]
[lld-macho] Parallelize scanning the symbol tables in export/unexport-ing.

(Split from D113167)
Benchmarking on one of our large apps which exports a few thousands symbols,
this showed an improvement of ~17%.

x ./LLD_no_parallel.txt
+ ./LLD_with_parallel.txt

    N           Min           Max        Median           Avg        Stddev
x  10         84.01         89.41         88.64        87.693     1.7424061
+  10          71.9         74.29         72.63        72.753    0.77734663
Difference at 95.0% confidence
-14.94 +/- 1.26763
-17.0367% +/- 1.44553%
(Student's t, pooled s = 1.34912)

(wallclock)

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

2 years ago[asan] Fix "no matching function" on GCC
Vitaly Buka [Sat, 13 Nov 2021 01:41:50 +0000 (17:41 -0800)]
[asan] Fix "no matching function" on GCC

2 years ago[gn build] (semi-manually) port cb0e14ce6dcd
Nico Weber [Sat, 13 Nov 2021 01:09:01 +0000 (20:09 -0500)]
[gn build] (semi-manually) port cb0e14ce6dcd

2 years ago[sanitizer] Fix test linking
Vitaly Buka [Sat, 13 Nov 2021 00:52:25 +0000 (16:52 -0800)]
[sanitizer] Fix test linking

2 years ago[ORC][ORC-RT] Register type metadata from __swift5_types MachO section
Ben Langmuir [Fri, 12 Nov 2021 22:45:02 +0000 (14:45 -0800)]
[ORC][ORC-RT] Register type metadata from __swift5_types MachO section

Similar to how the other swift sections are registered by the ORC
runtime's macho platform, add the __swift5_types section, which contains
type metadata. Add a simple test that demonstrates that the swift
runtime recognized the registered types.

rdar://85358530

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

2 years ago[RISCV] Fixed duplicate RUN line on float-intrinsics.ll. NFC
Craig Topper [Sat, 13 Nov 2021 00:26:13 +0000 (16:26 -0800)]
[RISCV] Fixed duplicate RUN line on float-intrinsics.ll. NFC

We had two identical RV64I RUN lines. One should be RV32I.

2 years ago[clang][objc][codegen] Skip emitting ObjC category metadata when the
Josh Learn [Sat, 13 Nov 2021 00:17:18 +0000 (16:17 -0800)]
[clang][objc][codegen] Skip emitting ObjC category metadata when the
category is empty

Currently, if we create a category in ObjC that is empty, we still emit
runtime metadata for that category. This is a scenario that could
commonly be run into when using __attribute__((objc_direct_members)),
which elides the need for much of the category metadata. This is
slightly wasteful and can be easily skipped by checking the category
metadata contents during CodeGen.

rdar://66177182

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

2 years ago[sanitizer] Switch dlsym hack to internal_allocator
Vitaly Buka [Thu, 11 Nov 2021 02:17:20 +0000 (18:17 -0800)]
[sanitizer] Switch dlsym hack to internal_allocator

Since glibc 2.34, dlsym does
  1. malloc 1
  2. malloc 2
  3. free pointer from malloc 1
  4. free pointer from malloc 2
These sequence was not handled by trivial dlsym hack.

This fixes https://bugs.llvm.org/show_bug.cgi?id=52278

Reviewed By: eugenis, morehouse

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

2 years ago[runtime-unroll] Use incrementing IVs instead of decrementing ones
Philip Reames [Fri, 12 Nov 2021 23:00:39 +0000 (15:00 -0800)]
[runtime-unroll] Use incrementing IVs instead of decrementing ones

This is one of those wonderful "in theory X doesn't matter, but in practice is does" changes. In this particular case, we shift the IVs inserted by the runtime unroller to clamp iteration count of the loops* from decrementing to incrementing.

Why does this matter?  A couple of reasons:
* SCEV doesn't have a native subtract node.  Instead, all subtracts (A - B) are represented as A + -1 * B and drops any flags invalidated by such.  As a result, SCEV is slightly less good at reasoning about edge cases involving decrementing addrecs than incrementing ones.  (You can see this in the inferred flags in some of the test cases.)
* Other parts of the optimizer produce incrementing IVs, and they're common in idiomatic source language.  We do have support for reversing IVs, but in general if we produce one of each, the pair will persist surprisingly far through the optimizer before being coalesced.  (You can see this looking at nearby phis in the test cases.)

Note that if the hardware prefers decrementing (i.e. zero tested) loops, LSR should convert back immediately before codegen.

* Mostly irrelevant detail: The main loop of the prolog case is handled independently and will simple use the original IV with a changed start value.  We could in theory use this scheme for all iteration clamping, but that's a larger and more invasive change.

2 years ago[lldb] temporarily disable TestPaths.test_interpreter_info on windows
Lawrence D'Anna [Fri, 12 Nov 2021 23:38:35 +0000 (15:38 -0800)]
[lldb] temporarily disable TestPaths.test_interpreter_info on windows

I'm disabling this test until the fix is reviewed
(here https://reviews.llvm.org/D113650/)

2 years ago[RISCV] Improve codegen for i32 udiv/urem by constant on RV64.
Craig Topper [Fri, 12 Nov 2021 21:20:20 +0000 (13:20 -0800)]
[RISCV] Improve codegen for i32 udiv/urem by constant on RV64.

The division by constant optimization often produces constants that
are uimm32, but not simm32. These constants require 3 or 4 instructions
to materialize without Zba.

Since these instructions are often used by a multiply with a LHS
that needs to be zero extended with an AND, we can switch the MUL
to a MULHU by shifting both inputs left by 32. Once we shift the
constant left, the upper 32 bits no longer need to be 0 so constant
materialization is free to use LUI+ADDIW. This reduces the constant
materialization from 4 instructions to 3 in some cases while also
reducing the zero extend of the LHS from 2 shifts to 1.

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

2 years agolld: const-qualify iterations through VarStreamArray, NFC
Duncan P. N. Exon Smith [Fri, 12 Nov 2021 22:22:00 +0000 (14:22 -0800)]
lld: const-qualify iterations through VarStreamArray, NFC

No functionality change here; just unblocking a patch to LLVM.

2 years agoIR: Fix const-correctness of SwitchInst::CaseIterator and CaseHandle
Duncan P. N. Exon Smith [Fri, 12 Nov 2021 02:07:14 +0000 (18:07 -0800)]
IR: Fix const-correctness of SwitchInst::CaseIterator and CaseHandle

Fix some confusion between the two types of `const` a pointer/iterator
can have. Users of a SwitchInst::CaseIterator should not (and do not!)
manually mutate the SwitchInst::CaseHandle that tracks its internal
state. Change operator*() to return `const CaseHandle&`, remove the
non-const-qualified operator*(), and const-qualify
CaseHandle::setValue() and CaseHandle::setSuccessor().

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

2 years agoADT: Avoid repeating iterator adaptor/facade template params, NFC
Duncan P. N. Exon Smith [Fri, 12 Nov 2021 21:50:29 +0000 (13:50 -0800)]
ADT: Avoid repeating iterator adaptor/facade template params, NFC

Take advantage of class name injection to avoid redundantly specifying
template parameters of iterator adaptor/facade base classes.

No functionality change, although the private typedefs changed in a
couple of cases.

  - Added a private typedef HashTableIterator::BaseT, following the
    pattern from r207084 / 3478d4b164e8d3eba01f5bfa3fc5bfb287a78b97, to
    pre-emptively appease MSVC (maybe it's not necessary anymore but
    looks like we do this pretty consistently). Otherwise, I removed
    private
  - Removed private typedefs filter_iterator_impl::BaseT and
    FilterIteratorTest::InputIterator::BaseT since there was only one
    use of each and the definition was no longer interesting.

2 years ago[SLP][NFCAdd a test for vector intrinsic with scalar parameter, NFC.
Alexey Bataev [Fri, 12 Nov 2021 21:45:38 +0000 (13:45 -0800)]
[SLP][NFCAdd a test for vector intrinsic with scalar parameter, NFC.

2 years agoformat_arg attribute does not support nullable instancetype return type
Félix Cloutier [Thu, 11 Nov 2021 02:03:36 +0000 (18:03 -0800)]
format_arg attribute does not support nullable instancetype return type

* The format_arg attribute tells the compiler that the attributed function
  returns a format string that is compatible with a format string that is being
  passed as a specific argument.
* Several NSString methods return copies of their input, so they would ideally
  have the format_arg attribute. A previous differential (D112670) added
  support for instancetype methods having the format_arg attribute when used
  in the context of NSString method declarations.
* D112670 failed to account that instancetype can be sugared in certain narrow
  (but critical) scenarios, like by using nullability specifiers. This patch
  resolves this problem.

Differential Revision: https://reviews.llvm.org/D113636
Reviewed By: ahatanak

Radar-Id: rdar://85278860