platform/upstream/llvm.git
22 months agoExpand Div/Rem: consider the case where the dividend is zero
Nuno Lopes [Thu, 1 Sep 2022 16:04:26 +0000 (17:04 +0100)]
Expand Div/Rem: consider the case where the dividend is zero
So we can't use ctlz in poison-producing mode

22 months agoRevert "[Pipelines] Introduce DAE after ArgumentPromotion"
Arthur Eubanks [Thu, 1 Sep 2022 15:42:36 +0000 (08:42 -0700)]
Revert "[Pipelines] Introduce DAE after ArgumentPromotion"

This reverts commit b10a341aa5b0b93b9175a8f11efc9a0955ab361e.

This commit exposes the pre-existing https://github.com/llvm/llvm-project/issues/56503 in some edge cases. Will fix that and then reland this.

22 months agoRemoving an accidentally duplicated heading; NFC
Aaron Ballman [Thu, 1 Sep 2022 15:44:11 +0000 (11:44 -0400)]
Removing an accidentally duplicated heading; NFC

22 months ago[AArch64][SVE] Add floating-point repeated complex pattern llc tests
Matt Devereau [Thu, 1 Sep 2022 15:00:37 +0000 (15:00 +0000)]
[AArch64][SVE] Add floating-point repeated complex pattern llc tests

22 months agoApply clang-tidy fixes for performance-unnecessary-value-param in InferIntRangeInterf...
Mehdi Amini [Mon, 29 Aug 2022 10:44:12 +0000 (10:44 +0000)]
Apply clang-tidy fixes for performance-unnecessary-value-param in InferIntRangeInterfaceImpls.cpp (NFC)

22 months agoApply clang-tidy fixes for readability-identifier-naming in AffineOps.cpp (NFC)
Mehdi Amini [Mon, 29 Aug 2022 10:32:39 +0000 (10:32 +0000)]
Apply clang-tidy fixes for readability-identifier-naming in AffineOps.cpp (NFC)

22 months agotweak zstd behavior in cmake and llvm config for better testing
Cole Kissane [Thu, 1 Sep 2022 14:49:42 +0000 (07:49 -0700)]
tweak zstd behavior in cmake and llvm config for better testing

add LLVM_PREFER_STATIC_ZSTD (default TRUE) cmake config flag
(compression test seems to fail for shared zstd on windows, note that zstd multithread is by default disabled in the static build so it may be a hidden variable)
propagate variable zstd_DIR in LLVMConfig.cmake.in
fix llvm-config CMakeLists.txt behavior for absolute libs windows
get zstd lib name

Reviewed By: phosek

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

22 months ago[DwarfEhPrepare] Assign dummy debug location for inserted _Unwind_Resume calls (PR57469)
Nikita Popov [Thu, 1 Sep 2022 08:13:35 +0000 (10:13 +0200)]
[DwarfEhPrepare] Assign dummy debug location for inserted _Unwind_Resume calls (PR57469)

DwarfEhPrepare inserts calls to _Unwind_Resume into landing pads.
If _Unwind_Resume happens to be defined in the same module and
debug info is used, then this leads to a verifier error:

  inlinable function call in a function with debug info must
    have a !dbg location
  call void @_Unwind_Resume(ptr %exn.obj) #0

Fix this by assigning a dummy location to the call. (As this
happens in the backend, inlining is not actually relevant here.)

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

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

22 months ago[flang] Handle special case for SHIFTA intrinsic
Valentin Clement [Thu, 1 Sep 2022 14:27:51 +0000 (16:27 +0200)]
[flang] Handle special case for SHIFTA intrinsic

This patch update the lowering of the shifta intrinsic to match
the behvior of gfortran. When the SHIFT value is equal to the
integer bitwidth then we handle it differently.
This is due to the operation used in lowering (`mlir::arith::ShRSIOp`)
that lowers to `ashr`.

Before this patch we have the following results:

```
SHIFTA(  -1, 8) =  0
SHIFTA(  -2, 8) =  0
SHIFTA( -30, 8) =  0
SHIFTA( -31, 8) =  0
SHIFTA( -32, 8) =  0
SHIFTA( -33, 8) =  0
SHIFTA(-126, 8) =  0
SHIFTA(-127, 8) =  0
SHIFTA(-128, 8) =  0
```

While gfortran is giving this:

```
SHIFTA(  -1, 8) = -1
SHIFTA(  -2, 8) = -1
SHIFTA( -30, 8) = -1
SHIFTA( -31, 8) = -1
SHIFTA( -32, 8) = -1
SHIFTA( -33, 8) = -1
SHIFTA(-126, 8) = -1
SHIFTA(-127, 8) = -1
SHIFTA(-128, 8) = -1
```

With this patch flang and gfortran have the same behavior.

Reviewed By: jeanPerier

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

22 months ago[PHITranslateAddr] Require dominance when searching for translated address (PR57025)
Nikita Popov [Tue, 30 Aug 2022 12:26:36 +0000 (14:26 +0200)]
[PHITranslateAddr] Require dominance when searching for translated address (PR57025)

This is a fix for PR57025 and an alternative to D131776. The problem
in the phi-translation-to-wrong-context.ll test case is that phi
translation of %gep.j into if2 pick %gep.i as the result. While this
instruction has the correct pointer address, it occurs in a context
where %i != 0. As such, we get a NoAlias result for the store in
if2, even though they do alias for %i == 0 (which is legal in the
original context of the pointer).

PHITranslateValue already has a MustDominate option, which can be
used to restrict PHI translation results to values that dominate the
translated-into block. However, this is more aggressive than what we
need and would significantly regress GVN results. In particular, if
we have a pointer value that does not require any translation, then
it is fine to continue using that value in the predecessor, because
the context is still correct for the original query. We only run into
problems if PHITranslateSubExpr() picks a completely random
instruction in a context that may have preconditions that do not hold.

Fix this by always performing the dominance checks in
PHITranslateSubExpr(), without enabling the more general MustDominate
requirement.

Fixes https://github.com/llvm/llvm-project/issues/57025. This also
fixes the test case for https://github.com/llvm/llvm-project/issues/30999,
but I'm not sure whether that's just the particular test case,
or a general solution to the problem.

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

22 months ago[clang][dataflow] Use `StringMap` for storing analysis states at annotated points...
Wei Yi Tee [Thu, 1 Sep 2022 13:50:38 +0000 (13:50 +0000)]
[clang][dataflow] Use `StringMap` for storing analysis states at annotated points instead of `vector<pair<string, StateT>>`.

Reviewed By: gribozavr2, sgatev, ymandel

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

22 months ago[CombinerHelper] Avoid deprecated method (NFC)
Nikita Popov [Thu, 1 Sep 2022 14:09:05 +0000 (16:09 +0200)]
[CombinerHelper] Avoid deprecated method (NFC)

22 months ago[LICM] Regenerate test checks (NFC)
Nikita Popov [Thu, 1 Sep 2022 14:06:26 +0000 (16:06 +0200)]
[LICM] Regenerate test checks (NFC)

22 months ago[clang][dataflow] Add `SetupTest` parameter for `AnalysisInputs`.
Wei Yi Tee [Thu, 1 Sep 2022 13:23:39 +0000 (13:23 +0000)]
[clang][dataflow] Add `SetupTest` parameter for `AnalysisInputs`.

Moves the work required for retrieving annotation states into the `SetupTest` and `PostVisitCFG` callback to avoid having to run a separate pass over the CFG after analysis has completed.

Reviewed By: gribozavr2, sgatev, ymandel

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

22 months ago[LICM] Remove unnecessary condition (NFC)
Nikita Popov [Thu, 1 Sep 2022 13:41:51 +0000 (15:41 +0200)]
[LICM] Remove unnecessary condition (NFC)

22 months ago[LICM] Fix thread safety checks for promotion of byval args
Nikita Popov [Thu, 1 Sep 2022 13:29:40 +0000 (15:29 +0200)]
[LICM] Fix thread safety checks for promotion of byval args

This code was relying on a very subtle contract: The expectation
was that for non-allocas, the unwind safety check would already
perform a capture check, so we don't need to perform it later.
This held true when this unwind safety was only handled for allocas
and noalias calls, but became incorrect when byval support was
added.

To avoid this kind of issue, just remove the dependency between the
unwind and thread-safety checks entirely. At worst, this means we
perform a redundant capture check. If this should turn out to be
problematic for compile-time, we can cache that query in a more
explicit way.

22 months ago[clang][dataflow] Refactor `TestingSupport.h`
Wei Yi Tee [Thu, 1 Sep 2022 12:48:33 +0000 (12:48 +0000)]
[clang][dataflow] Refactor `TestingSupport.h`

- Add `AnalysisInputs` struct as the parameters for `checkDataflow`, and renamed `AnalysisData` struct to `AnalysisOutputs` which contains the data structures generated from a dataflow analysis run.

- Remove compulsory binding from statement to annotations. Instead, `checkDataflow` in the most general form takes a `VerifyResults` callback which takes as input an `AnalysisOutputs` struct. This struct contains the data structures generated by the analysis that can then be tested. We then introduce two overloads/wrappers of `checkDataflow` for different mechanisms of testing - one which exposes annotation line numbers and is not restricted to statements, and the other which exposes states computed after annotated statements. In the future, we should look at retrieving the analysis states for constructs other than statements.

Reviewed By: gribozavr2, sgatev

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

22 months agoReapply "[DebugInfo] Extend the InstrRef LDV to support DbgValues with many Ops"
Stephen Tozer [Tue, 30 Aug 2022 13:30:47 +0000 (14:30 +0100)]
Reapply "[DebugInfo] Extend the InstrRef LDV to support DbgValues with many Ops"

Re-landing with an erroneous assert removed.

This reverts commit 58d104b352a65bec3fb7a8fd23bf2d408b4c76f7.

22 months ago[LICM] Add another byval capture test (NFC)
Nikita Popov [Thu, 1 Sep 2022 13:16:08 +0000 (15:16 +0200)]
[LICM] Add another byval capture test (NFC)

Variant with capture after the loop, in which case promotion is
safe.

22 months ago[clang] cleanup -fstrict-flex-arrays implementation
serge-sans-paille [Tue, 30 Aug 2022 14:49:53 +0000 (16:49 +0200)]
[clang] cleanup -fstrict-flex-arrays implementation

This is a follow up to https://reviews.llvm.org/D126864, addressing some remaining
comments.

It also considers union with a single zero-length array field as FAM for each
value of -fstrict-flex-arrays.

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

22 months ago[LICM] Add test for byval scalar promotion miscompile (NFC)
Nikita Popov [Thu, 1 Sep 2022 13:02:55 +0000 (15:02 +0200)]
[LICM] Add test for byval scalar promotion miscompile (NFC)

22 months ago[SPIRV] support builtin types and ExtInsts selection
Ilia Diachkov [Wed, 31 Aug 2022 11:53:02 +0000 (14:53 +0300)]
[SPIRV] support builtin types and ExtInsts selection

The patch adds the support of OpenCL and SPIR-V built-in types. It also
implements ExtInst selection and adds spv_unreachable and spv_alloca
intrinsics which improve the generation of the corresponding SPIR-V code.
Five LIT tests are included to demonstrate the improvement.

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

Co-authored-by: Aleksandr Bezzubikov <zuban32s@gmail.com>
Co-authored-by: Michal Paszkowski <michal.paszkowski@outlook.com>
Co-authored-by: Andrey Tretyakov <andrey1.tretyakov@intel.com>
Co-authored-by: Konrad Trifunovic <konrad.trifunovic@intel.com>
22 months ago[InstCombine] fix crash on type mismatch with fcmp fold
Sanjay Patel [Thu, 1 Sep 2022 12:32:06 +0000 (08:32 -0400)]
[InstCombine] fix crash on type mismatch with fcmp fold

The existing predicate doesn't work for a single-element
vector, so make sure we are not crossing scalar/vector types.

Test (was crashing) based on the post-commit example for:
482777123427

22 months ago[InstCombine] fold power-of-2 ctlz/cttz with inverted result
Sanjay Patel [Wed, 31 Aug 2022 20:05:53 +0000 (16:05 -0400)]
[InstCombine] fold power-of-2 ctlz/cttz with inverted result

When X is a power-of-two or zero and zero input is poison:
ctlz(i32 X) ^ 31 --> cttz(X)
cttz(i32 X) ^ 31 --> ctlz(X)

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

22 months ago[RISCV][NFC] Fix typo in comment in RISCVInstrInfoZicbo.td
Alex Bradbury [Thu, 1 Sep 2022 12:49:55 +0000 (13:49 +0100)]
[RISCV][NFC] Fix typo in comment in RISCVInstrInfoZicbo.td

Zicbop->Zicbom typo.

22 months ago[LICM] Add some debug output to scalar promotion (NFC)
Nikita Popov [Thu, 1 Sep 2022 08:48:49 +0000 (10:48 +0200)]
[LICM] Add some debug output to scalar promotion (NFC)

22 months ago[GVN] Pre-commit test case showing miscompile in github issue #57025
Bjorn Pettersson [Fri, 12 Aug 2022 12:56:23 +0000 (14:56 +0200)]
[GVN] Pre-commit test case showing miscompile in github issue #57025

This commit adds a reproducer for
  https://github.com/llvm/llvm-project/issues/57025
showing a miscompile in GVN.

Not sure how likely this kind of faults would be in a normal pipeline,
considering that the input IR has some dead code in it. On the other
hand, GVN itself sometimes creates dead basic blocks when splitting
critical edges. Anyway, the fault was found when doing fuzzy testing
using random pass pipelines.

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

22 months ago[SLP]Fix PR55734: SLP vectorizer's reduce_and formation introduces poison.
Alexey Bataev [Wed, 1 Jun 2022 22:37:51 +0000 (15:37 -0700)]
[SLP]Fix PR55734: SLP vectorizer's reduce_and formation introduces poison.

Need either follow the original order of the operands for bool logical
ops, or emit freeze instruction to avoid poison propagation.

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

22 months ago[GlobalISel] Add sdiv exact (X, constant) -> mul combine.
Amara Emerson [Mon, 25 Jul 2022 21:21:40 +0000 (14:21 -0700)]
[GlobalISel] Add sdiv exact (X, constant) -> mul combine.

This port of the SDAG optimization is only for exact sdiv case.

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

22 months ago[DebugInfo] Missing debug location after replacement in processSRem function
Yuanbo Li [Thu, 1 Sep 2022 10:03:48 +0000 (11:03 +0100)]
[DebugInfo] Missing debug location after replacement in processSRem function

This patch fixes an issue in which CorrelatedValuePropagation::processSRem
would create new instructions to represent the SRem instruction, but would not
correctly copy any existing debug location metadata to the new instruction.

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

22 months ago[Clang][Comments] Parse `<img src=""/>` in doc comments correctly
Egor Zhdan [Tue, 30 Aug 2022 11:55:43 +0000 (12:55 +0100)]
[Clang][Comments] Parse `<img src=""/>` in doc comments correctly

This is a valid HTML5 tag. Previously it triggered a Clang error (`HTML start tag prematurely ended, expected attribute name or '>'`) since Clang was treating `/>` as a text token. This was happening because after lexing the closing quote (`"`) the lexer state was reset to "Normal" while the tag was not actually closed yet: `>` was not yet parsed at that point.

rdar://91464292

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

22 months ago[lldb] [Core] Pass error/status from Communication::ReadThread()
Michał Górny [Tue, 23 Aug 2022 17:20:25 +0000 (19:20 +0200)]
[lldb] [Core] Pass error/status from Communication::ReadThread()

Ensure that the ConnectionStatus and Status from
Communication::ReadThread() is correctly passed to ::Read() in order
to fix further discrepancies between ::Read() calls in non-threaded
and threaded modes.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D132577

22 months ago[VPlan] Add field to track if intrinsic should be used for call. (NFC)
Florian Hahn [Thu, 1 Sep 2022 12:14:40 +0000 (13:14 +0100)]
[VPlan] Add field to track if intrinsic should be used for call. (NFC)

This patch moves the cost-based decision whether to use an intrinsic or
library call to the point where the recipe is created. This untangles
code-gen from the cost model and also avoids doing some extra work as
the information is already computed at construction.

Reviewed By: Ayal

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

22 months ago[mlir] Address post commit comments on 8f2457ccf01f00bb83bd391ac04209e75361fb9a and...
Nicolas Vasilache [Thu, 1 Sep 2022 11:37:56 +0000 (04:37 -0700)]
[mlir] Address post commit comments on 8f2457ccf01f00bb83bd391ac04209e75361fb9a and fix the test

22 months ago[Flang][OpenMP] Add support for real typed reductions in worksharing-loop
Dylan Fleming [Thu, 1 Sep 2022 10:24:32 +0000 (10:24 +0000)]
[Flang][OpenMP] Add support for real typed reductions in worksharing-loop

Allows addition/multiplication reductions to be used with
real types by adding getReductionOperation() to OpenMP.cpp,
which can select either integer or floating-point instruction.

Reviewed By: kiranchandramohan

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

22 months agoRevert "Expand Div/Rem: consider the case where the dividend is zero"
Nuno Lopes [Thu, 1 Sep 2022 11:10:35 +0000 (12:10 +0100)]
Revert "Expand Div/Rem: consider the case where the dividend is zero"

This reverts commit 4aed09868b5a51a29aade11d9d412c3313310f29.

22 months ago[CTE][docs] Fix bad links in ReleaseNotes
Nathan James [Thu, 1 Sep 2022 11:10:53 +0000 (12:10 +0100)]
[CTE][docs] Fix bad links in ReleaseNotes

22 months ago[mlir][Linalg] Add missing support for memory space to DropUnitDims
Nicolas Vasilache [Wed, 31 Aug 2022 22:08:35 +0000 (15:08 -0700)]
[mlir][Linalg] Add missing support for memory space to DropUnitDims

Previously, the memory space would not be propagated properly, creating invalid IR.

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

22 months agoExpand Div/Rem: consider the case where the dividend is zero
Nuno Lopes [Thu, 1 Sep 2022 11:00:03 +0000 (12:00 +0100)]
Expand Div/Rem: consider the case where the dividend is zero
So we can't use ctlz in poison-producing mode

22 months ago[DeadArgElim] Use structure bindings in foreach loops. NFC
Pavel Samolysov [Wed, 31 Aug 2022 14:44:34 +0000 (17:44 +0300)]
[DeadArgElim] Use structure bindings in foreach loops. NFC

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

22 months ago[gn build] Port d931ac9e27ca
LLVM GN Syncbot [Thu, 1 Sep 2022 10:19:04 +0000 (10:19 +0000)]
[gn build] Port d931ac9e27ca

22 months ago[clang][dataflow] Generalise match switch utility to other AST types and add a `CFGMa...
Wei Yi Tee [Thu, 1 Sep 2022 08:39:59 +0000 (08:39 +0000)]
[clang][dataflow] Generalise match switch utility to other AST types and add a `CFGMatchSwitch` which currently handles `CFGStmt` and `CFGInitializer`.

`MatchSwitch` currently takes in matchers and functions for the `Stmt` class.

This patch generalises the match switch utility (renamed to `ASTMatchSwitch`) to work for different AST node types by introducing a template argument which is the base type for the AST nodes that the match switch will handle.

A `CFGMatchSwitch` is introduced as a wrapper around multiple `ASTMatchSwitch`s for different base types. It works by unwrapping `CFGElement`s into their contained AST nodes and passing the nodes to the relevant `ASTMatchSwitch`. The `CFGMatchSwitch` currently only handles `CFGStmt` and `CFGInitializer`.

Reviewed By: gribozavr2, sgatev

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

22 months ago[clang][WebAssembly] Pass `-Wa,--no-type-check` through to the MC layer
Sam Clegg [Thu, 4 Aug 2022 23:03:21 +0000 (16:03 -0700)]
[clang][WebAssembly] Pass `-Wa,--no-type-check` through to the MC layer

I took as an example the `-Wa,--noexecstack` clang flag that maps down
to `cc1 -mnoexecstack`.

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

22 months ago[LLDB] Simplify cmake for instruction emulation unit tests
David Spickett [Wed, 31 Aug 2022 14:41:57 +0000 (14:41 +0000)]
[LLDB] Simplify cmake for instruction emulation unit tests

I got suspicious because of checking "ARM" for an "ARM64" plugin.
As far as I can tell these never needed an llvm target to function.

Looking at the corresponding cmake for the libraries under test they
don't reference target libraries either.

Reviewed By: labath

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

22 months ago[OpenCL][SPIR-V] Test extern functions with a pointer arg.
Anastasia Stulova [Thu, 1 Sep 2022 09:18:03 +0000 (10:18 +0100)]
[OpenCL][SPIR-V] Test extern functions with a pointer arg.

Added a test case that enhances coverage of opaque pointers
particularly for the problematic case with extern functions
for which there is no solution found for type recovery.

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

22 months ago[NFC][clang] LLVM_FALLTHROUGH => [[fallthrough]]
Sheng [Thu, 1 Sep 2022 09:17:46 +0000 (09:17 +0000)]
[NFC][clang] LLVM_FALLTHROUGH => [[fallthrough]]

22 months ago[LLVM] Add missing stdint include to Bit.h
David Spickett [Thu, 1 Sep 2022 08:54:57 +0000 (08:54 +0000)]
[LLVM] Add missing stdint include to Bit.h

To fix failing builds on Windows on Arm:
https://lab.llvm.org/staging/#/builders/59/builds/928/steps/4/logs/stdio

<...>/ADT/bit.h(50,5): error: unknown type name 'uint32_t'
    uint32_t v = Value;
    ^

22 months agoRevert "[test][msan] Basic debug info test"
Douglas Yung [Thu, 1 Sep 2022 09:09:04 +0000 (02:09 -0700)]
Revert "[test][msan] Basic debug info test"

This reverts commit ed241e873009dd0a32c6eb0dc02885d37c05e1cd.

This test is failing on many bots:

https://lab.llvm.org/buildbot/#/builders/3/builds/12656
https://lab.llvm.org/buildbot/#/builders/6/builds/12696
https://lab.llvm.org/buildbot/#/builders/9/builds/12687
https://lab.llvm.org/buildbot/#/builders/58/builds/25332
https://lab.llvm.org/buildbot/#/builders/67/builds/8059
https://lab.llvm.org/buildbot/#/builders/117/builds/8806
https://lab.llvm.org/buildbot/#/builders/139/builds/27430
https://lab.llvm.org/buildbot/#/builders/164/builds/24139
https://lab.llvm.org/buildbot/#/builders/216/builds/9144

22 months ago[LLDB] Make build.py use uname to set platform
Muhammad Omair Javaid [Wed, 31 Aug 2022 11:33:45 +0000 (16:33 +0500)]
[LLDB] Make build.py use uname to set platform

This patch makes build helper script build.py to use platform.uname for
machine/architecture detection. Visual studio environment when set using
various batch files like vcvars*.bat set PLATFORM environment variable
however VsDevCmd.bat does not set PLATFORM variable.

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

22 months ago[LLDB] Make API tests to run using MSYS tools
Muhammad Omair Javaid [Wed, 31 Aug 2022 08:08:57 +0000 (13:08 +0500)]
[LLDB] Make API tests to run using MSYS tools

MSYS 'uname' on windows returns "MSYS_NT*" instead of windows32 and also
MSYS 'pwd' returns non-windows path string.
This patch fixes Makefile.rules to make adjustments required to run LLDB
API tests using MSYS tools.

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

22 months ago[InstCombine] Fold extractvalue of phi
Nikita Popov [Thu, 1 Sep 2022 08:48:49 +0000 (10:48 +0200)]
[InstCombine] Fold extractvalue of phi

Just as we do for most other operations, we should push
extractvalue instructions through phis, if this does not increase
unfolded instruction count.

22 months ago[InstCombine] Add tests for extractvalue of phi (NFC)
Nikita Popov [Thu, 1 Sep 2022 08:46:44 +0000 (10:46 +0200)]
[InstCombine] Add tests for extractvalue of phi (NFC)

22 months ago[NFC] Emit builtin coroutine calls uniforally
Chuanqi Xu [Thu, 1 Sep 2022 08:30:43 +0000 (16:30 +0800)]
[NFC] Emit builtin coroutine calls uniforally

All the coroutine builtins were emitted in EmitCoroutineIntrinsic except
__builtin_coro_size. This patch tries to emit all the corotine builtins
uniformally.

22 months ago[MC][WebAssembly] Allow accurate errors in doBeforeLabelEmit
Sam Clegg [Wed, 31 Aug 2022 12:50:11 +0000 (05:50 -0700)]
[MC][WebAssembly] Allow accurate errors in doBeforeLabelEmit

Although we only currently have one error produced in this function I am
working on changes right now that add some more.  This change makes the
error location more accurate.

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

22 months ago[RISCV] When ISD::SETUGT && Imm == -1, has processed before lowering
liqinweng [Thu, 1 Sep 2022 07:38:09 +0000 (15:38 +0800)]
[RISCV] When ISD::SETUGT && Imm == -1, has processed before lowering

When ISD::SETUGT && Imm == -1, has processed before lowering. Use assert replace it

Reviewed By: craig.topper

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

22 months ago[RISCV][NFC] Add cost model tests of llvm.fmuladd
liqinweng [Thu, 1 Sep 2022 07:33:02 +0000 (15:33 +0800)]
[RISCV][NFC] Add cost model tests of llvm.fmuladd

Reviewed By: benshi001

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

22 months ago[clang][analyzer] Errno modeling code refactor (NFC).
Balázs Kéri [Thu, 1 Sep 2022 06:31:17 +0000 (08:31 +0200)]
[clang][analyzer] Errno modeling code refactor (NFC).

Some of the code used in StdLibraryFunctionsChecker is applicable to
other checkers, this is put into common functions. Errno related
parts of the checker are simplified and renamed. Documentations in
errno_modeling functions are updated.

This change makes it available to have more checkers that perform
modeling of some standard functions. These can set the errno state
with common functions and the bug report messages (note tags) can
look similar.

Reviewed By: steakhal, martong

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

22 months ago[mlir][interfaces] Drop `dest`/`tileDestOperands` from TilingInterface
Matthias Springer [Wed, 31 Aug 2022 13:57:40 +0000 (15:57 +0200)]
[mlir][interfaces] Drop `dest`/`tileDestOperands` from TilingInterface

`getTiledImplementation`/`generateResultTileValue` only computes the tiled operation, but does not insert the result into any tensor.

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

22 months agobazel fixes for c55b41d5199d2394dd6cdb8f52180d8b81d809d4
Tres Popp [Thu, 1 Sep 2022 06:19:50 +0000 (08:19 +0200)]
bazel fixes for c55b41d5199d2394dd6cdb8f52180d8b81d809d4

22 months ago[clang] trim trailing space in format tests. NFC
YingChi Long [Thu, 1 Sep 2022 03:25:41 +0000 (11:25 +0800)]
[clang] trim trailing space in format tests. NFC

Found in https://reviews.llvm.org/D132568

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

22 months ago[test][msan] Basic debug info test
Vitaly Buka [Thu, 1 Sep 2022 04:46:17 +0000 (21:46 -0700)]
[test][msan] Basic debug info test

22 months ago[ELF] --gdb-index: error if constant pool size exceeds UINT32_MAX
Fangrui Song [Thu, 1 Sep 2022 04:10:01 +0000 (21:10 -0700)]
[ELF] --gdb-index: error if constant pool size exceeds UINT32_MAX

If so, the last symbol's name_offset likely exceeds 0xffffffff and is not
supported by the format
(https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html#Index-Section-Format).
I have seen an internal oversized executable with such a corrupted .gdb_index

22 months ago[ELF] Correctly compute .gdb_index size when symbol's name offset overflows
Fangrui Song [Thu, 1 Sep 2022 04:04:26 +0000 (21:04 -0700)]
[ELF] Correctly compute .gdb_index size when symbol's name offset overflows

if `nameOff` overflows, `size` may be underestimated.
In writeTo, `memcpy(buf + sym.nameOff, sym.name.data(), sym.name.size());` may
cause an out-of-bounds write, leading to a SIGSEGV.

22 months ago[LoongArch] Support ISD::BR_CC and branch according to condition flag register
gonglingqin [Thu, 1 Sep 2022 02:42:19 +0000 (10:42 +0800)]
[LoongArch] Support ISD::BR_CC and branch according to condition flag register

Use bceqz/bcnez instead of movcf2gr + bnez/beqz for branch jumps.

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

22 months ago[NFC][LICM] Stop passing around unused BFI
Arthur Eubanks [Thu, 1 Sep 2022 02:14:58 +0000 (19:14 -0700)]
[NFC][LICM] Stop passing around unused BFI

Uses of this were removed in 1a25d0bfbb6b587caa03bacd121b67086a774598.

22 months ago[clang][Sema] check default argument promotions for printf
YingChi Long [Fri, 26 Aug 2022 11:26:32 +0000 (19:26 +0800)]
[clang][Sema] check default argument promotions for printf

The main focus of this patch is to make ArgType::matchesType check for
possible default parameter promotions when the argType is not a pointer.
If so, no warning will be given for `int`, `unsigned int` types as
corresponding arguments to %hhd and %hd. However, the usage of %hhd
corresponding to short is relatively rare, and it is more likely to be a
misuse. This patch keeps the original behavior of clang like this as
much as possible, while making it more convenient to consider the
default arguments promotion.

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

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

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

22 months ago[NFC] Fix typo
Mark Zhuang [Thu, 1 Sep 2022 02:07:57 +0000 (19:07 -0700)]
[NFC] Fix typo

Reviewed By: eopXD

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

22 months ago[runtimes] Shrink the set of runtimes included in the bootstrapping build by default
Louis Dionne [Tue, 23 Aug 2022 15:14:15 +0000 (11:14 -0400)]
[runtimes] Shrink the set of runtimes included in the bootstrapping build by default

This patch is in preparation for removing libcxx, libcxxabi and libunwind
from LLVM_ENABLE_PROJECTS. When we make that switch, folks who were
previously using LLVM_ENABLE_PROJECTS=all in order to build those
runtimes will be able to add LLVM_ENABLE_RUNTIMES=all to start building
those projects using the bootstrapping build.

This is technically a breaking change for folks who had been using
LLVM_ENABLE_RUNTIMES=all, however I suspect the set of people currently
doing that is extremely small, so this is likely acceptable (more than
breaking folks who are using LLVM_ENABLE_PROJECTS=all).

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

22 months ago[X86][bugfix] redefine __SSC_MARK to escape cpp string literal concatenation problem
Xiang1 Zhang [Thu, 25 Aug 2022 07:06:41 +0000 (15:06 +0800)]
[X86][bugfix] redefine __SSC_MARK to escape cpp string literal concatenation problem

Reviewed By: pengfei, RKSimon

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

22 months ago[Driver] Remove unimplemented Joined -a / --profile-blocks
Fangrui Song [Thu, 1 Sep 2022 01:13:16 +0000 (18:13 -0700)]
[Driver] Remove unimplemented Joined -a / --profile-blocks

GCC removed the option on 2010-08-03.
We support a few -a*. Having the Joined -a may make typos unnoticed.

22 months ago[Driver][test] Fix incorrect -arch= -amx-int8
Fangrui Song [Thu, 1 Sep 2022 01:08:19 +0000 (18:08 -0700)]
[Driver][test] Fix incorrect -arch= -amx-int8

This is not a driver option. It happens to work because of an ignored Joined -a.

22 months agoFix a bug in lldb-dotest that was uncovered by setting no value for dotest_args_str.
Jim Ingham [Thu, 1 Sep 2022 01:00:18 +0000 (18:00 -0700)]
Fix a bug in lldb-dotest that was uncovered by setting no value for dotest_args_str.
We were splitting the string, and adding that array to cmd.  But split generated
[''] which shows up later on as an empty "test directory search path".  That got
extended to the CWD + "" which generally doesn't have any tests, so

lldb-dotest -p SomeRealTest.py

would fail with a no matching tests error.

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

22 months ago[Driver] Remove Joined -Z and err_drv_use_of_Z_option
Fangrui Song [Thu, 1 Sep 2022 00:58:04 +0000 (17:58 -0700)]
[Driver] Remove Joined -Z and err_drv_use_of_Z_option

This takes a detour to report an error, but we can just remove Joined -Z
which is rejected by GCC.

22 months ago[test][msan] Re-format RUN lines
Vitaly Buka [Thu, 1 Sep 2022 00:54:59 +0000 (17:54 -0700)]
[test][msan] Re-format RUN lines

22 months agoApply clang-tidy fixes for readability-identifier-naming in TosaToLinalg.cpp (NFC)
Mehdi Amini [Mon, 29 Aug 2022 10:27:59 +0000 (10:27 +0000)]
Apply clang-tidy fixes for readability-identifier-naming in TosaToLinalg.cpp (NFC)

22 months agoApply clang-tidy fixes for readability-simplify-boolean-expr in SPIRVToLLVM.cpp ...
Mehdi Amini [Mon, 29 Aug 2022 10:25:52 +0000 (10:25 +0000)]
Apply clang-tidy fixes for readability-simplify-boolean-expr in SPIRVToLLVM.cpp (NFC)

22 months ago[Driver] Remove Joined -X
Fangrui Song [Thu, 1 Sep 2022 00:30:51 +0000 (17:30 -0700)]
[Driver] Remove Joined -X

The untested option triggers an IgnoredGCCCompat warning while GCC reports an error.
We support a few -X{assembler,linker,...}. Having the Joined -X may make typos unnoticed.

22 months ago[test][msan] Re-format RUN lines
Vitaly Buka [Wed, 31 Aug 2022 23:59:11 +0000 (16:59 -0700)]
[test][msan] Re-format RUN lines

22 months ago[lldb] Correctly add runtime test dependencies
Jonas Devlieghere [Wed, 31 Aug 2022 23:33:54 +0000 (16:33 -0700)]
[lldb] Correctly add runtime test dependencies

When a runtime is enabled through LLVM_ENABLE_RUNTIMES, it is loaded
after other projects (i.e. after LLDB). This means that the
corresponding targets don't exist when LLDB is configured. To support
runtimes being enable this way, we need to check if they're listed in
LLVM_ENABLE_RUNTIMES. For runtimes being enabled as projects (i.e.
through LLVM_ENABLE_RUNTIMES) we need to check for the target.

This patch unifies things and correctly adds compiler-rt and libcxx as
test dependencies in both scenarios.

22 months ago[mlir][tosa] Bitwidth mismatch should be long-long not long
Rob Suderman [Wed, 31 Aug 2022 23:02:29 +0000 (16:02 -0700)]
[mlir][tosa] Bitwidth mismatch should be long-long not long

Reviewed By: scotttodd

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

22 months ago[mlir] Ensure index attrs are always 64-bit APInts
Jeff Niu [Wed, 31 Aug 2022 22:05:41 +0000 (15:05 -0700)]
[mlir] Ensure index attrs are always 64-bit APInts

This patch ensures that index integer attributes can only be
constructed with APInts whose widths are equal to the index
internal storage bitwidth (64).

Reviewed By: rriddle

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

22 months ago[MachineCSE] Use TargetInstrInfo::isAsCheapAsAMove in isPRECandidate.
Craig Topper [Wed, 31 Aug 2022 22:05:35 +0000 (15:05 -0700)]
[MachineCSE] Use TargetInstrInfo::isAsCheapAsAMove in isPRECandidate.

Some targets like RISC-V require operands to be inspected to
determine if an instruction is similar to a move.

Spotted while investigating code differences between using an ADDI
vs an ADDIW. RISC-V has the isAsCheapAsAMove flag for ADDI, but
the TII hook checks the immediate is 0 or the register is X0. ADDIW
is never generated with X0 or with an immediate of 0 so it doesn't
have the isAsCheapAsAMove flag.

I don't know enough about the PRE code to write a test for this yet.

Reviewed By: reames

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

22 months ago[nfc][msan] Prepare the code for check sorting
Vitaly Buka [Wed, 31 Aug 2022 22:28:28 +0000 (15:28 -0700)]
[nfc][msan] Prepare the code for check sorting

22 months ago[lld][WebAssemby] Allow import module names to be empty strings.
Dan Gohman [Wed, 31 Aug 2022 18:41:25 +0000 (11:41 -0700)]
[lld][WebAssemby] Allow import module names to be empty strings.

The component-model [canonical ABI] is currently using import names with
empty strings. Remove the special cases for empty strings from
WasmObjectFile.cpp so that they can pass through as-is.

[canonical ABI]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/CanonicalABI.md

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

22 months ago[mlir][amdgpu] Fix signed/unsigned comparison for abid/cbsz comparison
Rob Suderman [Wed, 31 Aug 2022 22:29:27 +0000 (15:29 -0700)]
[mlir][amdgpu] Fix signed/unsigned comparison for abid/cbsz comparison

Unsigned/signed comparison failure due to implicit signed value.

Reviewed By: stella.stamenova

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

22 months ago[flang] Generate DOT_PRODUCT runtime call based on the result type.
Slava Zakharin [Wed, 31 Aug 2022 16:55:24 +0000 (09:55 -0700)]
[flang] Generate DOT_PRODUCT runtime call based on the result type.

We used to select the runtime function based on the first argument's
type, which was not correct behavior. The selection is done using
the result type now.

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

22 months ago[flang][runtime] Enable real/complex kind 10 and 16 variants of dot_product.
Slava Zakharin [Wed, 31 Aug 2022 20:42:39 +0000 (13:42 -0700)]
[flang][runtime] Enable real/complex kind 10 and 16 variants of dot_product.

HasCppTypeFor<> used to evaluate to false always, so kind 10 and 16
variants of dot_product were not instantiated even though the host
supported 80- and 128-bit real and complex data types.
In addition, HAS_FLOAT128 was not enabling complex kind=16 variant
of dot_product. This is fixed now.

Note that the change for HasCppTypeFor<> may also affect other
functions such as matmul, i.e. kind 10 and 16 variants of them
may become available now (depending on the build host).

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

22 months ago[mlir][sparse] Introduce new sparse_tensor.storage_get/set to access memory that...
Peiming Liu [Wed, 31 Aug 2022 20:44:41 +0000 (20:44 +0000)]
[mlir][sparse] Introduce new sparse_tensor.storage_get/set to access memory that stores the handle of a sparse tensor

Introduce new sparse_tensor.storage_get/set to access memory that stores the handle of a sparse tensor. The sparse tensor storage are represented as a tuple, these operation will later be eliminated and the tuple will be flattened after sparse tensor codegen

Reviewed By: aartbik

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

22 months ago[mlir][sparse] sparse storage scheme type conversion
Aart Bik [Wed, 31 Aug 2022 20:46:24 +0000 (13:46 -0700)]
[mlir][sparse] sparse storage scheme type conversion

This builds a compound type for the buffers required for the sparse storage scheme defined by the MLIR sparse tensor types. The use of a tuple allows for a simple 1:1 type conversion. A subsequent pass can expand this tuple into its component with an isolated 1:N type conversion.

Reviewed By: Peiming

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

22 months ago[RISCV] Slightly simplify coode in combineVWADD_W_VL_VWSUB_W_VL and combineMUL_VLToVW...
Craig Topper [Wed, 31 Aug 2022 21:10:02 +0000 (14:10 -0700)]
[RISCV] Slightly simplify coode in combineVWADD_W_VL_VWSUB_W_VL and combineMUL_VLToVWMUL_VL. NFC

Use computeMaxSignificantBits instead of ComputeNumSignBits. Create
APInt as part of call to MaskedValueIsZero instead of creating
a named temporary.

22 months ago[mlir][tosa] Fix left shift that was implicitly converted to 64-bit
Rob Suderman [Wed, 31 Aug 2022 21:55:34 +0000 (14:55 -0700)]
[mlir][tosa] Fix left shift that was implicitly converted to 64-bit

Missing long specifier so that a shift would occur in 64-bits rather
than implicitly in 32-bits.

Reviewed By: NatashaKnk

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

22 months ago[WebAssembly][MC] Update tests after recent removal of .size directives for functions
Sam Clegg [Wed, 31 Aug 2022 21:53:02 +0000 (14:53 -0700)]
[WebAssembly][MC] Update tests after recent removal of .size directives for functions

These were missing from https://reviews.llvm.org/D132929

22 months ago[MLIR] Keep but deprecate old autogenerated pass base classes
Michele Scuttari [Wed, 31 Aug 2022 21:38:31 +0000 (23:38 +0200)]
[MLIR] Keep but deprecate old autogenerated pass base classes

Restore the generation of the old pass base classes for better transitioning of external projects relying on them. They were eliminated with 67d0d7ac0acb0665d6a09f61278fbcf51f0114c2.

Reviewed By: rsmith

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

22 months ago[lld][WebAssembly] Rename SymbolTable::getSymbols to match ELF backend. NFC
Sam Clegg [Fri, 5 Aug 2022 19:54:29 +0000 (12:54 -0700)]
[lld][WebAssembly] Rename SymbolTable::getSymbols to match ELF backend. NFC

The ELF backend originally used `getSymbols()` but went though a
sequence of changes that resulted in this method being called
`symbols()`.

d8f8abbd4a2823f223bd7bc56445541fb221b512 replaced `getSymbols()` with
`forEachSymbol`.

a2fc96441788fba1e4709d63677f34ed8e321dae replaced `forEachSymbol` with
`llvm::iterator_range`.

e9262edf0d11a907763098d8e101219ccd9c43e9 replaced `llvm::iterator_range`
with `symbols()`.

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

22 months ago[WebAssembly][MC] Avoid the need for .size directives for functions
Sam Clegg [Tue, 30 Aug 2022 11:09:44 +0000 (04:09 -0700)]
[WebAssembly][MC] Avoid the need for .size directives for functions

Warn if `.size` is specified for a function symbol.  The size of a
function symbol is determined solely by its content.

I noticed this simplification was possible while debugging #57427, but
this change doesn't fix that specific issue.

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

22 months ago[lldb] Make the rumtimes target a test dependency
Jonas Devlieghere [Wed, 31 Aug 2022 21:23:57 +0000 (14:23 -0700)]
[lldb] Make the rumtimes target a test dependency

Make the rumtimes target a test dependency. This is needed or the parts
of the test suite that rely on the libcxx and libcxxabi.

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

22 months ago[mlir][AMDGPU] Define amdgpu.mfma operator
Krzysztof Drewniak [Tue, 30 Aug 2022 17:12:10 +0000 (17:12 +0000)]
[mlir][AMDGPU] Define amdgpu.mfma operator

The amdgpu.mfma operator is a wrapper around the Matrix Fused Multiply
Add (MFMA) instructions on some AMD GPUs (the CDNA-based MI-* cards).

This interface allows for selecting the operation to be performed by
specifying the dimensions of the multiplication to be performed and
any additional attributes (such as whether to use reduced-precision
floating-point math) that are needed to select the relevant mfma
instruction and set its parameters.

Reviewed By: ThomasRaoux, nirvedhmeshram

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

22 months agoreland: [Local] Allow creating callbr with duplicate successors
Nikita Popov [Wed, 31 Aug 2022 20:08:20 +0000 (13:08 -0700)]
reland: [Local] Allow creating callbr with duplicate successors

Since D129288, callbr is allowed to have duplicate successors. This patch removes a limitation which prevents optimizations from actually producing such callbrs.

This is probably the riskiest of all the recent callbr changes, because code with incorrect assumptions might be lurking somewhere. I fixed the one case I encountered ahead of time in https://github.com/llvm/llvm-project/commit/8201e3ef5c84561260218bc041209611aac690e3.

Reviewed By: nickdesaulniers

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

Originally landed as
commit 08860f525a23 ("[Local] Allow creating callbr with duplicate successors")

Reverted in
commit 1cf6b93df168 ("Revert "[Local] Allow creating callbr with duplicate successors"")

22 months ago[NFC][libc++] char_traits code cleanups.
Mark de Wever [Thu, 4 Aug 2022 17:44:21 +0000 (19:44 +0200)]
[NFC][libc++] char_traits code cleanups.

These cleanups were identified while working on D130295.

Reviewed By: #libc, ldionne, philnik

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

22 months ago[Frontend] Restore Preprocessor::getPredefines()
Roy Jacobson [Wed, 31 Aug 2022 19:27:09 +0000 (22:27 +0300)]
[Frontend] Restore Preprocessor::getPredefines()

https://reviews.llvm.org/rG6bbf51f3ed59ae37f0fec729f25af002111c9e74 from May removed Preprocessor::getPredefines() from Clang's API, presumably as a cleanup because this method is unused in the LLVM codebase.

However, it was/is used by a small number of third-party tools and is pretty harmless, so this patch adds it back and documents why it's here.

The issue was raised in https://github.com/llvm/llvm-project/issues/57483, it would be nice to be able to land it into Clang 15 as it breaks those third-party tools and we can't easily add it back in bug fix releases.

Reviewed By: brad.king, thieta

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