platform/upstream/llvm.git
15 months ago[RISCV] Fix a crash in RISCVGatherScatterLowering
Philip Reames [Sun, 16 Apr 2023 04:26:07 +0000 (21:26 -0700)]
[RISCV] Fix a crash in RISCVGatherScatterLowering

We were assuming that the constant must always be fixed length when this is not required.  Such code is unlikely after optimization, which is why we didn't see this previously.

15 months ago[JITLink][ELF][x86-64] Implement ELF::R_X86_64_NONE.
Lang Hames [Sun, 16 Apr 2023 03:13:38 +0000 (03:13 +0000)]
[JITLink][ELF][x86-64] Implement ELF::R_X86_64_NONE.

R_X86_64_NONE is a no-op, so we just need to return from addSingleRelocation
early.

15 months ago[LoongArch] Use empty debug location for register spill/reload
Ben Shi [Sat, 15 Apr 2023 04:44:30 +0000 (12:44 +0800)]
[LoongArch] Use empty debug location for register spill/reload

Spill/reload instructions are automatically generated by the
compiler and have no relation to the original source code. So it
would be better to not attach any debug location to them.
The X86/AArch64/ARM/Thumb backends all follow this way.

Reviewed By: xen0n

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

15 months ago[JITLink][x86-64] Add x86_64::Pointer8 edge kind, ELF::R_X86_64_8 reloc support.
Lang Hames [Sun, 16 Apr 2023 02:35:36 +0000 (02:35 +0000)]
[JITLink][x86-64] Add x86_64::Pointer8 edge kind, ELF::R_X86_64_8 reloc support.

This commit adds an x86-64 Pointer8 edge kind (8-bit pointer), and uses it to
implement support for the ELF::R_X86_64_8 relocation kind.

15 months ago[JITLink][ELF][x86-64] Replace R_X86_64_32 yaml testcase with asm version.
Lang Hames [Sun, 16 Apr 2023 02:07:31 +0000 (02:07 +0000)]
[JITLink][ELF][x86-64] Replace R_X86_64_32 yaml testcase with asm version.

The assembly version of this testcase is shorter and easier to read.

15 months ago[JITLink][x86-64] Implement ELF::R_X86_64_16.
Lang Hames [Sun, 16 Apr 2023 01:59:00 +0000 (01:59 +0000)]
[JITLink][x86-64] Implement ELF::R_X86_64_16.

We already had an x86_64::Pointer16 edge kind courtesy of Sunho's COFF/x86-64
work, it just needed to be wired up.

15 months ago[JITLink][aarch64] Update aarch64 test names
Lang Hames [Sat, 15 Apr 2023 20:13:21 +0000 (20:13 +0000)]
[JITLink][aarch64] Update aarch64 test names

Tests in test/ExecutionEngine/JITLink/AArch64 are for aarch64 only, so we don't
need to repeat 'aarch64' / 'arm64' in the individual test names.

Commit 8ad75c10372 made a similar change for the x86-64 tests.

15 months ago[clang-repl] JITTargetAddress --> ExecutorAddr, NFC
Jun Zhang [Sat, 15 Apr 2023 16:38:38 +0000 (00:38 +0800)]
[clang-repl] JITTargetAddress --> ExecutorAddr, NFC

Most of Orc and JITLink are movinng away from JITTargetAddress and
use ExecutorAddr instead.

Signed-off-by: Jun Zhang <jun@junz.org>
Differential Revision: https://reviews.llvm.org/D148434

15 months ago[mlir][tensor][bufferize] Fix dealloc placement in scf.forall op
Matthias Springer [Sat, 15 Apr 2023 03:18:56 +0000 (12:18 +0900)]
[mlir][tensor][bufferize] Fix dealloc placement in scf.forall op

The terminator of this op is special: it does not just yield a value,
but bufferizes to a memcpy. This requires special treatment to make sure
that deallocs are placed after the memcpy. (By default, deallocs are
placed right before the terminator.)

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

15 months ago[mlir][sparse][gpu] generate single module, unique kernel names
Aart Bik [Sat, 15 Apr 2023 01:30:29 +0000 (18:30 -0700)]
[mlir][sparse][gpu] generate single module, unique kernel names

This fixes a TODO in the first version.

Reviewed By: Peiming

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

15 months ago[FuzzMutate] Update unit testing
Peter Rong [Sat, 15 Apr 2023 23:39:01 +0000 (16:39 -0700)]
[FuzzMutate] Update unit testing

There are some typos in the previous patch e0117a3efacf that woulc break unit test and CI.
These typos are fixed now.

Signed-off-by: Peter Rong <PeterRong96@gmail.com>
15 months ago[FuzzMutate] RandomIRBuilder has more source and sink type now.
Peter Rong [Tue, 13 Dec 2022 03:04:41 +0000 (19:04 -0800)]
[FuzzMutate] RandomIRBuilder has more source and sink type now.

Source and Sink are required when generating a new instruction.
(Term defined by previous author, in LLVM terms it's probably Use and User.)
Previously, only instructions in the same block is considered when taking source and sink.

In this patch, more source and sink types are considered.
For source, we have SrcFromInstInCurBlock, FunctionArgument, InstInDominator, SrcFromGlobalVariable, and NewConstOrStack.
For sink, we have SinkToInstInCurBlock, PointersInDominator, InstInDominatee, NewStore, and SinkToGlobalVariable.

A unit test to make sure source always dominates an instruction, and the instruction always dominates the sink is included.

Reviewed By: arsenm

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

15 months ago[clang-tidy] Fix crash in --dump-config
Nathan James [Sat, 15 Apr 2023 21:58:15 +0000 (22:58 +0100)]
[clang-tidy] Fix crash in --dump-config

Fixes a crash in dump-config when checks emit warnings trying to read the config

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

Co-authored-by: Piotr Zegar <me@piotrzegar.pl>
Reviewed By: PiotrZSL

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

15 months ago[InstCombine] Precommit a test
Kazu Hirata [Sat, 15 Apr 2023 21:34:40 +0000 (14:34 -0700)]
[InstCombine] Precommit a test

This patch precommits a test for:

https://github.com/llvm/llvm-project/issues/61650

15 months agoUse isNegative (NFC)
Kazu Hirata [Sat, 15 Apr 2023 21:26:24 +0000 (14:26 -0700)]
Use isNegative (NFC)

15 months ago[lldb] Use StringMap::contains (NFC)
Kazu Hirata [Sat, 15 Apr 2023 21:22:13 +0000 (14:22 -0700)]
[lldb] Use StringMap::contains (NFC)

15 months ago[Target] Use range-based for loops (NFC)
Kazu Hirata [Sat, 15 Apr 2023 21:14:56 +0000 (14:14 -0700)]
[Target] Use range-based for loops (NFC)

15 months ago[JITLink][X86] Rename X86 test directory to x86-64, update test names.
Lang Hames [Sat, 15 Apr 2023 18:35:11 +0000 (18:35 +0000)]
[JITLink][X86] Rename X86 test directory to x86-64, update test names.

Tests in test/ExecutionEngine/JITLink/X86 were for x86-64 only (never i386) so
it makes sense to name the test directory x86-64, and drop x86-64 from the
individual test names.

15 months ago[InstCombine] Generate better code for std::bit_floor from libstdc++
Kazu Hirata [Sat, 15 Apr 2023 18:32:33 +0000 (11:32 -0700)]
[InstCombine] Generate better code for std::bit_floor from libstdc++

Without this patch, std::bit_floor<uint32_t> in libstdc++ is compiled
as:

  %eq0 = icmp eq i32 %x, 0
  %lshr = lshr i32 %x, 1
  %ctlz = tail call i32 @llvm.ctlz.i32(i32 %lshr, i1 false)
  %sub = sub i32 32, %ctlz
  %shl = shl i32 1, %sub
  %sel = select i1 %eq0, i32 0, i32 %shl

With this patch:

  %eq0 = icmp eq i32 %x, 0
  %ctlz = call i32 @llvm.ctlz.i32(i32 %x, i1 false)
  %lshr = lshr i32 -2147483648, %1
  %sel = select i1 %eq0, i32 0, i32 %lshr

This patch recognizes the specific pattern emitted for std::bit_floor
in libstdc++.

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

This patch fixes:

https://github.com/llvm/llvm-project/issues/61183

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

15 months agoRevert "Revert "Revert "[CMake] Bumps minimum version to 3.20.0."""
Mark de Wever [Sat, 15 Apr 2023 18:12:24 +0000 (20:12 +0200)]
Revert "Revert "Revert "[CMake] Bumps minimum version to 3.20.0."""

This reverts commit 1ef4c3c859728008cf707cad8d67f45ae5070ae1.

Two buildbots still haven't been updated.

15 months ago[JITLink][ELF][x86-64] Don't use intermediate edge-kinds in ELF/x86-64 backend.
Lang Hames [Sat, 15 Apr 2023 04:50:49 +0000 (04:50 +0000)]
[JITLink][ELF][x86-64] Don't use intermediate edge-kinds in ELF/x86-64 backend.

The mapping from ELF relocation types to JITLink x86-64 edge kinds is 1-1, so
we don't need the intermediate step.

15 months ago[clang][NFC] Fix DR test ordering
Vlad Serebrennikov [Sat, 15 Apr 2023 15:24:35 +0000 (18:24 +0300)]
[clang][NFC] Fix DR test ordering

Some C++ DR tests are disrupting the usual ascending order, introducing confusion, and making people put new tests in the wrong place (myself included). This change affects 15 tests out of roughly 700.

15 months ago[clang-tidy] Fix cppcoreguidelines-narrowing-conversions false positive
Nathan James [Sat, 15 Apr 2023 14:51:26 +0000 (14:51 +0000)]
[clang-tidy] Fix cppcoreguidelines-narrowing-conversions false positive

Fix https://llvm.org/PR49498.
The check notices 2 sides of a conditional operator have types with a different constness and so tries to examine the implicit cast.
As one side is infinity, the float narrowing detection sees when its casted to a double(which it already was) it thinks the result is out of range.

I've fixed this by just disregarding expressions where the builtin type(without quals) match as no conversion would take place.

However this has opened a can of worms. Currenty `float a = std::numeric_limits<double>::infinity();` is marked as narrowing.
Whats more suspicious is `double a = std::numeric_limits<float>::infinity();` is also marked as narrowing.
It could be argued `double inf -> float inf` is narrowing, but `float inf -> double inf` definitely isnt.

Reviewed By: carlosgalvezp

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

15 months ago[NFC][libc++] Removes incorrect sliceExpr friend.
Mark de Wever [Sat, 15 Apr 2023 15:01:38 +0000 (17:01 +0200)]
[NFC][libc++] Removes incorrect sliceExpr friend.

There is no type named sliceExpr, so it's likely a misspelling of
either slice_array or __slice_expr. Neither of which appear to
need the friend declaration.

This may indicate a unimplemented bit of `<valarray`, but ¯\_(ツ)_/¯
Nobody uses it anyway.

(Commit message provided by @EricWF.)

This reverts commit e13c43b229527234ec99f7f03aff3e1560c259c8.

15 months agoRevert "[NFC][libc++] Removes sliceExpr friend."
Mark de Wever [Sat, 15 Apr 2023 14:56:50 +0000 (16:56 +0200)]
Revert "[NFC][libc++] Removes sliceExpr friend."

This reverts commit d5193e34b81fb3e9c27aea541516112d8a5f708d.

Reverted at @EricWF's request so it can be relanded with a better commit
message.

15 months ago[clang-tidy][NFC] Fix format of header file comment in MisleadingCaptureDefaultByValu...
Carlos Galvez [Sat, 15 Apr 2023 14:49:01 +0000 (14:49 +0000)]
[clang-tidy][NFC] Fix format of header file comment in MisleadingCaptureDefaultByValueCheck.h

15 months agoRevert "[clang-tidy] Add misc-header-include-cycle check"
Piotr Zegar [Sat, 15 Apr 2023 13:16:35 +0000 (13:16 +0000)]
Revert "[clang-tidy] Add misc-header-include-cycle check"

This reverts commit 9ece8753d5e6f49c31c2d988ef69225c036b25e0.

15 months ago[Matrix] Split off transpose + dot product tests.
Florian Hahn [Sat, 15 Apr 2023 13:06:46 +0000 (14:06 +0100)]
[Matrix] Split off transpose + dot product tests.

15 months ago[clang-tidy] Add misc-header-include-cycle check
Piotr Zegar [Sat, 15 Apr 2023 12:39:25 +0000 (12:39 +0000)]
[clang-tidy] Add misc-header-include-cycle check

Check detects cyclic #include dependencies between user-defined headers.

Reviewed By: njames93

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

15 months ago[libc] Add `fetch_or` to the atomic interface
Joseph Huber [Tue, 11 Apr 2023 20:08:59 +0000 (15:08 -0500)]
[libc] Add `fetch_or` to the atomic interface

Summary:
This patch adds `fetch_or`. It is mainly useful for querying and set a
bit's status without using the more expensive `exchange` functions.

15 months ago[clang-tidy][NFC] Improve doc of cppcoreguidelines-misleading-capture-default-by...
Carlos Galvez [Sat, 15 Apr 2023 10:16:49 +0000 (10:16 +0000)]
[clang-tidy][NFC] Improve doc of cppcoreguidelines-misleading-capture-default-by-value

Also fix ordering in Release Notes.

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

15 months ago[NFC][libc++] Removes sliceExpr friend.
Mark de Wever [Fri, 14 Apr 2023 18:00:51 +0000 (20:00 +0200)]
[NFC][libc++] Removes sliceExpr friend.

The class is never defined. This was discovered while validating modules
in libc++.

Reviewed By: #libc, philnik

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

15 months agoRevert "Revert "[CMake] Bumps minimum version to 3.20.0.""
Mark de Wever [Sat, 15 Apr 2023 11:12:04 +0000 (13:12 +0200)]
Revert "Revert "[CMake] Bumps minimum version to 3.20.0.""

This reverts commit 92523a35a827539db8557bbc3ecab7f9ea3f6ade.

Reland to see whether CIs are updated.

15 months ago[libc++] Removes Clang 14 support.
Mark de Wever [Fri, 14 Apr 2023 18:12:27 +0000 (20:12 +0200)]
[libc++] Removes Clang 14 support.

Per our policy we only support the last two releases.

Reviewed By: #libc, EricWF, philnik

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

15 months ago[clang-tidy] Fix typedefs handling in bugprone-dangling-handle
Piotr Zegar [Sat, 15 Apr 2023 10:29:38 +0000 (10:29 +0000)]
[clang-tidy] Fix typedefs handling in bugprone-dangling-handle

Using 'hasUnqualifiedDesugaredType' to skip all type aliases when
checking for handle.

Fixes #38779

Reviewed By: carlosgalvezp

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

15 months ago[gn build] Port eedbe81b1c6d
LLVM GN Syncbot [Sat, 15 Apr 2023 10:21:07 +0000 (10:21 +0000)]
[gn build] Port eedbe81b1c6d

15 months ago[clang-tidy] Exclude template instantiations in modernize-use-override
Piotr Zegar [Sat, 15 Apr 2023 10:07:45 +0000 (10:07 +0000)]
[clang-tidy] Exclude template instantiations in modernize-use-override

Added IgnoreTemplateInstantiations option to modernize-use-override
check. Allows to ignore virtual function overrides that are part of
template instantiations. This can be useful in cases where the use
of the "override" keyword is not appropriate or causes issues with
template specialization.

Fixes #38276.

Reviewed By: carlosgalvezp

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

15 months ago[clang] Mark CWG2331 as N/A
Vlad Serebrennikov [Sat, 15 Apr 2023 10:15:05 +0000 (13:15 +0300)]
[clang] Mark CWG2331 as N/A

[[https://wg21.link/p1787 | P1787]]: CWG2331 is resolved by defining lookup from complete-class contexts and out-of-line member definitions.
Wording: The declaration set is the result of a single search in the scope of C for N from immediately after the class-specifier of C if P is in a complete-class context of C or from P otherwise. ([class.member.lookup]/4)

Reviewed By: #clang-language-wg, shafik

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

15 months ago[clang-tidy] Apply cppcoreguidelines-avoid-capture-default-when-capturin-this only...
Carlos Galvez [Fri, 14 Apr 2023 06:39:12 +0000 (06:39 +0000)]
[clang-tidy] Apply cppcoreguidelines-avoid-capture-default-when-capturin-this only to by-value capture default

Since Cpp Core Guidelines have accepted the change in the rules:
https://github.com/isocpp/CppCoreGuidelines/commit/3c90d590e138c3a1e4eb59234e410e00545326de

Also rename the check accordingly.

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

15 months ago[libunwind] Sync Unwind_AppleExtras.cpp with downstream version
Louis Dionne [Fri, 14 Apr 2023 16:49:03 +0000 (17:49 +0100)]
[libunwind] Sync Unwind_AppleExtras.cpp with downstream version

Both had diverged in a few ways, so this brings them both back in sync.

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

15 months ago[RISCV] Optimize multiplication with immediates
Ben Shi [Sat, 15 Apr 2023 09:10:06 +0000 (17:10 +0800)]
[RISCV] Optimize multiplication with immediates

The optimization of (mul x, c) to (ADD (SLLI x, i0), (SLLI x, i1))
is only enabled for i32 multiplication on rv64, because of
the regression in i64 multiplication on rv32.

However we can change the condition to that the immediate 'c'
should only be used once, then the above regression can also be
avoided, and ohter chances of optimization can be enabled.

Reviewed By: craig.topper

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

15 months ago[clang-tidy] Add support for long double in bugprone-incorrect-roundings
Piotr Zegar [Sat, 15 Apr 2023 08:34:41 +0000 (08:34 +0000)]
[clang-tidy] Add support for long double in bugprone-incorrect-roundings

Support all floating point representations for an 0.5 floating const.
Added missing tests.

Depend on D147906.

Reviewed By: carlosgalvezp

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

15 months ago[clang-tidy] Avoid float compare in bugprone-incorrect-roundings
Piotr Zegar [Sat, 15 Apr 2023 08:34:04 +0000 (08:34 +0000)]
[clang-tidy] Avoid float compare in bugprone-incorrect-roundings

Using APFloat to compare floating numbers instead of float/double.

Fixes: #46424

Reviewed By: carlosgalvezp

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

15 months agoFix uninitialized pointer members in Target/X86
Akshay Khadse [Sat, 15 Apr 2023 06:00:45 +0000 (14:00 +0800)]
Fix uninitialized pointer members in Target/X86

Reviewed By: LuoYuanke

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

15 months ago[InstSimplify] Precommit tests for dominate conditions are not single predecessor...
chenglin.bi [Sat, 15 Apr 2023 08:12:31 +0000 (16:12 +0800)]
[InstSimplify] Precommit tests for dominate conditions are not single predecessor; NFC

15 months ago[NFC][lsan] Add GetCurrentThreadId wrapper for GetCurrentThread
Vitaly Buka [Fri, 14 Apr 2023 23:22:54 +0000 (16:22 -0700)]
[NFC][lsan] Add GetCurrentThreadId wrapper for GetCurrentThread

I am going to change return type of GetCurrentThreadId() in the next
patch.

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

15 months ago[test][sanitizer] Add another stress test for pthread_create
Vitaly Buka [Sat, 15 Apr 2023 05:38:58 +0000 (22:38 -0700)]
[test][sanitizer] Add another stress test for pthread_create

15 months ago[NFC][sanitizer] Return nullptr instead of 0
Vitaly Buka [Sat, 15 Apr 2023 00:18:04 +0000 (17:18 -0700)]
[NFC][sanitizer] Return nullptr instead of 0

15 months ago[GISel] Legalize G_FSUB to G_FADD + G_FNEG even if G_FNEG is illegal
Sergei Barannikov [Thu, 13 Apr 2023 01:42:07 +0000 (04:42 +0300)]
[GISel] Legalize G_FSUB to G_FADD + G_FNEG even if G_FNEG is illegal

`G_FNEG` used to be legalized to `G_FSUB -0, x` causing infinite loop.
This is no longer the case after D84287.

Reviewed By: arsenm

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

15 months agoGuard against dereferencing a nullptr
Akshay Khadse [Sat, 15 Apr 2023 03:28:50 +0000 (11:28 +0800)]
Guard against dereferencing a nullptr

In `lib/CodeGen/PrologEpilogInserter.cpp` file, `RS` is assigned via `RS = TRI->requiresRegisterScavenging(MF) ? new RegScavenger() : nullptr;`. This means that `RS` can be `nullptr`. While executing the `TFI->processFunctionBeforeFrameFinalized(MF, RS);`, the `RS` can be dereferenced in the call `RS->enterBasicBlock(MBB);` in file `lib/Target/AMDGPU/SIFrameLowering.cpp`

Reviewed By: skan, arsenm

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

15 months ago[TableGen] Make InlinePatternFragments a member of TreePatternNode again. NFC
Craig Topper [Sat, 15 Apr 2023 02:40:56 +0000 (19:40 -0700)]
[TableGen] Make InlinePatternFragments a member of TreePatternNode again. NFC

Now that we use IntrusiveRefCntPtr instead of std::shared_ptr
we don't need to pass a TreePatternNodePtr to this method.

15 months ago[RISCV] Move RISCVInstrInfoZihintntl.td include out of the vendor extension section...
Craig Topper [Sat, 15 Apr 2023 02:30:45 +0000 (19:30 -0700)]
[RISCV] Move RISCVInstrInfoZihintntl.td include out of the vendor extension section. NFC

15 months ago[hwasan] [test] fix test broken by argument promotion pass
Florian Mayer [Sat, 15 Apr 2023 01:50:22 +0000 (18:50 -0700)]
[hwasan] [test] fix test broken by argument promotion pass

15 months agoRevert D148384 "[Demangle] replace use of llvm::StringView w/ std::string_view"
Fangrui Song [Sat, 15 Apr 2023 01:42:11 +0000 (18:42 -0700)]
Revert D148384 "[Demangle] replace use of llvm::StringView w/ std::string_view"

This reverts commit 3e559509b426b6aae735a7f57dbdaed1041d2622 and e0c4ffa796b553fa78c638a9584c05ac21fe07d5.

This still breaks Windows builds.

In addition, `#include <llvm/ADT/StringViewExtras.h>` in
llvm/include/llvm/Demangle/ItaniumDemangle.h is a library layering violation
(LLVMDemangle is the lowest LLVM library and cannot depend on LLVMSupport).

15 months ago[NewPM] Use PassID instead of pass name
Prem Chintalapudi [Sat, 15 Apr 2023 00:35:07 +0000 (17:35 -0700)]
[NewPM] Use PassID instead of pass name

PrintIRInstrumentation::shouldPrintAfterPass accepts a pass ID instead of a pass name

Reviewed By: aeubanks

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

15 months ago[MC] Add section flag 'l' for SHF_X86_64_LARGE
Arthur Eubanks [Fri, 14 Apr 2023 18:06:17 +0000 (11:06 -0700)]
[MC] Add section flag 'l' for SHF_X86_64_LARGE

Reviewed By: MaskRay

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

15 months ago[asan][test] Fix use-after-scope-capture test after D148269
Paul Kirth [Fri, 14 Apr 2023 23:51:34 +0000 (23:51 +0000)]
[asan][test] Fix use-after-scope-capture test after D148269

After enabling ArgPromotion at lower opt levels, the body of this test
was optimized away, and the CHECK lines no longer functioned.

Setting -O0 is a hammer, but gets the test passing again, until code owners
can find a better solution.

Reviewed By: fmayer

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

15 months ago[NFC][lsan] Move SetCurrentThread call
Vitaly Buka [Fri, 14 Apr 2023 22:43:56 +0000 (15:43 -0700)]
[NFC][lsan] Move SetCurrentThread call

Future patch will set the current context as well.
Existing callsite requires additional lock to find context.

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

15 months ago[Demangle] fix windows build
Nick Desaulniers [Fri, 14 Apr 2023 23:25:11 +0000 (16:25 -0700)]
[Demangle] fix windows build

Fixes diagnostics reported against
https://reviews.llvm.org/D148384

https://lab.llvm.org/buildbot/#/builders/127/builds/46749/steps/4/logs/stdio

Reviewed By: MaskRay

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

15 months ago[ValueTracking] Add `shl nsw %val, %cnt != 0` if `%val != 0`.
Noah Goldstein [Fri, 14 Apr 2023 19:34:23 +0000 (14:34 -0500)]
[ValueTracking] Add `shl nsw %val, %cnt != 0` if `%val != 0`.

Link: https://alive2.llvm.org/ce/z/mxZLJn
Reviewed By: nikic

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

15 months ago[ValueTracking] Use maximum shift count in `shl` when determining if `shl` can be...
Noah Goldstein [Sun, 9 Apr 2023 21:27:57 +0000 (16:27 -0500)]
[ValueTracking] Use maximum shift count in `shl` when determining if `shl` can be zero.

Previously only return `shl` non-zero if the shift value was `1`. We
can expand this if we have some bounds on the shift count.

For example:
    ```
    %cnt = and %c, 16 ; Max cnt == 16
    %val = or %v, 4 ; val[2] is known one
    %shl = shl %val, %cnt ; (val.known.one << cnt.maxval) != 0
    ```

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

15 months ago[ValueTracking] Add more tests for `shl` isKnownNonZero; NFC
Noah Goldstein [Sun, 9 Apr 2023 22:11:27 +0000 (17:11 -0500)]
[ValueTracking] Add more tests for `shl` isKnownNonZero; NFC

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

15 months agoAccount for PATCHABLE instrs in Branch Relaxation
Daniel Hoekwater [Tue, 11 Apr 2023 00:09:59 +0000 (17:09 -0700)]
Account for PATCHABLE instrs in Branch Relaxation

PATCHABLE_* instructions expand to up to 36-byte
sleds. Updating the size of PATCHABLE instructions
causes them to be outlined, so we need to add a
check to prevent the outliner from considering
basic blocks that contain PATCHABLE instructions.

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

15 months ago[flang] Remove `ignoring all compiler directives` warning
V Donaldson [Wed, 12 Apr 2023 22:37:19 +0000 (15:37 -0700)]
[flang] Remove `ignoring all compiler directives` warning

The explicit `ignoring all compiler directives` reminder warning is no
longer accurate.  Any similar, more accurate message is best generated
by the front end (change pending).

15 months ago[MCParser] Reject processor-specific section flags not known by the current target
Fangrui Song [Fri, 14 Apr 2023 23:06:12 +0000 (16:06 -0700)]
[MCParser] Reject processor-specific section flags not known by the current target

Catch accidentally used flags and match MCSectionELF.cpp
`MCSectionELF::printSwitchToSection`.

Reviewed By: aeubanks

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

15 months ago[Demangle] replace use of llvm::StringView w/ std::string_view
Nick Desaulniers [Fri, 14 Apr 2023 22:43:03 +0000 (15:43 -0700)]
[Demangle] replace use of llvm::StringView w/ std::string_view

This refactoring was waiting on converting LLVM to C++17.

Leave StringView.h and cleanup around for subsequent cleanup.

Reviewed By: MaskRay

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

15 months ago[libc] Add implementation of getchar
Michael Jones [Fri, 14 Apr 2023 22:36:39 +0000 (15:36 -0700)]
[libc] Add implementation of getchar

added getchar and getchar_unlocked which are just wrappers getc and getc_unlocked respectively.

Reviewed By: sivachandra, lntue, michaelrj

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

15 months ago[StringView] remove consumeFront
Nick Desaulniers [Fri, 14 Apr 2023 22:27:56 +0000 (15:27 -0700)]
[StringView] remove consumeFront

Towards converting our use of llvm::StringView to std::string_view,
remove a method that std::string_view doesn't have.

This could be moved to the nascent llvm/ADT/StringViewExtras.h, but the
use is highly localized to one TU. Move this to be a static function
there.

Reviewed By: MaskRay

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

15 months agoRevert ""Reland "[hwasan] Provide aliases for c allocation functions for Fuchsia""
Leonard Chan [Fri, 14 Apr 2023 22:31:09 +0000 (22:31 +0000)]
Revert ""Reland "[hwasan] Provide aliases for c allocation functions for Fuchsia""

This reverts commit 39ece7583a784976dea786d59e6564649b13d92d.

Reverting because I suspect this is leading to the failures we see in
fxbug.dev/125426. We're seeing unexpected OOMs and I suspect it's
because this change makes c-style allocation functions use hwasan's
allocator which might be worse than the default one (scudo). Reverting
for now to see if this unblocks the clang roll.

15 months ago[Clang] Fix defaulted equality operator so that it does not attempt to compare unname...
Shafik Yaghmour [Fri, 14 Apr 2023 21:56:36 +0000 (14:56 -0700)]
[Clang] Fix defaulted equality operator so that it does not attempt to compare unnamed bit-fields

If we look at class.bit p2 it tells us that that unnamed bit-fields are not
members and class.compare.default p5 tells us that we should only compare
non-static data members of the class.

This fixes: https://github.com/llvm/llvm-project/issues/61335 and https://github.com/llvm/llvm-project/issues/61417

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

15 months ago[SLP][NFC] Remove Limit from tryToVectorizeSequence() arguments.
Vasileios Porpodas [Fri, 14 Apr 2023 20:18:33 +0000 (13:18 -0700)]
[SLP][NFC] Remove Limit from tryToVectorizeSequence() arguments.

Limit turns out to be implemented in the exact same way for all calls to
tryToVectorizeSequence(). So this patch removes it and implements it internally
as a lambda function.

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

15 months agoValueTracking: Handle freeze in computeKnownFPClass
Matt Arsenault [Thu, 13 Apr 2023 13:35:18 +0000 (09:35 -0400)]
ValueTracking: Handle freeze in computeKnownFPClass

15 months ago[test][sanitizer] Add stress test for pthread_create
Vitaly Buka [Fri, 14 Apr 2023 21:28:31 +0000 (14:28 -0700)]
[test][sanitizer] Add stress test for pthread_create

15 months agoValueTracking: Implement computeKnownFPClass for arithmetic.fence
Matt Arsenault [Sun, 9 Apr 2023 11:10:46 +0000 (07:10 -0400)]
ValueTracking: Implement computeKnownFPClass for arithmetic.fence

15 months agoValueTracking: Add baseline test for arithmetic.fence computeKnownFPClass
Matt Arsenault [Sun, 9 Apr 2023 11:09:59 +0000 (07:09 -0400)]
ValueTracking: Add baseline test for arithmetic.fence computeKnownFPClass

15 months agoValueTracking: Add baseline test for computeKnownFPClass fpext handling
Matt Arsenault [Sun, 9 Apr 2023 11:23:53 +0000 (07:23 -0400)]
ValueTracking: Add baseline test for computeKnownFPClass fpext handling

15 months agoValueTracking: Implement computeKnownFPClass for llvm.trunc
Matt Arsenault [Sun, 9 Apr 2023 02:54:30 +0000 (22:54 -0400)]
ValueTracking: Implement computeKnownFPClass for llvm.trunc

15 months agoValueTracking: Add baseline test for trunc computeKnownFPClass handling
Matt Arsenault [Sun, 9 Apr 2023 10:49:48 +0000 (06:49 -0400)]
ValueTracking: Add baseline test for trunc computeKnownFPClass handling

15 months agoValueTracking: Handle non-splat vectors in computeKnownFPClass
Matt Arsenault [Mon, 10 Apr 2023 19:41:46 +0000 (15:41 -0400)]
ValueTracking: Handle non-splat vectors in computeKnownFPClass

Avoids some regressions when the implementation of isKnownNeverNaN is
replaced with computeKnownFPClass.

15 months ago[github] update action and use major version
Mohammed Keyvanzadeh [Fri, 14 Apr 2023 11:23:30 +0000 (14:53 +0330)]
[github] update action and use major version

- Update the `actions/download-artifact` action to version 3.
- Use the major version of an action instead of specifying the minor or patch versions.

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

15 months ago[libc++] Re-generate the ignore-format file with the CI's clang-format
Louis Dionne [Fri, 14 Apr 2023 21:14:16 +0000 (22:14 +0100)]
[libc++] Re-generate the ignore-format file with the CI's clang-format

99e52b68a4 re-generated that file with a clang-format version that differs
from the CI's clang-format, leading to CI breakage.

15 months ago[ELF] Fix SysV hash function.
Nathan Sidwell [Sun, 9 Apr 2023 17:28:34 +0000 (13:28 -0400)]
[ELF] Fix SysV hash function.

(a) Treat name as unsigned chars.

(b) Refactor for better optimization of main loop.

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

15 months ago[clang-format] Correctly indent comment above finalized PPDirective
Owen Pan [Thu, 13 Apr 2023 07:27:40 +0000 (00:27 -0700)]
[clang-format] Correctly indent comment above finalized PPDirective

Fixes #62107.

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

15 months ago[gn build] Port d6d30dd9590b
LLVM GN Syncbot [Fri, 14 Apr 2023 20:52:23 +0000 (20:52 +0000)]
[gn build] Port d6d30dd9590b

15 months ago[ASan] fix test broken by argument promotion pass
Florian Mayer [Fri, 14 Apr 2023 20:47:26 +0000 (13:47 -0700)]
[ASan] fix test broken by argument promotion pass

Reviewed By: vitalybuka

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

15 months ago[ADT] add StringViewExtras llvm::starts_with for std::string_view
Nick Desaulniers [Fri, 14 Apr 2023 20:41:52 +0000 (13:41 -0700)]
[ADT] add StringViewExtras llvm::starts_with for std::string_view

std::string_view::starts_with isn't available until C++20. Create
llvm::starts_with for now; we can delete this when LLVM moves to C++20
one day.

To run the newly added unit test:
$ cd llvm/build; ninja ADTTests; cd -
$ ./llvm/build/unittests/ADT/ADTTests --gtest_filter=StringViewExtrasTest.\*

Reviewed By: MaskRay, erichkeane

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

15 months ago[Tests] Added test for D128011
Dávid Bolvanský [Fri, 14 Apr 2023 20:37:55 +0000 (22:37 +0200)]
[Tests] Added test for D128011

15 months agoValueTracking: Implement computeKnownFPClass for canonicalize
Matt Arsenault [Sat, 8 Apr 2023 23:44:44 +0000 (19:44 -0400)]
ValueTracking: Implement computeKnownFPClass for canonicalize

15 months agoValueTracking: Add baseline test for computeKnownFPClass for canonicalize
Matt Arsenault [Sat, 8 Apr 2023 23:44:22 +0000 (19:44 -0400)]
ValueTracking: Add baseline test for computeKnownFPClass for canonicalize

15 months ago[OpenMP] Remove duplicates from the list if using 'auto'
Joseph Huber [Wed, 12 Apr 2023 20:08:59 +0000 (15:08 -0500)]
[OpenMP] Remove duplicates from the list if using 'auto'

Summary:
We can detect the user's GPUs via the `auto` option. But if the user has
multiple GPUs installed or set the list incorrectly, we need to remove
the duplicates.

15 months ago[libc] Remove duplicate architecture from the detected list
Joseph Huber [Fri, 14 Apr 2023 20:05:40 +0000 (15:05 -0500)]
[libc] Remove duplicate architecture from the detected list

Summary:
When we detect the architectures via `native` we can have systems with
multiple of the same GPU. We need to remove duplicates or else we will
try to build the same target multiple times.

15 months ago[StringView] remove popFront
Nick Desaulniers [Fri, 14 Apr 2023 20:09:01 +0000 (13:09 -0700)]
[StringView] remove popFront

Towards converting our use of llvm::StringView to std::string_view,
remove a method that std::string_view doesn't have.

llvm::StringView::popFront is similar to std::string_view::remove_prefix
but with a reference to std::string_view::front taken first.

Reviewed By: MaskRay

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

15 months ago[AArch64] Precommit a test
Jingu Kang [Fri, 14 Apr 2023 19:42:53 +0000 (20:42 +0100)]
[AArch64] Precommit a test

This patch precommits a test for:

https://reviews.llvm.org/D148347

15 months ago[MLIR][python bindings] implement `PyValue` subclassing to enable operator overloading
max [Fri, 14 Apr 2023 19:20:33 +0000 (14:20 -0500)]
[MLIR][python bindings] implement `PyValue` subclassing to enable operator overloading

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

15 months ago[scudo] The BaseAddr should be MappedBase in releasePagesToOS()
Chia-hung Duan [Fri, 14 Apr 2023 19:12:48 +0000 (19:12 +0000)]
[scudo] The BaseAddr should be MappedBase in releasePagesToOS()

This is used to make MemMapDefault be compliant with legacy APIs.

Reviewed By: fabio-d

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

15 months agoReland "[clang-scan-deps] Migrate to OptTable"
Alex Brachet [Fri, 14 Apr 2023 19:15:02 +0000 (19:15 +0000)]
Reland "[clang-scan-deps] Migrate to OptTable"

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

15 months agotest-release.sh: build projects and runtimes lists with semicolons
Dimitry Andric [Sun, 12 Mar 2023 18:53:12 +0000 (19:53 +0100)]
test-release.sh: build projects and runtimes lists with semicolons

While doing a test-release.sh run on FreeBSD, I ran into a sed error due
to the introduction of the GNU extension '\s' in commit 500587e23dfd.

Scanning for blanks (spaces and tabs) could be done in a more portable
fashion using the [[:blank:]] character class. But it is easier to avoid
the original problem, which is that the projects and runtime lists have
to be separated by semicolons, and cannot start with a semicolon.

Instead, use the shell's alternate value parameter expansion mechanism,
which makes it easy to append items to lists with separators in between,
and without any leading separator. This also avoids having to run sed on
the end result.

In addition, build any selected runtimes in the second phase, otherwise
the third phase can fail to find several symbols in compiler-rt, if that
has been built. This is because the host's compiler-rt is not guaranteed
to have those symbols.

Reviewed By: tstellar

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

15 months agoFix tls_get_addr handling for glibc >=2.25
Thurston Dang [Wed, 12 Apr 2023 20:53:49 +0000 (20:53 +0000)]
Fix tls_get_addr handling for glibc >=2.25

This changes the sanitizers' tls_get_addr handling from
a heuristic check of __signal_safe_memalign allocations
(which has only been used in a since deprecated version
of Google's runtime), to using the sanitizers' interface
function to check if it is a malloc allocation (used
since glibc >= 2.25).

This is one of the approaches proposed by Keno in
https://github.com/google/sanitizers/issues/1409#issuecomment-1214244142

This moves the weak annotation of __sanitizer_get_allocated_size/begin from the header to sanitizer_tls_get_addr.cpp, as suggested by Vitaly in D148060.

Reviewed By: vitalybuka

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

15 months ago[bazel] Fix build after 33468a5
Christian Sigg [Fri, 14 Apr 2023 18:44:19 +0000 (20:44 +0200)]
[bazel] Fix build after 33468a5

Add missing dependency.

15 months agoValueTracking: Handle fptrunc in computeKnownFPClass
Matt Arsenault [Sun, 9 Apr 2023 11:18:07 +0000 (07:18 -0400)]
ValueTracking: Handle fptrunc in computeKnownFPClass

Handle nan.