platform/upstream/llvm.git
19 months ago[mlir] Fix build breakage introduced by D139026
Matthias Springer [Thu, 1 Dec 2022 08:16:17 +0000 (09:16 +0100)]
[mlir] Fix build breakage introduced by D139026

19 months ago[mlir][linalg][transform] Add structured.replace op
Matthias Springer [Wed, 30 Nov 2022 17:27:30 +0000 (18:27 +0100)]
[mlir][linalg][transform] Add structured.replace op

This op is useful for debugging/experiments and allows users to replace ops (without arguments + IsolatedFromAbove) with the given op in the region of transform op.

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

19 months ago[MLIR][Transform] Disambiguate ternary operator for MSVC
Benjamin Kramer [Thu, 1 Dec 2022 07:58:37 +0000 (08:58 +0100)]
[MLIR][Transform] Disambiguate ternary operator for MSVC

mlir/lib/Dialect/SCF/TransformOps/SCFTransformOps.cpp(42): error C2446: ':': no conversion from 'OpTy' to 'OpTy'
        with
        [
            OpTy=mlir::scf::ForOp
        ]
        and
        [
            OpTy=mlir::AffineForOp
        ]
mlir/lib/Dialect/SCF/TransformOps/SCFTransformOps.cpp(42): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

19 months ago[clang-tidy] Add misc-use-anonymous-namespace check
Carlos Galvez [Thu, 3 Nov 2022 11:04:10 +0000 (11:04 +0000)]
[clang-tidy] Add misc-use-anonymous-namespace check

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

19 months ago[Driver] Add test for -stdlib++-isystem with -nostdinc
Shoaib Meenai [Thu, 1 Dec 2022 07:09:28 +0000 (23:09 -0800)]
[Driver] Add test for -stdlib++-isystem with -nostdinc

This further clarifies the intent of the flag.

19 months ago[RISCV] Use Register instead of unsigned. NFC
Craig Topper [Thu, 1 Dec 2022 06:51:57 +0000 (22:51 -0800)]
[RISCV] Use Register instead of unsigned. NFC

19 months ago[mlir] Change scf::LoopNest to store 'results'.
Christian Sigg [Tue, 15 Nov 2022 13:19:35 +0000 (14:19 +0100)]
[mlir] Change scf::LoopNest to store 'results'.

This fixes the case where scf::LoopNest::loops is empty.

Change LoopVector and ValueVector to SmallVector.

Reviewed By: ftynse

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

19 months ago[X86] Add ExpandLargeFpConvert Pass and enable for X86
Freddy Ye [Thu, 1 Dec 2022 05:47:25 +0000 (13:47 +0800)]
[X86] Add ExpandLargeFpConvert Pass and enable for X86

As stated in
https://discourse.llvm.org/t/rfc-llc-add-expandlargeintfpconvert-pass-for-fp-int-conversion-of-large-bitint/65528,
this implementation is very similar to ExpandLargeDivRem, which expands
‘fptoui .. to’, ‘fptosi .. to’, ‘uitofp .. to’, ‘sitofp .. to’ instructions
with a bitwidth above a threshold into auto-generated functions. This is
useful for targets like x86_64 that cannot lower fp convertions with more
than 128 bits. The expanded nodes are referring from the IR generated by
`compiler-rt/lib/builtins/floattidf.c`, `compiler-rt/lib/builtins/fixdfti.c`,
and etc.

Corner cases:
1. For fp16: as there is no related builtins added in compliler-rt. So I
mainly utilized the fp32 <-> fp16 lib calls to implement.
2. For fp80: as this pass is soft fp emulation and no fp80 instructions can
help in this problem. I recommend users to deprecate this usage. For now, the
implementation uses fp128 as the temporary conversion type and inserts
fptrunc/ext at top/end of the function.
3. For bf16: as clang FE currently doesn't support bf16 algorithm operations
(convert to int, float, +, -, *, ...), this patch doesn't consider bf16 for
now.
4. For unsigned FPToI: since both default hardware behaviors and libgcc are
ignoring "returns 0 for negative input" spec. This pass follows this old way
to ignore unsigned FPToI. See this example:
https://gcc.godbolt.org/z/bnv3jqW1M

The end-to-end tests are uploaded at https://reviews.llvm.org/D138261

Reviewed By: LuoYuanke, mgehre-amd

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

19 months agoEnhance stack protector for calling no return function
Xiang1 Zhang [Mon, 28 Nov 2022 07:02:04 +0000 (15:02 +0800)]
Enhance stack protector for calling no return function

Reviewed By: LuoYuanke, WangPengfei, lebedev.ri

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

19 months agoReport which modules have forcefully completed types in statistics.
Greg Clayton [Thu, 24 Nov 2022 04:28:03 +0000 (20:28 -0800)]
Report which modules have forcefully completed types in statistics.

A previous patch added the ability for us to tell if types were forcefully completed. This patch adds the ability to see which modules have forcefully completed types and aggregates the number of modules with forcefully completed types at the root level.

We add a module specific setting named "debugInfoHadIncompleteTypes" that is a boolean value. We also aggregate the number of modules at the root level that had incomplete debug info with a key named "totalModuleCountWithIncompleteTypes" that is a count of number of modules that had incomplete types.

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

19 months ago[mlir][spirv] Fix missing parameter usage
Lei Zhang [Thu, 1 Dec 2022 05:05:16 +0000 (05:05 +0000)]
[mlir][spirv] Fix missing parameter usage

This was accidentially removed during refactoring.

Reviewed By: kuhar

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

19 months ago[RISCV] Add ANDI to getRegAllocationHints.
Craig Topper [Thu, 1 Dec 2022 04:54:27 +0000 (20:54 -0800)]
[RISCV] Add ANDI to getRegAllocationHints.

19 months ago[RISCV] Replace hardcoded constant with OPIVI.Value in tablegen. NFC
Craig Topper [Thu, 1 Dec 2022 04:10:13 +0000 (20:10 -0800)]
[RISCV] Replace hardcoded constant with OPIVI.Value in tablegen. NFC

19 months ago[AArch64][SME][NFC]: Enable lowering truncate for enhancement.
Hassnaa Hamdi [Thu, 1 Dec 2022 03:44:42 +0000 (03:44 +0000)]
[AArch64][SME][NFC]: Enable lowering truncate for enhancement.

Enable lowering truncate to enhance the generated code.

19 months ago[AArch64][SME]: Scalarize masked gather/scatter in streaming mode.
Hassnaa Hamdi [Tue, 29 Nov 2022 16:40:37 +0000 (16:40 +0000)]
[AArch64][SME]: Scalarize masked gather/scatter in streaming mode.

Add testing files:
 - streaming-compatible-expand-masked-gather-scatter.ll

Reviewed By: david-arm, sdesmalen

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

19 months ago[AArch64][SME]: Generate streaming-compatible code for ld2-alloca.
Hassnaa Hamdi [Wed, 30 Nov 2022 09:45:47 +0000 (09:45 +0000)]
[AArch64][SME]: Generate streaming-compatible code for ld2-alloca.

To generate code compatible to streaming mode:
 - disable lowering interleaved load to avoid generating invalid NEON intrinsics.

Reviewed By: sdesmalen

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

19 months ago[AArch64][SME]: Add precursory tests for D138791
Hassnaa Hamdi [Mon, 28 Nov 2022 12:40:46 +0000 (12:40 +0000)]
[AArch64][SME]: Add precursory tests for D138791

Testing files:
 - ld2-alloca.ll

19 months ago[AMX] Support AMX-FP16 new intrinsic interface
Xiang1 Zhang [Thu, 1 Dec 2022 01:23:44 +0000 (09:23 +0800)]
[AMX] Support AMX-FP16 new intrinsic interface

We support AMX-FP16 isa in https://reviews.llvm.org/D135941 now.
The old  intrinsic interface need to manually write tile registers.
So we support its new intrinsic interface to let it be able to do register allocation.

Reviewed By: LuoYuanke

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

19 months ago[LoongArch] Add remaining intrinsics for CRC check instructions
gonglingqin [Thu, 1 Dec 2022 01:18:00 +0000 (09:18 +0800)]
[LoongArch] Add remaining intrinsics for CRC check instructions

After D137316 implements the intrinsics of the first crc check instruction
and related diagnosis, this patch implements the intrinsics of all remaining
crc check instructions.

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

19 months ago[AArch64][SME]: Add streaming-compatible testing files.
Hassnaa Hamdi [Tue, 29 Nov 2022 12:57:56 +0000 (12:57 +0000)]
[AArch64][SME]: Add streaming-compatible testing files.

Testing files:
 - int-compares.ll
 - int-immediates.ll
 - log-reduce.ll

Reviewed By: david-arm, sdesmalen

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

19 months ago[OpenMP][LegacyPM] Remove OpenMPOptCGSCCLegacyPass
LiaoChunyu [Wed, 30 Nov 2022 12:23:55 +0000 (20:23 +0800)]
[OpenMP][LegacyPM] Remove OpenMPOptCGSCCLegacyPass

Using the legacy pass manager for the optimization pipeline is deprecated.
I see the new PM is available.

Reviewed By: aeubanks, jdoerfert

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

19 months ago[AArch64][SME]: Add streaming-compatible testing files.
Hassnaa Hamdi [Tue, 29 Nov 2022 12:58:47 +0000 (12:58 +0000)]
[AArch64][SME]: Add streaming-compatible testing files.

Testing files:
 - limit-duplane.ll
 - optimize-ptrue.ll
 - ptest.ll

Reviewed By: david-arm, sdesmalen

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

19 months ago[mlir] Update HeapAsmResourceBlob::allocate API to make alignment explicit
River Riddle [Tue, 29 Nov 2022 02:48:12 +0000 (18:48 -0800)]
[mlir] Update HeapAsmResourceBlob::allocate API to make alignment explicit

This effectively matches the same API changes that were made to
UnmanagedAsmResourceBlob.

19 months ago[mlir] Cleanup lingering problems surrounding attribute/type aliases
River Riddle [Tue, 29 Nov 2022 02:35:00 +0000 (18:35 -0800)]
[mlir] Cleanup lingering problems surrounding attribute/type aliases

This commit refactors attribute/type alias generation to be similar to how
we do it for operations, i.e. we generate aliases determined on what is
actually necessary when printing the IR (using a dummy printer for alias
collection). This allows for generating aliases only when necessary, and
also allows for proper propagation of when a nested alias can be deferred.
This also necessitated a fix for location parsing to actually parse aliases
instead of ignoring them.

Fixes #59041

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

19 months ago[Driver] Only check -nostdinc++ for -stdlib++-isystem
Shoaib Meenai [Thu, 1 Dec 2022 00:45:08 +0000 (16:45 -0800)]
[Driver] Only check -nostdinc++ for -stdlib++-isystem

A drive-by change in 53c98d85a8a609552448043d5512e70313b1eb1b made
-stdlib++-isystem be suppressed by -nostdinc and -nostdlibinc in
addition to -nostdinc++. However, that's contrary to the intent of the
flag. It's common to provide your own C++ headers (e.g. when building
libc++ by itself or as a compiler-rt dependency) but rely on the system
C headers, and having -stdlib++-isystem only look at -nostdinc++ allows
us to customize both the C header path (via -nostdinc or -nostdlibinc)
and the C++ header path (via -stdlib++-isystem) at the toolchain level
but still let users of the toolchain provide their own C++ headers. Add
a comment explaining the rationale to make it clearer.

19 months ago[runtimes] Fix runtimes-test-depends
Shoaib Meenai [Thu, 1 Dec 2022 00:41:31 +0000 (16:41 -0800)]
[runtimes] Fix runtimes-test-depends

The dependency list is stored in a global property, so we need to fetch
it to a variable before using that variable. We also need to add the
list contents as dependencies correctly.

19 months ago[AArch64][SME]: Add streaming-compatible testing files.
Hassnaa Hamdi [Tue, 29 Nov 2022 12:57:01 +0000 (12:57 +0000)]
[AArch64][SME]: Add streaming-compatible testing files.

Testing files:
 - subvector.ll
 - permute-rev.ll
 - permute-zip-uzp-trn.ll
 - vector-shuffle.ll

Reviewed By: david-arm, sdesmalen

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

19 months ago[libc] add unsafe mode to strlen
Michael Jones [Thu, 14 Jul 2022 22:17:18 +0000 (15:17 -0700)]
[libc] add unsafe mode to strlen

The only safe way to implement strlen involves reading the string one
char at a time. It is faster to read in larger blocks, but this leads to
reading beyond the string boundary, which is undefined behavior. This
patch adds an implementation and flag to use this fast but unsafe
version of strlen.

Reviewed By: sivachandra

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

19 months ago[clang-tidy] Suppress google-objc-avoid-throwing-exception in system macros 🫢
Stephane Moore [Wed, 9 Nov 2022 19:07:53 +0000 (11:07 -0800)]
[clang-tidy] Suppress google-objc-avoid-throwing-exception in system macros 🫢

The google-objc-avoid-throwing-exception check enforces the Google
Objective-C Style Guide's prohibition on throwing exceptions in user
code but the check incorrectly triggers findings for code emitted from
system headers. This commit suppresses any findings that do not have
valid locations or are emitted from macros in system headers.

Avoid Throwing Exceptions, Google Objective-C Style Guide:
https://github.com/google/styleguide/blob/gh-pages/objcguide.md#avoid-throwing-exceptions

Test Notes:
Ran clang-tidy lit tests.

Reviewed By: gribozavr2

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

19 months ago[HWASAN] Modified __hwasan::Thread::unique_id_ to be u32 instead of u64.
Kirill Stoimenov [Thu, 1 Dec 2022 00:18:49 +0000 (00:18 +0000)]
[HWASAN] Modified __hwasan::Thread::unique_id_ to be u32 instead of u64.

This is needed for LSAN integration work. LSAN uses context to store thread_id << 32 + stack_id. In order to fit both we would need thread_id to be 32 bit.

Reviewed By: vitalybuka

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

19 months ago[mlir][spirv] Improve vector extract/insert element conversion
Lei Zhang [Thu, 1 Dec 2022 00:35:41 +0000 (00:35 +0000)]
[mlir][spirv] Improve vector extract/insert element conversion

* Fix type conversions around positions--we need to use the
  converted value from the adaptor.
* Convert constant position cases to composite extract/insert.

Reviewed By: kuhar

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

19 months ago[mlir][spirv] Drop experimental LinalgToSPIRV pass
Jakub Kuderski [Thu, 1 Dec 2022 00:25:39 +0000 (19:25 -0500)]
[mlir][spirv] Drop experimental LinalgToSPIRV pass

This experimental pass is unused and obsolete.

Reviewed By: antiagainst

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

19 months ago[mlir][spirv] Check GlobalVariableOp result to be of pointer types
Lei Zhang [Thu, 1 Dec 2022 00:07:19 +0000 (19:07 -0500)]
[mlir][spirv] Check GlobalVariableOp result to be of pointer types

Querying the storage class in the verifier will assume the result
type is of pointer types. We need to check that's true first to
make sure it won't crash.

Reviewed By: kuhar

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

19 months ago[mlgo][nfc] Make `LoggedFeatureSpec` an implementation detail
Mircea Trofin [Wed, 30 Nov 2022 18:03:45 +0000 (10:03 -0800)]
[mlgo][nfc] Make `LoggedFeatureSpec` an implementation detail

It's an artifact very specific to using TFAgents during training, so it
belongs with ModelUnderTrainingRunner.

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

19 months ago[mlir][vector] Reapply remaining cleanups from D139022. NFC.
Jakub Kuderski [Wed, 30 Nov 2022 23:52:54 +0000 (18:52 -0500)]
[mlir][vector] Reapply remaining cleanups from D139022. NFC.

It appears that structured bindings in function templates require extra
`template` keyword sparkled before `.cast<T>()` calls.

19 months ago[FuzzMutate] New InsertPHINode strategy.
Peter Rong [Tue, 29 Nov 2022 02:42:11 +0000 (18:42 -0800)]
[FuzzMutate] New InsertPHINode strategy.

PHI Node can't be modeled like other instructions since its operand
number depends on predecessors. So we have a stand alone strategy for it.

Signed-off-by: Peter Rong <PeterRong96@gmail.com>
Reviewed By: arsenm

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

19 months ago[gn build] Port b95646fe7058
LLVM GN Syncbot [Wed, 30 Nov 2022 22:46:01 +0000 (22:46 +0000)]
[gn build] Port b95646fe7058

19 months ago[mlir][vector] Attempt to please gcc 9. NFC.
Jakub Kuderski [Wed, 30 Nov 2022 22:39:00 +0000 (17:39 -0500)]
[mlir][vector] Attempt to please gcc 9. NFC.

This is a post-commit fix to D139022.

19 months agoRevert "Use-after-return sanitizer binary metadata"
Marco Elver [Wed, 30 Nov 2022 22:35:50 +0000 (23:35 +0100)]
Revert "Use-after-return sanitizer binary metadata"

This reverts commit d3c851d3fc8b69dda70bf5f999c5b39dc314dd73.

Some bots broke:

- https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8796062278266465473/overview
- https://lab.llvm.org/buildbot/#/builders/124/builds/5759/steps/7/logs/stdio

19 months agoReapply "[mlir][vector] Clean up use of `llvm::zip` in `VectorOps.cpp`"
Jakub Kuderski [Wed, 30 Nov 2022 22:27:23 +0000 (17:27 -0500)]
Reapply "[mlir][vector] Clean up use of `llvm::zip` in `VectorOps.cpp`"

This reverts commit 0689edd68717df9218a6a8b2b3897263d36a5cc9.

Reapply D139022 without `enumerate` over `zip` to fix build errors on
gcc 9.4.

19 months agoRevert "[mlir][vector] Clean up use of `llvm::zip` in `VectorOps.cpp`"
Jakub Kuderski [Wed, 30 Nov 2022 22:23:18 +0000 (17:23 -0500)]
Revert "[mlir][vector] Clean up use of `llvm::zip` in `VectorOps.cpp`"

This reverts commit f22a573b2b8afaee88001168eeeb70c77f28a03e.

There's a buildbot that report compilation errors:
https://lab.llvm.org/buildbot/#/builders/199/builds/13507.

19 months ago[NFC][SROA] Ensure that all check lines in SROA tests are autogenerated
Roman Lebedev [Wed, 30 Nov 2022 22:16:21 +0000 (01:16 +0300)]
[NFC][SROA] Ensure that all check lines in SROA tests are autogenerated

19 months ago[mlir][vector] Clean up use of `llvm::zip` in `VectorOps.cpp`
Jakub Kuderski [Wed, 30 Nov 2022 22:11:35 +0000 (17:11 -0500)]
[mlir][vector] Clean up use of `llvm::zip` in `VectorOps.cpp`

- Use `zip_equal` where iteratees are supposted to have equal lenght.
- Use `zip_first` where the first iteratee is supposed to be the
  shortest.
- Use `llvm::enumerate` instead of calculating index manually.
- Use structured bindings to unpack tuples where appropriate.
- Fix a bug in a comparison in `intersectsWhereNonNegative`.

Both `zip_first` (after D138858) and `zip_equal` (introduced in D138865)
assert interatee lengths, which allows us to more precisely convey
whether we want to iterate over the common prefix (`zip`), or expect all
lengths to be the same (`zip_equal`).

Reviewed By: dcaballe, antiagainst

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

19 months ago[analyzer] Test depends on windows as host, not target
Paul Robinson [Wed, 30 Nov 2022 22:11:40 +0000 (14:11 -0800)]
[analyzer] Test depends on windows as host, not target

19 months agoAdd a log message to the IR interpreter.
Adrian Prantl [Wed, 30 Nov 2022 22:06:58 +0000 (14:06 -0800)]
Add a log message to the IR interpreter.

This line existed in our internal branch and seems to be generally
useful, so I'm upstreaming it.

19 months ago[AArch64] Make sure we don't emit packed unwind for .seh_save_any_reg_p
Eli Friedman [Wed, 30 Nov 2022 21:47:35 +0000 (13:47 -0800)]
[AArch64] Make sure we don't emit packed unwind for .seh_save_any_reg_p

Obvious oversight in implementation in D135417.

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

19 months ago[Hexagon] Convert tests to check 'target=hexagon-.*'
Paul Robinson [Wed, 30 Nov 2022 21:32:42 +0000 (13:32 -0800)]
[Hexagon] Convert tests to check 'target=hexagon-.*'

Part of the project to eliminate special handling for triples in lit
expressions.

19 months ago[lldb] Change FindDefinitionTypeForDWARFDeclContext() to take DWARFDIE
Arthur Eubanks [Wed, 23 Nov 2022 22:29:40 +0000 (14:29 -0800)]
[lldb] Change FindDefinitionTypeForDWARFDeclContext() to take DWARFDIE

This simplifies an upcoming patch.

Reviewed By: labath

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

19 months ago[DataFormatter] Fix variant npos with `_LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION...
Jordan Rupprecht [Wed, 30 Nov 2022 21:20:13 +0000 (13:20 -0800)]
[DataFormatter] Fix variant npos with `_LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION` enabled.

This data formatter should print "No Value" if a variant is unset. It does so by checking if `__index` has a value of `-1`, however it does so by interpreting it as a signed int.

By default, `__index` has type `unsigned int`. When `_LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION` is enabled, the type of `__index` is either `unsigned char`, `unsigned short`, or `unsigned int`, depending on how many fields there are -- as small as possible. For example, when `std::variant` has only a few types, the index type is `unsigned char`, and the npos value will be interpreted by LLDB as `255` when it should be `-1`.

This change does not special case the variant optimization; it just reads the type instead of assuming it's `unsigned int`.

Reviewed By: labath

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

19 months ago[asan][aarch64] Don't use 64 bit allocator for Apple ios family
Roy Sundahl [Wed, 30 Nov 2022 17:57:06 +0000 (09:57 -0800)]
[asan][aarch64] Don't use 64 bit allocator for Apple ios family

The recent change (https://reviews.llvm.org/D137136) to unconditionally
choose the 64 bit allocator on aarch64 breaks Apple iOS family of devices
which purposely use a smaller address space than is used with macOS.

rdar://102527313

Reviewed By: thetruestblue, yln

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

19 months ago[test] Fix aggregate initialization incompatible with c++20
Samira Bazuzi [Wed, 30 Nov 2022 20:48:42 +0000 (12:48 -0800)]
[test] Fix aggregate initialization incompatible with c++20

In C++20, types that declare or delete any constructors are no longer aggregates, breaking compilation of many existing uses of aggregate initialization. In this test, provide a one-arg constructor so that `StructWithoutCopyOrMove{1}` still works.

19 months ago[lldb] Use LLDB_ENABLE_SWIG as the canonical CMake variable
Jonas Devlieghere [Wed, 30 Nov 2022 20:42:53 +0000 (12:42 -0800)]
[lldb] Use LLDB_ENABLE_SWIG as the canonical CMake variable

Use LLDB_ENABLE_SWIG instead of SWIG_EXECUTABLE or SWIG_FOUND as the
canonical CMake variable to determine whether we have SWIG available in
LLDB. This is a follow-up to b3c978e850d3.

19 months ago[InstSimplify] (X && Y) ? X : Y --> Y
Sanjay Patel [Wed, 30 Nov 2022 20:31:55 +0000 (15:31 -0500)]
[InstSimplify] (X && Y) ? X : Y --> Y

Similar to the recent fold that was added for 'or' in D138815:
https://alive2.llvm.org/ce/z/PBapTJ

19 months ago[InstSimplify] add tests for select with common 'and' ops; NFC
Sanjay Patel [Wed, 30 Nov 2022 20:28:11 +0000 (15:28 -0500)]
[InstSimplify] add tests for select with common 'and' ops; NFC

19 months ago[clang][TargetInfo] Use LangAS for getPointer{Width,Align}()
Alex Richardson [Fri, 18 Nov 2022 12:14:00 +0000 (12:14 +0000)]
[clang][TargetInfo] Use LangAS for getPointer{Width,Align}()

Mixing LLVM and Clang address spaces can result in subtle bugs, and there
is no need for this hook to use the LLVM IR level address spaces.
Most of this change is just replacing zero with LangAS::Default,
but it also allows us to remove a few calls to getTargetAddressSpace().

This also removes a stale comment+workaround in
CGDebugInfo::CreatePointerLikeType(): ASTContext::getTypeSize() does
return the expected size for ReferenceType (and handles address spaces).

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

19 months ago[Windows] Canonicalize on 'target=.*-windows'
Paul Robinson [Wed, 30 Nov 2022 20:07:27 +0000 (12:07 -0800)]
[Windows] Canonicalize on 'target=.*-windows'

Part of the project to eliminate special handling for triples in lit
expressions.

19 months ago[PS4/PS5] Convert tests to check 'target=<triple>'
Paul Robinson [Wed, 30 Nov 2022 20:02:06 +0000 (12:02 -0800)]
[PS4/PS5] Convert tests to check 'target=<triple>'

Part of the project to eliminate special handling for triples in lit
expressions.

19 months ago[InstCombine] canonicalize trunc + insert as bitcast + shuffle, part 1 (2nd try)
Sanjay Patel [Wed, 30 Nov 2022 19:48:32 +0000 (14:48 -0500)]
[InstCombine] canonicalize trunc + insert as bitcast + shuffle, part 1 (2nd try)

The first attempt was reverted because a clang test changed
unexpectedly - the file is already marked with a FIXME, so
I just updated it this time to pass.

Original commit message:
This is the main patch for converting a truncated scalar that is
inserted into a vector to bitcast+shuffle. We could go either way
on patterns like this, but this direction will allow collapsing a
pair of these sequences on the motivating example from issue

The patch is split into 3 parts to make it easier to see the
progression of tests diffs. We allow inserting/shuffling into a
different size vector for flexibility, so there are several test
variations. The length-changing is handled by shortening/padding
the shuffle mask with undef elements.

In part 1, handle the basic pattern:
inselt undef, (trunc T), IndexC --> shuffle (bitcast T), IdentityMask

Proof for the endian-dependency behaving as expected:
https://alive2.llvm.org/ce/z/BsA7yC

The TODO items for handling shifts and insert into an arbitrary base
vector value are implemented as follow-ups.

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

19 months ago[flang] Use proper attributes for runtime calls with 'i1' arguments/returns.
Slava Zakharin [Fri, 18 Nov 2022 20:08:02 +0000 (12:08 -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/D137050

19 months ago[mlir][sparse][vectorization] implement "index" vectorization
Aart Bik [Tue, 29 Nov 2022 23:02:38 +0000 (15:02 -0800)]
[mlir][sparse][vectorization] implement "index" vectorization

This adds the capability to vectorize computations like a[i] = i.
This also generalizes the supported unary and binary ops and
adds a test for each to ensure actual SIMD code can result.

Reviewed By: bixia

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

19 months ago[compiler-rt] Fix check-profile dependencies
Shoaib Meenai [Wed, 30 Nov 2022 01:32:06 +0000 (17:32 -0800)]
[compiler-rt] Fix check-profile dependencies

It relies on InstrProfData.inc being in the compiler resource directory.

Reviewed By: ellis

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

19 months ago[runtimes] Add check-profile dependencies to runtimes
Shoaib Meenai [Wed, 30 Nov 2022 01:43:37 +0000 (17:43 -0800)]
[runtimes] Add check-profile dependencies to runtimes

check-profile needs llvm-cov and llvm-profdata.

Reviewed By: phosek

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

19 months ago[runtimes] Create check- targets for LLVM_RUNTIME_DISTRIBUTION_COMPONENTS
Shoaib Meenai [Wed, 30 Nov 2022 01:41:57 +0000 (17:41 -0800)]
[runtimes] Create check- targets for LLVM_RUNTIME_DISTRIBUTION_COMPONENTS

The sub-component check targets won't be automatically created until the
runtime configurations have run (and the main LLVM configure has rerun
afterwards). Work around this by creating check- targets for components
in LLVM_RUNTIME_DISTRIBUTION_COMPONENTS as well (and making sure they
get the proper test dependencies).

Reviewed By: phosek

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

19 months ago[runtimes] Support sub-components in LLVM_RUNTIME_DISTRIBUTION_COMPONENTS
Shoaib Meenai [Wed, 30 Nov 2022 01:38:12 +0000 (17:38 -0800)]
[runtimes] Support sub-components in LLVM_RUNTIME_DISTRIBUTION_COMPONENTS

Right now, sub-components are only accounted for when the runtime has
been configured and the main LLVM configure is rerun after that. We can
make use of LLVM_RUNTIME_DISTRIBUTION_COMPONENTS to make sub-component
targets available from the start, but that currently clashes with the
sub-component target generation once they are picked up. Make sure we
don't create duplicate targets; an analogous check already exists in
runtime_default_target.

Reviewed By: phosek

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

19 months ago[runtimes] Name stripped install targets consistently
Shoaib Meenai [Wed, 30 Nov 2022 01:34:23 +0000 (17:34 -0800)]
[runtimes] Name stripped install targets consistently

We were previously naming sub-component stripped install targets as
`install-${component}-stripped-${triple}`, whereas everywhere else names
them `install-${component}-${triple}-stripped`. This inconsistency would
cause issues when LLVM_RUNTIME_DISTRIBUTION_COMPONENTS contained a
sub-component (which I'm addding support for next).

Reviewed By: phosek, #libc, #libc_abi, ldionne

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

19 months agoRevert "[InstCombine] canonicalize trunc + insert as bitcast + shuffle, part 1"
Sanjay Patel [Wed, 30 Nov 2022 19:10:02 +0000 (14:10 -0500)]
Revert "[InstCombine] canonicalize trunc + insert as bitcast + shuffle, part 1"

This reverts commit a4c466766db77cd1fb42d7f98f32bb87a3d38829.
This broke clang tests that are wrongly dependent on the optimizer.

19 months ago[RISCV][Codegen] Account for LMUL in Vector floating-point instructions
Michael Maitland [Thu, 3 Nov 2022 17:27:32 +0000 (10:27 -0700)]
[RISCV][Codegen] Account for LMUL in Vector floating-point instructions

It is likley that subtargets act differently for vector floating-point instructions based on the LMUL.
This patch creates seperate SchedRead, SchedWrite, WriteRes, ReadAdvance for each relevant LMUL.

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

19 months ago[RISCV] Inline RISCVFrameLowering::adjustReg out of existance [nfc]
Philip Reames [Wed, 30 Nov 2022 19:02:19 +0000 (11:02 -0800)]
[RISCV] Inline RISCVFrameLowering::adjustReg out of existance [nfc]

This was requested by a reviewer in D138926.

19 months ago[Nomination] Adding Mozilla representative to security group
serge-sans-paille [Tue, 29 Nov 2022 06:45:55 +0000 (07:45 +0100)]
[Nomination] Adding Mozilla representative to security group

Hey folks,

I recently moved from Redhat to Mozilla, still working on compiler /
build issues. I'd like to both

- resign as a member of Redhat

- apply as a member of Mozilla

Mozilla's mission makes it very sensible to compiler security flags, so
it makes sense (at least to me) to have it represented in the group.

Although I've been a discrete member of group, I'm still actively
dealing with some security-related patches [0] and blogging about it [1,2]

[0] https://reviews.llvm.org/D137707
[1] https://developers.redhat.com/articles/2022/06/02/use-compiler-flags-stack-protection-gcc-and-clang
[2] https://developers.redhat.com/articles/2022/09/29/benefits-limitations-flexible-array-members

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

19 months ago[FuncSpec] Invalidate analyses when deleting a fully specialised function
Momchil Velikov [Wed, 30 Nov 2022 18:28:31 +0000 (18:28 +0000)]
[FuncSpec] Invalidate analyses when deleting a fully specialised function

Deleting a fully specialised function left dangling pointers in
`FunctionAnalysisManager`, which causes an internal compiler error
when the function's storage was reused.

Fixes bug #58759.

Reviewed By: ChuanqiXu

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

Change-Id: Ifed378c748af35e8fe7dcbdddb0f41b8777cbe87

19 months ago[RISCV] Adjust code to fallthrough to a single adjustReg callsite [nfc]
Philip Reames [Wed, 30 Nov 2022 18:44:51 +0000 (10:44 -0800)]
[RISCV] Adjust code to fallthrough to a single adjustReg callsite [nfc]

Note that we have to now pass alignment to that callsite because the wrapper previously did that for us for fixed offsets.

19 months ago[RISCV] Teach getRegAllocationHints about compressible SRAI/SRLI.
Craig Topper [Wed, 30 Nov 2022 18:28:55 +0000 (10:28 -0800)]
[RISCV] Teach getRegAllocationHints about compressible SRAI/SRLI.

Similar to previous patches for ADDI/ADDIW/SLLI/ADD, but restricted
to only cases where the register is x8-x15(GPRC reg class).

I've restricted it so that we can be precise about whether the
resulting instruction would be compressible. Changing the register
allocation may make some other instruction not compressible so we
should try to be accurate.

Reviewed By: asb

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

19 months agoAdd async_funcs_only option to AsyncToAsyncRuntime pass
yijiagu [Wed, 30 Nov 2022 18:14:56 +0000 (10:14 -0800)]
Add async_funcs_only option to AsyncToAsyncRuntime pass

This change adds async_funcs_only option to AsyncToAsyncRuntimePass. The goal is to convert async functions to regular functions in early stages of compilation pipeline.

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

19 months ago[InstCombine] canonicalize trunc + insert as bitcast + shuffle, part 1
Sanjay Patel [Wed, 30 Nov 2022 18:04:46 +0000 (13:04 -0500)]
[InstCombine] canonicalize trunc + insert as bitcast + shuffle, part 1

This is the main patch for converting a truncated scalar that is
inserted into a vector to bitcast+shuffle. We could go either way
on patterns like this, but this direction will allow collapsing a
pair of these sequences on the motivating example from issue

The patch is split into 3 parts to make it easier to see the
progression of tests diffs. We allow inserting/shuffling into a
different size vector for flexibility, so there are several test
variations. The length-changing is handled by shortening/padding
the shuffle mask with undef elements.

In part 1, handle the basic pattern:
inselt undef, (trunc T), IndexC --> shuffle (bitcast T), IdentityMask

Proof for the endian-dependency behaving as expected:
https://alive2.llvm.org/ce/z/BsA7yC

The TODO items for handling shifts and insert into an arbitrary base
vector value are implemented as follow-ups.

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

19 months agomsan: update tests for new memory mappings on aarch64
Thurston Dang [Wed, 30 Nov 2022 18:18:28 +0000 (18:18 +0000)]
msan: update tests for new memory mappings on aarch64

D137666 changed the memory mappings for msan on aarch64.
This patch updates two more tests to match the new
mappings.

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

19 months agoFix bazel build for https://reviews.llvm.org/D138980
Sterling Augustine [Wed, 30 Nov 2022 18:16:34 +0000 (10:16 -0800)]
Fix bazel build for https://reviews.llvm.org/D138980

19 months ago[RISCV] Merge two versions of adjustReg on TRI [nfc]
Philip Reames [Wed, 30 Nov 2022 18:09:46 +0000 (10:09 -0800)]
[RISCV] Merge two versions of adjustReg on TRI [nfc]

After ac1ec9e, the version with the StackOffset param has a strict superset of behavior.  As a result, we can switch callers to use it, and then inline the other version into the now-single caller.

19 months ago[AMDGPU] Use s_cmp instead of s_cmpk
Jay Foad [Wed, 30 Nov 2022 10:39:53 +0000 (10:39 +0000)]
[AMDGPU] Use s_cmp instead of s_cmpk

Don't bother pre-shrinking "s_cmp_lg_u32 reg, 0" to s_cmpk_lg_u32
because 0 is already an inline constant so the s_cmpk form is no
smaller.

This is just for consistency with the surrounding code and to simplify a
downstream patch.

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

19 months ago[flang] Delegate pointer association to class(*) pointer to the runtime
Valentin Clement [Wed, 30 Nov 2022 17:57:28 +0000 (18:57 +0100)]
[flang] Delegate pointer association to class(*) pointer to the runtime

Pointer association with an unlimited polymorphic pointer on the lhs
requires more than just updating the base_addr. Delegate the association to
the runtime function `PointerAssociation`.

Reviewed By: PeteSteinfeld

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

19 months ago[RISCV] Reuse and generalize adjustReg from another spot in frame lowering [nfc]
Philip Reames [Wed, 30 Nov 2022 17:38:21 +0000 (09:38 -0800)]
[RISCV] Reuse and generalize adjustReg from another spot in frame lowering [nfc]

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

19 months agomsan: update shadow constant in strlen_of_shadow test
Thurston Dang [Wed, 30 Nov 2022 17:25:30 +0000 (17:25 +0000)]
msan: update shadow constant in strlen_of_shadow test

strlen_of_shadow hardcodes the mem-to-shadow
constant. That constant was changed in D137666;
this CL updates the test accordingly.
(Other tests will be updated separately.)

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

19 months ago[mlir][spirv] Allow controlling subgroup size
Lei Zhang [Wed, 30 Nov 2022 17:33:38 +0000 (12:33 -0500)]
[mlir][spirv] Allow controlling subgroup size

This commit extends the `ResourceLimitsAttr` to support specifying
a minimal and maximal subgroup size, and extends `EntryPointABIAttr`
to support specifying the requested subgroup size. This is possible
now in Vulkan with the VK_EXT_subgroup_size_control extension.
For OpenCL it's possible to use the `SubgroupSize` execution mode
directly.

Reviewed By: ThomasRaoux

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

19 months ago[RISCV] Share code for fixed offsets adjustRegs (thus materializing fewer constants)
Philip Reames [Wed, 30 Nov 2022 15:22:52 +0000 (07:22 -0800)]
[RISCV] Share code for fixed offsets adjustRegs (thus materializing fewer constants)

This reuses the existing optimized implementation of adjustReg, and commons up code. This has the effect of enabling two code changes for the new caller. First, we enable the "split andi" lowering (with no alignment requirement), and second we use a sub with smaller constant in register instead of a add with negative constant in register.

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

19 months ago[include-cleaner] Move RecordedPP::RecordedIncludes -> Includes in Types.h. NFC
Sam McCall [Wed, 30 Nov 2022 15:33:50 +0000 (16:33 +0100)]
[include-cleaner] Move RecordedPP::RecordedIncludes -> Includes in Types.h. NFC

Requiring everything that wants to match Includes to depend on Record is weird.
This isn't lightweight enough that it feels perfect in Types, could be its own
header instead. But pragmatically it doesn't add bad deps, and is widely used.

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

19 months ago[include-cleaner] Record whether includes are spelled with <angle> quotes
Sam McCall [Wed, 30 Nov 2022 16:00:31 +0000 (17:00 +0100)]
[include-cleaner] Record whether includes are spelled with <angle> quotes

This is needed to accurately remove headers with tooling::IncludeHeaders in the
rare cases where <foo> and "foo" resolve to something different.

This is also nice to have in HTML report and command-line -print=changes output.

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

19 months ago[NFC] Add missing period
eopXD [Wed, 30 Nov 2022 17:07:15 +0000 (09:07 -0800)]
[NFC] Add missing period

19 months agoRecommit "[VPlan] Add VPDerivedIVRecipe, use for VPScalarIVStepsRecipe."
Florian Hahn [Wed, 30 Nov 2022 17:04:19 +0000 (17:04 +0000)]
Recommit "[VPlan] Add VPDerivedIVRecipe, use for VPScalarIVStepsRecipe."

This reverts commit bf15f1e489aa2f1ac13268c9081a992a8963eb5b.

The updated version fixes a crash by checking the induction kind instead
of the opcode; for integer inductions, the step is always added, but the
opcode might not be set.

19 months ago[Threading] Ensure Tests Reflect Disabled Threads
Archibald Elliott [Wed, 30 Nov 2022 15:18:14 +0000 (15:18 +0000)]
[Threading] Ensure Tests Reflect Disabled Threads

D137836 changed what llvm::get_physical_cores returns when threads are
disabled, to bring it inline with the other parts of Threading. It now
returns the value for "unknown" when threading is disabled.

This commit updates the tests (which are failing on some platforms), to
also reflect this change.

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

19 months ago[mlir] Fix a warning
Kazu Hirata [Wed, 30 Nov 2022 16:57:07 +0000 (08:57 -0800)]
[mlir] Fix a warning

This patch fixes:

  mlir/lib/Dialect/Vector/IR/VectorOps.cpp:1751:13: error: unused
  function 'allBitsSet' [-Werror,-Wunused-function]

19 months ago[Basic] Fix a warning
Kazu Hirata [Wed, 30 Nov 2022 16:57:05 +0000 (08:57 -0800)]
[Basic] Fix a warning

This patch fixes:

  clang/lib/Basic/SourceManager.cpp:1292:19: error: comparison of
  integers of different signs: 'long' and 'unsigned long'
  [-Werror,-Wsign-compare]

19 months ago[LV] Add test showing crash with 0fa666ecedc3.
Florian Hahn [Wed, 30 Nov 2022 16:51:24 +0000 (16:51 +0000)]
[LV] Add test showing crash with 0fa666ecedc3.

19 months ago[RISCV] Add macro to imply compiler availability on RISC-V Vector intrinsics version
eopXD [Tue, 29 Nov 2022 16:37:51 +0000 (08:37 -0800)]
[RISCV] Add macro to imply compiler availability on RISC-V Vector intrinsics version

According to version_macro.adoc under rvv-intrinsic-doc, the compiler
should have a macro to imply such availability.

Link: https://github.com/riscv-non-isa/rvv-intrinsic-doc/blob/master/version_macro.adoc
Reviewed By: kito-cheng, asb

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

19 months ago[MLIR][Transform] Consolidate the transform ops of get_parent_for and loop unroll...
Amy Wang [Wed, 30 Nov 2022 15:59:13 +0000 (10:59 -0500)]
[MLIR][Transform] Consolidate the transform ops of get_parent_for and loop unroll from affine and scf dialects.

This patch consolidates the two transform ops from the affine dialect
and the scf dialect to avoid code duplication.

This is to address the review comments from
https://reviews.llvm.org/D137997.

The transform ops directory / file structure for the affine dialect is
kept for the purpose of forth-coming transform ops
for affine, but get_parent_for and unroll are removed.

Reviewed By: nicolasvasilache

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

19 months ago[mlir][vector] Use zip_equal instead of size assertions. NFC.
Jakub Kuderski [Wed, 30 Nov 2022 16:06:17 +0000 (11:06 -0500)]
[mlir][vector] Use zip_equal instead of size assertions. NFC.

19 months ago[libc][math] Improve the performance of subtraction for UInt<>.
Tue Ly [Tue, 22 Nov 2022 16:33:40 +0000 (11:33 -0500)]
[libc][math] Improve the performance of subtraction for UInt<>.

Use built-in sub_with_borrow to improve the performance of subtraction
for UInt<>.

Microbenchmark: https://quick-bench.com/q/UEg6Z6VK4PP2yLBtTi9C0cL9xpY

Reviewed By: sivachandra

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

19 months ago[libc][docs] Fix code block not being emitted
Joseph Huber [Wed, 30 Nov 2022 15:33:06 +0000 (09:33 -0600)]
[libc][docs] Fix code block not being emitted

19 months ago[AIX][LTO] Enabling Context Sensitive PGO Options
Qiongsi Wu [Wed, 30 Nov 2022 14:57:55 +0000 (09:57 -0500)]
[AIX][LTO] Enabling Context Sensitive PGO Options

This patch enables context sensitive PGO (CSPGO) for LTO on AIX. Two parts are involved:

  # Frontend logic is added so libLTO can understand the CSPGO related options.
  # Two options are added to the backend so that the LTOCodeGenerator can understand the CSPGO related options and make use of them.

Reviewed By: MaskRay

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

19 months ago[LV] Update test to use opaque pointers.
Florian Hahn [Wed, 30 Nov 2022 15:21:52 +0000 (15:21 +0000)]
[LV] Update test to use opaque pointers.

19 months ago[RISCV][TTI] Account for constant materialization cost when costing arithmetic operations
Philip Reames [Wed, 30 Nov 2022 15:12:53 +0000 (07:12 -0800)]
[RISCV][TTI] Account for constant materialization cost when costing arithmetic operations

At the IR level, we generally assume that constants are free to materialize. However, for RISCV due to some quirks of the ISA, materializing arbitrary constants can be rather expensive. We frequently fallback to constant pool loads.

We've been slowly moving in the direction of modeling the cost of the remat as part of the instruction cost. This has the effect of disincentivizing vectorization - mostly SLP - when we'd have to materialize an expensive constant.

We need better modeling of which constants are expensive and not, but the moment let's be consistent with how we model arithmetic and memory instructions. The difference between the two is that arithmetic can sometimes fold a splat operation which stores can not.

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

19 months ago[Sanitizers] Fix test that never ran anywhere
Paul Robinson [Wed, 30 Nov 2022 15:19:39 +0000 (07:19 -0800)]
[Sanitizers] Fix test that never ran anywhere

Incorrect REQUIRES clause. Also fixed the incorrect 'opt' line
and removed a redundant -mtriple option.