platform/upstream/llvm.git
14 months ago[mlir] Fix unqualified call to 'std::move' in TransformOps.cpp
Jie Fu [Fri, 2 Jun 2023 14:06:46 +0000 (22:06 +0800)]
[mlir] Fix unqualified call to 'std::move' in TransformOps.cpp

/data/llvm-project/mlir/lib/Dialect/Transform/IR/TransformOps.cpp:230:35: error: unqualified call to 'std::move' [-Werror,-Wunqualified-std-cast-call]
  patterns.try_emplace(attr, [f = move(fn)](RewritePatternSet &patternSet) {
                                  ^
                                  std::
1 error generated.

14 months ago[mlir][vector][transform] Register vector dialect patterns
Matthias Springer [Fri, 2 Jun 2023 13:39:04 +0000 (15:39 +0200)]
[mlir][vector][transform] Register vector dialect patterns

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

14 months agoFix "[compiler-rt] Avoid memintrinsic calls inserted by the compiler"
Marco Elver [Fri, 2 Jun 2023 13:47:21 +0000 (15:47 +0200)]
Fix "[compiler-rt] Avoid memintrinsic calls inserted by the compiler"

Add interface attribute to __sanitizer_internal_mem* declarations as
well, as otherwise some compilers (MSVC) will complain.

14 months ago[GlobalIsel][X86] Add G_ADD/G_SUB i8/i16 and promotion legalization tests
Simon Pilgrim [Fri, 2 Jun 2023 13:41:15 +0000 (14:41 +0100)]
[GlobalIsel][X86] Add G_ADD/G_SUB i8/i16 and promotion legalization tests

Add i8/i16/i24/i42 ADD/SUB test coverage

14 months ago[GlobalIsel][X86] Regenerate G_ADD/G_SUB vector legalization tests
Simon Pilgrim [Fri, 2 Jun 2023 13:40:03 +0000 (14:40 +0100)]
[GlobalIsel][X86] Regenerate G_ADD/G_SUB vector legalization tests

14 months ago[mlir][tensor] Implement getBufferType for ReshapeOp.
Ingo Müller [Fri, 26 May 2023 09:43:16 +0000 (09:43 +0000)]
[mlir][tensor] Implement getBufferType for ReshapeOp.

This function should be implemented for ops that work in one-shot
bufferization.

Reviewed By: springerm

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

14 months ago[compiler-rt] Avoid memintrinsic calls inserted by the compiler
Marco Elver [Tue, 30 May 2023 09:59:22 +0000 (11:59 +0200)]
[compiler-rt] Avoid memintrinsic calls inserted by the compiler

D135716 introduced -ftrivial-auto-var-init=pattern where supported.
Unfortunately this introduces unwanted memset() for large stack arrays,
as shown by the new tests added for asan and msan (tsan already had this
test).

In general, the problem of compiler-inserted memintrinsic calls
(memset/memcpy/memmove) is not new to compiler-rt, and has been a
problem before.

To avoid introducing unwanted memintrinsic calls, we redefine
memintrinsics as __sanitizer_internal_mem* at the assembly level for
most source files automatically (where sanitizer_common_internal_defs.h
is included).

In few cases, redefining a symbol in this way causes issues for
interceptors, namely the memintrinsic interceptor themselves. For such
source files we have to selectively disable the redefinition.

Other alternatives have been considered, but simply do not work well in
the context of compiler-rt:

1. Linker --wrap:  this does not work because --wrap only
   applies to the final link, and would not apply when building
   sanitizer static libraries.

2. Changing references to memset() via objcopy:  this may work,
   but due to the complexities of the build system, introducing
   such a post-processing step for the right object files (in
   particular object files defining memset cannot be touched)
   seems infeasible.

The chosen solution works well (as shown by the tests). Other libraries
have chosen the same solution where nothing else works (see e.g. glibc's
"symbol-hacks.h").

v3:
- Don't use ALIAS() to alias internal_mem*() functions to
  __sanitizer_internal_mem*() functions, but just define them as
  ALWAYS_INLINE functions instead. This will work on darwin and windows.

v2:
- Fix ubsan_minimal build where compiler decides to insert
  memset/memcpy: ubsan_minimal has work without RTSanitizerCommonLibc,
  therefore do not redefine the builtins.
- Fix definition of internal_mem* functions with compilers that want the
  aliased function to already be defined before.
- Fix definition of __sanitizer_internal_mem* functions with compilers
  more pedantic about attribute placement around extern "C".

Reviewed By: vitalybuka, dvyukov

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

14 months ago[mlir][tensor][transform] Register tensor dialect patterns
Matthias Springer [Fri, 2 Jun 2023 13:27:55 +0000 (15:27 +0200)]
[mlir][tensor][transform] Register tensor dialect patterns

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

14 months ago[GlobalIsel][X86] Move G_BSWAP/G_CTPOP/G_CTLZ legalization before legacy handling
Simon Pilgrim [Fri, 2 Jun 2023 13:05:06 +0000 (14:05 +0100)]
[GlobalIsel][X86] Move G_BSWAP/G_CTPOP/G_CTLZ legalization before legacy handling

Also merge 32-bit/64-bit handling of G_CTPOP/G_CTLZ using legalIf()

14 months ago[mlir][transform] Add ApplyPatternsOp and PatternRegistry
Matthias Springer [Fri, 2 Jun 2023 12:57:22 +0000 (14:57 +0200)]
[mlir][transform] Add ApplyPatternsOp and PatternRegistry

Add a new transform op that applies patterns to a targeted payload op. Patterns can be registered by transform dialect extensions in a pattern registry.

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

14 months ago[mlir][transform] Utilize op interface instead of tensor::TrackingListener
Matthias Springer [Fri, 2 Jun 2023 12:42:56 +0000 (14:42 +0200)]
[mlir][transform] Utilize op interface instead of tensor::TrackingListener

Add a new interface `FindPayloadReplacementOpInterface` to specify ops that should be skipped when looking for payload replacement ops. Such ops are typically metadata-only ops.

With this change, we no longer need to maintain a custom TrackingListener in the tensor dialect.

Note: `CastOpInterface` by itself is not sufficient. Some metadata-only ops such as "tensor.reshape" are not casts, and it would be incorrect for them to implement the `CastOpInterface`.

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

14 months ago[Clang][RISCV] Add test coverage for `_mu` overloaded variant for the load intrinsics...
eopXD [Fri, 2 Jun 2023 12:35:56 +0000 (05:35 -0700)]
[Clang][RISCV] Add test coverage for `_mu` overloaded variant for the load intrinsics. NFC

Maps to amendment in under specification:
riscv-non-isa/rvv-intrinsic-doc#233

Signed-off-by: eop Chen <eop.chen@sifive.com>
14 months ago[ValueTracking] Use correct struct kind for forward declaration (NFC)
Nikita Popov [Fri, 2 Jun 2023 12:33:54 +0000 (14:33 +0200)]
[ValueTracking] Use correct struct kind for forward declaration (NFC)

14 months agoSimpleLoopUnswitch: Add missing test coverage for divergent target check
Matt Arsenault [Fri, 2 Jun 2023 10:18:21 +0000 (06:18 -0400)]
SimpleLoopUnswitch: Add missing test coverage for divergent target check

No tests failed when I removed the hasBranchDivergence check, so
add one.

14 months ago[InstCombine] Handle assumes in multi-use demanded bits simplification
Nikita Popov [Fri, 2 Jun 2023 10:52:27 +0000 (12:52 +0200)]
[InstCombine] Handle assumes in multi-use demanded bits simplification

This fixes the largest remaining discrepancy between results of
computeKnownBits() and SimplifyDemandedBits(). We only care about
the multi-use case here, because the assume necessarily introduces
an extra use.

14 months ago[SVE ACLE] Extend IR combines for fmul, fsub, fadd to cover _u variants
Jolanta Jensen [Wed, 17 May 2023 09:21:40 +0000 (09:21 +0000)]
[SVE ACLE] Extend IR combines for fmul, fsub, fadd to cover _u variants

This patch extends existing IR combines for: fmul, fsub and fadd,
relying on all active predicate to also apply to their equivalent
undef (_u) intrinsics.

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

14 months ago[clangd] Use FileManager for getCanonicalPath, NFC
Haojian Wu [Fri, 2 Jun 2023 10:12:54 +0000 (12:12 +0200)]
[clangd] Use FileManager for getCanonicalPath, NFC

get rid of the SourceManager dependency -- getCanonicalPath doesn't use
other SourceManager fields.

14 months ago[AArch64] Don't use tbl lowering if ZExt can be folded into user.
Florian Hahn [Fri, 2 Jun 2023 10:53:03 +0000 (11:53 +0100)]
[AArch64] Don't use tbl lowering if ZExt can be folded into user.

If the ZExt can be lowered to a single ZExt to the next power-of-2 and
the remaining ZExt folded into the user, don't use tbl lowering.

Fixes #62620.

Reviewed By: efriedma

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

14 months ago[GlobalIsel][X86] Update legalization of G_ADD/G_SUB
Simon Pilgrim [Fri, 2 Jun 2023 10:33:51 +0000 (11:33 +0100)]
[GlobalIsel][X86] Update legalization of G_ADD/G_SUB

Replace the legacy legalizers for G_ADD/G_SUB with a pattern that should work for the full mixture of scalar/vector types we need to support for most opcodes.

If we can decide on this as a suitable pattern we can reuse it for the other op types, but G_ADD/G_SUB are the only ones that have decent legalizer test coverage at this stage.

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

14 months ago[MLIR][Bufferization] Improve documentation of introduction and `summary`s
rikhuijzer [Fri, 2 Jun 2023 09:46:46 +0000 (11:46 +0200)]
[MLIR][Bufferization] Improve documentation of introduction and `summary`s

This patch suggests to add a sentence in the introduction which clarifies
the aim of the dialect in one sentence. I hope that I understood it correctly.

For the `summary` fields, I have scrolled through the Bufferization page
(<https://mlir.llvm.org/docs/Bufferization>) and added missing summaries
or standardized existing ones to make the summaries easier to read.

Reviewed By: springerm

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

14 months ago[GlobalIsel][X86] Legalize G_BSWAP III
Thorsten Schütt [Fri, 2 Jun 2023 09:18:38 +0000 (11:18 +0200)]
[GlobalIsel][X86] Legalize G_BSWAP III

Reviewed By: RKSimon

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

14 months ago[ValueTracking] Replace Query with SimplifyQuery (NFC)
Nikita Popov [Fri, 2 Jun 2023 09:05:55 +0000 (11:05 +0200)]
[ValueTracking] Replace Query with SimplifyQuery (NFC)

These implement essentially the same thing, so normalize
ValueTracking to use SimplifyQuery. In the future we can directly
expose the SimplifyQuery-based APIs.

14 months ago[LoongArch] Use Subtarget consistently during LoongArchISelLowering init. NFC
Weining Lu [Fri, 2 Jun 2023 08:20:32 +0000 (16:20 +0800)]
[LoongArch] Use Subtarget consistently during LoongArchISelLowering init. NFC

14 months ago[AArch64] Add additional zext/mull tests.
Florian Hahn [Fri, 2 Jun 2023 08:16:30 +0000 (09:16 +0100)]
[AArch64] Add additional zext/mull tests.

Extra test coverage for D150482.

14 months ago[MI] Don't use std::function for all_uses/all_defs iterators (NFC)
Nikita Popov [Fri, 2 Jun 2023 07:17:48 +0000 (09:17 +0200)]
[MI] Don't use std::function for all_uses/all_defs iterators (NFC)

This mitigates the compile-time regression from D151424. The use
of std::function is not necessary here, as we're passing in a
static function.

14 months agoFix isKnownNeverInfOrNaN() call in AMDGPU after ORE removal 97b5cc214aee48e30391bfcd2...
Haojian Wu [Fri, 2 Jun 2023 07:32:46 +0000 (09:32 +0200)]
Fix isKnownNeverInfOrNaN() call in AMDGPU after ORE removal 97b5cc214aee48e30391bfcd2cde4252163d7406

14 months ago[X86] Add schedule module for SapphireRapids
Haohai Wen [Fri, 2 Jun 2023 07:10:24 +0000 (15:10 +0800)]
[X86] Add schedule module for SapphireRapids

The X86SchedSapphireRapids.td file is automatically generated by
schedtool (D130897). Most of instruction's scheduling information
is from SapphireRapids tpt/lat data provided by intel doc. Some data
is from measured ADL-P data in uops.info. The rest instruction's
scheduling information is from skylake server schedule model in order
to get a relative complete model.

Reviewed By: LuoYuanke

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

14 months ago[SimplifyLibCalls] Fix isKnownNeverInfinity() call after ORE removal
Nikita Popov [Fri, 2 Jun 2023 07:20:57 +0000 (09:20 +0200)]
[SimplifyLibCalls] Fix isKnownNeverInfinity() call after ORE removal

Missed this in 97b5cc214aee48e30391bfcd2cde4252163d7406.

14 months ago[ValueTracking] Remove ORE argument (NFC-ish)
Nikita Popov [Fri, 26 May 2023 13:14:31 +0000 (15:14 +0200)]
[ValueTracking] Remove ORE argument (NFC-ish)

The ORE argument threaded through ValueTracking is used only in a
single, untested place. It is also essentially never passed: The
only places that do so have been added very recently as part of the
KnownFPClass migration, which is vanishingly unlikely to hit this
code path. Remove this effectively dead argument.

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

14 months ago[cuda, NVPTX] Signed char and (unsigned)long builtins of ldg and ldu
Jakub Chlanda [Thu, 1 Jun 2023 10:41:06 +0000 (12:41 +0200)]
[cuda, NVPTX] Signed char and (unsigned)long builtins of ldg and ldu

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

14 months agoRevert "[clang][Diagnostics] Split source ranges into line ranges before..."
Timm Bäder [Fri, 2 Jun 2023 07:02:04 +0000 (09:02 +0200)]
Revert "[clang][Diagnostics] Split source ranges into line ranges before..."

This reverts commit fc1262bd58ac54ad0a0bfa9750254b81c742bbb5.

This causes build bot failures because of a parser test case:
https://lab.llvm.org/buildbot/#/builders/139/builds/41961

14 months ago[clang][Diagnostics] Split source ranges into line ranges before...
Timm Bäder [Tue, 23 May 2023 14:33:59 +0000 (16:33 +0200)]
[clang][Diagnostics] Split source ranges into line ranges before...

... emitting them.

This makes later code easier to understand, since we emit the code
snippets line by line anyway.
It also fixes the weird underlinig of multi-line source ranges.

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

14 months ago[mlir][IR][NFC] Move CastOpInterface helpers to mlir/Interfaces
Matthias Springer [Fri, 2 Jun 2023 06:32:01 +0000 (08:32 +0200)]
[mlir][IR][NFC] Move CastOpInterface helpers to mlir/Interfaces

These helpers should not be part of the IR build unit.

The interface is now implemented on `builtin.unrealized_conversion_cast` with an external model.

Also rename the CastOpInterfaces Bazel target name to CastInterfaces to be consistent with the CMake target name.

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

14 months ago[clang][Interp][NFC] Print Function name in unreachable type failures
Timm Bäder [Fri, 19 May 2023 07:30:24 +0000 (09:30 +0200)]
[clang][Interp][NFC] Print Function name in unreachable type failures

and pass Record* pointers around as const.

14 months ago[clang][Interp][NFC] Add FunctionPointer.h header comment
Timm Bäder [Fri, 19 May 2023 06:57:52 +0000 (08:57 +0200)]
[clang][Interp][NFC] Add FunctionPointer.h header comment

14 months ago[RISCV] Modify a tablegen multiclass for a future patch. NFC
Craig Topper [Fri, 2 Jun 2023 05:38:00 +0000 (22:38 -0700)]
[RISCV] Modify a tablegen multiclass for a future patch. NFC

Split the vop_type parameter to VPatBinaryVL_VF into vop1_type
and vop2_type. This will allows to be used for vfwadd.wf in
a future patch.

14 months ago[AMDGPU] WQM: Allow insertion of exact mode transition as terminator
Carl Ritson [Fri, 2 Jun 2023 01:34:37 +0000 (10:34 +0900)]
[AMDGPU] WQM: Allow insertion of exact mode transition as terminator

Allow WQM pass to insert transitions to exact mode among block
terminators, instead of forcing them to occur before terminators.

This should not yield any functional change, but allows block
splitting of control flow, such as that in D145329.

Reviewed By: arsenm

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

14 months agoFix TableGen emitter: hasValue() has been renamed has_value()
Mehdi Amini [Fri, 2 Jun 2023 03:54:32 +0000 (20:54 -0700)]
Fix TableGen emitter: hasValue() has been renamed has_value()

This codepath isn't exercised in-tree right now unfortunately, this only
happens when a dialect does not use the default entry points for types
parsing AND is extensible: both of these aren't the default settings and
the combination of them isn't common.

Fix #63058

14 months ago[RISCV][NFC] Use common prefix to simplify test.
Jianjian GUAN [Thu, 1 Jun 2023 09:32:25 +0000 (17:32 +0800)]
[RISCV][NFC] Use common prefix to simplify test.

Reviewed By: frasercrmck

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

14 months ago[lldb] Take StringRef names in GetChildAtNamePath (NFC)
Dave Lee [Sun, 28 May 2023 23:03:42 +0000 (16:03 -0700)]
[lldb] Take StringRef names in GetChildAtNamePath (NFC)

Following D151810, this changes `GetChildAtNamePath` to take a path of `StringRef`
values instead of `ConstString`.

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

14 months ago[lldb] Take StringRef name in GetIndexOfChildWithName (NFC)
Dave Lee [Sun, 28 May 2023 22:52:06 +0000 (15:52 -0700)]
[lldb] Take StringRef name in GetIndexOfChildWithName (NFC)

As with D151615, which changed `GetIndexOfChildMemberWithName` to take a `StringRef`
instead of a `ConstString`, this change does the same for `GetIndexOfChildWithName`.

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

14 months ago[libc++] Refactor the mandatory header inclusion tests to .gen.py
Louis Dionne [Wed, 31 May 2023 16:43:14 +0000 (09:43 -0700)]
[libc++] Refactor the mandatory header inclusion tests to .gen.py

This allows removing a bunch of boilerplate from the test suite and
reducing the amount of manual stuff contributors have to do when they
add a new public header.

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

14 months ago[libc++] Make sure we use POSIX paths in header_information.py
Louis Dionne [Thu, 1 Jun 2023 18:18:53 +0000 (11:18 -0700)]
[libc++] Make sure we use POSIX paths in header_information.py

Otherwise, the various lists of headers have different content based
on whether they are run on Windows or other platforms, which makes it
really difficult to write .gen.py tests correctly.

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

14 months ago[FuzzMutate] Handle BB without predecessor, avoid insertion after `musttail call...
Henry Yu [Fri, 2 Jun 2023 02:51:41 +0000 (19:51 -0700)]
[FuzzMutate] Handle BB without predecessor, avoid insertion after `musttail call`, avoid sinking token type

FuzzMutate didn't consider some corner cases and leads to mutation failure when mutating some modules.
This patch fixes 3 bugs:

- Add null check when encountering basic blocks without predecessor to avoid segmentation fault
- Avoid insertion after `musttail call` instruction
- Avoid sinking token type

Unit tests are also added.

Reviewed By: Peter

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

14 months ago[X86][MC] Use MCInstrDesc to access CondCode operand
Amir Ayupov [Fri, 2 Jun 2023 01:59:27 +0000 (18:59 -0700)]
[X86][MC] Use MCInstrDesc to access CondCode operand

BOLT may add an extra MCOperand as annotation, making the number of operands in
MCInst different from MCInstrDesc information. A recent change broke our use as
the last operand is no longer a cond code.

Partially revert 287dd0142c08caad5b32628f3842dfd5d5c59d03 to rely on MCInstrDesc
to access CondCode operand.

Reviewed By: skan

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

14 months agoRestrict the test from 22667e3220de5ead353a2148265d841644b63824
Jim Ingham [Fri, 2 Jun 2023 01:42:06 +0000 (18:42 -0700)]
Restrict the test from 22667e3220de5ead353a2148265d841644b63824

I fixed some long-standing failures in SBTarget::FindGlobalVariables
but the fix is in the the accelerator table lookups.  I fixed it in
the DWARF mappable tables but not everyone uses those, so I had to
restrict the test to systems I know did.

14 months ago[lldb/crashlog] Add test for non-symbolicated report crash
Med Ismail Bennani [Fri, 2 Jun 2023 00:50:55 +0000 (17:50 -0700)]
[lldb/crashlog] Add test for non-symbolicated report crash

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
14 months ago[lldb/crashlog] Run python formatter (nfc)
Med Ismail Bennani [Fri, 2 Jun 2023 00:13:16 +0000 (17:13 -0700)]
[lldb/crashlog] Run python formatter (nfc)

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
14 months ago[lldb/crashlog] Create interactive crashlog with no binary
Med Ismail Bennani [Fri, 2 Jun 2023 00:10:39 +0000 (17:10 -0700)]
[lldb/crashlog] Create interactive crashlog with no binary

This patch changes the way we load a crash report into a scripted
process by creating a empty target.

To do so, it parses the architecture information from the report (for
both the legacy and json format) and uses that to create a target that
doesn't have any executable, like what we do when attaching to a process.

For the legacy format, we mostly rely on the `Code Type` line, since the
architure is an optional field on the `Binary Images` sections.

However for the json format, we first try to get the architecture while
parsing the image dictionary if we couldn't find it, we try to infer it
using the "flavor" key when parsing the frame's registers.

If the architecture is still not set after parsing the report, we raise
an exception.

rdar://107850263

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

Differential

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
14 months ago[lldb/crashlog] Fix crash when loading non-symbolicated report
Med Ismail Bennani [Wed, 31 May 2023 22:29:24 +0000 (15:29 -0700)]
[lldb/crashlog] Fix crash when loading non-symbolicated report

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

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

rdar://109836386

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

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

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

Reviewed By: Peiming

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

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

There were two bugs here.

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

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

You might theoretically need to do this Mangled comparison in

DWARFMappedHash::MemoryTable::FindByName

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

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

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

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

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

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

Feedback is very much appreciated.

Reviewed By: arsenm

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

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

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

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

Fixes #54409

Reviewed By: rnk

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

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

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

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

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

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

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

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

This reverts commit 76d71f3792b2b1864992446f7b1028b026dccd11.

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

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

Reviewed By: nicolasvasilache, hanchung, awarzynski

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

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

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

Reviewed By: nicolasvasilache, hanchung, awarzynski

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

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

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

Reviewed By: nicolasvasilache, hanchung

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

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

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

Reviewed By: #libc, ldionne

Spies: ldionne, libcxx-commits

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

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

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

Reviewed By: sivachandra

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

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

Fixes #62897

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

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

This recovers the regressions from D151472.

Reviewed By: RKSimon

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

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

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

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

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

rdar://110017569

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

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

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

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

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

Reviewed By: Peter

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

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

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

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

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

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

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

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

Reviewed By: aeubanks

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

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

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

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

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

Reviewed By: klausler

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

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

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

The new semantics are as follows:

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

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

Depends on: D151088

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

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

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

The new semantics are as follows:

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

A patch for bbc will follow.

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

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

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

Reviewed By: maksfb

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

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

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

Example:

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

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

Reviewed By: nikic

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

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

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

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

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

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

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

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

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

Reviewed By: kiranchandramohan, tblah

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

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

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

Reviewed By: erichkeane

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Fixes #53386

Reviewed By: MaskRay

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

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

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

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

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

Depends on D151853.

Reviewed By: benlangmuir

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

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

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

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

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

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

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

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

This reverts commit 731f9ac6e53611dabb51c52bfc8011c2aab7790b.

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

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

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

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

Reviewed By: #libc_abi, phosek, MaskRay

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

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

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

Reviewed By: benlangmuir

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

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

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

Reviewed By: benlangmuir

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

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

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

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

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