platform/upstream/llvm.git
20 months ago[Assignment Tracking][1/*] Add initial docs for Assignment Tracking
OCHyams [Wed, 2 Nov 2022 13:42:52 +0000 (13:42 +0000)]
[Assignment Tracking][1/*] Add initial docs for Assignment Tracking

The Assignment Tracking debug-info feature is outlined in this RFC:

https://discourse.llvm.org/t/
  rfc-assignment-tracking-a-better-way-of-specifying-variable-locations-in-ir

Add documentation outlining the intent and design.

20 months ago[InstCombine] fold mul with decremented "shl -1" factor (2nd try)
Sanjay Patel [Wed, 2 Nov 2022 13:15:11 +0000 (09:15 -0400)]
[InstCombine] fold mul with decremented "shl -1" factor (2nd try)

This is a corrected version of:
bc886e9b587b

I made a copy-paste error that created an "add" instead of the
intended "sub" on that attempt. The regression tests showed the
bug, but I overlooked that.

As I said in a comment on issue #58717, the bug reports resulting
from the botched patch confirm that the pattern does occur in
many real-world applications, so hopefully eliminating the multiply
results in better code.

I added one more regression test in this version of the patch,
and here's an Alive2 proof to show that exact example:
https://alive2.llvm.org/ce/z/dge7VC

Original commit message:

This is a sibling to:
6064e92b0a84
...but we canonicalize the shl+add to shl+xor,
so the pattern is different than I expected:
https://alive2.llvm.org/ce/z/8CX16e

I have not found any patterns that are safe
to propagate no-wrap, so that is not included
here.

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

20 months ago[DebugInfo] Fix minor debug info bug in deleteDeadLoop
OCHyams [Thu, 20 Oct 2022 14:40:14 +0000 (15:40 +0100)]
[DebugInfo] Fix minor debug info bug in deleteDeadLoop

Using a DebugVariable as the set key rather than std::pair<DIVariable *,
DIExpression *> ensures we don't accidently confuse multiple instances of
inlined variables.

Reviewed By: jryans

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

20 months ago[BasicAA] Re-enable cs-cs-arm.ll test (PR58738)
Nikita Popov [Wed, 2 Nov 2022 13:21:38 +0000 (14:21 +0100)]
[BasicAA] Re-enable cs-cs-arm.ll test (PR58738)

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

20 months ago[mlir][linalg] Fix crash in canonicalization pattern
Matthias Springer [Wed, 2 Nov 2022 11:36:54 +0000 (12:36 +0100)]
[mlir][linalg] Fix crash in canonicalization pattern

This crash was due to incorrect usage of `hasTensorSemantics`, which has changed recently with DestinationStyleOpInterface. An op has tensor semantics if all of its inits and inputs are tensors. Previously, only inits needed to be tensors.

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

20 months ago[Test] Add test exposing crash in SimpleLoopUnswitch
Dmitry Makogon [Wed, 2 Nov 2022 12:55:56 +0000 (19:55 +0700)]
[Test] Add test exposing crash in SimpleLoopUnswitch

The test crashes with an assert in unswitchNontrivialInvariants.

20 months ago[InstCombine] use logical-and matcher to avoid crash
Sanjay Patel [Wed, 2 Nov 2022 12:21:42 +0000 (08:21 -0400)]
[InstCombine] use logical-and matcher to avoid crash

Follow-on to:
ec0b406e16c44f1554

This should prevent crashing for example like issue #58552
by not matching a select-of-vectors-with-scalar-condition.

The test that shows a regression seems unlikely to occur
in real code.

This also picks up an optimization in the case where a real
(bitwise) logic op is used. We could already convert some
similar select ops to real logic via impliesPoison(), so
we don't see more diffs on commuted tests. Using commutative
matchers (when safe) might also handle one of the TODO tests.

20 months ago[InstCombine] add tests for logical-and / logical-or folds; NFC
Sanjay Patel [Wed, 2 Nov 2022 12:14:44 +0000 (08:14 -0400)]
[InstCombine] add tests for logical-and / logical-or folds; NFC

Similar to 29661fe94bf12ced1 - there are matching
deficiencies and a potential crash lurking in
these patterns.

20 months ago[wasm] Always treat DWARF expression addresses as load addresses
Philip Pfaffe [Wed, 2 Nov 2022 10:51:18 +0000 (10:51 +0000)]
[wasm] Always treat DWARF expression addresses as load addresses

When resolving absolute addresses for DW_OP_addr or DW_OP_addrx, these are always load addresses rather than file addresses in wasm.

Reviewed By: DavidSpickett

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

20 months agoReenable POSIX builtin library functions in gnu2x mode
Aaron Ballman [Wed, 2 Nov 2022 11:56:43 +0000 (07:56 -0400)]
Reenable POSIX builtin library functions in gnu2x mode

gnu17 and earlier modes automatically expose several POSIX C APIs, and
this was accidentally disabled for gnu2x in
7d644e1215b376ec5e915df9ea2eeb56e2d94626.

This restores the behavior for gnu2x mode (without changing the
behavior in C standards modes instead of GNU modes).

Fixes #56607

20 months ago[InstCombine] Remove redundant splats in InstCombineVectorOps
Matt Devereau [Wed, 12 Oct 2022 09:20:05 +0000 (09:20 +0000)]
[InstCombine] Remove redundant splats in InstCombineVectorOps

Splatting the first vector element of the result of a BinOp, where any of the
BinOp's operands are the result of a first vector element splat can be simplified to
splatting the first vector element of the result of the BinOp

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

20 months ago[AMDGPU][NFC] Split MC tests into promoted from VOP1 to VOP3 and only VOP3
Mirko Brkusanin [Tue, 1 Nov 2022 15:32:55 +0000 (16:32 +0100)]
[AMDGPU][NFC] Split MC tests into promoted from VOP1 to VOP3 and only VOP3

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

20 months ago[AMDGPU][NFC] Split MC tests into promoted from VOP2 to VOP3 and only VOP3
Mirko Brkusanin [Tue, 1 Nov 2022 15:22:45 +0000 (16:22 +0100)]
[AMDGPU][NFC] Split MC tests into promoted from VOP2 to VOP3 and only VOP3

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

20 months ago[RuntimeDyld] Require x86_64-linux for IFUNC test
Moritz Sichert [Wed, 2 Nov 2022 11:08:52 +0000 (12:08 +0100)]
[RuntimeDyld] Require x86_64-linux for IFUNC test

This test was introduced by a667aa4de041816cb4865bce8f523228f2332ffa. It
assumes that it runs on x86_64 on linux, so require that for the test.

20 months ago[AMDGPU] Constify a couple of methods. NFC.
Jay Foad [Wed, 2 Nov 2022 11:03:59 +0000 (11:03 +0000)]
[AMDGPU] Constify a couple of methods. NFC.

20 months ago[LoopPredication][NFCI] Perform 'visited' check before pushing to worklist
Max Kazantsev [Wed, 2 Nov 2022 11:02:59 +0000 (18:02 +0700)]
[LoopPredication][NFCI] Perform 'visited' check before pushing to worklist

This prevents duplicates to be pushed into the stack and hypothetically
should reduce memory footprint on ugly cornercases with multiple repeating
duplicates in 'and' tree.

20 months ago[clangd] Index unscoped enums in class scope for code completion
Tom Praschan [Wed, 2 Nov 2022 11:50:50 +0000 (12:50 +0100)]
[clangd] Index unscoped enums in class scope for code completion

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

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

20 months ago[mlir] Make `OperationFingerPrint` class public
Ivan Butygin [Mon, 31 Oct 2022 13:16:03 +0000 (14:16 +0100)]
[mlir] Make `OperationFingerPrint` class public

It can be useful to external users as well for detecting if there were any changes in IR between passes.

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

20 months ago[MachineCombiner] Add `const` to `shouldReduceRegisterPressure` arguments. NFC
Anton Sidorenko [Tue, 1 Nov 2022 16:32:39 +0000 (19:32 +0300)]
[MachineCombiner] Add `const` to `shouldReduceRegisterPressure` arguments. NFC

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

20 months ago[RuntimeDyld] Added support for relocation of indirect functions
Moritz Sichert [Wed, 20 Jan 2021 16:08:47 +0000 (17:08 +0100)]
[RuntimeDyld] Added support for relocation of indirect functions

In ELF, symbols of type STT_GNU_IFUNC need to be resolved by calling the
function at the symbol's address. This is implemented by adding special
stubs for all symbols of that type.

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

20 months ago[ValueLattice] Use DL-aware folding in getCompare()
Nikita Popov [Wed, 2 Nov 2022 09:41:11 +0000 (10:41 +0100)]
[ValueLattice] Use DL-aware folding in getCompare()

Use DL-aware ConstantFoldCompareInstOperands() API instead of
ConstantExpr API. The practical effect of this is that SCCP can
now fold comparisons that require DL.

20 months ago[ValueLattice] Move getCompare() out of line (NFC)
Nikita Popov [Wed, 2 Nov 2022 09:33:44 +0000 (10:33 +0100)]
[ValueLattice] Move getCompare() out of line (NFC)

This is a fairly large method that is unlikely to benefit from
inlining.

20 months ago[SCCP] Add test for icmp that requires DL to fold (NFC)
Nikita Popov [Wed, 2 Nov 2022 09:30:04 +0000 (10:30 +0100)]
[SCCP] Add test for icmp that requires DL to fold (NFC)

20 months agoReapply [ValueLattice] Fix getCompare() for undef values
Nikita Popov [Tue, 1 Nov 2022 15:39:20 +0000 (16:39 +0100)]
Reapply [ValueLattice] Fix getCompare() for undef values

Relative to the previous attempt, this also updates the
ValueLattice unit tests.

-----

Resolve the TODO about incorrect getCompare() behavior. This can
be made more precise (e.g. by materializing the undef value and
performing constant folding on it), but for now just return an
unknown result to fix the correctness issue.

This should be NFC in terms of user-visible behavior, because the
only user of this method (SCCP) was already guarding against
UndefValue results.

20 months ago[AA] Remove some overloads (NFC)
Nikita Popov [Tue, 1 Nov 2022 15:23:26 +0000 (16:23 +0100)]
[AA] Remove some overloads (NFC)

Having all these instruction-specific overloads does not seem to
provide any compile-time benefit, so drop them in favor of the
generic methods accepting "const Instruction *". Only leave behind
the per-instruction AAQI overloads, which are part of the internal
implementation.

20 months ago[mlir][transform] Add PrintOp to transform dialect
Matthias Springer [Wed, 2 Nov 2022 09:09:46 +0000 (10:09 +0100)]
[mlir][transform] Add PrintOp to transform dialect

This op dumps the associated payload IR to stderr. It has proven useful for printf-style debugging.

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

20 months ago[reland][libc] Switch to new implementation of mem* functions
Guillaume Chatelet [Wed, 2 Nov 2022 09:03:58 +0000 (09:03 +0000)]
[reland][libc] Switch to new implementation of mem* functions

The new framework makes it explicit which processor feature is being
used and allows for easier per platform customization:
 - ARM cpu now uses trivial implementations to reduce code size.
 - Memcmp, Bcmp and Memmove have been optimized for x86
 - Bcmp has been optimized for aarch64.

This is a reland of https://reviews.llvm.org/D135134 (b3f1d58, 028414881381)

Reviewed By: courbet

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

20 months agoRevert "[FLANG] Fix MSVC + clang-cl build"
Muhammad Omair Javaid [Wed, 2 Nov 2022 09:06:43 +0000 (13:06 +0400)]
Revert "[FLANG] Fix MSVC + clang-cl build"

This reverts commit 870fbf8e300f3012470593ac087219a04d52857f.

20 months ago[ConstraintElimination] Do not crash on vector GEP in decomposeGEP
Bjorn Pettersson [Tue, 1 Nov 2022 18:55:23 +0000 (19:55 +0100)]
[ConstraintElimination] Do not crash on vector GEP in decomposeGEP

Commit 359bc5c541ae4b02 caused
 Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"'
failures in decomposeGEP when the GEP pointer operand is a vector.

Fix is to use DataLayout::getIndexTypeSizeInBits when fetching the
index size, as it will use the scalar type in case of a ptr vector.

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

20 months ago[AArch64][SVE2] Add the SVE2.1 ld1q gather & st1q scatter instructions
David Sherwood [Tue, 1 Nov 2022 15:09:26 +0000 (15:09 +0000)]
[AArch64][SVE2] Add the SVE2.1 ld1q gather & st1q scatter instructions

This patch adds the assembly/disassembly for the following instructions:

ld1q : Gather load quadwords
st1q : Scatter store quadwords

The reference can be found here:
https://developer.arm.com/documentation/ddi0602/2022-09

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

20 months ago[libc] Improve testing of mem functions
Guillaume Chatelet [Thu, 27 Oct 2022 17:01:14 +0000 (17:01 +0000)]
[libc] Improve testing of mem functions

This patch extracts the testing logic from `op_tests.cpp` into
`memory_check_utils.h` so we can reuse it for mem* function integration
tests.

This makes testing consistent and thorough.
For instance this catches a bug that got unnoticed during submission of
D136595 and D135134. Integration test for memcmp was only testing a
single size.

This also leverages ASAN to make sure that data is not read / written
outside permitted boundaries

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

20 months ago[AArch64][SVE2] Add the SVE2.1 while & pext predicate pair instructions
David Sherwood [Wed, 26 Oct 2022 10:40:02 +0000 (10:40 +0000)]
[AArch64][SVE2] Add the SVE2.1 while & pext predicate pair instructions

This patch adds the assembly/disassembly for the following
predicate pair instructions:

pext:    Set pair of predicates from predicate-as-counter
whilelt: While incrementing signed scalar less than scalar
whilele: While incrementing signed scalar less than or equal to scalar
whilegt: While incrementing signed scalar greater than scalar
whilege: While incrementing signed scalar greater than or equal to scalar
whilelo: While incrementing unsigned scalar lower than scalar
whilels: While incrementing unsigned scalar lower or same as scalar
whilehs: While decrementing unsigned scalar higher or same as scalar
whilehi: While decrementing unsigned scalar higher than scalar

The reference can be found here:
https://developer.arm.com/documentation/ddi0602/2022-09

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

20 months ago[FLANG] Fix MSVC + clang-cl build
Muhammad Omair Javaid [Mon, 31 Oct 2022 20:53:16 +0000 (00:53 +0400)]
[FLANG] Fix MSVC + clang-cl build

Flang build on windows with MSVC environment and clang-cl compiler
requires clang_rt.builtin.${target} library. This patch allows us to
locate and include this link library. This is mostly needed for flang
runtime and associated unittests. Clang implicitly uses this library
while calling lld-link via clang driver however a standalone call to
lld-link doesnt link against clang_rt library on its own.

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

20 months ago[CLANG] XFAIL c-strings.c & volatile-1.c AArch64/Windows
Muhammad Omair Javaid [Wed, 2 Nov 2022 08:29:21 +0000 (12:29 +0400)]
[CLANG] XFAIL c-strings.c & volatile-1.c AArch64/Windows

c-strings.c and volatile-1.c failing due to alignment issue on WoA. I am
going to mark them as XFAIL for now.

20 months ago[asan][test] Convert some tests to use opaque pointers
Fangrui Song [Wed, 2 Nov 2022 08:26:48 +0000 (01:26 -0700)]
[asan][test] Convert some tests to use opaque pointers

20 months ago[X86] Use default attributes for more intrinsics
Nikita Popov [Tue, 1 Nov 2022 13:24:41 +0000 (14:24 +0100)]
[X86] Use default attributes for more intrinsics

This is a continuation of D136939, adding the default attributes
(nosync, nofree, nocallback and willreturn) to more readnone
X86 intrinsics.

This still doesn't cover all of them...

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

20 months ago[LoongArch] Inline one-time-used variable and format codes. NFC.
gonglingqin [Tue, 1 Nov 2022 11:31:30 +0000 (19:31 +0800)]
[LoongArch] Inline one-time-used variable and format codes. NFC.

20 months ago[flang] lower intrinsic constants to HLFIR
Jean Perier [Wed, 2 Nov 2022 07:36:45 +0000 (08:36 +0100)]
[flang] lower intrinsic constants to HLFIR

Use the utility to lower Constant<T> that was split from current lowering
in https://reviews.llvm.org/D136955.

The difference in HLFIR is the addition of a fir.declare on constant
outlined in memory so that all the information about them is available.

Lowering to HLFIR is enabled in Brideg::genExprValue to allow testing
of scalar constant lowering.

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

20 months ago[libc] Add definitions of a few missing macros and types.
Siva Chandra Reddy [Tue, 1 Nov 2022 22:27:21 +0000 (22:27 +0000)]
[libc] Add definitions of a few missing macros and types.

20 months ago[hwasan] Remove no-op setDSOLocal. NFC
Fangrui Song [Wed, 2 Nov 2022 07:17:16 +0000 (00:17 -0700)]
[hwasan] Remove no-op setDSOLocal. NFC

PrivateLinkage and HiddenVisibility are implicitly dso_local.

20 months ago[CSKY] Fix the adjustFixupValue of fixup_csky_pcrel_uimm7_scale4
Zi Xuan Wu (Zeson) [Mon, 31 Oct 2022 10:07:37 +0000 (18:07 +0800)]
[CSKY] Fix the adjustFixupValue of fixup_csky_pcrel_uimm7_scale4

The logic to calculate the offset of lrw16 is complex and the Value
before adjustFixupValue should in range of 0 <= (Value >> 2) <= 0xfe.

It also influences the relax condition.

20 months ago[CSKY] Fix .bss directive compling error created by --save-temps
Zi Xuan Wu (Zeson) [Fri, 28 Oct 2022 02:26:32 +0000 (10:26 +0800)]
[CSKY] Fix .bss directive compling error created by --save-temps

.bss without symbol and num following can't be compiled in CSKY target, which is consistent to GCC behavior.
So when --save-temps generates .bss, we should UsesELFSectionDirectiveForBSS to avoid such error.

20 months ago[compiler-rt] Switch from llvm-config to find_package(LLVM)
Michał Górny [Sat, 29 Oct 2022 17:03:37 +0000 (19:03 +0200)]
[compiler-rt] Switch from llvm-config to find_package(LLVM)

Replace the use of the deprecated `llvm-config` tool with LLVM's CMake
files for detecting LLVM in standalone builds.

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

20 months ago[llvm-debuginfo-analyzer] Fix memory leak reported by sanitizers.
Carlos Alberto Enciso [Tue, 1 Nov 2022 12:41:04 +0000 (12:41 +0000)]
[llvm-debuginfo-analyzer] Fix memory leak reported by sanitizers.

The sanitizer reported memory leak issues; the command line
used in the test case is:

llvm-debuginfo-analyzer --attribute=level
                        --print=instructions
                        pr-incorrect-instructions-dwarf-clang.o

When dealing with logical instruction lines associated with
an artificial logical scope, skip the process of finding
their enclosing scope. Just add them to the scope.

Create logical debug lines only if the command line specifies:
  --print=lines or --print=elements or --print=all

Reviewed By: jryans, vitalybuka

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

20 months ago[clang][modules][deps] System module maps might not be affecting
Jan Svoboda [Wed, 2 Nov 2022 04:57:42 +0000 (21:57 -0700)]
[clang][modules][deps] System module maps might not be affecting

The dependency scanner relies on the module map filtering logic in `ASTWriter`. The algorithm currently considers all system module maps affecting, which is not only sub-optimal, but can also cause failures when building a module explicitly (see attached test case).

This patch applies the same filtering logic to system module maps.

Reviewed By: Bigcheese

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

20 months ago[AArch64] Improve codegen for shifted mask op
chenglin.bi [Wed, 2 Nov 2022 05:11:35 +0000 (13:11 +0800)]
[AArch64] Improve codegen for shifted mask op

The special case for bit extraction pattern is  `((x >> C) & mask) << C`.
It can be combined to `x & (mask << C)` by return true in isDesirableToCommuteWithShift.

Fix: #56427

Reviewed By: dmgreen

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

20 months ago[mlir][vector] Fix distribution of scf.for with value coming from above
Thomas Raoux [Tue, 1 Nov 2022 06:25:47 +0000 (06:25 +0000)]
[mlir][vector] Fix distribution of scf.for with value coming from above

When a value used in the forOp is defined outside the region but within
the parent warpOp we need to return and distribute the value to pass it
to new operations created within the loop.
Also simplify the lambda interface.

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

20 months ago[Attributor][NFCI] Move MemIntrinsic handling into the initializer
Johannes Doerfert [Fri, 7 Oct 2022 18:43:23 +0000 (11:43 -0700)]
[Attributor][NFCI] Move MemIntrinsic handling into the initializer

The handling for MemIntrinsic is not dependent on optimistic
information, no need to put it in update for now. Added a TODO though.

20 months ago[Attributor][NFC] Hide verbose output behind `attributor-verbose`
Johannes Doerfert [Fri, 7 Oct 2022 18:37:37 +0000 (11:37 -0700)]
[Attributor][NFC] Hide verbose output behind `attributor-verbose`

20 months ago[OpenMP] Utilize the "non-uniform-workgroup" to simplify DeviceRTL
Johannes Doerfert [Fri, 7 Oct 2022 13:34:29 +0000 (06:34 -0700)]
[OpenMP] Utilize the "non-uniform-workgroup" to simplify DeviceRTL

OpenMP offloading always uses uniform workgroups, see
https://reviews.llvm.org/D135374. The runtime doesn't need to handle
non-uniform workgroups at all either.

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

20 months agoRevert "[RISCV] Enable the LocalStackSlotAllocation pass support"
Craig Topper [Wed, 2 Nov 2022 03:03:41 +0000 (20:03 -0700)]
Revert "[RISCV] Enable the LocalStackSlotAllocation pass support"

This reverts commit 82c820b95cf7ec284baf182cf838ca9e26758098.

This failed llvm-testsuite in our downstream and a similar issue
was reported by @rogfer01.

20 months ago[clang][modules] Account for non-affecting inputs in `ASTWriter`
Jan Svoboda [Wed, 2 Nov 2022 02:23:51 +0000 (19:23 -0700)]
[clang][modules] Account for non-affecting inputs in `ASTWriter`

In D106876, we stopped serializing module map files that didn't affect compilation of the current module.

However, since each `SourceLocation` is simply an offset into `SourceManager`'s global buffer of concatenated input files in, these need to be adjusted during serialization. Otherwise, they can incorrectly point after the buffer or into subsequent input file.

This patch starts adjusting `SourceLocation`s, `FileID`s and other `SourceManager` offsets in `ASTWriter`.

Reviewed By: dexonsmith

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

20 months ago[clang][modules] NFCI: Avoid unnecessary serialization logic for non-affecting files
Jan Svoboda [Wed, 2 Nov 2022 02:19:06 +0000 (19:19 -0700)]
[clang][modules] NFCI: Avoid unnecessary serialization logic for non-affecting files

This patch delays some `ASTWriter` logic until after we've checked whether the source location entry we're serializing as an affecting file or not.

Depends on D137214.

Reviewed By: dexonsmith

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

20 months ago[libc++] Use stack buffers for uninitialized storage in tests.
Konstantin Varlamov [Wed, 2 Nov 2022 02:20:08 +0000 (19:20 -0700)]
[libc++] Use stack buffers for uninitialized storage in tests.

This makes the tests more minimal, and in particular it avoids relying on a complete `<cstdlib>`, which may not be available on all platforms.

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

20 months ago[clang] NFC: Extract lower-level SourceManager functions
Jan Svoboda [Wed, 2 Nov 2022 02:11:24 +0000 (19:11 -0700)]
[clang] NFC: Extract lower-level SourceManager functions

This is a prep-patch for D136624 which allows querying `SourceManager` with raw offsets instead of `SourceLocation`s.

Reviewed By: dexonsmith

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

20 months ago[clang][modules] NFCI: Scaffolding for serialization of adjusted SourceManager offsets
Jan Svoboda [Wed, 2 Nov 2022 02:06:54 +0000 (19:06 -0700)]
[clang][modules] NFCI: Scaffolding for serialization of adjusted SourceManager offsets

This patch is a NFC prep for D136624, where we start adjusting offsets into `SourceManager`.

Depends on D137213.

Reviewed By: dexonsmith

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

20 months ago[clang][modules] NFCI: Pragma diagnostic mappings: write/read FileID instead of Sourc...
Jan Svoboda [Wed, 2 Nov 2022 01:57:41 +0000 (18:57 -0700)]
[clang][modules] NFCI: Pragma diagnostic mappings: write/read FileID instead of SourceLocation

For pragma diagnostic mappings, we always write/read `SourceLocation` with offset 0. This is equivalent to just writing a `FileID`, which is exactly what this patch starts doing.

Depends on D137211.

Reviewed By: dexonsmith

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

20 months ago[clang][modules] NFCI: Unify FileID writing/reading
Jan Svoboda [Wed, 2 Nov 2022 01:45:55 +0000 (18:45 -0700)]
[clang][modules] NFCI: Unify FileID writing/reading

This patch adds new functions for writing/reading `FileID`s and uses them to replace some ad-hoc code.

Reviewed By: dexonsmith

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

20 months agoLangRef: Attempt to formulate some rules for addrspacecast
Matt Arsenault [Tue, 18 Jun 2019 23:03:09 +0000 (19:03 -0400)]
LangRef: Attempt to formulate some rules for addrspacecast

Some work will be needed to comply with these rules for non-integral
pointers.

20 months agoRevert "[Sanitizers] Modified __aarch64__ to use the 64 bit version of the allocator."
Vitaly Buka [Wed, 2 Nov 2022 00:04:10 +0000 (17:04 -0700)]
Revert "[Sanitizers] Modified __aarch64__ to use the 64 bit version of the allocator."

We need to land asan_allocator.h patches first.

This reverts commit 75a8cdbc0659dc20746f31721cc48ef00c49f746.

20 months ago[mlir][sparse] Fix windows build.
bixia1 [Tue, 1 Nov 2022 23:55:24 +0000 (16:55 -0700)]
[mlir][sparse] Fix windows build.

Reviewed By: aartbik

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

20 months ago[clang][modules] NFC: Remove unused lambda argument
Jan Svoboda [Tue, 1 Nov 2022 23:53:46 +0000 (16:53 -0700)]
[clang][modules] NFC: Remove unused lambda argument

20 months ago[llvm-profgen] Fix a typo in collectProfiledFunctions
Hongtao Yu [Tue, 1 Nov 2022 22:17:57 +0000 (15:17 -0700)]
[llvm-profgen] Fix a typo in collectProfiledFunctions

As titled. The change should have minimal impact since the targets of branch samples are mostly covered by range samples.

Reviewed By: wenlei, wlei

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

20 months agoFix DenseMap with APInt keys
Weverything [Tue, 4 Oct 2022 21:34:10 +0000 (14:34 -0700)]
Fix DenseMap with APInt keys

The empty key value for APInt was colliding with a valid zero-width
APInt.  Change the internal value of empty key and tombstone values
for APInt to avoid this collision.

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

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

20 months ago[libc][Obvious] Fix a typo in a CMake file.
Siva Chandra Reddy [Tue, 1 Nov 2022 23:18:34 +0000 (23:18 +0000)]
[libc][Obvious] Fix a typo in a CMake file.

20 months ago[libc] Skip setjmp tests under sanitizers.
Siva Chandra Reddy [Tue, 1 Nov 2022 23:13:57 +0000 (23:13 +0000)]
[libc] Skip setjmp tests under sanitizers.

20 months ago[AArch64][GlobalISel] Add a simple cross-regclass copy optimization post-selection.
Amara Emerson [Tue, 25 Oct 2022 03:51:24 +0000 (20:51 -0700)]
[AArch64][GlobalISel] Add a simple cross-regclass copy optimization post-selection.

This does some trivial cross-regclass folding, where we can either do some extra
constraining to eliminate the copy or modify uses to use a smaller regclass.

There are minor code size improvements on average.

Program                                       size.__text
                                              before         after           diff
tramp3d-v4/tramp3d-v4                         366000.00      366012.00       0.0%
mafft/pairlocalalign                          248196.00      248188.00      -0.0%
7zip/7zip-benchmark                           568612.00      568592.00      -0.0%
kimwitu++/kc                                  434704.00      434676.00      -0.0%
Bullet/bullet                                 456128.00      456096.00      -0.0%
sqlite3/sqlite3                               284136.00      284100.00      -0.0%
ClamAV/clamscan                               381492.00      381396.00      -0.0%
SPASS/SPASS                                   412052.00      411944.00      -0.0%
lencod/lencod                                 428060.00      427912.00      -0.0%
consumer-typeset/consumer-typeset             413148.00      411116.00      -0.5%
                           Geomean difference                               -0.1%

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

20 months ago[libc] Add x86_64 implementation of setjmp and longjmp.
Siva Chandra Reddy [Tue, 1 Nov 2022 06:18:12 +0000 (06:18 +0000)]
[libc] Add x86_64 implementation of setjmp and longjmp.

Reviewed By: michaelrj

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

20 months ago[mlir][sparse] Add rewriting rule for the convert operator.
bixia1 [Mon, 31 Oct 2022 04:55:25 +0000 (21:55 -0700)]
[mlir][sparse] Add rewriting rule for the convert operator.

Reviewed By: aartbik

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

20 months agoHonor LLVM_LIBDIR_SUFFIX
serge-sans-paille [Sun, 30 Oct 2022 17:25:04 +0000 (18:25 +0100)]
Honor LLVM_LIBDIR_SUFFIX

Some distribution install libraries under lib64. LLVM supports this
through LLVM_LIBDIR_SUFFIX, have bolt do the same.

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

20 months ago[mlir][TOSA]Add optional attributes to TOSA custom op
Eric Kunze [Tue, 1 Nov 2022 22:09:56 +0000 (15:09 -0700)]
[mlir][TOSA]Add optional attributes to TOSA custom op

The implementation_attrs attr allows passing of backend specific
attributes to TOSA custom ops.

Also adds a config option to avoid namespace collisions on the
identifier.

Reviewed By: rsuderman

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

20 months ago[llvm-c] Harmonize usage of unwrap (NFC)
Aaron Puchert [Tue, 1 Nov 2022 21:26:40 +0000 (22:26 +0100)]
[llvm-c] Harmonize usage of unwrap (NFC)

Some places were using unwrap<T>(x) = cast<T>(unwrap(x)), even though
the unwrapped value already had type T. Removing the template argument
makes it clear that no cast is intended.

Other places were using cast<T>(unwrap(x)), we replace that with the
shorthand unwrap<T>(x) for consistency.

20 months agoAdd tests which need right Insert Point for merged load
bipmis [Tue, 1 Nov 2022 21:49:44 +0000 (21:49 +0000)]
Add tests which need right Insert Point for merged load

20 months ago[mlir][Linalg] Drop usage of tileWithLinalgTilingOptions in the structured.tile transform
Nicolas Vasilache [Thu, 14 Jul 2022 15:55:03 +0000 (08:55 -0700)]
[mlir][Linalg] Drop usage of tileWithLinalgTilingOptions in the structured.tile transform

This is on a path to deprecation.
Context: https://discourse.llvm.org/t/psa-retire-tileandfuselinalgops-method/63850

As the interface-based transformation is more generic, some additional folding of AffineMin/MaxOp and some extra canonicalizations are needed.
This can be further evolved.

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

20 months agoPatch up attributes on a newly enabled test
Paul Robinson [Tue, 1 Nov 2022 21:14:13 +0000 (14:14 -0700)]
Patch up attributes on a newly enabled test

20 months ago[lldb] Document QSetDetachOnError packet
Felipe de Azevedo Piovezan [Fri, 28 Oct 2022 15:39:17 +0000 (11:39 -0400)]
[lldb] Document QSetDetachOnError packet

The packet was introduced in 106d02866d4d54b09c08e6a12915dba58e709294.

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

20 months agoFix release note indentation; NFC
Aaron Ballman [Tue, 1 Nov 2022 20:54:08 +0000 (16:54 -0400)]
Fix release note indentation; NFC

20 months ago[flang] Add atomic_or to list of intrinsics
Katherine Rasmussen [Mon, 31 Oct 2022 17:53:04 +0000 (10:53 -0700)]
[flang] Add atomic_or to list of intrinsics

Add the atomic subroutine, atomic_or, to the list of
intrinsic subroutines, add its last dummy argument to a check
for a coindexed-object, and update test.

Reviewed By: PeteSteinfeld

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

20 months ago[lit][REQUIRES] Fix some tests with incorrect REQUIRES clauses
Paul Robinson [Mon, 24 Oct 2022 15:34:30 +0000 (08:34 -0700)]
[lit][REQUIRES] Fix some tests with incorrect REQUIRES clauses

These weren't running anywhere because of bad specifications.
One test has bit-rotted and had to be XFAILed, the rest are okay.

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

20 months ago[Sanitizers] Modified __aarch64__ to use the 64 bit version of the allocator.
Kirill Stoimenov [Mon, 31 Oct 2022 23:29:39 +0000 (23:29 +0000)]
[Sanitizers] Modified __aarch64__ to use the 64 bit version of the allocator.

This change will switch SizeClassAllocator32 to SizeClassAllocator64 on ARM. This might potentially affect ARM platforms with 39-bit address space. This addresses [[ https://github.com/google/sanitizers/issues/703  | issues/703  ]], but unlike [[ https://reviews.llvm.org/D60243 | D60243 ]] it defaults to 64 bit allocator.

Reviewed By: vitalybuka, MaskRay

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

20 months ago[InstCombine] use logical-or matcher to avoid crash
Sanjay Patel [Tue, 1 Nov 2022 20:26:20 +0000 (16:26 -0400)]
[InstCombine] use logical-or matcher to avoid crash

This should prevent crashing for the example in issue #58552
by not matching a select-of-vectors-with-scalar-condition.

A similar change is likely needed for the related fold to
properly fix that kind of bug.

The test that shows a regression seems unlikely to occur
in real code.

This also picks up an optimization in the case where a real
(bitwise) logic op is used. We could already convert some
similar select ops to real logic via impliesPoison(), so
we don't see more diffs on commuted tests. Using commutative
matchers (when safe) might also handle one of the TODO tests.

20 months ago[InstCombine] add tests for logical-and / logical-or folds; NFC
Sanjay Patel [Tue, 1 Nov 2022 19:14:47 +0000 (15:14 -0400)]
[InstCombine] add tests for logical-and / logical-or folds; NFC

20 months ago[flang] Handle pointer assignment with polymorphic entities
Valentin Clement [Tue, 1 Nov 2022 20:46:07 +0000 (21:46 +0100)]
[flang] Handle pointer assignment with polymorphic entities

This patch forces pointer and allocatable polymorphic entities to be
tracked as descriptor. It also enables the pointer assignment between
polymorphic entities. Pointer association between a non-polymorphic
pointer and a polyrmophic target might require some more work as
per 10.2.2.3 point 1.

Reviewed By: PeteSteinfeld

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

20 months agoAddress post commit review feedback from D137046
Philip Reames [Tue, 1 Nov 2022 20:34:59 +0000 (13:34 -0700)]
Address post commit review feedback from D137046

It was pointed out the verifier rejects inttoptr and ptrtoint casts with inputs and outputs whose scalability doesn't match.  As such, checking the input type separately from the type of the cast itself is redundant.

20 months ago[CodeView][clang] Add flag to disable emitting command line into CodeView
Arthur Eubanks [Fri, 21 Oct 2022 18:05:04 +0000 (11:05 -0700)]
[CodeView][clang] Add flag to disable emitting command line into CodeView

In https://reviews.llvm.org/D80833, there were concerns about
determinism emitting the commandline into CodeView. We're actually
hitting these when running clang-cl on Linux (cross compiling) versus on
Windows (e.g. -fmessage-length being inferred on terminals).

Add -g[no-]codeview-command-line to enable/disable this feature.
It's still on by default to preserve the current state of clang.

Reviewed By: thakis, rnk

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

20 months ago[GlobalOpt] Don't remove inalloca from varargs functions
Arthur Eubanks [Tue, 1 Nov 2022 18:37:10 +0000 (11:37 -0700)]
[GlobalOpt] Don't remove inalloca from varargs functions

Varargs and inalloca have a weird interaction where varargs are actually
passed via the inalloca alloca. Removing inalloca breaks the varargs
because they're still not passed as separate arguments.

Fixes #58718

Reviewed By: rnk

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

20 months ago[libc++] Improves modular build.
Mark de Wever [Tue, 25 Oct 2022 19:56:01 +0000 (21:56 +0200)]
[libc++] Improves modular build.

Makes sure headers having a xxx_result as return type export the proper
header. Without exporting these modularized headers are not self
contained.

This is related to D136045.

Reviewed By: #libc, ldionne

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

20 months ago[libc++][doc] Updates implementation status.
Mark de Wever [Sat, 29 Oct 2022 10:15:37 +0000 (12:15 +0200)]
[libc++][doc] Updates implementation status.

Claim some tasks for formatting and mark some parts as complete, which
was missed in the commits completing the task.

Reviewed By: #libc, ldionne

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

20 months ago[libc++][format] Fixes default string alignment.
Mark de Wever [Sat, 29 Oct 2022 10:50:26 +0000 (12:50 +0200)]
[libc++][format] Fixes default string alignment.

Fixes https://llvm.org/PR58315

Reviewed By: #libc, ldionne

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

20 months ago[libc++] Validates valid weekday indexed range.
Mark de Wever [Sat, 29 Oct 2022 10:27:54 +0000 (12:27 +0200)]
[libc++] Validates valid weekday indexed range.

No code changes, but only increased the range in the tests.

Completes:
- LWG3273. Specify weekday_indexed to range of [0, 7]

Reviewed By: #libc, ldionne

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

20 months ago[Concepts] Correctly handle failure when checking concepts recursively
Erich Keane [Mon, 31 Oct 2022 15:43:08 +0000 (08:43 -0700)]
[Concepts] Correctly handle failure when checking concepts recursively

Based on discussion on the core reflector, it was made clear that a
concept that depends on itself should be a hard error, not a constraint
failure. This patch implements a stack of constraint-checks-in-progress
to make sure we quit, rather than hitting stack-exhaustion.

Note that we DO need to be careful to make sure we still check
constraints properly that are caused by a previous constraint, but not
derived from (such as when a check causes us to check special member
function generation), so we cannot use the existing logic to see if this
is being instantiated.

This fixes https://github.com/llvm/llvm-project/issues/44304 and
https://github.com/llvm/llvm-project/issues/50891.

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

20 months ago[PatternMatch] don't match a scalar select of bool vectors as a logical-and or logical-or
Sanjay Patel [Tue, 1 Nov 2022 18:35:56 +0000 (14:35 -0400)]
[PatternMatch] don't match a scalar select of bool vectors as a logical-and or logical-or

Most folds based on these matchers already check to make sure the
condition type is the same as the select type, and it seems unlikely
that a fold would want to handle a scalar-select-of-vectors pattern
(there are no regression tests for it).

This is a preliminary step for fixing #issue 58552. The fold(s)
responsible for that crash (D101807, D101375) don't use the matchers
yet, but they probably should.

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

20 months ago[Concepts] Improve diagnostics on a missing 'auto' keyword.
Erich Keane [Tue, 1 Nov 2022 18:37:35 +0000 (11:37 -0700)]
[Concepts] Improve diagnostics on a missing 'auto' keyword.

As reported in https://github.com/llvm/llvm-project/issues/49192,
we did a pretty poor job diagnosing cases where someone forgot 'auto', a
nd is probably in the middle of a variable declaration.  This patch
makes us properly diagnose in cases where the next token is a reference,
or CVR qualifier.

20 months ago[clang][Lex] Header map search case insensitivity
Troy Johnson [Tue, 1 Nov 2022 18:06:30 +0000 (11:06 -0700)]
[clang][Lex] Header map search case insensitivity

Correct D135801 to be case insensitive.

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

20 months ago[X86] Add SchedWriteVecExtend scheduler per-width wrapper
Simon Pilgrim [Tue, 1 Nov 2022 18:18:53 +0000 (18:18 +0000)]
[X86] Add SchedWriteVecExtend scheduler per-width wrapper

Replaces hard coded uses of WriteShuffleX/WriteVPMOV256 for VPMOVSX/VPMOVZX vector extension instructions

20 months ago[asan] Add missing __asan_set_shadow_0x() calls.
Roy Sundahl [Tue, 1 Nov 2022 17:49:25 +0000 (10:49 -0700)]
[asan] Add missing __asan_set_shadow_0x() calls.

Add new calls introduced in https://reviews.llvm.org/D136197 to weak_symbols.txt.

Reviewed By: vitalybuka

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

20 months ago[mlir][sparse] replace magic constant with symbol
Aart Bik [Tue, 1 Nov 2022 17:34:13 +0000 (10:34 -0700)]
[mlir][sparse] replace magic constant with symbol

Reviewed By: Peiming

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

20 months agoSystemZ: Register null target streamer
Matt Arsenault [Sat, 29 Oct 2022 19:35:27 +0000 (12:35 -0700)]
SystemZ: Register null target streamer

Fixes at least one null dereference.

20 months agoXCore: Register null MCTargetStreamer
Matt Arsenault [Sat, 29 Oct 2022 19:55:57 +0000 (12:55 -0700)]
XCore: Register null MCTargetStreamer

Fixes null dereference when printing globals

20 months ago[SCEVExpander] Forget SCEV when replacing congruent phi.
Florian Hahn [Tue, 1 Nov 2022 17:47:47 +0000 (17:47 +0000)]
[SCEVExpander] Forget SCEV when replacing congruent phi.

Otherwise there may be stale values left over in the cache, causing a
SCEV verification failure.

Fixes #58702.