platform/upstream/llvm.git
23 months ago[mlir][dataflow] Remove Abstract{Sparse,Dense}Lattice::isAtFixpoint() and an ineffect...
Zhixun Tan [Mon, 15 Aug 2022 17:20:48 +0000 (13:20 -0400)]
[mlir][dataflow] Remove Abstract{Sparse,Dense}Lattice::isAtFixpoint() and an ineffective optimization to simplify public API

Currently, in the MLIR `{Sparse,Dense}DataFlowAnalysis` API, there is a small optimization:

Before running a transfer function, if the "out state" is already at the pessimistic fixpoint (bottom lattice value), then we know that it cannot possibly be changed, therefore we can skip the transfer function.

I benchmarked and found that this optimization is ineffective, so we can remove it and simplify `{Sparse,Dense}DataFlowAnalysis`. In a subsequent patch, I plan to change/remove the concept of the pessimistic fixpoint so that the API is further simplified.

Benchmark: I ran the following tests 5 times (after 3 warmup runs), and timed the `initializeAndRun()` function.

| Test | Before (us) | After (us) |
| mlir-opt -test-dead-code-analysis mlir/test/Analysis/DataFlow/test-dead-code-analysis.mlir | 181.2536 | 187.7074 |
| mlir-opt -- -test-dead-code-analysis mlir/test/Analysis/DataFlow/test-last-modified-callgraph.mlir | 109.5504 | 105.0654 |
| mlir-opt -- -test-dead-code-analysis mlir/test/Analysis/DataFlow/test-last-modified.mlir | 333.3646 | 322.4224 |
| mlir-opt -- -allow-unregistered-dialect -sccp mlir/test/Analysis/DataFlow/test-combined-sccp.mlir | 1027.1492 | 1081.818 |

Note: `test-combined-sccp.mlir` is crafted by combining `mlir/test/Transforms/sccp.mlir`, `mlir/test/Transforms/sccp-structured.mlir` and `mlir/test/Transforms/sccp-callgraph.mlir`.

Reviewed By: aartbik, Mogball

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

23 months ago[mlir] Simplify is_splat use in MatchAllPred. NFC.
Jakub Kuderski [Mon, 15 Aug 2022 17:17:42 +0000 (13:17 -0400)]
[mlir] Simplify is_splat use in MatchAllPred. NFC.

This is a simple cleanup after https://reviews.llvm.org/D131289.

Reviewed By: antiagainst, Mogball

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

23 months ago[LLDB][NFC] Reliability Fixes for FormatEntity
Slava Gurevich [Sun, 14 Aug 2022 06:46:21 +0000 (23:46 -0700)]
[LLDB][NFC] Reliability Fixes for FormatEntity

 - Remove dead code
 - Fix incorrect null-reference check

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

23 months ago[OpenMP][libomptarget] Fix run region async condition
Kevin Sala Penads [Mon, 15 Aug 2022 17:07:27 +0000 (13:07 -0400)]
[OpenMP][libomptarget] Fix run region async condition

This patch fixes a condition in the openmp/libomptarget/src/device.cpp file. The code was checking if the run_region plugin API function was implemented, but it should actually check the run_region_async function instead.

Reviewed By: tianshilei1992

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

23 months ago[ORC][COFF] Introduce DLLImportDefinitionGenerator.
Sunho Kim [Mon, 15 Aug 2022 16:35:18 +0000 (01:35 +0900)]
[ORC][COFF] Introduce DLLImportDefinitionGenerator.

This class will be used to properly solve the `__imp_` symbol and jump-thunk generation issues. It is assumed to be the last definition generator to be called, and as it's the last generator the only symbols remaining in the lookup set are the symbols that are supposed to be queried outside this jitdylib. Instead of just letting them through, we issue another lookup invocation and fetch the allocated addresses, and then create jitlink graph containing `__imp_` GOT symbols and jump-thunks targetting the fetched addresses.

Reviewed By: lhames

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

23 months ago[InstCombine] reduce sub-with-overflow ==/!= 0
Sanjay Patel [Mon, 15 Aug 2022 16:25:24 +0000 (12:25 -0400)]
[InstCombine] reduce sub-with-overflow ==/!= 0

The basic patterns look like this:
https://alive2.llvm.org/ce/z/MDj9EC

The tests have a use of the overflow value too.
Otherwise, existing folds should reduce already.

This was noted as a missing IR fold in:
926e7312b2f20f2f7b

Hopefully, this makes it easier to implement a backend
fix because we should get the same IR regardless of
whether the source used builtins or inline code.

23 months ago[InstCombine] add tests for compare of sub-with-overflow; NFC
Sanjay Patel [Mon, 15 Aug 2022 15:30:09 +0000 (11:30 -0400)]
[InstCombine] add tests for compare of sub-with-overflow; NFC

23 months ago[InstCombine] known-phi-br.ll - add multiuse of compare results to avoid predicate...
Simon Pilgrim [Mon, 15 Aug 2022 16:53:21 +0000 (17:53 +0100)]
[InstCombine] known-phi-br.ll - add multiuse of compare results to avoid predicate inverse and add negative tests

Feedback from D131838

23 months ago[llvm] Include utils/unittest before projects and runtimes
Jonas Devlieghere [Mon, 15 Aug 2022 16:42:41 +0000 (09:42 -0700)]
[llvm] Include utils/unittest before projects and runtimes

Include utils/unittest before projects and runtimes so that downstream
projects can check for the existence of the llvm_gtest target. This is
motivated by 9c6c4d675bd1 which fixes the stand-alone build
configuration where LLVM_MAIN_SRC_DIR does not exist.

Differential revision: https://reviews.llvm.org/D124314

23 months ago[mlir][nvpu] Prevent F32ToTF32 pattern to generate illegal IR
Thomas Raoux [Mon, 15 Aug 2022 16:16:46 +0000 (16:16 +0000)]
[mlir][nvpu] Prevent F32ToTF32 pattern to generate illegal IR

We shouldn't apply this pattern to non F32->F32 mma.sync operations.

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

23 months ago[lldb][debugserver] Revert "Use llvm::all_of (NFC)" for debugserver
Michael Buch [Mon, 15 Aug 2022 16:22:16 +0000 (17:22 +0100)]
[lldb][debugserver] Revert "Use llvm::all_of (NFC)" for debugserver

Commit [6d9cd9199a6fdeab0412117bcefc28f625510b61](https://reviews.llvm.org/rG6d9cd9199a6fdeab0412117bcefc28f625510b61) added a dependency on llvm to debugserver.
This breaks the build. Since we don't want to add a dependency on llvm, this
patch reverts the offending commit.

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

23 months ago[flang][docs] Add lowering design doc for polymorphic entities
Valentin Clement [Mon, 15 Aug 2022 16:12:46 +0000 (18:12 +0200)]
[flang][docs] Add lowering design doc for polymorphic entities

This document aims to give insights at the representation of polymorphic
entities in FIR and how polymorphic related constructs and features are lowered
to FIR.

Reviewed By: klausler, razvanlupusoru

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

23 months ago[flang] Handle mixed types in DOT_PRODUCT simplification.
Slava Zakharin [Thu, 11 Aug 2022 21:36:23 +0000 (14:36 -0700)]
[flang] Handle mixed types in DOT_PRODUCT simplification.

Fortran runtime supports mixed types by casting the loaded values
to the result type, so DOT_PRODUCT simplification has to do the same.

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

23 months ago[mlir] Revisit `LinalgLoopDistributionOptions`.
Mahesh Ravishankar [Mon, 15 Aug 2022 04:03:41 +0000 (04:03 +0000)]
[mlir] Revisit `LinalgLoopDistributionOptions`.

This patch cleans up the way `LinalgLoopDistributionOptions` are meant
to be used. The option just contains a call back that takes the list
of loop ranges that represent the loops that are to be distributed.
These loops are the outer parallel loops of the tiled operation which
have non-zero tile sizes specified. The call back returns for each of
the loops,
- The procId to use,
- The number of processors,
- The distribution method to use for that loop.

Reviewed By: antiagainst, hanchung

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

23 months ago[CMake] Update FindGPRC to use add_llvm_library
Steven Wu [Mon, 15 Aug 2022 15:54:01 +0000 (08:54 -0700)]
[CMake] Update FindGPRC to use add_llvm_library

add_clang_library is not available in components other than clang and
clang-tool-extras. Trying to use this module elsewhere will cause cmake
error. `add_clang_library` doesn't seem necessary for clangd's GRPC.
Change it to a more generic `add_llvm_library` so it is easier to build
other downstream projects with GRPC that doesn't depend on clang.

Reviewed By: akyrtzi

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

23 months ago[clang] fix missing initialization of original number of expansions
Matheus Izvekov [Fri, 12 Aug 2022 19:50:30 +0000 (21:50 +0200)]
[clang] fix missing initialization of original number of expansions

When expanding undeclared function parameters, we should initialize
the original number of expansions, if known, before trying to expand
them, otherwise a length mismatch with an outer pack might not be
diagnosed.

Fixes PR56094.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D131802

23 months agoDynamicMemRefType: iteration and access by indices
Michele Scuttari [Mon, 15 Aug 2022 15:17:54 +0000 (17:17 +0200)]
DynamicMemRefType: iteration and access by indices

The methods to perform such operations have been implemented for the DynamicMemRefType in a way that is similar to the implementation for StridedMemRefType. Up until here one could pass an unranked memref to the library, and thus obtain a “dynamic” memref descriptor, but then there would have been no possibility to operate on its content.

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

23 months ago[RISCV] Enable isTruncateFree in SDAG for i64->i32 on rv64.
Craig Topper [Mon, 15 Aug 2022 15:32:22 +0000 (08:32 -0700)]
[RISCV] Enable isTruncateFree in SDAG for i64->i32 on rv64.

We have a good selection of W instructions, so promoting a truncated
value back to i64 is often free.

This appears to be a net code size reduction on SPECINT2006.

This has been split from D130397 as one of the patches needed to
complete that.

Reviewed By: reames

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

23 months ago[InstSimplify] sle on i1 also encodes implication
Craig Topper [Mon, 15 Aug 2022 15:17:54 +0000 (08:17 -0700)]
[InstSimplify] sle on i1 also encodes implication

We already support SGE, so the same logic should hold for SLE with
the LHS and RHS swapped.

I didn't see this in the wild. Just happened to walk past this code
and thought it was odd that it was asymmetric in what condition
codes it handled.

Reviewed By: spatel, reames

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

23 months ago[llvm] [cmake] Move LLVM_INSTALL_PACKAGE_DIR top-level to fix llvm-config
Michał Górny [Mon, 15 Aug 2022 07:50:14 +0000 (09:50 +0200)]
[llvm] [cmake] Move LLVM_INSTALL_PACKAGE_DIR top-level to fix llvm-config

Move the `LLVM_INSTALL_PACKAGE_DIR` declaration from llvm/cmake/modules
directory to the top-level llvm/CMakeLists.txt, in order to fix
the regression in `llvm-config --cmakedir` output for installed LLVM.
Since the tools directory is processed by CMake prior to
llvm/cmake/modules, the llvm-config executable ended up using
the variable prior to it being defined and incorrectly used an empty
path, resulting in e.g.:

    $ llvm-config --cmakedir
    /usr/lib/llvm/16/

With this patch, the path is defined (and therefore the default value
is being set) prior to adding the tools subdirectory and llvm-config
starts working correctly:

    $ llvm-config --cmakedir
    /usr/lib/llvm/16/lib64/cmake/llvm

This fixes a regression introduced by D130539.  Thanks to Petr Polezhaev
for reporting the problem @ https://bugs.gentoo.org/865165

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

23 months ago[X86] Freeze shl(x,1) -> add(x,x) vector fold (PR50468)
Simon Pilgrim [Mon, 15 Aug 2022 15:17:12 +0000 (16:17 +0100)]
[X86] Freeze shl(x,1) -> add(x,x) vector fold (PR50468)

Vector fold shl(x,1) -> add(freeze(x),freeze(x)) to avoid the undef issues identified in PR50468

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

23 months ago[libc++][test] Fix conversion signed/unsigned in test/support/MoveOnly.h
Igor Zhukov [Mon, 15 Aug 2022 13:31:03 +0000 (20:31 +0700)]
[libc++][test] Fix conversion signed/unsigned in test/support/MoveOnly.h

Reviewed By: jloser, philnik

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

23 months ago[llvm-objdump] Start on -chained_fixups for llvm-otool
Nico Weber [Mon, 15 Aug 2022 13:06:57 +0000 (09:06 -0400)]
[llvm-objdump] Start on -chained_fixups for llvm-otool

And --chained-fixups for llvm-objdump.

For now, this only prints the dyld_chained_fixups_header and adds
plumbing for the flag. This will be expanded in future commits.

When Apple's effort to upstream their chained fixups code continues,
we'll replace this code with the then-upstreamed code. But we need
something in the meantime for testing ld64.lld's chained fixups
code.

Update chained-fixups.yaml with a file that actually contains
the chained fixup data (`LinkEditData` doesn't encode it yet,
so use `__LINKEDIT` via `--raw-segment=data`).

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

23 months ago[flang][openacc][NFC] Add test with allocatable and pointer arrays
Valentin Clement [Mon, 15 Aug 2022 14:44:51 +0000 (16:44 +0200)]
[flang][openacc][NFC] Add test with allocatable and pointer arrays

This patch adds tests for the handling of array sections for
arrays with the ALLOCATABLE or POINTER attribute.

Reviewed By: razvanlupusoru

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

23 months ago[X86] Fold insert_vector_elt(undef, elt, 0) --> scalar_to_vector(elt)
Simon Pilgrim [Mon, 15 Aug 2022 13:56:02 +0000 (14:56 +0100)]
[X86] Fold insert_vector_elt(undef, elt, 0) --> scalar_to_vector(elt)

I had hoped to make this a generic fold in DAGCombine, but there's quite a few regressions in Thumb2 MVE that need addressing first.

Fixes regressions from D106675.

23 months ago[NFC][SmallVector] Use std::conditional_t instead of std::conditional
wangyihan [Mon, 15 Aug 2022 13:11:42 +0000 (21:11 +0800)]
[NFC][SmallVector] Use std::conditional_t instead of std::conditional

Signed-off-by: wangyihan <yihan.wang@intel.com>
23 months ago[DAG] Ensure more Legal BUILD_VECTOR elements types in shuffle->And combine
David Green [Mon, 15 Aug 2022 13:41:45 +0000 (14:41 +0100)]
[DAG] Ensure more Legal BUILD_VECTOR elements types in shuffle->And combine

This is a followup to D131350, which caused another problem for i64
types being split into i32 on i32 targets. This patch tries to make sure
that either Illegal types are OK, or that the element types of a
buildvector are legal and bigger than or equal to the size of the
original elements.

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

23 months ago[mlir][linalg][python] Add named constructor for MatchOp
Matthias Springer [Mon, 15 Aug 2022 11:02:17 +0000 (13:02 +0200)]
[mlir][linalg][python] Add named constructor for MatchOp

This constructor makes it easier to match for ops by their name.

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

23 months agoSilence MSVC codecvt deprecation warnings
Aaron Ballman [Mon, 15 Aug 2022 12:36:56 +0000 (08:36 -0400)]
Silence MSVC codecvt deprecation warnings

This silences warnings about use of deprecated codecvt functionality
after the switch to build with C++17.

23 months agoRevert "(Reland) [fastalloc] Support allocating specific register class in fastalloc"
Luo, Yuanke [Mon, 15 Aug 2022 11:38:41 +0000 (19:38 +0800)]
Revert "(Reland) [fastalloc] Support allocating specific register class in fastalloc"

This reverts commit 30f9e6ebd30b79d13f99eaca4d829e0da07186b3.

23 months ago[AVR] Only push and clear R1 in interrupts when necessary
Ayke van Laethem [Sun, 16 Jan 2022 08:34:04 +0000 (09:34 +0100)]
[AVR] Only push and clear R1 in interrupts when necessary

R1 is a reserved register, but LLVM gives the APIs to know when it is
used or not. So this patch uses these APIs to only save/clear/restore R1
in interrupts when necessary.

The main issue here was getting inline assembly to work. One could argue
that this is the job of Clang, but for consistency I've made sure that
R1 is always usable in inline assembly even if that means clearing it
when it might not be needed.

Information on inline assembly in AVR can be found here:

https://www.nongnu.org/avr-libc/user-manual/inline_asm.html#asm_code

Essentially, this seems to suggest that r1 can be freely used in avr-gcc
inline assembly, even without specifying it as an input operand.

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

23 months ago[AVR] Use @earlyclobber instead of register scavenging
Ayke van Laethem [Sat, 13 Aug 2022 19:51:30 +0000 (21:51 +0200)]
[AVR] Use @earlyclobber instead of register scavenging

The code to support the case when the register allocator has assigned
the same register to the src and the dst register operand isn't actually
needed:

  * LDWRdPtr and LDDWRdPtrQ have an @earlyclobber on the output
    register, so the register allocator will make sure to allocate a
    different register for the output register.
  * LDDWRdYQ does not have an @earlyclobber, but the pointer register is
    the fixed Y register which is reserved. The register allocator won't
    use reserved registers for the output value.

This removes a special case in the code that makes the pseudo
instruction expansion pass more complicated than it needs to be.

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

23 months ago[AVR] Support unaligned store
Ayke van Laethem [Fri, 24 Jun 2022 00:43:11 +0000 (02:43 +0200)]
[AVR] Support unaligned store

This patch really just extends D39946 towards stores as well as loads.
While the patch is in SelectionDAGBuilder, it only applies to AVR (the
only target that supports unaligned atomic operations).

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

23 months ago[IR] Change access rights of PredIterator members
Dmitry Vassiliev [Mon, 15 Aug 2022 12:25:58 +0000 (14:25 +0200)]
[IR] Change access rights of PredIterator members

These members were made private here https://github.com/llvm/llvm-project/commit/6177386b05ddaaee04160b153a41ed4edbd7bcaf without an explanation.
Our customers have an own implementation inherited from PredIterator with updated advancePastNonTerminators().
The access specifier protected looks resonable and safe here.

Reviewed By: RKSimon

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

23 months agoRevert "[SCEV] Use context to strengthen flags of BinOps"
Max Kazantsev [Mon, 15 Aug 2022 11:51:59 +0000 (18:51 +0700)]
Revert "[SCEV] Use context to strengthen flags of BinOps"

This reverts commit 34ae308c73e4d76dbdab25a6206d3fbc5ebafdf5.

Our internal testing found a miscompile. Not sure if it's caused by
this patch or it revealed something else. Reverting while investigating.

23 months ago[DAG] canCreateUndefOrPoison - add freeze(sign_extend_inreg(x,vt)) -> sign_extend_inr...
Simon Pilgrim [Mon, 15 Aug 2022 11:18:51 +0000 (12:18 +0100)]
[DAG] canCreateUndefOrPoison - add freeze(sign_extend_inreg(x,vt)) -> sign_extend_inreg(freeze(x),vt) support

Guaranteed not to create undef/poison

23 months ago[DAGCombine] Combine signext_inreg of extract-extend
Peter Waller [Tue, 9 Aug 2022 15:13:50 +0000 (15:13 +0000)]
[DAGCombine] Combine signext_inreg of extract-extend

The outer signext_inreg is redundant in the following:

  Fold (signext_inreg (extract_subvector (zext|anyext|sext iN_value to _) _) from iN)
       -> (extract_subvector (signext iN_value to iM))

Tests are precommitted and clone those by analogy from the AND case in
the same file. Add a negative test to check extension width is handled
correctly.

This patch supersedes D130700.

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

23 months ago[DAG] canCreateUndefOrPoison - add freeze(assertsext/zext(x,bt)) -> assertsext/zext...
Simon Pilgrim [Mon, 15 Aug 2022 10:07:27 +0000 (11:07 +0100)]
[DAG] canCreateUndefOrPoison - add freeze(assertsext/zext(x,bt)) -> assertsext/zext(freeze(x),vt) support

These are guaranteed not to create undef/poison (although they may pass through) - the associated ISD::VALUETYPE node is also guaranteed never to generate poison

23 months ago[mlir][bufferize] Fix bug in AllocTensorElimination
Matthias Springer [Mon, 15 Aug 2022 09:14:43 +0000 (11:14 +0200)]
[mlir][bufferize] Fix bug in AllocTensorElimination

AllocTensorElimination does currently not support chains where the type is
changing. AllocTensorElimination used to generate invalid IR for such
inputs. With this commit, AllocTensorElimination does no longer apply to
such inputs. (It can be extended to support such IR if needed.)

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

23 months agoMake demangler independent of LLVM again
Benjamin Kramer [Mon, 15 Aug 2022 09:44:28 +0000 (11:44 +0200)]
Make demangler independent of LLVM again

The demangler is not supposed to include bits of LLVM, so it can't use STLExtras.

This undoes part of 6d9cd9199a6fdeab0412117bcefc28f625510b61

23 months ago[LLDB] Remove __future__ imports from examples
David Spickett [Fri, 12 Aug 2022 13:14:00 +0000 (13:14 +0000)]
[LLDB] Remove __future__ imports from examples

Not needed now that we require python 3.

Reviewed By: kastiglione, JDevlieghere

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

23 months ago[LLDB] Remove __future__ imports from tests
David Spickett [Fri, 12 Aug 2022 10:56:09 +0000 (10:56 +0000)]
[LLDB] Remove __future__ imports from tests

Not needed now that we require python 3.

Reviewed By: kastiglione, JDevlieghere

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

23 months ago[AArch64] Tests for non-temporal loads.
Zain Jaffal [Mon, 15 Aug 2022 08:15:50 +0000 (09:15 +0100)]
[AArch64] Tests for non-temporal loads.

Add some test cases for D131773 where LDNP could be used as well as
negative tests.

Reviewed By: fhahn

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

23 months ago[NFC][trace][intel pt] add simple documentation line
Walter Erquinigo [Mon, 15 Aug 2022 07:55:36 +0000 (00:55 -0700)]
[NFC][trace][intel pt] add simple documentation line

23 months ago[flang] Install runtime libs with the toolchain
Diana Picus [Thu, 11 Aug 2022 09:21:40 +0000 (11:21 +0200)]
[flang] Install runtime libs with the toolchain

Make sure that FortranDecimal, FortranRuntime and Fortran_main are
installed/packaged even when LLVM_INSTALL_TOOLCHAIN_ONLY is enabled.
They are used by flang to link executables, so they should be provided
even with minimal installs.

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

23 months ago[ADT] Make SmallSet::insert(const T &) return const_iterator
Zijia Zhu [Mon, 15 Aug 2022 05:43:59 +0000 (13:43 +0800)]
[ADT] Make SmallSet::insert(const T &) return const_iterator

This patch makes `SmallSet::insert(const T &)` return
`std::pair<const_iterator, bool>` instead of
`std::pair<NoneType, bool>`. This will exactly match std::set's behavior
and make deduplicating items with SmallSet easier.

Reviewed By: dblaikie, lattner

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

23 months ago[DebugInfo] -fdebug-prefix-map: handle '#line "file"' for asm source
Fangrui Song [Mon, 15 Aug 2022 03:58:23 +0000 (20:58 -0700)]
[DebugInfo] -fdebug-prefix-map: handle '#line "file"' for asm source

`getContext().setMCLineTableRootFile` (from D62074) sets `RootFile.Name` to
`FirstCppHashFilename`. `RootFile.Name` is not processed by -fdebug-prefix-map
and will go to DW_TAG_compile_unit's DT_AT_name and DW_TAG_label's
DW_AT_decl_file. Remap `RootFile.Name`.

Fix another issue reported by https://github.com/llvm/llvm-project/issues/56609

Reviewed By: #debug-info, dblaikie, raj.khem

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

23 months ago[ADT] Deprecate Optional::map
Kazu Hirata [Mon, 15 Aug 2022 00:51:59 +0000 (17:51 -0700)]
[ADT] Deprecate Optional::map

This patch deprecates Optional::map in favor of Optional::transform
for consistency with std::optional::transform in C++23.

Note that I've migrated all known users of Optional::map.

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

23 months ago[X86][RISCV] Pre-commit tests for D130862. NFC
Craig Topper [Sun, 14 Aug 2022 23:15:45 +0000 (16:15 -0700)]
[X86][RISCV] Pre-commit tests for D130862. NFC

Reviewed By: RKSimon

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

23 months agoUse llvm::none_of (NFC)
Kazu Hirata [Sun, 14 Aug 2022 23:25:39 +0000 (16:25 -0700)]
Use llvm::none_of (NFC)

23 months ago[clangd] Use llvm::any_of (NFC)
Kazu Hirata [Sun, 14 Aug 2022 23:25:38 +0000 (16:25 -0700)]
[clangd] Use llvm::any_of (NFC)

23 months agoUse llvm::all_of (NFC)
Kazu Hirata [Sun, 14 Aug 2022 23:25:36 +0000 (16:25 -0700)]
Use llvm::all_of (NFC)

23 months ago[libc++][spaceship] Implement std::variant::operator<=>
Kent Ross [Sun, 14 Aug 2022 23:14:57 +0000 (16:14 -0700)]
[libc++][spaceship] Implement std::variant::operator<=>

Implements [variant.relops] and [variant.monostate.relops] for P1614R2

Reviewed By: Mordante, #libc, avogelsgesang

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

23 months ago[Support] Fix no-stat build. NFC
David Green [Sun, 14 Aug 2022 22:55:31 +0000 (23:55 +0100)]
[Support] Fix no-stat build. NFC

After 9144e4933463d35df259ca8a5207119e1fc0c97c this performs the same
transform inside the other ifdef.

23 months ago[c++] implements DR692, DR1395 and tentatively DR1432, about partial ordering of...
Yuanfang Chen [Thu, 11 Aug 2022 19:53:41 +0000 (12:53 -0700)]
[c++] implements DR692, DR1395 and tentatively DR1432, about partial ordering of variadic template partial specialization or function template

DR692 handles two cases: pack expansion (for class/var template) and function parameter pack. The former needs DR1432 as a fix, and the latter needs DR1395 as a fix. However, DR1432 has not yet made a wording change. so I made a tentative fix for DR1432 with the same spirit as DR1395.

Reviewed By: aaron.ballman, erichkeane, #clang-language-wg

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

23 months ago[Hexagon] Distribute disjoint intervals at the end of expand-condsets
Krzysztof Parzyszek [Sun, 14 Aug 2022 20:57:44 +0000 (15:57 -0500)]
[Hexagon] Distribute disjoint intervals at the end of expand-condsets

This fixes https://github.com/llvm/llvm-project/issues/56050.

23 months ago[Hexagon] Make some loops in HexagonExpandCondsets.cpp range-based, NFC
Krzysztof Parzyszek [Sun, 14 Aug 2022 20:22:41 +0000 (15:22 -0500)]
[Hexagon] Make some loops in HexagonExpandCondsets.cpp range-based, NFC

Plus some readability changes.

23 months ago[Sema] Avoid isNullPointerConstant invocation
Justin Stitt [Sun, 14 Aug 2022 20:28:49 +0000 (13:28 -0700)]
[Sema] Avoid isNullPointerConstant invocation

DiagnoseNullConversion is needlessly calling isNullPointerConstant which
is an expensive routine due to its calls to a constant evaluator --
which we don't need.

Building the Linux Kernel (x86_64) with this fix has improved build
times by ~2.1%. This is mainly due to the following methods no longer
needing to be called anywhere near as often:
1) ExprConstant::CheckICE (reduced CPU cycles by ~90%)
2) IntExprEvaluator::VisitBinaryOperator (reduced CPU cycles by ~50%)

Reviewed By: rtrieu, nickdesaulniers

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

23 months agoInstCombine: use poison instead of undef as placeholder in insertvalue [NFC]
Nuno Lopes [Sun, 14 Aug 2022 20:37:23 +0000 (21:37 +0100)]
InstCombine: use poison instead of undef as placeholder in insertvalue [NFC]
These vectors are fully initialized so the placeholder value is irrelevant

23 months agoRevert "[clang] adds unary type transformations as compiler built-ins"
Nico Weber [Sun, 14 Aug 2022 19:57:38 +0000 (15:57 -0400)]
Revert "[clang] adds unary type transformations as compiler built-ins"

This reverts commit bc60cf2368de90918719dc7e3d7c63a72cc007ad.
Doesn't build on Windows and breaks gcc 9 build, see
https://reviews.llvm.org/D116203#3722094 and
https://reviews.llvm.org/D116203#3722128

Also revert two follow-ups. One fixed a warning added in
bc60cf2368de90918719dc7e3d7c63a72cc007ad, the other
makes use of the feature added in bc60cf2368de90918719dc7e3d7c63a72cc007ad
in libc++:

Revert "[libcxx][NFC] utilises compiler builtins for unary transform type-traits"
This reverts commit 06a1d917ef1f507aaa2f6891bb654696c866ea3a.

Revert "[Sema] Fix a warning"
This reverts commit c85abbe879ef3257de4db862ce249b060cc3d2a4.

23 months ago[flang] Remove redundant string initialization (NFC)
Kazu Hirata [Sun, 14 Aug 2022 19:52:01 +0000 (12:52 -0700)]
[flang] Remove redundant string initialization (NFC)

Identified with readability-redundant-string-init.

23 months ago[mlir] Remove redundant member initialization (NFC)
Kazu Hirata [Sun, 14 Aug 2022 19:51:59 +0000 (12:51 -0700)]
[mlir] Remove redundant member initialization (NFC)

Identified with readability-redundant-member-init.

23 months ago[Transforms] Qualify auto in range-based for loops (NFC)
Kazu Hirata [Sun, 14 Aug 2022 19:51:58 +0000 (12:51 -0700)]
[Transforms] Qualify auto in range-based for loops (NFC)

Identified with readability-qualified-auto.

23 months ago[Support] Drop unnecessary const from a return type (NFC)
Kazu Hirata [Sun, 14 Aug 2022 19:51:56 +0000 (12:51 -0700)]
[Support] Drop unnecessary const from a return type (NFC)

Identified with readability-const-return-type.

23 months ago[JITLink] Fix some missing std::moves.
Lang Hames [Sun, 14 Aug 2022 18:42:26 +0000 (11:42 -0700)]
[JITLink] Fix some missing std::moves.

This should fix failures on some bots due to 1cf81274f42
(e.g. https://lab.llvm.org/buildbot#builders/196/builds/16684)

23 months ago[Sema] Fix a warning
Kazu Hirata [Sun, 14 Aug 2022 18:25:19 +0000 (11:25 -0700)]
[Sema] Fix a warning

This patch fixes:

  clang/lib/Sema/SemaType.cpp:9469:3: error: default label in switch
  which covers all enumeration values
  [-Werror,-Wcovered-switch-default]

23 months ago[gn build] Port 1cf81274f425
LLVM GN Syncbot [Sun, 14 Aug 2022 17:56:25 +0000 (17:56 +0000)]
[gn build] Port 1cf81274f425

23 months ago[M68k] Fix MSVC llvm::Optional<> deprecation warnings
Simon Pilgrim [Sun, 14 Aug 2022 17:54:37 +0000 (18:54 +0100)]
[M68k] Fix MSVC llvm::Optional<> deprecation warnings

Use has_value()/value() instead of hasValue()/getValue()

23 months ago[JITLink] Add eh-frame CFI inspector, fix crash on malformed FDEs.
Lang Hames [Sat, 13 Aug 2022 03:52:34 +0000 (20:52 -0700)]
[JITLink] Add eh-frame CFI inspector, fix crash on malformed FDEs.

Add a fix to check that FDE pc-begin targets are defined before calling
getBlock (which will crash if the target is not defined). FDE pc-begins
pointing at undefined symbols are expected to arise only in obscure
circumstances (malformed objects, or removal of targets by JITLink
passes), but we want to handle them gracefully. With this patch the
FDE will be retained, but without any keepalive edge to it. Unless
some pass takes action to mark it as live it will be dead-stripped.

To make it easier for passes to connect FDEs to their targets a new
EHFrameCFIBlockInspector utility is added. This allows clients to
quickly determine whether a CFI record is a CIE or an FDE (assuming
that it's valid), and retrieve any personality, pc-begin, cie, or
LSDA edges associated with it.

23 months ago[libcxx][NFC] utilises compiler builtins for unary transform type-traits
Christopher Di Bella [Sun, 14 Aug 2022 16:53:00 +0000 (16:53 +0000)]
[libcxx][NFC] utilises compiler builtins for unary transform type-traits

Depends on D116203

Reviewed By: #libc, philnik

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

23 months ago[clang] adds unary type transformations as compiler built-ins
Christopher Di Bella [Wed, 10 Aug 2022 21:31:03 +0000 (21:31 +0000)]
[clang] adds unary type transformations as compiler built-ins

Adds

* `__add_lvalue_reference`
* `__add_pointer`
* `__add_rvalue_reference`
* `__decay`
* `__make_signed`
* `__make_unsigned`
* `__remove_all_extents`
* `__remove_extent`
* `__remove_const`
* `__remove_volatile`
* `__remove_cv`
* `__remove_pointer`
* `__remove_reference`
* `__remove_cvref`

These are all compiler built-in equivalents of the unary type traits
found in [[meta.trans]][1]. The compiler already has all of the
information it needs to answer these transformations, so we can skip
needing to make partial specialisations in standard library
implementations (we already do this for a lot of the query traits). This
will hopefully improve compile times, as we won't need use as much
memory in such a base part of the standard library.

[1]: http://wg21.link/meta.trans

Co-authored-by: zoecarver
Reviewed By: aaron.ballman, rsmith

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

23 months ago[LV] Add tests for vectorizing select of minimum idx idiom.
Florian Hahn [Sun, 14 Aug 2022 16:44:11 +0000 (17:44 +0100)]
[LV] Add tests for vectorizing select of minimum idx idiom.

Test cases for selecting the index with the minimum value.

23 months ago[X86] combineVectorShiftImm - fold (shl (add X, X), C) -> (shl X, (C + 1))
Simon Pilgrim [Sun, 14 Aug 2022 16:41:58 +0000 (17:41 +0100)]
[X86] combineVectorShiftImm - fold (shl (add X, X), C) -> (shl X, (C + 1))

Noticed while investigating the regressions in D106675

23 months ago[libc++][test] fix C4267 warning in bitset.members\to_ulong.pass.cpp
Igor Zhukov [Sun, 14 Aug 2022 10:33:15 +0000 (17:33 +0700)]
[libc++][test] fix C4267 warning in bitset.members\to_ulong.pass.cpp

Reviewed By: philnik

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

23 months ago[X86] Add test coverage for lshr/ashr with freeze
Simon Pilgrim [Sun, 14 Aug 2022 14:29:59 +0000 (15:29 +0100)]
[X86] Add test coverage for lshr/ashr with freeze

23 months ago[DAG] canCreateUndefOrPoison - add freeze(shl(x,y)) -> shl(freeze(x),y) support
Simon Pilgrim [Sun, 14 Aug 2022 12:54:52 +0000 (13:54 +0100)]
[DAG] canCreateUndefOrPoison - add freeze(shl(x,y)) -> shl(freeze(x),y) support

These are guaranteed not to create undef/poison if the shift amount is known to be in range

23 months ago[clang][doc] Removes an extra space.
Mark de Wever [Sun, 14 Aug 2022 13:16:43 +0000 (15:16 +0200)]
[clang][doc] Removes an extra space.

23 months ago[X86] Add test coverage for shl nsw with freeze
Simon Pilgrim [Sun, 14 Aug 2022 12:42:35 +0000 (13:42 +0100)]
[X86] Add test coverage for shl nsw with freeze

23 months ago[X86] freeze-binary.ll - tweak freeze_mul_nsw test to avoid mul by pow-2
Simon Pilgrim [Sun, 14 Aug 2022 12:35:56 +0000 (13:35 +0100)]
[X86] freeze-binary.ll - tweak freeze_mul_nsw test to avoid mul by pow-2

Enabling freeze(shl()) -> shl(freeze()) was affecting this test

23 months ago[X86] Add test coverage for shl with freeze
Simon Pilgrim [Sun, 14 Aug 2022 12:32:58 +0000 (13:32 +0100)]
[X86] Add test coverage for shl with freeze

23 months ago[DAG] canCreateUndefOrPoison - add freeze(and/or/xor(x,y)) -> and/or/xor(freeze(x...
Simon Pilgrim [Sun, 14 Aug 2022 12:14:46 +0000 (13:14 +0100)]
[DAG] canCreateUndefOrPoison - add freeze(and/or/xor(x,y)) -> and/or/xor(freeze(x),y) support

These are guaranteed not to create undef/poison

23 months ago[X86] Add test coverage for and/or/xor with freeze
Simon Pilgrim [Sun, 14 Aug 2022 12:01:59 +0000 (13:01 +0100)]
[X86] Add test coverage for and/or/xor with freeze

23 months ago[libc++] Uses operator<=> in string.
Mark de Wever [Tue, 19 Jul 2022 05:56:23 +0000 (07:56 +0200)]
[libc++] Uses operator<=> in string.

Implements part of:
- P1614R2 The Mothership has Landed

Reviewed By: avogelsgesang, #libc, philnik

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

23 months ago[libc++][test] Disables clang-tidy test for GCC.
Mark de Wever [Sat, 13 Aug 2022 13:01:44 +0000 (15:01 +0200)]
[libc++][test] Disables clang-tidy test for GCC.

Increasing the constexpr evaluation limit breaks this clang-tidy test
for GCC. As discussed in D131317 disable the test in GCC.

Reviewed By: philnik, #libc

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

23 months ago[ORC_RT][COFF] Fix cross compilation with mingw headers
Martin Storsjö [Sun, 14 Aug 2022 10:47:16 +0000 (13:47 +0300)]
[ORC_RT][COFF] Fix cross compilation with mingw headers

Mingw headers are all lowercase, and can be used for cross compilation
from case sensitive file systems.

The official Windows SDK headers aren't self-consistent wrt upper/lower
case, so those headers can't be used on case sensitive systems without
a layer providing case insensitivity anyway.

This matches other includes of windows.h throughout the codebase.

23 months ago[Polly] Remove the test case that depends on InstCombine and DeLICM.
Roman Gareev [Sun, 14 Aug 2022 09:50:22 +0000 (12:50 +0300)]
[Polly] Remove the test case that depends on InstCombine and DeLICM.

23 months ago[Orc] Use IntervalMap to store free memory regions in MapperJITLinkMemoryManager
Anubhab Ghosh [Tue, 9 Aug 2022 12:22:13 +0000 (17:52 +0530)]
[Orc] Use IntervalMap to store free memory regions in MapperJITLinkMemoryManager

MapperJITLinkMemoryManager uses a free list to keep track of available
memory regions. Using an IntervalMap instead of vector allow automatic
coalescing of memory regions as they are freed.

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

23 months ago[gn build] Port 7ae66e5e9593
LLVM GN Syncbot [Sun, 14 Aug 2022 08:35:03 +0000 (08:35 +0000)]
[gn build] Port 7ae66e5e9593

23 months ago[libc++] Implement P2417R2 (A more constexpr bitset)
Nikolas Klauser [Sat, 13 Aug 2022 11:52:35 +0000 (13:52 +0200)]
[libc++] Implement P2417R2 (A more constexpr bitset)

Reviewed By: ldionne, #libc

Spies: jloser, arichardson, libcxx-commits, arphaman

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

23 months ago[libc++] Granularize the rest of type_traits
Nikolas Klauser [Sat, 13 Aug 2022 21:10:31 +0000 (23:10 +0200)]
[libc++] Granularize the rest of type_traits

Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny

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

23 months ago[NFC] Combine test cases of verifier
Liqin.Weng [Sun, 14 Aug 2022 02:12:16 +0000 (10:12 +0800)]
[NFC] Combine test cases of verifier

Reviewed By: benshi001

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

23 months ago[Triple] Add llvm::Triple::isRISCV{32,64}
Alexey Baturo [Sun, 14 Aug 2022 01:51:35 +0000 (18:51 -0700)]
[Triple] Add llvm::Triple::isRISCV{32,64}

Reviewed By: vitalybuka, MaskRay, craig.topper

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

23 months ago[X86][FP16] Promote FP16->[U]INT to FP16->FP32->[U]INT
Phoebe Wang [Sun, 14 Aug 2022 01:03:09 +0000 (09:03 +0800)]
[X86][FP16] Promote FP16->[U]INT to FP16->FP32->[U]INT

This is to avoid f16->i64 being lowered to `__fixhfdi/__fixunshfdi` on 32-bits since neither libgcc nor compiler-rt provide them. https://godbolt.org/z/cjWEsea5v

It also helps to improve the performance by promoting the vector type.

Reviewed By: LuoYuanke

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

23 months ago[llvm] Update FileSystem test that failed spuriously
Ben Langmuir [Sun, 14 Aug 2022 01:12:39 +0000 (18:12 -0700)]
[llvm] Update FileSystem test that failed spuriously

This test failed spuriously in an environment that appears to ignore the
'x' bit permission on directories. Allow for that possibility.

23 months agofix some bad logic that was removing all successor phi nodes, not just
John Regehr [Sun, 14 Aug 2022 01:14:10 +0000 (19:14 -0600)]
fix some bad logic that was removing all successor phi nodes, not just
out of chunk ones. the non-default second argument to
removePredecessor() is necessary to avoid creating invalid IR on
examples like the one in the provided test case

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

23 months ago[llvm-readobj] Remove unused member variable. NFC
Fangrui Song [Sun, 14 Aug 2022 01:14:24 +0000 (18:14 -0700)]
[llvm-readobj] Remove unused member variable. NFC

23 months ago[libc++] Implement `operator<=>` for `thread::id`
Adrian Vogelsgesang [Sun, 31 Jul 2022 23:12:42 +0000 (16:12 -0700)]
[libc++] Implement `operator<=>` for `thread::id`

The new operator<=> is mapped onto the existing functions
__libcpp_thread_id_equal and __libcpp_thread_id_less. Introducing a
new __libcpp_thread_id_compare_three_way might lead to more efficient
code. Given that we can still introduce __libcpp_thread_id_compare_three_way
later, for this commit I opted to not break ABI. If requested, I will
add __libcpp_thread_id_compare_three_way in a follow-up commit.

Implements part of P1614R2 "The Mothership has Landed"

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

23 months ago[libc++] Add a bunch of missing _LIBCPP_HIDE_FROM_ABI
Nikolas Klauser [Sat, 13 Aug 2022 11:23:16 +0000 (13:23 +0200)]
[libc++] Add a bunch of missing _LIBCPP_HIDE_FROM_ABI

Reviewed By: ldionne, Mordante, var-const, huixie90, #libc

Spies: jloser, libcxx-commits, arichardson, miyuki

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

23 months ago[AArch64] Fix signed integer overflow in CSINC case
Vitaly Buka [Fri, 12 Aug 2022 22:43:05 +0000 (15:43 -0700)]
[AArch64] Fix signed integer overflow in CSINC case

https://lab.llvm.org/staging/#/builders/224/builds/2/steps/16/logs/stdio

Reviewed By: dmgreen

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

23 months ago[DAG] canCreateUndefOrPoison - add freeze(add/sub/mul(x,y)) -> add/sub/mul(freeze...
Simon Pilgrim [Sat, 13 Aug 2022 19:57:51 +0000 (20:57 +0100)]
[DAG] canCreateUndefOrPoison - add freeze(add/sub/mul(x,y)) -> add/sub/mul(freeze(x),y,z) support

These are guaranteed not to create undef/poison as long as there are no poison generating flags