platform/upstream/llvm.git
17 months ago[lldb/crashlog] Fix crash when loading non-symbolicated report
Med Ismail Bennani [Wed, 31 May 2023 22:29:24 +0000 (15:29 -0700)]
[lldb/crashlog] Fix crash when loading non-symbolicated report

This patch should address the crashes when parsing a the crash report
frame dictionary.

If the crash report is not symbolicated, the `symbolLocation` key will
be missing. In that case, we should just use the `imageOffset`.

rdar://109836386

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

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
17 months ago[mlir][sparse] enhance sparse reduction support
Aart Bik [Thu, 1 Jun 2023 20:34:39 +0000 (13:34 -0700)]
[mlir][sparse] enhance sparse reduction support

Formerly, we accepted and/prod reductions as a standard
reduction but these change the semantics after sparsification
by not looking at implicit zeros. Therefore, we only accept
standard reductions that are insensitive to implicit vs.
explicit zeros, and leave the more complex reductions to
the sparse_tensor.reduce custom reduction implementation.

Reviewed By: Peiming

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

17 months agoFix regex & startsWith name lookup in SBTarget::FindGlobalVariables
Jim Ingham [Thu, 1 Jun 2023 23:12:52 +0000 (16:12 -0700)]
Fix regex & startsWith name lookup in SBTarget::FindGlobalVariables

There were two bugs here.

eMatchTypeStartsWith searched for "symbol_name" by adding ".*" to the
end of the symbol name and treating that as a regex, which isn't
actually a regex for "starts with". The ".*" is in fact a no-op.  When
we finally get to comparing the name, we compare against whatever form
of the name was in the accelerator table. But for C++ that might be
the mangled name. We should also try demangled names here, since most
users are going the see demangled not mangled names.  I fixed these
two bugs and added a bunch of tests for FindGlobalVariables.

This change is in the DWARF parser code, so there may be a similar bug
in PDB, but the test for this was already skipped for Windows, so I
don't know about this.

You might theoretically need to do this Mangled comparison in

DWARFMappedHash::MemoryTable::FindByName

except when we have names we always chop them before looking them up
so I couldn't see any code paths that fail without that change. So I
didn't add that to this patch.

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

17 months ago[RISCV][GlobalISel] Remove unused variable 'Index' (NFC)
Jie Fu [Thu, 1 Jun 2023 23:10:24 +0000 (07:10 +0800)]
[RISCV][GlobalISel] Remove unused variable 'Index' (NFC)

/data/llvm-project/llvm/lib/Target/RISCV/GISel/RISCVCallLowering.cpp:272:12: error: variable 'Index' set but not used [-Werror,-Wunused-but-set-variable]
  unsigned Index = 0;
           ^
1 error generated.

17 months ago[RISCV][GlobalISel] Add lowerCall for calling convention
Nitin John Raj [Thu, 1 Jun 2023 22:35:06 +0000 (15:35 -0700)]
[RISCV][GlobalISel] Add lowerCall for calling convention

This patch implements minimal support for lowering function calls to callees with arguments and/or return values according to the RISC-V calling convention. Integer, pointer and aggregate types are supported.

Feedback is very much appreciated.

Reviewed By: arsenm

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

17 months ago[lld][COFF] Retry failed paths to take advantage of winsysroot search paths
Arthur Eubanks [Wed, 31 May 2023 15:52:21 +0000 (08:52 -0700)]
[lld][COFF] Retry failed paths to take advantage of winsysroot search paths

With /winsysroot and without /machine, we don't know which paths to add to the search paths.

We do autodetect machine type and add winsysroot search paths in SymbolTable::addFile(), but that happens after all input files are opened. So in the loop where we read files, if we fail to open a file we can retry with the winsysroot search path potentially added by reading a previous file. This will fail if we try to open something in the winsysroot before reading a file that can give us the architecture, but shrug.

Fixes #54409

Reviewed By: rnk

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

17 months agoAMDGPU: Refine undef handling for llvm.amdgcn.class intrinsic
Matt Arsenault [Wed, 24 May 2023 14:56:09 +0000 (15:56 +0100)]
AMDGPU: Refine undef handling for llvm.amdgcn.class intrinsic

This barely matters since 99% are converted to the generic intrinsic now,
and the only real difference is the target intrinsic supports a variable
test mask. Start propagating poison. Prefer folding to a defined result (false)
for an undef test mask. Propagate undef for the first operand.

17 months ago[RISCV] Separate slideup/down pseudoinstructions from FMA instructions earlier in...
Craig Topper [Thu, 1 Jun 2023 22:25:40 +0000 (15:25 -0700)]
[RISCV] Separate slideup/down pseudoinstructions from FMA instructions earlier in the class hierarchy.

Remove RISCVMaskedPseudo from vslideup/down. I hadn't intended to
include them. I missed that they used the same classes as FMA.
They weren't tested and I don't have a use case yet.

This is also needed as I attempt refactor the classes to improve
D151850.

17 months ago[RISCV] Move vslideup/down tablegen classes together. NFC
Craig Topper [Thu, 1 Jun 2023 21:25:07 +0000 (14:25 -0700)]
[RISCV] Move vslideup/down tablegen classes together. NFC

17 months agoReland "[mlir][Vector] Extend xfer drop unit dim patterns"
Diego Caballero [Thu, 1 Jun 2023 21:47:48 +0000 (21:47 +0000)]
Reland "[mlir][Vector] Extend xfer drop unit dim patterns"

This reverts commit 76d71f3792b2b1864992446f7b1028b026dccd11.

17 months ago[mlir][Vector] Prevent vector-to-scalar xfer patterns from triggering on sub-vectors
Diego Caballero [Thu, 1 Jun 2023 21:45:39 +0000 (21:45 +0000)]
[mlir][Vector] Prevent vector-to-scalar xfer patterns from triggering on sub-vectors

Patterns that convert extract(transfer_read) into a scalar load where
incorrectly triggering for cases where a sub-vector instead of a scalar
was extracted.

Reviewed By: nicolasvasilache, hanchung, awarzynski

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

17 months ago[mlir][Vector] Add support for 0-D 'vector.shape_cast' lowering
Diego Caballero [Thu, 1 Jun 2023 21:45:11 +0000 (21:45 +0000)]
[mlir][Vector] Add support for 0-D 'vector.shape_cast' lowering

This PR adds support for shape casting from and to 0-D vectors.

Reviewed By: nicolasvasilache, hanchung, awarzynski

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

17 months ago[mlir][Vector] Disable 'vector.extract' folding for unsupported 0-D vectors
Diego Caballero [Thu, 1 Jun 2023 21:44:41 +0000 (21:44 +0000)]
[mlir][Vector] Disable 'vector.extract' folding for unsupported 0-D vectors

The `vector.extract` folding patterns do not support 0-D vectors
(actually, 0-D vector support couldn't even be implemented as a folding
pattern as it would require replacing `vector.extract` with a
`vector.extractelement` op). This patch is bailing out folding when 0-D
vectors are found.

Reviewed By: nicolasvasilache, hanchung

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

17 months ago[gn build] Port d51a84b4059c
LLVM GN Syncbot [Thu, 1 Jun 2023 22:11:58 +0000 (22:11 +0000)]
[gn build] Port d51a84b4059c

17 months ago[libc++][PSTL] Implement std::stable_sort
Nikolas Klauser [Thu, 1 Jun 2023 22:05:11 +0000 (15:05 -0700)]
[libc++][PSTL] Implement std::stable_sort

Reviewed By: #libc, ldionne

Spies: ldionne, libcxx-commits

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

17 months ago[libc] Add strtoint32 and strtoint64 tests
Michael Jones [Thu, 1 Jun 2023 21:01:04 +0000 (14:01 -0700)]
[libc] Add strtoint32 and strtoint64 tests

There were regressions in the testing framework due to none of the
functioning buildbots having a 32 bit long. This allowed the 32 bit
version of the strtointeger function to go untested. This patch adds
tests for strtoint32 and strtoint64, which are internal testing
functions that use constant integer sizes. It also fixes the tests to
properly handle these situations.

Reviewed By: sivachandra

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

17 months ago[GlobalISel] Delete code in GIMatcher complaining about unreachable rules.
Amara Emerson [Thu, 1 Jun 2023 21:10:52 +0000 (14:10 -0700)]
[GlobalISel] Delete code in GIMatcher complaining about unreachable rules.

Fixes #62897

17 months ago[TargetLowering][ARM][AArch64] Remove usage of NoSignedWrap/NoUnsignedWrap from AVGFL...
Craig Topper [Thu, 1 Jun 2023 21:18:08 +0000 (14:18 -0700)]
[TargetLowering][ARM][AArch64] Remove usage of NoSignedWrap/NoUnsignedWrap from AVGFLOOR/CEIL transform.

Use computeOverflowForUnsignedAdd and computeOverflowForSignedAdd
instead. Unfortunately, this recomputes some known bits and sign bits
we may have already computed, but was the easiest fix without a lot
of restructuring.

This recovers the regressions from D151472.

Reviewed By: RKSimon

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

17 months ago[Sanitizers][Darwin][ASanABI] Fix architecture config for ASan Abi
Blue Gaston [Wed, 31 May 2023 22:23:06 +0000 (15:23 -0700)]
[Sanitizers][Darwin][ASanABI] Fix architecture config for ASan Abi

Moved setting supported architecture to parent cmake configuration files
so they can be read by both lib and test CMakeList.txt.

Fixed issue with check-asan-abi that did not filter for current host architecture
which caused x86_64 bots to run Arm64 tests.

Added x86_64 as a supported arch to the test cmake file.

rdar://110017569

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

17 months ago[RISCV] Rename VPseudoBinaryTailPolicy to VPseudoTernaryMaskPolicy. NFC
Craig Topper [Thu, 1 Jun 2023 21:00:44 +0000 (14:00 -0700)]
[RISCV] Rename VPseudoBinaryTailPolicy to VPseudoTernaryMaskPolicy. NFC

17 months ago[FuzzMutate] Avoid calling function with metadata/token parameter/return type for...
Henry Yu [Thu, 1 Jun 2023 20:56:20 +0000 (13:56 -0700)]
[FuzzMutate] Avoid calling function with metadata/token parameter/return type for `InsertFunctionStrategy`

When there is a function with metadata/token parameter/return type, `InsertFunctionStrategy` will crash.

This patch fixes the problem by falling back to create function declaration when the sampled function contains metadata/token parameter/return type.

Reviewed By: Peter

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

17 months ago[flang] CUDA Fortran - part 5/5: statement semantics
Peter Klausler [Sat, 6 May 2023 22:03:39 +0000 (15:03 -0700)]
[flang] CUDA Fortran - part 5/5: statement semantics

Canonicalize !$CUF KERNEL DO loop nests, similar to OpenACC/OpenMP
canonicalization.  Check statements and expressions in device contexts
for usage that isn't supported.  Add more tests, and include some
tweaks to standard modules needed to build CUDA Fortran modules.

Depends on https://reviews.llvm.org/D150159,
https://reviews.llvm.org/D150161, https://reviews.llvm.org/D150162, &
https://reviews.llvm.org/D150163.

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

17 months ago[libc++] Extract ccache stats after the bootstrapping build
Louis Dionne [Thu, 1 Jun 2023 20:16:19 +0000 (13:16 -0700)]
[libc++] Extract ccache stats after the bootstrapping build

17 months agoAllow configuring InlinerThreshold in C bindings for the new pass manager
Dmitry Dolgov [Thu, 1 Jun 2023 15:56:00 +0000 (08:56 -0700)]
Allow configuring InlinerThreshold in C bindings for the new pass manager

C bindings for the new pass manager seem to allow to set any option from LLVMPassBuilderOptions, except InlinerThreshold. Allow to configure it as well.

Reviewed By: aeubanks

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

17 months ago[flang] Fix character initialization after continuation
Leandro Lupori [Wed, 31 May 2023 22:11:51 +0000 (22:11 +0000)]
[flang] Fix character initialization after continuation

The insertion of a space on a line continuation right before
a character literal was confusing TokenSequence::ToLowerCase(),
that was unable to identify the character literal as such,
causing it to be converted to lower case.

Fix this by skipping spaces in the beginning and end of each
token, before testing for token type.

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

Reviewed By: klausler

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

17 months ago[flang][hlfir] Separate -emit-fir and -emit-hlfir for bbc
Tom Eccles [Mon, 22 May 2023 14:53:08 +0000 (14:53 +0000)]
[flang][hlfir] Separate -emit-fir and -emit-hlfir for bbc

In review for https://reviews.llvm.org/D146278, @vzakhari asked to
separate -emit-fir and -emit-hlfir. This will allow FIR to be easily
outputted after the HLFIR passes have been run.

The new semantics are as follows:

| Action      | -hlfir? | Result                          |
| =========== | ======= | =============================== |
| -emit-hlfir | N       | Outputs HLFIR                   |
| -emit-hlfir | Y       | Outputs HLFIR                   |
| -emit-fir   | N       | Outputs FIR, using old lowering |
| -emit-fir   | Y       | Outputs FIR, lowering via HLFIR |

This is tested in flang/test/HLFIR/hlfir-flags.f90

Depends on: D151088

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

17 months ago[flang][hlfir] Separate -emit-fir and -emit-hlfir for flang-new
Tom Eccles [Mon, 22 May 2023 12:55:10 +0000 (12:55 +0000)]
[flang][hlfir] Separate -emit-fir and -emit-hlfir for flang-new

In review for https://reviews.llvm.org/D146278, @vzakhari asked to
separate -emit-fir and -emit-hlfir. This will allow FIR to be easily
outputted after the HLFIR passes have been run.

The new semantics are as follows:

| Action      | -flang-experimental-hlfir? | Result |
| =========== | ========================== | =============================== |
| -emit-hlfir | N                          | Outputs HLFIR                   |
| -emit-hlfir | Y                          | Outputs HLFIR                   |
| -emit-fir   | N                          | Outputs FIR, using old lowering |
| -emit-fir   | Y                          | Outputs FIR, lowering via HLFIR |

A patch for bbc will follow.

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

17 months ago[BOLT][DWARF] Fix handling of GCed CU function
Alexander Yermolovich [Thu, 1 Jun 2023 19:06:47 +0000 (12:06 -0700)]
[BOLT][DWARF] Fix handling of GCed CU function

A CU can have only one function so CU will have low_pc/high_pc. If this funciton
is GCed by LLD low_pc will become 0x0, and BOLT can't map this to output. We
kind of were getting away with it in monolithic DWARF, but with split DWARF
there is only skeleton CU, so we end up with rnglist with header and array, but
no body. This caused LLDB to report an error.

Reviewed By: maksfb

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

17 months ago[SDAG] Preserve unpredictable metadata, teach X86CmovConversion to respect this metadata
Dávid Bolvanský [Thu, 1 Jun 2023 18:56:12 +0000 (20:56 +0200)]
[SDAG] Preserve unpredictable metadata, teach X86CmovConversion to respect this metadata

Sometimes an developer would like to have more control over cmov vs branch. We have unpredictable metadata in LLVM IR, but currently it is ignored by X86 backend. Propagate this metadata and avoid cmov->branch conversion in X86CmovConversion for cmov with this metadata.

Example:

```
int MaxIndex(int n, int *a) {
    int t = 0;
    for (int i = 1; i < n; i++) {
        // cmov is converted to branch by X86CmovConversion
        if (a[i] > a[t]) t = i;
    }
    return t;
}

int MaxIndex2(int n, int *a) {
    int t = 0;
    for (int i = 1; i < n; i++) {
        // cmov is preserved
        if (__builtin_unpredictable(a[i] > a[t])) t = i;
    }
    return t;
}
```

Reviewed By: nikic

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

17 months ago[Fuchsia] Reland: Add llvm-debuginfod to toolchain
Daniel Thornburgh [Tue, 30 May 2023 21:20:46 +0000 (14:20 -0700)]
[Fuchsia] Reland: Add llvm-debuginfod to toolchain

17 months ago[MLIR][doc] Improve/fix the doc on mlir.vector.transfer_read (NFC)
Mehdi Amini [Wed, 31 May 2023 20:28:44 +0000 (13:28 -0700)]
[MLIR][doc] Improve/fix the doc on mlir.vector.transfer_read (NFC)

This doc was written 4 years ago, some refresh in the example was
overdue I suspect.

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

17 months agoFixing broken test in D140524 "Flang implementation for COMPILER_VERSION and COMPILER...
Hussain Kadhem [Thu, 1 Jun 2023 17:20:15 +0000 (13:20 -0400)]
Fixing broken test in D140524 "Flang implementation for COMPILER_VERSION and COMPILER_OPTIONS intrinsics".

17 months ago[FLANG] Change loop versioning to use shift instead of divide
Mats Petersson [Thu, 1 Jun 2023 10:39:26 +0000 (11:39 +0100)]
[FLANG] Change loop versioning to use shift instead of divide

Despite me being convinced that the use of divide didn't produce any
divide instructions, it does in fact add more instructions than using
a plain shift operation.

This patch simply changes the divide to a shift right, with an
assert to check that the "divisor" is a power of two.

Reviewed By: kiranchandramohan, tblah

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

17 months ago[clang][docs] document __attribute__((cleanup())) GNU C extension
Nick Desaulniers [Thu, 1 Jun 2023 18:18:03 +0000 (11:18 -0700)]
[clang][docs] document __attribute__((cleanup())) GNU C extension

Provide an example of how to use this extension and more importantly,
document that cleanup functions are run in reverse nested order.

Reviewed By: erichkeane

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

17 months ago[CodeGen] Make use of MachineInstr::all_defs and all_uses. NFCI.
Jay Foad [Wed, 24 May 2023 13:57:23 +0000 (14:57 +0100)]
[CodeGen] Make use of MachineInstr::all_defs and all_uses. NFCI.

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

17 months ago[tsan] Invoke malloc/free hooks on darwin
Jin Xin Ng [Thu, 1 Jun 2023 03:59:01 +0000 (03:59 +0000)]
[tsan] Invoke malloc/free hooks on darwin

Matches behaviour from tsan_interceptors_posix. This is covered by sanitizer_common/TestCases/malloc_hook.cpp (which is currently failing on darwin)
I've tested it on an arm-based Mac & also compiled to x86_64 on it.

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

17 months ago[LV] Split off invariance check from isUniform (NFCI).
Florian Hahn [Thu, 1 Jun 2023 18:09:11 +0000 (19:09 +0100)]
[LV] Split off invariance check from isUniform (NFCI).

After 572cfa3fde5433, isUniform now checks VF based uniformity instead of
just invariance as before.

As follow-up cleanup suggested in D148841, separate the invariance check
out and update callers that currently check only for invariance.

This also moves the implementation of isUniform from LoopAccessAnalysis
to LoopVectorizationLegality, as LoopAccesAnalysis doesn't use the more
general isUniform.

17 months ago[libc++] Add a few more mising HIDE_FROM_ABI macros
Louis Dionne [Thu, 1 Jun 2023 18:07:40 +0000 (11:07 -0700)]
[libc++] Add a few more mising HIDE_FROM_ABI macros

17 months ago[mlir][gpu][sparse] fix broken type in cusparseCreateCsr
Kun Wu [Thu, 1 Jun 2023 18:00:21 +0000 (18:00 +0000)]
[mlir][gpu][sparse] fix broken type in cusparseCreateCsr

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

17 months ago[ARM] Emit code alignment after .arm and .thumb directives
Antonio Abbatangelo [Thu, 1 Jun 2023 18:05:38 +0000 (11:05 -0700)]
[ARM] Emit code alignment after .arm and .thumb directives

Emit a 4-byte alignment after the .arm directive and a 2-byte alignment
after the .thumb directive. The new behavior matches GNU assembler.

Fixes #53386

Reviewed By: MaskRay

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

17 months ago[mlir][sparse][gpu] fixing broken literal names in cuda runner macros
Kun Wu [Thu, 1 Jun 2023 17:46:08 +0000 (17:46 +0000)]
[mlir][sparse][gpu] fixing broken literal names in cuda runner macros

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

17 months ago[clang] Use `FileEntryRef` in modular header search (part 1/2)
Jan Svoboda [Wed, 31 May 2023 06:26:24 +0000 (23:26 -0700)]
[clang] Use `FileEntryRef` in modular header search (part 1/2)

This patch removes some deprecated uses of `{File,Directory}Entry::getName()`. No functional change indended.

Depends on D151853.

Reviewed By: benlangmuir

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

17 months ago[gn build] Port 217709cbae34
LLVM GN Syncbot [Thu, 1 Jun 2023 17:26:03 +0000 (17:26 +0000)]
[gn build] Port 217709cbae34

17 months agoPrevent some spurious error messages in the debugserver logs.
Jim Ingham [Thu, 1 Jun 2023 17:21:23 +0000 (10:21 -0700)]
Prevent some spurious error messages in the debugserver logs.

DNBGetDeploymentInfo was calling GetPlatformString w/o checking that
the load command it was processing actually provided a platform string.
That caused a bunch of worrisome looking error messages in the debugserver
log output.

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

17 months agoAdd EXC_SYSCALL to the set of ignorable mach exceptions.
Jim Ingham [Wed, 31 May 2023 21:43:00 +0000 (14:43 -0700)]
Add EXC_SYSCALL to the set of ignorable mach exceptions.
Add some more tests of what exceptions we accept and don't accept.

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

17 months agoRevert "[Fuchsia] Add llvm-debuginfod to toolchain"
Haowei Wu [Thu, 1 Jun 2023 17:20:17 +0000 (10:20 -0700)]
Revert "[Fuchsia] Add llvm-debuginfod to toolchain"

This reverts commit 731f9ac6e53611dabb51c52bfc8011c2aab7790b.

17 months ago[mlir][sparse][gpu] add result type to spmv and spmm gpu libgen path
Kun Wu [Fri, 26 May 2023 21:46:22 +0000 (21:46 +0000)]
[mlir][sparse][gpu] add result type to spmv and spmm gpu libgen path

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

17 months agoremove Demangle/StringView.h
Nick Desaulniers [Thu, 1 Jun 2023 17:09:43 +0000 (10:09 -0700)]
remove Demangle/StringView.h

Now that we've converted libcxxabi and llvm Demangle to use
std::string_view, this code no longer has any users. Bye bye!

Reviewed By: #libc_abi, phosek, MaskRay

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

17 months ago[clang] NFCI: Split `HeaderSearch::findAllModulesForHeader()`
Jan Svoboda [Wed, 31 May 2023 05:58:49 +0000 (22:58 -0700)]
[clang] NFCI: Split `HeaderSearch::findAllModulesForHeader()`

This mimics the `ModuleMap` API and enables D151854, where the `AllowCreation = true` function needs `FileEntryRef` but `AllowCreation = false` functions is happy with plain `FileEntry`. No functional change intended.

Reviewed By: benlangmuir

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

17 months ago[clang] NFCI: Use `FileEntryRef` in `ModuleMapCallbacks`
Jan Svoboda [Wed, 31 May 2023 17:35:59 +0000 (10:35 -0700)]
[clang] NFCI: Use `FileEntryRef` in `ModuleMapCallbacks`

This patch removes path hackery from `ModuleMapCallbacks` by adopting `FileEntryRef`. No functional change intended.

Reviewed By: benlangmuir

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

17 months ago[lldb][NFCI] Remove use of ConstString from UnixSignals::SignalCode
Alex Langford [Thu, 25 May 2023 23:22:13 +0000 (16:22 -0700)]
[lldb][NFCI] Remove use of ConstString from UnixSignals::SignalCode

On llvm.org and all downstream forks that I'm aware of, SignalCodes are
always created from C string literals. They are never compared to
anything so they take up space in the ConstString StringPool for no
tangible benefit.

I've changed the type here to `const llvm::StringLiteral` instead of
using a `StringRef` or a `const char *` to express intent -- These
strings come from constant data whose lifetime is directly tied to that
of the running process (and are thus safe to store).

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

17 months agoRevert "[ARM] Allow D-reg copies to use VMOVD with fpregs64"
David Green [Thu, 1 Jun 2023 16:49:25 +0000 (17:49 +0100)]
Revert "[ARM] Allow D-reg copies to use VMOVD with fpregs64"

This reverts commit 0a762ec1b09d96734a3462f8792a5574d089b24d.

Some CPUs enable fp64 by default (such as cortex-m7). When specifying a
single-precision fpu with them like -mfpu=fpv5-sp-d16, the fp64 feature will
be disabled, but fpreg64 will not. We need to disable them both correctly under
clang in order for the backend to be able to use the reliably. In the meantime
this reverts 0a762ec1b09d96734 until that issue is fixed.

17 months ago[Lex] Only warn on defining or undefining language-defined builtins
John Brawn [Thu, 1 Jun 2023 10:09:40 +0000 (11:09 +0100)]
[Lex] Only warn on defining or undefining language-defined builtins

D144654 made it so that we warn on any defining or undefining of
builtin macros. However the C and C++ standards only forbid the
defining or undefining of macros defined in the language standard
itself, but clang defines more macros than those and warning on those
may not be helpful.

Resolve this by only warning if the builtin macro name is the name of
a macro defined by the language. This is done in a way that removes
some of the existing checks, as those were made redundant by
restricting the warning in this way.

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

17 months agoFlang implementation for COMPILER_VERSION and COMPILER_OPTIONS intrinsics
Hussain Kadhem [Thu, 1 Jun 2023 16:31:51 +0000 (12:31 -0400)]
Flang implementation for COMPILER_VERSION and COMPILER_OPTIONS intrinsics

This revision implements the Fortran intrinsic procedures COMPILER_VERSION and COMPILER_OPTIONS from the iso_fortran_env module.
To be able to set the COMPILER_OPTIONS string according to the original compiler driver invocation, a string is passed to the frontend driver using the environment variable FLANG_COMPILER_OPTIONS_STRING, for lack of a better mechanism.

Fixes #59233

Reviewed By: awarzynski

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

17 months ago[clang][Darwin] Error out when missing requested libarclite library
Keith Smiley [Thu, 1 Jun 2023 01:55:17 +0000 (18:55 -0700)]
[clang][Darwin] Error out when missing requested libarclite library

Starting with the SDKs provided with Xcode 14.3, this library no longer
exists. Before this change this results in an opaque linker error in the
case that your deployment target is low enough that this library is
added. This produces a more useful error message in that case.

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

17 months ago[MachineInstr] Implement new operand accessors all_defs and all_uses
Jay Foad [Wed, 24 May 2023 13:19:33 +0000 (14:19 +0100)]
[MachineInstr] Implement new operand accessors all_defs and all_uses

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

17 months ago[ThinLTO] Restructure promotion / internalization decisions (NFC)
Teresa Johnson [Thu, 1 Jun 2023 15:57:35 +0000 (08:57 -0700)]
[ThinLTO] Restructure promotion / internalization decisions (NFC)

Restructures the combined index based promotion and internalization
decision code so that it is a bit easier to follow. This is in
preparation for a bugfix to this code that will modify one part of the
logic.

17 months ago[NFC][libc++][tests] Move directories under stringstream
Piotr Fusik [Thu, 1 Jun 2023 15:58:36 +0000 (08:58 -0700)]
[NFC][libc++][tests] Move directories under stringstream

Reviewed By: #libc, philnik

Spies: libcxx-commits

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

17 months ago[gn build] Port ee6ec2c5f1a5
LLVM GN Syncbot [Thu, 1 Jun 2023 15:52:25 +0000 (15:52 +0000)]
[gn build] Port ee6ec2c5f1a5

17 months ago[libc++][PSTL] Implement std::reduce and std::transform_reduce
Nikolas Klauser [Thu, 1 Jun 2023 15:51:35 +0000 (08:51 -0700)]
[libc++][PSTL] Implement std::reduce and std::transform_reduce

Reviewed By: ldionne, #libc

Spies: libcxx-commits, miyuki

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

17 months ago[IPSCCP] Decouple queries for function analysis results.
Alexandros Lamprineas [Thu, 1 Jun 2023 14:09:08 +0000 (15:09 +0100)]
[IPSCCP] Decouple queries for function analysis results.

The SCCPSolver is using a structure (AnalysisResultsForFn) where it keeps
pointers to various analyses needed by the IPSCCP pass. These analyses are
requested all at the same time, which can become problematic in some cases.
For example one could be retrieved via getCachedAnalysis() prior to the
actual execution of the analysis. In more detail:

The IPSCCP pass uses a DomTreeUpdater to preserve the PostDominatorTree
in case the PostDominatorTreeAnalysis had run before IPSCCP. Starting with
commit 1b1232047e83b the IPSCCP pass may use BlockFrequencyAnalysis for
some functions in the module. As a result, the PostDominatorTreeAnalysis
may not run until the BlockFrequencyAnalysis has run, since the latter
analysis depends on the former. Currently, we setup the DomTreeUpdater
using getCachedAnalysis to retrieve a PostDominatorTree. This happens
before BlockFrequencyAnalysis has run, therefore the cached analysis can
become invalid by the time we use it.

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

17 months ago[DAGCombiner] Do not fold fadd (fmul x, y), (fmul x, y) -> fma x, y, (fmul x, y)
Jay Foad [Thu, 1 Jun 2023 14:21:09 +0000 (15:21 +0100)]
[DAGCombiner] Do not fold fadd (fmul x, y), (fmul x, y) -> fma x, y, (fmul x, y)

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

17 months ago[OpenCL] Add CLK_UNORM_INT_101010_2 channel type
Sven van Haastregt [Thu, 1 Jun 2023 15:21:54 +0000 (16:21 +0100)]
[OpenCL] Add CLK_UNORM_INT_101010_2 channel type

This new channel data type was added in OpenCL C 3.0.

17 months ago[libc++][NFC] Use TEST_HAS_NO_FILESYSTEM_LIBRARY in the test suite
Louis Dionne [Wed, 31 May 2023 18:40:01 +0000 (11:40 -0700)]
[libc++][NFC] Use TEST_HAS_NO_FILESYSTEM_LIBRARY in the test suite

This replaces some uses of internal libc++ macros with the equivalent
macro from "test_macros.h".

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

17 months ago[libc++] Use .gen.py tests to generate _LIBCPP_VERSION tests
Louis Dionne [Wed, 31 May 2023 17:07:54 +0000 (10:07 -0700)]
[libc++] Use .gen.py tests to generate _LIBCPP_VERSION tests

This removes the need for contributors to do some manual steps
when adding a new public header.

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

17 months ago[LV] Bail out on loop-variant steps when rewriting SCEV exprs.
Florian Hahn [Thu, 1 Jun 2023 15:14:02 +0000 (16:14 +0100)]
[LV] Bail out on loop-variant steps when rewriting SCEV exprs.

If the step is not loop-invariant, we cannot create a modified AddRec,
as the start needs to be loop-invariant. Mark those cases as
CannotAnalyze and bail out, to fix a crash.

17 months ago[NFC][TargetTransformInfo] Make getInliningThreholdMultiplier and getInlinerVectorBon...
Juan Manuel MARTINEZ CAAMAÑO [Thu, 1 Jun 2023 14:54:49 +0000 (16:54 +0200)]
[NFC][TargetTransformInfo] Make getInliningThreholdMultiplier and getInlinerVectorBonusPercent const

Reviewed By: jlebar

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

17 months ago[libc++][NFC] Fix header guard for <typeinfo>
Louis Dionne [Thu, 1 Jun 2023 15:06:44 +0000 (08:06 -0700)]
[libc++][NFC] Fix header guard for <typeinfo>

17 months ago[Clang] Convert some tests to opaque pointers (NFC)
Nikita Popov [Thu, 1 Jun 2023 14:31:46 +0000 (16:31 +0200)]
[Clang] Convert some tests to opaque pointers (NFC)

17 months ago[BOLT][CMake] Redo the build and install targets
Petr Hosek [Fri, 26 May 2023 22:11:24 +0000 (22:11 +0000)]
[BOLT][CMake] Redo the build and install targets

The existing BOLT install targets are broken on Windows becase they
don't properly handle the output extension. We cannot use the existing
LLVM macros since those make assumptions that don't hold for BOLT. This
change instead implements custom macros following the approach used by
Clang and LLD.

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

17 months ago[AMDGPU] New test case where we should not form FMA
Jay Foad [Thu, 1 Jun 2023 14:10:16 +0000 (15:10 +0100)]
[AMDGPU] New test case where we should not form FMA

17 months ago[InstCombine] Use DL-aware constant folding for phi compare
Nikita Popov [Thu, 1 Jun 2023 13:57:42 +0000 (15:57 +0200)]
[InstCombine] Use DL-aware constant folding for phi compare

Serves the dual purpose of avoiding an extra InstCombine iteration
for the DL-aware folding and removing one icmp constexpr use.

17 months ago[z/OS] Disable pr59765-modules-global-ctor-dtor.cppm on z/OS to make it unsupported.
Zibi Sarbinowski [Thu, 1 Jun 2023 13:42:52 +0000 (08:42 -0500)]
[z/OS] Disable pr59765-modules-global-ctor-dtor.cppm on z/OS to make it unsupported.

[z/OS] Disable pr59765-modules-global-ctor-dtor.cppm

Reviewed By: SeanP

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

17 months ago[clangd] NFC, use const HeaderSearch when possible.
Haojian Wu [Thu, 1 Jun 2023 13:31:43 +0000 (15:31 +0200)]
[clangd] NFC, use const HeaderSearch when possible.

17 months ago[InstCombine] Disable generation of fshl/fshr for rotates
Paulo Matos [Thu, 1 Jun 2023 13:27:33 +0000 (15:27 +0200)]
[InstCombine] Disable generation of fshl/fshr for rotates

Disable conversion of funnel shifts (fshl/fshr) into rotates
unless one of the operands is known to be a constant value.

Reviewed By: nikic

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

17 months agoRevert "[SCCP] Constant propagation through freeze instruction"
Nikita Popov [Thu, 1 Jun 2023 13:30:46 +0000 (15:30 +0200)]
Revert "[SCCP] Constant propagation through freeze instruction"

This reverts commit 559d47a1790e1a9f9b1f8838a443eb7624ef1ac7.

Caused failure on sanitizer-aarch64-linux-bootstrap-ubsan:

    clang++: /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/lib/Transforms/Utils/SCCPSolver.cpp:442: llvm::ValueLatticeElement &llvm::SCCPInstVisitor::getValueState(llvm::Value *): Assertion `!V->getType()->isStructTy() && "Should use getStructValueState"' failed.

17 months ago[InstCombine] Remove old add in foldLShrOverflowBit()
Nikita Popov [Thu, 1 Jun 2023 13:29:27 +0000 (15:29 +0200)]
[InstCombine] Remove old add in foldLShrOverflowBit()

Explicitly remove the old add instruction, so we don't need a
separate InstCombine iteration to DCE it.

17 months ago[include-cleaner] NFC, use const HeaderSearch when possible.
Haojian Wu [Thu, 1 Jun 2023 13:21:08 +0000 (15:21 +0200)]
[include-cleaner] NFC, use const HeaderSearch when possible.

17 months ago[SDAG] Fix incorrect use of undef for boolean contents (PR63055)
Nikita Popov [Thu, 1 Jun 2023 12:18:19 +0000 (14:18 +0200)]
[SDAG] Fix incorrect use of undef for boolean contents (PR63055)

FoldSetCC() returns UNDEF in a number of cases. However, the SetCC
result must follow BooleanContents. Unless the type is a
pre-legalization i1 or we have UndefinedBooleanContents, the use of
UNDEF will not uphold the requirement that the top bits are either
zero or match the low bit. In such cases, return zero instead.

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

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

17 months ago[Tooling] NFC, use const HeaderSearch for isSelfContainedHeader.
Haojian Wu [Thu, 1 Jun 2023 13:12:58 +0000 (15:12 +0200)]
[Tooling] NFC, use const HeaderSearch for isSelfContainedHeader.

17 months ago[flang][openacc] Add lowering for multiply operator
Valentin Clement [Thu, 1 Jun 2023 13:16:03 +0000 (22:16 +0900)]
[flang][openacc] Add lowering for multiply operator

Add support for the * operation in OpenACC lowering. Support is added
for the types currently supported.

Depends on D151564

Reviewed By: razvanlupusoru

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

17 months ago[flang][openacc] Initial reduction clause lowering
Valentin Clement [Thu, 1 Jun 2023 13:14:42 +0000 (22:14 +0900)]
[flang][openacc] Initial reduction clause lowering

Add initial support to lower reduction clause to its representation in MLIR.

This patch adds support for addition of integer and real scalar types. Other
operators and types will be added with follow up patches.

Reviewed By: razvanlupusoru

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

17 months ago[clang] NFC, make more HeaderSearch methods const.
Haojian Wu [Thu, 1 Jun 2023 13:01:21 +0000 (15:01 +0200)]
[clang] NFC, make more HeaderSearch methods const.

17 months ago[SCCP] Constant propagation through freeze instruction
Mikhail Gudim [Thu, 1 Jun 2023 13:04:27 +0000 (15:04 +0200)]
[SCCP] Constant propagation through freeze instruction

The freeze instruction has not been handled by SCCPInstVisitor.
This patch adds SCCPInstVisitor::visitFreezeInst(FreezeInst &I)
method to handle freeze instructions.

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

17 months ago[clangd] NFC, remove an unused member in
Haojian Wu [Thu, 1 Jun 2023 12:52:46 +0000 (14:52 +0200)]
[clangd] NFC, remove an unused member in
IncludeStructure::RecordHeaders.

17 months ago[AMDGPU] New test case where it is better not to form FMA
Jay Foad [Thu, 1 Jun 2023 12:32:17 +0000 (13:32 +0100)]
[AMDGPU] New test case where it is better not to form FMA

17 months ago[libc] Reduce math tests runtime further
Guillaume Chatelet [Thu, 1 Jun 2023 10:28:04 +0000 (10:28 +0000)]
[libc] Reduce math tests runtime further

Reviewed By: lntue

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

17 months ago[clang][NFC] Make HeaderSearch::suggestPathToFileForDiagnostics method const.
Haojian Wu [Thu, 1 Jun 2023 11:57:02 +0000 (13:57 +0200)]
[clang][NFC] Make HeaderSearch::suggestPathToFileForDiagnostics method const.

17 months ago[X86] Add test for PR63055 (NFC)
Nikita Popov [Thu, 1 Jun 2023 12:31:28 +0000 (14:31 +0200)]
[X86] Add test for PR63055 (NFC)

17 months ago[LoopLoadElimination] Add support for stride equal to -1
Igor Kirillov [Thu, 25 May 2023 12:53:17 +0000 (12:53 +0000)]
[LoopLoadElimination] Add support for stride equal to -1

This patch allows us to gain all the benefits provided by
LoopLoadElimination pass to descending loops.

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

17 months ago[LinkerWrapper] Fix static library symbol resolution
Joseph Huber [Wed, 31 May 2023 20:47:43 +0000 (15:47 -0500)]
[LinkerWrapper] Fix static library symbol resolution

The linker wrapper performs its own very basic symbol resolution for the
purpose of supporting standard static library semantics. We do this here
because the Nvidia `nvlink` wrapper does not support static linking and
we have some offloading specific extensions.

Currently, we always place symbols in the "table" even if they aren't
extracted. This caused the logic to fail when many files were used that
referenced the same undefined variable. This patch changes the pass to
only add the symbols to the global "table" if the file is actually
extracted.

Reviewed By: tra

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

17 months ago[X86] Fix masked store scheduler ports for skylake models
Simon Pilgrim [Wed, 31 May 2023 15:51:07 +0000 (16:51 +0100)]
[X86] Fix masked store scheduler ports for skylake models

Only uses port2+3 for agen, and was missing port4 for the actual store

Noticed while investigating the skylake vs icelake diffs for Issue #62602

17 months ago[flang][OpenMP] Verify support for private/firstprivate on unstructured sections
Nimish Mishra [Thu, 1 Jun 2023 10:31:34 +0000 (16:01 +0530)]
[flang][OpenMP] Verify support for private/firstprivate on unstructured sections

Verification of support for lowering private/firstprivate clauses
on unstructured sections.

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

Reviewed By: TIFitis

17 months ago[OpenMP] Add support for declare target initializer expressions
Ritanya B Bharadwaj [Thu, 1 Jun 2023 09:21:32 +0000 (04:21 -0500)]
[OpenMP] Add support for declare target initializer expressions

Initial support for OpenMP 5.0 declare target "as if" behavior for "initializer expressions".
OpenMP 5.0, 2.12.7 declare target.

Reviewed By: Alexey

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

17 months ago[AArch64] Increase the cost of i1 inserts / extracts
David Green [Thu, 1 Jun 2023 09:54:53 +0000 (10:54 +0100)]
[AArch64] Increase the cost of i1 inserts / extracts

i1 inserts will need an extra cset, and i1 extracts need a cmp (or tst) in
order to be used. This increase the cost of them a little to account for those
extra instructions.
https://godbolt.org/z/3c5z4G7Mh

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

17 months ago[InstCombine] Fix worklist management in rewriteGEPAsOffset() more thoroughly
Nikita Popov [Thu, 1 Jun 2023 08:58:58 +0000 (10:58 +0200)]
[InstCombine] Fix worklist management in rewriteGEPAsOffset() more thoroughly

We need to add the replaced instruction itself to the worklist as
well. We want to remove the old instructions, but can't easily do
so directly, as the icmp is also one of the users and we need to
retain it until the fold has finished.

17 months ago[X86] Align stack to 16-bytes on 32-bit with X86_INTR call convention
Antonio Abbatangelo [Thu, 1 Jun 2023 08:18:12 +0000 (16:18 +0800)]
[X86] Align stack to 16-bytes on 32-bit with X86_INTR call convention

Adds a dynamic stack alignment to functions under the interrupt call
convention on x86-32. This fixes the issue where the stack can be
misaligned on entry, since x86-32 makes no guarantees about the stack
pointer position when the interrupt service routine is called.

The alignment is done by overriding X86RegisterInfo::shouldRealignStack,
and by setting the correct alignment in X86FrameLowering::calculateMaxStackAlign.
This forces the interrupt handler to be dynamically aligned, generating
the appropriate `and` instruction in the prologue and `lea` in the
epilogue. The `no-realign-stack` attribute can be used as an opt-out.

Fixes #26851

Reviewed By: pengfei

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

17 months ago[clang][Interp] Optionally cast comparison result to non-bool
Timm Bäder [Thu, 1 Jun 2023 07:48:04 +0000 (09:48 +0200)]
[clang][Interp] Optionally cast comparison result to non-bool

Our comparison opcodes always produce a Boolean value and push it on the
stack. However, the result of such a comparison in C is int, so the
later code expects an integer value on the stack.

Work around this problem by casting the boolean value to int in those
cases. This is not ideal for C however. The comparison is usually
wrapped in a IntegerToBool cast anyway.

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

17 months ago[InstCombine] Fix worklist management in transformToIndexedCompare()
Nikita Popov [Thu, 1 Jun 2023 08:31:13 +0000 (10:31 +0200)]
[InstCombine] Fix worklist management in transformToIndexedCompare()

Use replaceInstUsesWith() rather than plain RAUW to make sure the
old instructions are added back to the worklist for DCE.

17 months ago[DWP] add overflow check for llvm-dwp tools if offset overflow
zhuna [Thu, 1 Jun 2023 07:53:50 +0000 (15:53 +0800)]
[DWP] add overflow check for llvm-dwp tools if offset overflow

Now, if the offset overflow happens, we just silently ignore it.
We will generate a bad dwp file, which will crash the gdb or make
it undefined behavior, and hard to address the root cause. So, we
need to produce some messages if overflow happens.

Reviewed By: ayermolo, dblaikie, steven.zhang

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