platform/upstream/llvm.git
18 months ago[mlir][bufferization] Fix failing lit test
Maya Amrami [Tue, 31 Jan 2023 10:56:59 +0000 (12:56 +0200)]
[mlir][bufferization] Fix failing lit test

Checks were too strict and by the time the patch was submitted,
the output of the test changed.

Reviewed By: springerm

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

18 months ago[Polly] Fix tests (NFC)
Nikita Popov [Tue, 31 Jan 2023 11:05:14 +0000 (12:05 +0100)]
[Polly] Fix tests (NFC)

Missed in 5f01a626dd0615df49773d419c75aeb33666ee83.

18 months ago[PowerPC] Improve materialization for immediates which is almost a 32 bit splat.
esmeyi [Tue, 31 Jan 2023 11:02:17 +0000 (06:02 -0500)]
[PowerPC] Improve materialization for immediates which is almost a 32 bit splat.

Summary: Some 64 bit constants can be materialized with fewer instructions than we currently use. We consider a 64 bit immediate value divided into four parts, Hi16OfHi32 (bits 48...63), Lo16OfHi32 (bits 32...47), Hi16OfLo32 (bits 16...31), Lo16OfLo32 (bits 0...15). When any three parts are equal, the immediate can be treated as "almost" a splat of a 32 bit value in a 64 bit register. For such case, we can use 3 instructions to generate the splat and use 1 instruction to modify the different part:

Reviewed By: shchenz

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

18 months ago[bazel] Add missing includes for 5212058
Goran Flegar [Tue, 31 Jan 2023 10:41:35 +0000 (11:41 +0100)]
[bazel] Add missing includes for 5212058

18 months ago[LICM] Regenerate test checks (NFC)
Nikita Popov [Tue, 31 Jan 2023 10:48:35 +0000 (11:48 +0100)]
[LICM] Regenerate test checks (NFC)

18 months ago[ConstantFold] Fix inbounds inference on mismatching source element type
Nikita Popov [Mon, 30 Jan 2023 14:30:20 +0000 (15:30 +0100)]
[ConstantFold] Fix inbounds inference on mismatching source element type

When inferring that a GEP of a global variable is inbounds because
there is no notional overindexing, we need to check that the
global value type and the GEP source element type match.

This was not necessary with typed pointers (because we would have
a bitcast in between), but is necessary with opaque pointers.

We should be able to recover some of the safe cases by performing
an offset based inbounds inference in DL-aware ConstantFolding.

18 months ago[AArch64] turn extended vecreduce bigger than v16i8 into udot/sdot
Zain Jaffal [Mon, 23 Jan 2023 10:08:33 +0000 (10:08 +0000)]
[AArch64] turn extended vecreduce bigger than v16i8 into udot/sdot

We can do this by breaking vecreduce into v16i8 vectors generating udot/sdot and concatenating them.

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

18 months ago[Clang] Fix typo in ReleaseNotes.rst
Corentin Jabot [Tue, 31 Jan 2023 10:19:30 +0000 (11:19 +0100)]
[Clang] Fix typo in ReleaseNotes.rst

18 months ago[2/3][Clang][RISCV] Add `__riscv_` for non-overloaded intrinsics
eopXD [Thu, 26 Jan 2023 17:01:41 +0000 (09:01 -0800)]
[2/3][Clang][RISCV] Add `__riscv_` for non-overloaded intrinsics

This commit adds prefix for the non-overloaded RVV intrinsics.

This is the 2nd commit of a patch-set to add __riscv_ for all RVV
intrinsics.

This follows the naming guideline under riscv-c-api-doc to add the
`__riscv_` suffix for all RVV intrinsics.

Pull Request:
riscv-non-isa/riscv-c-api-doc#31
riscv-non-isa/rvv-intrinsic-doc#189

Depends on D142085.

Reviewed By: kito-cheng

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

18 months ago[InstCombine] Add additional constexpr gep inbounds tests (NFC)
Nikita Popov [Tue, 31 Jan 2023 10:15:45 +0000 (11:15 +0100)]
[InstCombine] Add additional constexpr gep inbounds tests (NFC)

18 months ago[AArch64] Add additional tests for dotreduce to check for `v4i8` and `v24i8`
Zain Jaffal [Tue, 31 Jan 2023 09:52:34 +0000 (09:52 +0000)]
[AArch64] Add additional tests for dotreduce to check for `v4i8` and `v24i8`

Reviewed By: fhahn

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

18 months ago[Thumb2] Upgrade intrinsic upgrading code
Sergei Barannikov [Mon, 30 Jan 2023 16:07:20 +0000 (19:07 +0300)]
[Thumb2] Upgrade intrinsic upgrading code

Enabling opaque pointers has changed the mangled names of these two ARM
intrinsics:

`arm.mve.vldr.gather.offset.predicated.v2i64.p0i64.v2i64.v4i1`
`arm.mve.vstr.scatter.offset.predicated.p0i64.v2i64.v2i64.v4i1`

They are now spelled as:

`arm.mve.vldr.gather.offset.predicated.v2i64.p0.v2i64.v4i1`
`arm.mve.vstr.scatter.offset.predicated.p0.v2i64.v2i64.v4i1`

Upgrade intrinsic upgrading code to account for the change in names.

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

18 months ago[Clang] Implement Change scope of lambda trailing-return-type
Corentin Jabot [Sun, 6 Feb 2022 21:58:43 +0000 (22:58 +0100)]
[Clang] Implement Change scope of lambda trailing-return-type

This implements P2036R3 and P2579R0.
That is, explicit, int, and implicit capture become visible
at the start of the parameter head.

Reviewed By: aaron.ballman

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

18 months ago[clang][compiler-rt] Support LLVM_ENABLE_PER_TARGET_RUNTIME_DIR on Arm Linux and BSD
David Spickett [Thu, 1 Dec 2022 14:54:17 +0000 (14:54 +0000)]
[clang][compiler-rt] Support LLVM_ENABLE_PER_TARGET_RUNTIME_DIR on Arm Linux and BSD

The orginal single folder layout produced libraries in the form:
lib/linux/<libname>-<archname>.a

That archname for Arm depended on whether you had hard or soft float.
This is sometimes shown as "arm" (soft) vs. "armhf" (hard).

If this is set in a triple we do it in the final portion, the ABI.
"gnueabi" for soft float, "gnueabihf" for hard float.

Meaning that the expected triple is:
arm-unknown-linux-gnueabihf
Not this:
armhf-unknown-linux-gnueabihf

For the per target layout I have decided to rely on the ABI portion
of the triple instead of the arch name used for the old layout
(doing that would produce the invalid triple above).

This means that building with triple:
armv8l-unknown-linux-gnueabihf
Will result in libraries in:
lib/arm-unknown-linux-gnueabihf/

And clang will now know to look for "arm" instead of "armv8l".
Meaning that we can share libraries between an armv8 and armv7 build
as we did with the previous layout. In addition to handling spelling
differences e.g. "armv8l" with an "l" on some Linux distros.

compiler-rt will autodetect that the "armhf" and/or "arm" architecture
can be built. We then replace the given triple's architecture with that.
Then if the triple's float ABI doesn't match, we change that. That new
triple is then used as the folder name.

If you select to build only the given triple, with COMPILER_RT_DEFAULT_TARGET_ONLY,
compiler-rt will not autodetect the architecture and for that I assume you
know what you're doing. In that case the library path will use the unomdified triple.

From what I can tell, this is how most large builds e.g Android and
Arm's Embedded Toolchain for llvm do things. I assume that big endian "armeb"
builds would end up doing this too.

Bare metal builds will not be using per target runtime dirs so they
remain as they were.

Depends on D139536

Reviewed By: MaskRay, phosek

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

18 months agoRevert "[2/3][Clang][RISCV] Add `__riscv_` for non-overloaded intrinsics"
eopXD [Tue, 31 Jan 2023 09:45:42 +0000 (01:45 -0800)]
Revert "[2/3][Clang][RISCV] Add `__riscv_` for non-overloaded intrinsics"

This reverts commit 2153544865a9733b06579823814c981f735e4201.
Buildbot failure https://lab.llvm.org/buildbot#builders/139/builds/35218
shows left-out test cases that were not updated.

18 months ago[2/3][Clang][RISCV] Add `__riscv_` for non-overloaded intrinsics
eopXD [Thu, 26 Jan 2023 17:01:41 +0000 (09:01 -0800)]
[2/3][Clang][RISCV] Add `__riscv_` for non-overloaded intrinsics

This commit adds prefix for the non-overloaded RVV intrinsics.

This is the 2nd commit of a patch-set to add __riscv_ for all RVV
intrinsics.

This follows the naming guideline under riscv-c-api-doc to add the
`__riscv_` suffix for all RVV intrinsics.

Pull Request:
riscv-non-isa/riscv-c-api-doc#31
riscv-non-isa/rvv-intrinsic-doc#189

Depends on D142085.

Reviewed By: kito-cheng

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

18 months ago [mlir][OneShotModuleBufferize] Add a new flag: no-analysis-func-filter
Maya Amrami [Mon, 30 Jan 2023 14:11:56 +0000 (16:11 +0200)]
 [mlir][OneShotModuleBufferize] Add a new flag: no-analysis-func-filter

OneShotModuleBufferize fails if the input IR cannot be analyzed.
One can set CopyBeforeWrite=true in order to skip analysis.
In that case, a buffer copy is inserted on every write.
This leads to many copies, also in FuncOps that could be analyzed.

This change aims to copy buffers only when it is a must.
When running OneShotModuleBufferize with CopyBeforeWrite=false,
FuncOps whose names are specified in noAnalysisFuncFilter will not be
analyzed. Ops in these FuncOps will not be analyzed as well.
They will be bufferized with CopyBeforeWrite=true,
while the other ops will be bufferized with CopyBeforeWrite=false.

Reviewed By: springerm

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

18 months ago[1/3][Clang][RISCV] Add `__riscv_` prefix for vread, vwrite, vlenb, vsetvl, and vsetvlmax
eopXD [Thu, 26 Jan 2023 16:31:56 +0000 (08:31 -0800)]
[1/3][Clang][RISCV] Add `__riscv_` prefix for vread, vwrite, vlenb, vsetvl, and vsetvlmax

This commit adds prefix for intrinsics that are defined through
`HeaderCode` under `riscv_vector.td`.

This is the 1st commit of a patch-set to add `__riscv_` for all RVV
intrinsics.

This follows the naming guideline under riscv-c-api-doc to add the
`__riscv_` suffix for all RVV intrinsics.

Pull Request:
riscv-non-isa/riscv-c-api-doc#31
riscv-non-isa/rvv-intrinsic-doc#189

Depends on D142016.

Reviewed By: kito-cheng

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

18 months ago[flang] Lower storage_size intrinsic for polymorphic entities
Valentin Clement [Tue, 31 Jan 2023 08:44:07 +0000 (09:44 +0100)]
[flang] Lower storage_size intrinsic for polymorphic entities

Lower STOARGE_SIZE intrinsic when the argument is polymoprhic
or unlimited polymorphic. STOARGE_SIZE for monomorphic entity is folded
by the frontend.

Reviewed By: vzakhari, vdonaldson

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

18 months agoRevert "[GuardWidening] Choose right point for generating wide condition for branches...
Max Kazantsev [Tue, 31 Jan 2023 08:37:02 +0000 (15:37 +0700)]
Revert "[GuardWidening] Choose right point for generating wide condition for branches. PR60234"

This reverts commit 5cb568a37a53a9b0fd8fc9c2c35870cad43623e9.

Internal testing found failures, need to investigate.

18 months ago[mlir][vector][bufferize] Fix Windows build failure introduced by D141686
Matthias Springer [Tue, 31 Jan 2023 08:33:06 +0000 (09:33 +0100)]
[mlir][vector][bufferize] Fix Windows build failure introduced by D141686

18 months ago[IR][doc] Alignment is always set in memory for load/store/alloca/cmpxchg/atomicrmw.
Guillaume Chatelet [Thu, 26 Jan 2023 14:08:20 +0000 (14:08 +0000)]
[IR][doc] Alignment is always set in memory for load/store/alloca/cmpxchg/atomicrmw.

Context https://reviews.llvm.org/D142459#4081179

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

18 months agoReland "[mlir][LLVM] Add all LLVM parameter attributes"
Christian Ulmann [Tue, 31 Jan 2023 07:54:52 +0000 (08:54 +0100)]
Reland "[mlir][LLVM] Add all LLVM parameter attributes"

This change was reverted because it introduced a linking issue due to
duplicated symbols. Making sure that the detail helper only has a static
header implementation fixes this issue.

Reviewed By: gysit

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

18 months ago[mlir][vector][bufferize] Bufferize vector.mask and vector.yield
Matthias Springer [Tue, 31 Jan 2023 07:56:03 +0000 (08:56 +0100)]
[mlir][vector][bufferize] Bufferize vector.mask and vector.yield

The masked op can currently not bufferize out-of-place. Such IR would be rejected by the One-Shot Bufferize because it would mean that a new buffer allocation is yielded from a block. Furthermore, only one operation is currently allowed inside `vector.mask`.

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

18 months ago[mlir] Adjust AttributeTest to show skip behavior.
Adrian Kuegel [Tue, 31 Jan 2023 07:08:44 +0000 (08:08 +0100)]
[mlir] Adjust AttributeTest to show skip behavior.

walk() skips identical sub-attributes. Adjust the unit test to show
this.

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

18 months ago[libc] Unify full build and default build static archive targets to just "libc".
Siva Chandra Reddy [Tue, 31 Jan 2023 07:08:49 +0000 (07:08 +0000)]
[libc] Unify full build and default build static archive targets to just "libc".

18 months ago[Fuchsia] Re-enable HWASan for globals in runtimes
Petr Hosek [Mon, 30 Jan 2023 18:54:46 +0000 (18:54 +0000)]
[Fuchsia] Re-enable HWASan for globals in runtimes

This is now supported.

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

18 months ago[runtimes][libc] Keep the libc target as "libc".
Siva Chandra Reddy [Mon, 30 Jan 2023 18:56:22 +0000 (18:56 +0000)]
[runtimes][libc] Keep the libc target as "libc".

It currently renamed to "llvmlibc" under the runtimes/boostrap build.
This prevents us from making a full libc build.

Reviewed By: phosek

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

18 months ago[mlir] Remove redundant virtual keyword. NFC
Adrian Kuegel [Tue, 31 Jan 2023 07:18:51 +0000 (08:18 +0100)]
[mlir] Remove redundant virtual keyword. NFC

Found by ClangTidyLegacy check.

18 months ago[clangd] Stop filtering lit tests based on target-triple
Kadir Cetinkaya [Tue, 31 Jan 2023 07:01:35 +0000 (08:01 +0100)]
[clangd] Stop filtering lit tests based on target-triple

We are performing this filtering due to having unix style file paths in
certain tests. Hence we're actually trying to filter based on host
platform and not the target-triple LLVM is using.

2493a7016416c90038be5c816e12a7ad07cee054 introduced filtering based on
host platform already, so we can get rid of target-triple based
filtering now.

18 months ago[mlir][SubElements] Remove the ability to override implementations
River Riddle [Tue, 31 Jan 2023 06:42:14 +0000 (22:42 -0800)]
[mlir][SubElements] Remove the ability to override implementations

It's much cleaner and simpler to drive wacky configs via the
AttrTypeSubElementHandler interface, instead of override.

18 months ago[GuardWidening] Choose right point for generating wide condition for branches. PR60234
Max Kazantsev [Tue, 31 Jan 2023 05:29:26 +0000 (12:29 +0700)]
[GuardWidening] Choose right point for generating wide condition for branches. PR60234

When guards are represented as widenable branches, there is a tricky
situation when the branch stays in loop but widenable condition doesn't.
It means that the widenable condition is loop-invariant, and some other
optimizations could have done changes using this fact.

If widening is allowed to create widened condition inside this loop,
and join the loop-invariant wc with some non-invariant facts, it can
cause miscompile. See example of this at https://github.com/llvm/llvm-project/issues/60234.

The solution is to adjust the point of generationg the wide condition,
and therefore of hoisting all related parts there. It should not be before
the branch, but before the widenable_condition call. The fact that `wc()`
and the wide condition are in the same block guarantees that they will
not violate the invariance property for any loop.

Differential Revision: https://reviews.llvm.org/D142693
Reviewed By: apilipenko

18 months ago[mlir][vector] Add folder for bitcast of integer splat constants
Quinn Dawkins [Mon, 30 Jan 2023 15:42:42 +0000 (10:42 -0500)]
[mlir][vector] Add folder for bitcast of integer splat constants

This is a similar to the existing folder for f16 to f32 added with
D96041 but instead for integer types where destination bits > source bits.

Reviewed By: ThomasRaoux

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

18 months ago[lldb] Remove unimplemented SBTraceCursor::GetExecutionContextRef
Jonas Devlieghere [Tue, 31 Jan 2023 04:27:28 +0000 (20:27 -0800)]
[lldb] Remove unimplemented SBTraceCursor::GetExecutionContextRef

Fixes TAPI verification error:

  SBTraceCursor.h:130:23: error: declaration has external linkage, but dynamic library doesn't have symbol '__ZN4lldb13SBTraceCursor22GetExecutionContextRefEv'
  SBExecutionContext &GetExecutionContextRef();
                      ^

Remove the method as it doesn't have an implementation.

18 months ago[AVR][NFC] Refactor 'AVRAsmPrinter::PrintAsmOperand'
Ben Shi [Fri, 20 Jan 2023 02:34:08 +0000 (10:34 +0800)]
[AVR][NFC] Refactor 'AVRAsmPrinter::PrintAsmOperand'

Reviewed By: Chenbing.Zheng, aykevl

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

18 months ago[Doc] Removes extra argument of ReplaceInstWithValue()
Vasileios Porpodas [Tue, 31 Jan 2023 01:13:29 +0000 (17:13 -0800)]
[Doc] Removes extra argument of ReplaceInstWithValue()

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

18 months ago[PowerPC] Pre-commit test for fix to peephole opt
Nemanja Ivanovic [Tue, 31 Jan 2023 02:59:51 +0000 (20:59 -0600)]
[PowerPC] Pre-commit test for fix to peephole opt

This just adds a test case with current code gen. The patch
with the fix will correct the code gen.

18 months ago[lldb,FreeBSD] getValue => operator* for Optional migration
Fangrui Song [Tue, 31 Jan 2023 02:57:54 +0000 (18:57 -0800)]
[lldb,FreeBSD] getValue => operator* for Optional migration

18 months ago[InstCombine][LV] Fold (add (zext (add X, -1)), 1) -> (zext X) if X is non-zero.
Craig Topper [Tue, 31 Jan 2023 01:45:01 +0000 (17:45 -0800)]
[InstCombine][LV] Fold (add (zext (add X, -1)), 1) -> (zext X) if X is non-zero.

This artifact can appear from the vectorizer. (add X, -1) is the
backedge taken count. It gets zero extended and then 1 is added to
it to get the trip count.

There is usually a dominating branch that rules out X being zero.

Alive: https://alive2.llvm.org/ce/z/NsRDwX

18 months ago[InstCombine] Add test cases for D142783. NFC"
Craig Topper [Tue, 31 Jan 2023 01:44:55 +0000 (17:44 -0800)]
[InstCombine] Add test cases for D142783. NFC"

18 months ago[MLIR] Remove unnecessary Block argument on MemRefDependenceGraph::init
Uday Bondhugula [Tue, 31 Jan 2023 01:22:45 +0000 (06:52 +0530)]
[MLIR] Remove unnecessary Block argument on MemRefDependenceGraph::init

Remove unnecessary Block argument on MemRefDependenceGraph::init.
`block` is already a field on MDG.

Reviewed By: dcaballe

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

18 months ago[mlir][vector] Clarify vector.contract promotion behavior
Lei Zhang [Tue, 31 Jan 2023 00:05:19 +0000 (00:05 +0000)]
[mlir][vector] Clarify vector.contract promotion behavior

This commit updates vector.contract documentation to clarify
the promotion behavior if operands and the result have different
bitwidths. It also adds a check to disable signed/unsigned integer
types and only allow signless integers.

Reviewed By: ThomasRaoux

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

18 months ago[NFC] Correct argument comment typo
Gregory Alfonso [Tue, 31 Jan 2023 00:06:45 +0000 (16:06 -0800)]
[NFC] Correct argument comment typo

For Darwin, the boolean being passed is called IsSimulator, not "IsImulator"

Reviewed By: MaskRay

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

18 months ago[Libomptarget] Fix building AMDGPU tests
Joseph Huber [Mon, 30 Jan 2023 23:52:04 +0000 (17:52 -0600)]
[Libomptarget] Fix building AMDGPU tests

Summary:
Accidentally deleted this.

18 months ago[RISCV] Peak through BITCAST in isUsedByReturnOnly
Luke Lau [Mon, 30 Jan 2023 17:51:12 +0000 (17:51 +0000)]
[RISCV] Peak through BITCAST in isUsedByReturnOnly

A follow up to 47b1f8362aa409b591b5e9c8a9ff0e3e1d76ed9c,
This covers some more cases on soft-float ABIs with the f/d extension.
I left the TODO in as there is still the case where we need to handle rv32i without f/d, but that looks like it requires changes to SelectionDAGLegalize::ExpandFPLibCall

Reviewed By: asb, reames

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

18 months ago[flang] Use proper attributes for runtime calls with 'i1' arguments/returns.
Slava Zakharin [Sat, 28 Jan 2023 02:14:00 +0000 (18:14 -0800)]
[flang] Use proper attributes for runtime calls with 'i1' arguments/returns.

Clang uses signext/zeroext attributes for integer arguments shorter than
the default 'int' type on a target. So Flang has to match this for functions
from Fortran runtime and also for BIND(C) routines. This patch implements
ABI adjustments only for Fortran runtime calls. BIND(C) part will be done
separately.

This resolves https://github.com/llvm/llvm-project/issues/58579

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

18 months ago[X86] Move RDFLAGS/WRFLAGS expansion until after RA
Bill Wendling [Mon, 30 Jan 2023 21:19:52 +0000 (13:19 -0800)]
[X86] Move RDFLAGS/WRFLAGS expansion until after RA

The register allocator may introduce reloads in the middle of reading
and writing the EFLAGS register, due to the RDFLAGS & WRFLAGS pseudos
being expanded before RA. This may cause an issue where the stack
pointer was adjusted but the stack offset for the reload wasn't
accounted for (see [1]).

To avoid this, expand these pseudos after register allocation.

[1] https://github.com/llvm/llvm-project/issues/59102

Reviewed By: craig.topper, nickdesaulniers, pengfei

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

18 months agolld/COFF: simplify startswith+substr
Fangrui Song [Mon, 30 Jan 2023 23:28:10 +0000 (15:28 -0800)]
lld/COFF: simplify startswith+substr

18 months ago[hwasan] Support __lsan_default_options
Fangrui Song [Mon, 30 Jan 2023 23:07:46 +0000 (15:07 -0800)]
[hwasan] Support __lsan_default_options

Reviewed By: vitalybuka

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

18 months ago[lldb/test] Skip TestStackCoreScriptedProcess if Asan is enabled
Med Ismail Bennani [Mon, 30 Jan 2023 23:01:31 +0000 (15:01 -0800)]
[lldb/test] Skip TestStackCoreScriptedProcess if Asan is enabled

This patch skips TestStackCoreScriptedProcess because the test times out
when the Address Sanitizer is running.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
18 months ago[PowerPC] Fix incorrect shift amount for build_vector
Nemanja Ivanovic [Mon, 30 Jan 2023 22:34:50 +0000 (16:34 -0600)]
[PowerPC] Fix incorrect shift amount for build_vector

The pattern for a build_vector node was incorrect for big endian
subtargets.

18 months ago[flang] Fixed Flang LIT testing after D142548.
Slava Zakharin [Mon, 30 Jan 2023 22:35:31 +0000 (14:35 -0800)]
[flang] Fixed Flang LIT testing after D142548.

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

18 months ago[LSAN][HWASAN] Run LSAN tests with HWASAN enabled
Kirill Stoimenov [Mon, 30 Jan 2023 20:20:55 +0000 (20:20 +0000)]
[LSAN][HWASAN] Run LSAN tests with HWASAN enabled

A lot of tests are disabled by using UNSUPPORTED. The plan is to remove UNSUPPORTED for tests that are fixed.

Reviewed By: vitalybuka

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

18 months ago[lldb/swig] Remove deprecated flags for generating bindings
Med Ismail Bennani [Mon, 30 Jan 2023 22:07:32 +0000 (14:07 -0800)]
[lldb/swig] Remove deprecated flags for generating bindings

This patch conditionaly removes the `-py3` swig flag that was used to
generate python3 bindings, since it's unsued since SWIG 4.1.0.

```
Deprecated command line option: -py3. Ignored, this option is no longer supported
```

This also removes the `-shadow` flag that have been deprecated since 2002.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
18 months ago[bazel] Port 155e0cf5dc2f
Benjamin Kramer [Mon, 30 Jan 2023 22:01:26 +0000 (23:01 +0100)]
[bazel] Port 155e0cf5dc2f

18 months ago[AIX][CMake] Use top-level tools in llvm_ExternalProject_Add
David Tenty [Mon, 9 Jan 2023 22:45:39 +0000 (17:45 -0500)]
[AIX][CMake] Use top-level tools in llvm_ExternalProject_Add

This change force us to use the top-level CMake's detected tools. We
need to do this as a temporary workaround as when using CMake
versions >= 3.22 we'll pickup the built llvm-ranlib by default if it's
in the path (which it is when doing a sub build via
llvm_ExternalProject_Add for the runtimes).

llvm-ranlib runs into problems on AIX due to missing 64-bit
functionality to be added by
https://reviews.llvm.org/D142479 and https://reviews.llvm.org/D142660.
Once those patches land, this can be reverted.

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

18 months ago[lldb] Use lldbassert in BuildObjCObjectPointerType
Jonas Devlieghere [Wed, 25 Jan 2023 00:29:26 +0000 (16:29 -0800)]
[lldb] Use lldbassert in BuildObjCObjectPointerType

This assert is only checked in Debug builds but ignored in all other
builds. This replaces this code with lldbassert which should print a
warning to the user in release builds and actually asserts in debug
builds.

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

18 months ago[NFC] [llvm-cov] Remove unnecessary logic from llvm-cov debuginfod.
Daniel Thornburgh [Mon, 30 Jan 2023 21:19:05 +0000 (13:19 -0800)]
[NFC] [llvm-cov] Remove unnecessary logic from llvm-cov debuginfod.

Indexed profiles already have a sorted and uniqued binary ID list, and
due to this, duplicates are harmless in the list of binary IDs found,
since it's set_differenced from the list in the indexed profile.

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

18 months ago[llvm-cov] Add split-file to compiler-rt test requirements.
Daniel Thornburgh [Mon, 30 Jan 2023 21:17:17 +0000 (13:17 -0800)]
[llvm-cov] Add split-file to compiler-rt test requirements.

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

18 months ago[libc++] Remove <experimental/coroutine>
Chuanqi Xu [Thu, 23 Sep 2021 14:33:45 +0000 (10:33 -0400)]
[libc++] Remove <experimental/coroutine>

We've been shipping <coroutine> since LLVM 14, so LLVM 17 won't ship
the <experimental/coroutine> header per our policy for removing TSes.

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

18 months ago[Clang] Fix unconditional access to Attr pointer when checking if _Nullable is applic...
Shafik Yaghmour [Mon, 30 Jan 2023 21:26:02 +0000 (13:26 -0800)]
[Clang] Fix unconditional access to Attr pointer when checking if _Nullable is applicable to a type

In TransformAttributedType(...) when checking if _Nullable can be applied to a
type it dereferences TL.getAttr() unconditionally which we can see from the code
earlier in the function is not correct since it is expected to be nullptr in
some cases.

It looks like the correct course of action is to use TL.getModifiedLoc() over
TL.getAttr()->getLocation() in the case that TL.getAttr() returns a nullptr.

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

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

18 months ago[Pseudo Probe] Do not instrument EH blocks.
Hongtao Yu [Thu, 26 Jan 2023 06:26:47 +0000 (22:26 -0800)]
[Pseudo Probe] Do not instrument EH blocks.

This change avoids inserting probes to EH blocks. Pseudo probe can prevent block merging when probes in the blocks look different. This has a chained effect to passes incurring exponential IR growth (such as jump threading) and as a consequence the compilation may time out.  Not inserting probes to EH blocks could mitigate the issue. Another benefit is that both IR size and binary size are smaller. Since EH blocks are usually cold, the change should have minimal impact to profile quality.

Testing:

Out of two internal large benchmarks, no perf impact seen. 1% size savings to both the `text` and the `pseudo_probe` section.

Reviewed By: wenlei

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

18 months ago[libc++] Add missing include promote.h in <cmath>
Louis Dionne [Thu, 26 Jan 2023 19:46:53 +0000 (14:46 -0500)]
[libc++] Add missing include promote.h in <cmath>

As a fly-by, also remove a superfluous <cstddef> include in promote.h.

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

18 months ago[InstCombine] reduce icmp_eq0-of-and-of-select-of-constants
Sanjay Patel [Mon, 30 Jan 2023 20:34:29 +0000 (15:34 -0500)]
[InstCombine] reduce icmp_eq0-of-and-of-select-of-constants

This is the most basic patch to handle fixing issue #57666.

D133919 proposes to handle much more than this in a single patch,
but I've used 10 regression tests just to make sure this part is
doing what I expected and nothing more, and it already shows even
more potential TODO items.

The more general proofs from D133919 are correct, but I want to
enable this in smaller steps to reduce risk:
https://alive2.llvm.org/ce/z/RrVEyX

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

18 months ago[InstCombine] add tests for icmp-of-and-of-select-of-constants; NFC
Sanjay Patel [Sun, 29 Jan 2023 16:53:38 +0000 (11:53 -0500)]
[InstCombine] add tests for icmp-of-and-of-select-of-constants; NFC

This overlaps with the tests proposed in D134064
and providing coverage for D133919, but it is
both limited in scope and more comprehensive
because there are many potential ways to transform
these kinds of patterns.

18 months ago[mlir][Pass] Handle spaces in pipeline strings
Bruno Schmitt [Mon, 30 Jan 2023 20:49:19 +0000 (12:49 -0800)]
[mlir][Pass] Handle spaces in pipeline strings

An user might want to add extra spaces for better readability, e.g:
```
mypm = pm.PassManager.parse(f"""builtin.module(
    mypass1,
        func.func(mypass2,mypass3)
)""")
```
GitHub issue #59151

The parser was not taking into account the possibility of spaces after
`)`or `}`

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

18 months ago[mlir][AsmPrinter] Gracefully handle empty symbol
Bruno Schmitt [Mon, 30 Jan 2023 20:48:07 +0000 (12:48 -0800)]
[mlir][AsmPrinter] Gracefully handle empty symbol

The GenericOp printer should support malformed IR without crashing

GitHub issue #59529

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

18 months ago[RISCV] Use custom operand parsing for FenceArg.
Craig Topper [Mon, 30 Jan 2023 20:20:07 +0000 (12:20 -0800)]
[RISCV] Use custom operand parsing for FenceArg.

Rather than parsing a symbol and checking its name, look for an
identifier during parsing.

I've also handled the 0 immediate during parsing, though we could
let that go through the normal immediate parsing if we need to support
expressions that evaluate to 0. We don't have tests for that currently.

Reviewed By: asb, frasercrmck

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

18 months agoAMDGPU: Update machine divergence analysis test
Matt Arsenault [Mon, 30 Jan 2023 20:07:40 +0000 (16:07 -0400)]
AMDGPU: Update machine divergence analysis test

18 months agoAMDGPU/GlobalISel: Add stub custom regbankselect pass
Matt Arsenault [Wed, 18 Jan 2023 11:02:30 +0000 (06:02 -0500)]
AMDGPU/GlobalISel: Add stub custom regbankselect pass

Uniformity analysis needs to be the fundamental basis for
regbank decisions. The considerations of the default pass
are secondary, but potentially useful for some edge cases (e.g.
selecting AGPRs when arbitrary loads and stores can directly use
them). This needs to be a separate pass since it requires new
analysis dependencies.

Boilerplate to subclass the existing pass which does nothing
different.

18 months agoRecommit "[SCCP] Support NUW/NSW inference for all overflowing binary operators."
Florian Hahn [Mon, 30 Jan 2023 20:15:28 +0000 (20:15 +0000)]
Recommit "[SCCP] Support NUW/NSW inference for all overflowing binary operators."

This reverts commit 43acb61a08fffada31fb2e20e45fcc8492ef76b9.

Recommit the patch after fixing the issue causing the revert in 4e607ec4987.
Extra tests have been added in 5c6cb61ad416a544.

Original commit message:

   Extend the NUW/NSW inference logic add in 72121a20cd and cdeaf5f28c3dc
    to all overflowing binary operators.

    Reviewed By: nikic

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

18 months ago[test] Require asserts in count-visits.ll
Arthur Eubanks [Mon, 30 Jan 2023 19:58:33 +0000 (11:58 -0800)]
[test] Require asserts in count-visits.ll

-stats doesn't work in release builds without stats enabled.

Followup to D142853

18 months agoRevert "[LSAN][HWASAN] Run LSAN tests with HWASAN enabled"
Hans Wennborg [Mon, 30 Jan 2023 19:39:38 +0000 (20:39 +0100)]
Revert "[LSAN][HWASAN] Run LSAN tests with HWASAN enabled"

This broke the sanitizer tests on Mac, see e.g.
https://green.lab.llvm.org/green/job/clang-stage1-RA/32739/ and comment on the
code review.

> A lot of tests are disabled by using UNSUPPORTED. The plan is to remove UNSUPPORTED for tests that are fixed.
>
> Reviewed By: vitalybuka
>
> Differential Revision: https://reviews.llvm.org/D142676

This reverts commit f9a01630988716f1b52afe6727f34fe86c07c58a.
and follow-up commit bf47ffaa76fbda1ba96d41ee2681e45d2445be1e
(https://reviews.llvm.org/D142812).

18 months agoImprove example documentation for __builtin_offsetof; NFC
Aaron Ballman [Mon, 30 Jan 2023 19:54:59 +0000 (14:54 -0500)]
Improve example documentation for __builtin_offsetof; NFC

This implements some post-commit feedback from D142723

18 months agoFix handling of braced-init temporaries for modernize-use-emplace
BigPeet [Mon, 30 Jan 2023 19:52:20 +0000 (14:52 -0500)]
Fix handling of braced-init temporaries for modernize-use-emplace

Fixes #55870

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

18 months agoAMDGPU/GlobalISel: Partially fix getGenericInstructionUniformity
Matt Arsenault [Wed, 18 Jan 2023 15:57:53 +0000 (10:57 -0500)]
AMDGPU/GlobalISel: Partially fix getGenericInstructionUniformity

This was broken for the common case of instructions which are uniform
if their inputs are uniform. This is broken for control flow intrinsics
since the API currently does not express which result operand is in question.

This generates failures in just about every intrinsic test when uniformity
analysis is performed without this.

18 months agoAMDGPU: Partially fix machine uniformity for inline asm
Matt Arsenault [Wed, 18 Jan 2023 13:58:00 +0000 (08:58 -0500)]
AMDGPU: Partially fix machine uniformity for inline asm

This was assuming virtual registers only, and asserting on physical.
This was also ignoring AGPRs, and only considering VGPRs.

Reporting the instruction as uniform or not is conceptually wrong,
this should be reported per-operand. An inline asm statement could
include uniform and non-uniform components. This should report
purely for the register defs and ignore the uses.

Fixes asserting on most of the inline asm tests when uniformity
analysis is used.

18 months agoAMDGPU: Fix null dereference in getInstructionUniformity
Matt Arsenault [Wed, 18 Jan 2023 13:20:09 +0000 (08:20 -0500)]
AMDGPU: Fix null dereference in getInstructionUniformity

This was failing when it couldn't find an allocatable class
for special physical register inputs (like $mode), which are all
scalars.

This avoids numerous test failures when regbankselect is updated
to use uniformity analysis.

18 months ago[SCCP] Add sub tests for NUW/NSW flag inference.
Florian Hahn [Mon, 30 Jan 2023 19:40:36 +0000 (19:40 +0000)]
[SCCP] Add sub tests for NUW/NSW flag inference.

Those tests add coverage for a miscompile with 024115ab14822a97c.

18 months ago[MC] Allow .pushsection between .cfi_startproc/.cfi_endproc
Alex Brachet [Mon, 30 Jan 2023 19:27:18 +0000 (19:27 +0000)]
[MC] Allow .pushsection between .cfi_startproc/.cfi_endproc

This follows the behavior of gnu assemblers. This is useful when
writing inline assembly.

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

18 months agoReland [LTO] Demangle the function name in DiagnosticInfoDontCall message
Kyuwon Cho [Mon, 30 Jan 2023 18:10:50 +0000 (10:10 -0800)]
Reland [LTO] Demangle the function name in DiagnosticInfoDontCall message

Previously, dontcall attribute message on LTO prints the mangled function name.

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

Relanded with proper IR -> Demangle dependency.

Reviewed By: aeubanks

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

18 months agoRevert "[LTO] Demangle the function name in DiagnosticInfoDontCall message"
Arthur Eubanks [Mon, 30 Jan 2023 19:16:41 +0000 (11:16 -0800)]
Revert "[LTO] Demangle the function name in DiagnosticInfoDontCall message"

This reverts commit cb05c2ffc79eefe74c569263e27fcb5fad167ba3.

Breaks https://lab.llvm.org/buildbot/#/builders/121/builds/27524/steps/4/logs/stdio

18 months agoclang/OpenCL: Apply default attributes to enqueued blocks
Matt Arsenault [Thu, 12 Jan 2023 15:07:18 +0000 (10:07 -0500)]
clang/OpenCL: Apply default attributes to enqueued blocks

This was missing important environment context, like denormal-fp-math
and target-features. Curiously this seems to be losing nounwind. Note
this only fixes the actual invoke kernel. The invoke function is
already setting the default attribute set for internal
functions. However that is still buggy since it's not applying any use
function attributes (it's also missing uniform-work-group-size).

There seem to be too many different functions for setting attributes
with inconsistent behavior. The Function overload of
addDefaultFunctionAttributes seems to miss the target-cpu and
target-features. The AttrBuilder one seems to miss optnone (but that
seems to be disallowed on blocks anyway). Neither one calls
setTargetAttributes, when it probably should. uniform-work-group-size
is also set through AMDGPU code when it should be emitting generically
as a language property.

I also noticed update_cc_test_checks for attributes seem to not
connect the captured attribute variables to the attributes at the end
(although I think the numbers happen to work out correctly).

18 months agoclang/OpenCL: Extend tests for enqueued block attributes
Matt Arsenault [Thu, 12 Jan 2023 15:05:28 +0000 (10:05 -0500)]
clang/OpenCL: Extend tests for enqueued block attributes

Baseline tests showing that enqueued blocks are not getting the
correct attributes applied.

18 months agoclang/OpenCL: Fix not setting convergent on block invoke kernels
Matt Arsenault [Wed, 11 Jan 2023 01:08:00 +0000 (20:08 -0500)]
clang/OpenCL: Fix not setting convergent on block invoke kernels

Yet another example how convergent not being the default is dangerous
and backwards.

18 months agoclang/OpenCL: Don't use a Function for the block type
Matt Arsenault [Wed, 11 Jan 2023 00:25:48 +0000 (19:25 -0500)]
clang/OpenCL: Don't use a Function for the block type

The AMDGPU value for this is not really a function. Currently we're
emitting IR that isn't true to what will eventually be emitted.

18 months ago[OpenMP][NVPTX] Guard the target name macro definition
Shilei Tian [Mon, 30 Jan 2023 19:02:22 +0000 (14:02 -0500)]
[OpenMP][NVPTX] Guard the target name macro definition

18 months ago[LTO] Demangle the function name in DiagnosticInfoDontCall message
Kyuwon Cho [Mon, 30 Jan 2023 18:10:50 +0000 (10:10 -0800)]
[LTO] Demangle the function name in DiagnosticInfoDontCall message

Previously, dontcall attribute message on LTO prints the mangled function name.

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

Reviewed By: aeubanks

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

18 months ago[CGSCC] Add pass which counts the max number of times we visit a function
Arthur Eubanks [Sun, 29 Jan 2023 23:48:04 +0000 (15:48 -0800)]
[CGSCC] Add pass which counts the max number of times we visit a function

This will help with finding potential pathological CGSCC cases.

Reviewed By: asbirlea

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

18 months ago[SCCP] Flip range arguments for NSW region check.
Florian Hahn [Mon, 30 Jan 2023 18:03:18 +0000 (18:03 +0000)]
[SCCP] Flip range arguments for NSW region check.

This brings the operand order in line with the NUW handling, which was
missed out in 72121a20cda4dc91d0ef5548f930.

At the moment this is NFC as we only additions, but it
should fix miscompiles with 024115ab14822a recommitted.

18 months ago[RISCV] Replace multiple ifs with a switch. NFC
Craig Topper [Mon, 30 Jan 2023 17:53:48 +0000 (09:53 -0800)]
[RISCV] Replace multiple ifs with a switch. NFC

D108961 will add more instructions to this.

18 months agoRevert "[AIX][BigArchive] Treat the archive is empty if the first child member offset...
Mitch Phillips [Mon, 30 Jan 2023 17:41:55 +0000 (09:41 -0800)]
Revert "[AIX][BigArchive] Treat the archive is empty if the first child member offset is zero"

This reverts commit 7f0003c19c3a47f484ea9cc929728808b27ace32.

Reason: This broke the ASan buildbot, see the comments in
https://reviews.llvm.org/D138986 for more information.

18 months ago[libc++] Add [[clang::lifetimebound]] to min/max algorithms
Nikolas Klauser [Tue, 10 Jan 2023 23:01:37 +0000 (00:01 +0100)]
[libc++] Add [[clang::lifetimebound]] to min/max algorithms

Reviewed By: Mordante, #libc

Spies: libcxx-commits

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

18 months ago[libc] Add an off-by-default option to silence "skipping" messages from CMake.
Siva Chandra Reddy [Sat, 28 Jan 2023 09:26:46 +0000 (09:26 +0000)]
[libc] Add an off-by-default option to silence "skipping" messages from CMake.

Reviewed By: lntue

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

18 months ago[libc] Use a more general way to determine the compiler's target triple.
Siva Chandra Reddy [Sat, 28 Jan 2023 00:14:14 +0000 (00:14 +0000)]
[libc] Use a more general way to determine the compiler's target triple.

Reviewed By: lntue

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

18 months ago[mem2reg][debuginfo] Handle op_deref when converting dbg.declare
Felipe de Azevedo Piovezan [Thu, 19 Jan 2023 15:02:28 +0000 (12:02 -0300)]
[mem2reg][debuginfo] Handle op_deref when converting dbg.declare

The conversion of dbg.declare into dbg.values doesn't take into account
the DIExpression attached to the intrinsic. In particular, when
converting:

```
store %val, ptr %alloca
dbg.declare(ptr %alloca, !SomeVar, !DIExpression())
```

Mem2Reg will try to figure out if `%val` has the size of `!SomeVar`. If
it does, then a non-undef dbg.value is inserted:

```
dbg.value(%val, !SomeVar, !DIExpression())
```

This makes sense: the alloca is _the_ address of the variable. So a
store to the alloca is a store to the variable. However, if the
expression in the original intrinsic is a `DW_OP_deref`, this logic is
not applicable:

```
store ptr %val, ptr %alloca
dbg.declare(ptr %alloca, !SomeVar, !DIExpression(DW_OP_deref))
```

Here, the alloca is *not* the address of the variable. A store to the
alloca is *not* a store to the variable. As such, querying whether
`%val` has the same size as `!SomeVar` is meaningless.

This patch addresses the issue by:
1. Allowing the conversion when the expression is _only_ a `DW_OP_deref`
without any other expressions (see code comment).
2. Checking that the expression does not start with a `DW_OP_deref`
before applying the logic that checks whether the value being stored and
the variable have the same length.

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

18 months ago[AArch64] Replace AEK_CRYPTO with relevant features in cpu definitions
David Green [Mon, 30 Jan 2023 16:05:25 +0000 (16:05 +0000)]
[AArch64] Replace AEK_CRYPTO with relevant features in cpu definitions

This replaces AEK_CRYPTO in the AArch64TargetParser definitions,
replacing the composite Crypto features with the constituent parts.
AEK_CRYPTO is replaced with either AEK_AES | AEK_SHA2 or AEK_AES |
AEK_SHA2 | AEK_SHA3 | AEK_SHA4 depending on if the cpu is Arm-v8.4+.
This helps get the features correct in some more places like
target(cpu=..) attributes.

Otherwise this is hopefully an NFC for -mcpu options but seems like a
cleaner design.

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

18 months ago[libc++] Don't assume that string_view::const_iterator is a raw pointer
Louis Dionne [Mon, 28 Nov 2022 13:01:46 +0000 (08:01 -0500)]
[libc++] Don't assume that string_view::const_iterator is a raw pointer

Our implementation of std::format assumed that string_view's iterators
were raw pointers in various places. If we want to introduce a checked
iterator in debug mode, that won't be true anymore. This patch removes
that assumption.

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

18 months ago[mlir][llvm] Import access group metadata.
Tobias Gysi [Mon, 30 Jan 2023 14:38:28 +0000 (15:38 +0100)]
[mlir][llvm] Import access group metadata.

The revision adds support to import access group metadata from LLVM IR.
It closely follows the design of the TBAA metadata import with an
up-front conversion of the metadata nodes to operations stored in the
body of a module-level metadata operation. The revision chooses to use
only one module-level metadata operation for all kinds of metadata.
This  design ensures there is only one metadata operation that pollutes
the user namespace.

The import of loop metadata, which will use the access groups,
is left to a follow up revision.

Reviewed By: Dinistro

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

18 months ago[InstCombine] Regenerate test checks (NFC)
Nikita Popov [Mon, 30 Jan 2023 14:28:27 +0000 (15:28 +0100)]
[InstCombine] Regenerate test checks (NFC)