platform/upstream/llvm.git
21 months agoRevert "[ADT] Remove redundaunt typename (NFC)"
Kazu Hirata [Sun, 30 Oct 2022 20:20:50 +0000 (13:20 -0700)]
Revert "[ADT] Remove redundaunt typename (NFC)"

This reverts commit 95eaefd0df7564a380f71a6909a5bd6b3ad32ab2.

I accidentally committed a patch to add a redundant typename.

21 months ago[test][asan] Make the printf-5.c test case actually emit a volatile memcpy.
Patrick Walton [Sun, 30 Oct 2022 18:07:38 +0000 (11:07 -0700)]
[test][asan] Make the printf-5.c test case actually emit a volatile memcpy.

The current test in printf-5.c appears to try to emit a volatile memcpy for the
format string, but it doesn't because the volatile qualifier is implicitly
casted away. Using a string literal instead preserves the volatile qualifier.

This is a follow-up to D137031 and is a prerequisite for D136822, which elides
memcpys in more instances and would otherwise break this test.

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

21 months ago[ADT] Remove redundaunt typename (NFC)
Kazu Hirata [Sun, 30 Oct 2022 20:17:04 +0000 (13:17 -0700)]
[ADT] Remove redundaunt typename (NFC)

21 months ago[AMDGPU] Fix a warning
Kazu Hirata [Sun, 30 Oct 2022 20:09:59 +0000 (13:09 -0700)]
[AMDGPU] Fix a warning

This patch fixes:

  llvm/lib/Target/AMDGPU/SIInstrInfo.cpp:7383: warning: enumerated
  mismatch in conditional expression:
  ‘llvm::AMDGPU::UfmtGFX11::UnifiedFormat’ vs
  ‘llvm::AMDGPU::UfmtGFX10::UnifiedFormat’

21 months ago[Mips] Fix a warning
Kazu Hirata [Sun, 30 Oct 2022 20:03:32 +0000 (13:03 -0700)]
[Mips] Fix a warning

This patch fixes:

  llvm/lib/Target/Mips/MipsInstrInfo.cpp:71:52: warning: enumerated
  and non-enumerated type in conditional expression [-Wextra]

21 months ago[flang][MSVC] Work around what seems to be a bogus MSVC error
Peter Klausler [Sun, 30 Oct 2022 19:40:19 +0000 (12:40 -0700)]
[flang][MSVC] Work around what seems to be a bogus MSVC error

Recode a recent patch in an attempt to dodge a nonsensical error
from MSVC 14.

21 months ago[Hexagon] Remove HexagonVectorCombine::simplify
Kazu Hirata [Sun, 30 Oct 2022 19:56:59 +0000 (12:56 -0700)]
[Hexagon] Remove HexagonVectorCombine::simplify

This patch fixes:

  llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp:1554:6: warning:
  ‘llvm::Value*
  {anonymous}::HexagonVectorCombine::simplify(llvm::Value*) const’
  defined but not used [-Wunused-function]

21 months ago[Analysis] Fix warnings
Kazu Hirata [Sun, 30 Oct 2022 19:52:06 +0000 (12:52 -0700)]
[Analysis] Fix warnings

This patch fixes:

  llvm/utils/unittest/googletest/include/gtest/gtest.h:1526:11: error:
  comparison of integers of different signs: 'const unsigned long' and
  'const int' [-Werror,-Wsign-compare]

21 months agoManagedStatic: remove from DebugCounter
Nicolai Hähnle [Mon, 4 Jul 2022 10:52:08 +0000 (12:52 +0200)]
ManagedStatic: remove from DebugCounter

[Re-submit after earlier revert due to a test failure. Commit dce78646f07
("clang-tblgen build: avoid duplicate inclusion of libLLVMSupport")
is believe to address the root cause of the test failure.]

Follow the pattern used in MLIR for the cl::opt instances.

v2:
- make DebugCounter::isCountingEnabled public so that the
  DebugCounterOwner doesn't have to be a nested class. This simplifies
  later changes

v3:
- remove the indirection via DebugCounterOwner::instance()

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

21 months ago[flang] Fix a warning
Kazu Hirata [Sun, 30 Oct 2022 19:33:39 +0000 (12:33 -0700)]
[flang] Fix a warning

This patch fixes:

  flang/lib/Evaluate/fold-integer.cpp:613:25: error: lambda capture
  'name' is not used [-Werror,-Wunused-lambda-capture]

21 months ago[flang][MSVC] Resolve warning message
Peter Klausler [Sun, 30 Oct 2022 18:20:13 +0000 (11:20 -0700)]
[flang][MSVC] Resolve warning message

MSVC emits a warning on some recently patched code; fix it.

21 months ago[JITLink][AArch64] Remove unused Pointer64Anon edge kind.
Lang Hames [Sun, 30 Oct 2022 18:11:27 +0000 (11:11 -0700)]
[JITLink][AArch64] Remove unused Pointer64Anon edge kind.

Pointer64Anon was lifted out of the MachO backend and into aarch64.h when that
header was created, but Pointer64Anon is really a MachO-specific "normalized"
relocation value, rather than a generic Edge::Kind. Any uses can be safely
replaced with Pointer64.

(Side note: the role of MachOPointer64Anon is to aid MachO relocation parsing:
For MachOPointer64, the target symbol is specified by the r_symbolnum field in
the relocation. For MachOPointer64Anon the address of the anonymous target is
read from the fixup location.)

21 months ago[flang] Complex constructors are scalar only
Peter Klausler [Fri, 14 Oct 2022 21:28:22 +0000 (14:28 -0700)]
[flang] Complex constructors are scalar only

The common language extension that allows arbitary expressions
to be used as components in a complex constructor (x,y) -- not both
constant, since that would make it a complex literal constant --
still have to be scalar; it's not an elemental operation like the
CMPLX() intrinsic function is.

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

21 months ago[flang] Emit warnings when results of folding some integer intrinsics overflow
Peter Klausler [Fri, 14 Oct 2022 00:14:20 +0000 (17:14 -0700)]
[flang] Emit warnings when results of folding some integer intrinsics overflow

When the compile-time result value of a reference to an integer-valued intrinsic
function COUNT, ICHAR, IACHAR, INDEX, SCAN, or VERIFY cannot be represented in
the selected result kind, emit a warning.

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

21 months ago[ValueTracking] Assert known bits sanity in isKnownNonZero
Philip Reames [Sun, 30 Oct 2022 17:52:27 +0000 (10:52 -0700)]
[ValueTracking] Assert known bits sanity in isKnownNonZero

These are the same asserts we have in other query routines; cover this interface too.

21 months ago[X86] Remove unnecessary MMX PACKSS/PACKUS SchedWriteRes overrides
Simon Pilgrim [Sun, 30 Oct 2022 17:41:53 +0000 (17:41 +0000)]
[X86] Remove unnecessary MMX PACKSS/PACKUS SchedWriteRes overrides

These overrides should now match the default WriteShuffle schedules

This also fixes a typo where we were missing load latencies for the memory folded variants

21 months ago[VectorUtils] Add getShuffleDemandedElts helper
Simon Pilgrim [Sun, 30 Oct 2022 17:03:49 +0000 (17:03 +0000)]
[VectorUtils] Add getShuffleDemandedElts helper

We have similar code to translate a demanded elements mask for a shuffle's operands in multiple places - this patch adds a helper function to VectorUtils and updates a number of locations to use it directly.

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

21 months ago[flang] Stricter scrutiny of MOVE_ALLOC calls
Peter Klausler [Thu, 13 Oct 2022 23:44:34 +0000 (16:44 -0700)]
[flang] Stricter scrutiny of MOVE_ALLOC calls

Enforce remaining semantic restrictions on the arguments to MOVE_ALLOC,
namely that the first two arguments must be allocatable (!) and that
if the source is polymorphic, so must the destination be.

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

21 months ago[clang-tools-extra] Use llvm::find (NFC)
Kazu Hirata [Sun, 30 Oct 2022 16:41:55 +0000 (09:41 -0700)]
[clang-tools-extra] Use llvm::find (NFC)

21 months agoAllow scalable vectors in computeKnownBits
Philip Reames [Sun, 30 Oct 2022 15:42:36 +0000 (08:42 -0700)]
Allow scalable vectors in computeKnownBits

This extends the computeKnownBits analysis to support scalable vectors. The critical detail is in deciding how to represent the demanded elements of a vector whose length is unknown at compile time.

For this patch, I adopt the convention that we track one bit which corresponds to all lanes. That is, that bit is implicitly broadcast to all lanes of the scalable vector resulting in all lanes being demanded. This is the same convention we use in getSplatValue in SelectionDAG.

Note that this convention doesn't actually impact much. Most of the code is agnostic to the interpretation of the demanded elements, and the few cases which actually care need case by case handling anyways. In this patch, I just bail out of those cases.

A prior patch (D128159) proposed using a different convention in SDAG. I don't see any strong reason to prefer one scheme over the other, so I propose we go with this one as it's conceptually the simplest. Getting known and demanded bit optimizations unblocked at all is a significant win.

I've locally implemented this scheme in reasonable large parts of ValueTracking.cpp and SelectionDAG equivalents, and have not hit any blockers. If this is approved, I plan to post a series of patches plumbing this through all the relevant parts.

In the discussion on that patch, a preference was expressed for introducing some form of abstraction around the demanded elements. I'll note that I've played with several variations on that idea locally, and have yet to find anything which results in more readable code. If anyone has concrete ideas in this area, I'm happy to explore in follow up patches. I'd strongly prefer to be making API changes in NFC manner with tests in place.

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

21 months ago[X86] Fix simd integer ALU and shuffle port allocations
Simon Pilgrim [Sun, 30 Oct 2022 14:23:51 +0000 (14:23 +0000)]
[X86] Fix simd integer ALU and shuffle port allocations

znver1/2 uses pipes0/1/3 for most integer ALU and nearly all integer/float shuffles occur on pipes1/2

More cleanup work to hopefully get shuffle kinds costs testing added to the D103695 script sometime soon

Confirmed with the AMD SoG, Agner + instlatx64

21 months ago[X86] Ensure 256-bit sqrt + crosslane shuffles are set to 2 uops + half rate
Simon Pilgrim [Sun, 30 Oct 2022 14:01:48 +0000 (14:01 +0000)]
[X86] Ensure 256-bit sqrt + crosslane shuffles are set to 2 uops + half rate

Fixes another mismatch between the D103695 script and the znver1 scheduler model

Confirmed with the AMD SoG, Agner + instlatx64

21 months ago[InstCombine] refactor the SimplifyUsingDistributiveLaws NFC
zhongyunde [Sun, 30 Oct 2022 13:00:54 +0000 (21:00 +0800)]
[InstCombine] refactor the SimplifyUsingDistributiveLaws NFC

Precommit for D136015
Reviewed By: spatel
Differential Revision: https://reviews.llvm.org/D137019

21 months agoFix the clang Sphinx build
Aaron Ballman [Sun, 30 Oct 2022 12:59:33 +0000 (08:59 -0400)]
Fix the clang Sphinx build

This should address the issue found in:
https://lab.llvm.org/buildbot/#/builders/92/builds/34906

21 months ago[clang-format] Adds a formatter for aligning trailing comments over empty lines
Yusuke Kadowaki [Sun, 30 Oct 2022 12:21:20 +0000 (12:21 +0000)]
[clang-format] Adds a formatter for aligning trailing comments over empty lines

This patch addresses https://github.com/llvm/llvm-project/issues/19756

Reviewed By: MyDeveloperDay, HazardyKnusperkeks

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

21 months ago[test][InstCombine] Add tests for removing memcpy to an alloca that is passed to...
Patrick Walton [Sun, 30 Oct 2022 02:03:29 +0000 (19:03 -0700)]
[test][InstCombine] Add tests for removing memcpy to an alloca that is passed to a readonly nocapture function parameter, in preparation for D136822.

This commit adds tests to Transforms/InstCombine/memcpy-from-global.ll that
test various situations involving memcpy from a constant to an alloca that is
then passed to function parameters with various attributes. The forthcoming
D136822 allows InstCombine to remove these memcpys if they're passed to a
single readonly nocapture parameter.

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

21 months ago[InstCombine] Avoid deleting volatile memcpys.
Patrick Walton [Sun, 30 Oct 2022 00:34:57 +0000 (17:34 -0700)]
[InstCombine] Avoid deleting volatile memcpys.

InstCombine can replace memcpy to an alloca with a pointer directly to the
source in certain cases. Unfortunately, it also did so for volatile memcpys.
This patch makes it stop doing that.

This was discovered in D136822.

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

21 months ago[test][InstCombine] Add a test case for volatile memcpy forwarding in InstCombine...
Patrick Walton [Sat, 29 Oct 2022 23:38:27 +0000 (16:38 -0700)]
[test][InstCombine] Add a test case for volatile memcpy forwarding in InstCombine, which is currently optimized incorrectly.

D136822 demonstrated that we currently delete volatile memcpys in InstCombine,
which we shouldn't do. This commit adds a test for this. A forthcoming commit
will fix it.

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

21 months ago[clang][Interp] Implement bitXor opcode
Timm Bäder [Sat, 22 Oct 2022 14:59:19 +0000 (16:59 +0200)]
[clang][Interp] Implement bitXor opcode

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

21 months ago[clang][Interp] Implement left and right shifts
Timm Bäder [Sat, 22 Oct 2022 16:19:10 +0000 (18:19 +0200)]
[clang][Interp] Implement left and right shifts

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

21 months ago[mlir] Fix a warning
Kazu Hirata [Sun, 30 Oct 2022 07:18:08 +0000 (00:18 -0700)]
[mlir] Fix a warning

This patch fixes:

  mlir/include/mlir/IR/PatternMatch.h:1209:72: warning: parameter
  ‘values’ set but not used [-Wunused-but-set-parameter]

21 months ago[clang][Interp] Implement add and sub compound assign operators
Timm Bäder [Sat, 22 Oct 2022 13:32:27 +0000 (15:32 +0200)]
[clang][Interp] Implement add and sub compound assign operators

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

21 months ago[ADT] Remove redundant typename (NFC)
Kazu Hirata [Sun, 30 Oct 2022 06:50:56 +0000 (23:50 -0700)]
[ADT] Remove redundant typename (NFC)

21 months ago[clang-format] Don't crash on malformed preprocessor conditions
sstwcw [Sun, 30 Oct 2022 02:18:58 +0000 (02:18 +0000)]
[clang-format] Don't crash on malformed preprocessor conditions

Previously the program would crash on this input:

```
#else
#if X
```

The problem was that in `parsePPElse`, `PPBranchLevel` would be
incremented when the first `#else` gets parsed, but `PPLevelBranchCount`
and `PPLevelBranchIndex` would not be updated together.

I found the problem when working on D135740.

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

21 months ago[flang] Abstract interfaces can't be designated or referenced
Peter Klausler [Thu, 13 Oct 2022 17:38:55 +0000 (10:38 -0700)]
[flang] Abstract interfaces can't be designated or referenced

Broaden the check for misuse of ABSTRACT procedure interfaces by
doing it in expression analysis rather than name resolution so that
cases like pointer assignment targets and actual arguments are also
diagnosed as errors.

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

21 months ago[flang] Stricter scrutiny of deferred type parameters (C702)
Peter Klausler [Wed, 12 Oct 2022 22:15:33 +0000 (15:15 -0700)]
[flang] Stricter scrutiny of deferred type parameters (C702)

Semantics checks C702, which disallows deferred type parameters for
any entity that is neither an allocatable nor a pointer, only during
name resolution of type declaration statements.  This check needs to
be broader, since Fortran entities can have their types specified in
other ways.  Rewrite the check and move it to the general declaration
checking pass.

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

21 months ago[flang] Catch C721 violations in defined interfaces
Peter Klausler [Wed, 12 Oct 2022 00:21:14 +0000 (17:21 -0700)]
[flang] Catch C721 violations in defined interfaces

Fortran's constraint C721 allows an assumed-length CHARACTER
entity to be declared in a very limited set of circumstances that
does not include an explicit external interface definition.

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

21 months ago[flang] Catch inconsistent function/subroutine usage of procedure pointer components
Peter Klausler [Tue, 11 Oct 2022 23:31:47 +0000 (16:31 -0700)]
[flang] Catch inconsistent function/subroutine usage of procedure pointer components

When a derived type has a procedure pointer component with no interface,
we can't do a lot of checking on its call sites, but we can at least require
that the same procedure pointer component be used consistently as either
a function or as a subroutine, but not both.

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

21 months ago[flang] Warn about overflow from folding complex ABS()
Peter Klausler [Tue, 11 Oct 2022 22:00:08 +0000 (15:00 -0700)]
[flang] Warn about overflow from folding complex ABS()

Emit a warning when the result of folding a call to
ABS() with a complex argument results in an overflow.

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

21 months ago[flang] Recode a line to dodge a clang warning
Peter Klausler [Sat, 29 Oct 2022 23:00:24 +0000 (16:00 -0700)]
[flang] Recode a line to dodge a clang warning

Rewrite a correct use of "&" -- conjunction without short-circuiting --
from a recent patch into multiple lines so that clang doesn't warn
about it.

21 months ago[llvm-objdump] Add --no-print-imm-hex to tests depending on it.
Daniel Thornburgh [Sat, 29 Oct 2022 03:04:08 +0000 (20:04 -0700)]
[llvm-objdump] Add --no-print-imm-hex to tests depending on it.

This prepares for an upcoming change to make --print-imm-hex the default
behavior of llvm-objdump. These tests were updated in a semi-automatic
fashion.

See D136972 for details.

21 months ago[test][AliasAnalysis] Add some baseline tests in preparation for getModRefInfoMask().
Patrick Walton [Fri, 28 Oct 2022 19:42:01 +0000 (12:42 -0700)]
[test][AliasAnalysis] Add some baseline tests in preparation for getModRefInfoMask().

This commit adds some tests in preparation for D136659, which allows alias
analysis to treat locally-invariant memory pointed to by readonly noalias
pointers the same as globally-invariant memory in some cases. The existing
behavior for these tests is marked as expected and will be changed when that
diff lands.

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

21 months ago[test] Remove readonly from some parameters that are written through in tests.
Patrick Walton [Thu, 27 Oct 2022 20:01:20 +0000 (13:01 -0700)]
[test] Remove readonly from some parameters that are written through in tests.

In D136659 I found a few tests that write through readonly parameters:

* Analysis/BasicAA/pr18573.ll: @foo1 writes through %arr.ptr, but declares it
readonly. I removed the readonly annotation.

* CodeGen/ARM/ParallelDSP/aliasing.ll: @restrict writes through the readonly
%arg3, @store_alias_arg3_illegal_1 writes through the readonly %arg3, and
@store_alias_arg3_illegal_2 writes through the readonly %arg3. I removed
readonly from all three. Also, I added some CHECK-LABEL directives to make it
harder for FileCheck output to be mixed up.

* Transforms/LoopVectorize/AArch64/sve-gather-scatter.ll:
@gather_nxv4i32_ind64_stride2 writes through the readonly %a. I removed the
readonly attribute.

* Transforms/LoopVectorize/interleaved-accesses.ll: @load_gap_reverse writes
through the readonly %P1 and %P2. Also, the corresponding C code in the comment
didn't match the test. I removed the readonly attribute from both parameters
and corrected the C code.

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

21 months ago[flang] Enforce constraint C911
Peter Klausler [Tue, 11 Oct 2022 19:45:05 +0000 (12:45 -0700)]
[flang] Enforce constraint C911

Diagnose attempts to use an non-polymorphic instance of an
abstract derived type.

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

21 months ago[flang] Speed up folding of LEN_TRIM()
Peter Klausler [Mon, 10 Oct 2022 21:42:16 +0000 (14:42 -0700)]
[flang] Speed up folding of LEN_TRIM()

LEN_TRIM's folding is currently based on VERIFY(), and it is kind of
slow for the very large CHARACTER arguments that can show up in artificial
test suites.  Rewrite in terms of single-character accesses.

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

21 months ago[flang] Improve error recovery for bad/missing construct END statements
Peter Klausler [Mon, 10 Oct 2022 20:47:12 +0000 (13:47 -0700)]
[flang] Improve error recovery for bad/missing construct END statements

When a multi-statement construct should end with a particular END statement
like "END SELECT", and that construct's END statement is missing or
unrecognizable, the error recovery productions should not misinterpret
a program unit END statement that follows and consume it as a misspelled
construct END statement. Doing so leads to cascading errors or a failed parse.

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

21 months ago[flang] Fix warning from clang 16 on recent patch
Peter Klausler [Sat, 29 Oct 2022 19:43:19 +0000 (12:43 -0700)]
[flang] Fix warning from clang 16 on recent patch

Add an explicit empty initializer to a new struct member definition
to silence warnings from clang 16 about missing initializers.

21 months ago[ORC] Mark late-claimed weak symbols as live in ObjectLinkingLayer.
Lang Hames [Sat, 29 Oct 2022 17:48:09 +0000 (17:48 +0000)]
[ORC] Mark late-claimed weak symbols as live in ObjectLinkingLayer.

ObjectLinkingLayer attempts to claim responsibility for weak definitions that
are present in LinkGraphs, but not present in the corresponding
MaterializationResponsibility object. Where such a claim is successful, the
symbol should be marked as live to prevent it from being dead stripped.

(For the curious: Such "late-breaking" definitions are introduced somewhere in
the materialization pipeline after the initial responsibility set is calculated.
The usual source is the complier or assembler. Examples of common late-breaking
definitions include personality pointers, e.g. "DW.ref.__gxx_personality_v0",
and named constant pool entries, e.g. __realXX..XX.)

The failure to mark these symbols live caused few problems in practice because
late-breaking definitions are usually anchored by existing live definitions
within the graph (e.g. DW.ref.__gxx_personality_v0 is transitively referenced by
functions via eh-frame records), and so they usually survived dead-stripping
anyway. This accidental persistence isn't a principled solution though, and it
fails altogether if a late-breaking definition is not otherwise referenced by
the graph, with the result that the now-claimed symbol is stripped triggering a
"Failed to materialize symbols" error in ORC. Marking such symbols live is the
correct solution.

No testcase, as it's difficult to construct a situation where a late-breaking
definition is inserted without being referenced outside the context of new
backend bringup or plugin-specific shenanigans.

See discussion in https://reviews.llvm.org/D133452 and
https://reviews.llvm.org/D136877.

21 months agoRevert "Handle errors in expansion of response files"
Serge Pavlov [Sat, 29 Oct 2022 18:58:47 +0000 (01:58 +0700)]
Revert "Handle errors in expansion of response files"

This reverts commit 17eb198de934eced784e16ec15e020a574ba07e1.
Reverted for investigation, because ClangDriverTests failed on some builders.

21 months ago[flang] Catch and diagnose attempts to misuse NULL()
Peter Klausler [Fri, 7 Oct 2022 23:52:37 +0000 (16:52 -0700)]
[flang] Catch and diagnose attempts to misuse NULL()

Some intrinsic functions can handle NULL() as an actual argument; most
can't.  Distinguish the two with a new ArgFlag facility in the intrinsic
procedure table.  Also transform some confusing Optionality codes that
were standing in for flags into ArgFlags.  Last, return false for a NULL()
pointer from the utility IsActuallyConstant(), ensuring that it can
still deal with a nested NULL() for components in structure constructors.

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

21 months ago[VPlan] Use onlyFirstLaneUsed in sinkScalarOperands.
Florian Hahn [Sat, 29 Oct 2022 18:45:19 +0000 (19:45 +0100)]
[VPlan] Use onlyFirstLaneUsed in sinkScalarOperands.

Replace custom code to check if only the first lane is used by generic
helper `onlyFirstLaneUsed`. This enables VPlan-based sinking in a few
additional cases and was suggested in D133760.

Reviewed By: Ayal

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

21 months ago[Hexagon] Report changes in HvxIdioms pass
Krzysztof Parzyszek [Sat, 29 Oct 2022 18:29:58 +0000 (11:29 -0700)]
[Hexagon] Report changes in HvxIdioms pass

It can produce some dead code, which is harmless in the end, but breaks
expensive checks when unreported. This should be fixed eventually, but
it's a low priority.

21 months ago[flang] Clarify cases where name resolution of generic shadowing can be overridden
Peter Klausler [Fri, 7 Oct 2022 19:58:43 +0000 (12:58 -0700)]
[flang] Clarify cases where name resolution of generic shadowing can be overridden

Fortran famously allows a generic interface definition to share a
scope with a procedure or derived type of the same name.  When that
shadowed name is accessed via host or USE association, but is also
defined by an interface in the generic, then name resolution needs
to fix up the representation of the shadowing so that the new interface
definition is seen as the shadowed symbol -- the host or USE associated
name is not material to the situation.  See the new test case for
particular examples.

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

21 months ago[Hexagon] Break up vectors into HVX-sized chunks in HvxIdioms
Krzysztof Parzyszek [Tue, 25 Oct 2022 21:23:34 +0000 (14:23 -0700)]
[Hexagon] Break up vectors into HVX-sized chunks in HvxIdioms

This will allow recognizing Q.31 multiplications on vectors that are
multiplies of HVX vectors. At the moment this comes at the expense of
Q.15 multiplications, which now are handled as 32-bit multiplications
with shifts.
In the longer term this will likely be replaced by a different scheme
of "legalizing" vectors, which is necessary for idiom recognition, at
least where using direct HVX instrinsics is desired.

21 months agoRecommit [AArch64] Optimize memcmp when the result is tested for [in]equality with 0
zhongyunde [Sat, 29 Oct 2022 18:03:44 +0000 (02:03 +0800)]
Recommit [AArch64] Optimize memcmp when the result is tested for [in]equality with 0

Fixes 1st issue of https://github.com/llvm/llvm-project/issues/58061
Fixes the crash of https://github.com/llvm/llvm-project/issues/58675

Reviewed By: dmgreen, efriedma
Differential Revision: https://reviews.llvm.org/D136244

21 months ago[Hexagon] Fix vector concatenation
Krzysztof Parzyszek [Tue, 25 Oct 2022 20:34:47 +0000 (13:34 -0700)]
[Hexagon] Fix vector concatenation

21 months ago[InstCombine] fold mul with incremented "shl 1" factor
Sanjay Patel [Sat, 29 Oct 2022 14:53:23 +0000 (10:53 -0400)]
[InstCombine] fold mul with incremented "shl 1" factor

X * ((1 << Z) + 1) --> (X << Z) + X

https://alive2.llvm.org/ce/z/P-7WK9

It's possible that we could do better with propagating
no-wrap, but this carries over the existing logic and
appears to be correct.

The naming differences on the existing folds are a result
of using getName() to set the final value via Builder.
That makes it easier to transfer no-wrap rather than the
gymnastics required from the raw create instruction APIs.

21 months ago[InstCombine] create helper function for mul patterns with 1<<X; NFC
Sanjay Patel [Sat, 29 Oct 2022 13:33:00 +0000 (09:33 -0400)]
[InstCombine] create helper function for mul patterns with 1<<X; NFC

There are at least 2 other potential patterns that could go here.

21 months ago[X86] Remove the WriteDPPSZ schedule pair
Simon Pilgrim [Sat, 29 Oct 2022 15:28:37 +0000 (16:28 +0100)]
[X86] Remove the WriteDPPSZ schedule pair

There's never been a 512-bit vdpps instruction (and the implementation is so convoluted there probably won't ever be)

21 months ago[X86] Remove 256-bit scheduler classes
Simon Pilgrim [Sat, 29 Oct 2022 15:23:41 +0000 (16:23 +0100)]
[X86] Remove 256-bit scheduler classes

SLM (silvermont) doesn't support any AVX instructions

21 months agoHandle errors in expansion of response files
Serge Pavlov [Fri, 14 Oct 2022 13:07:09 +0000 (20:07 +0700)]
Handle errors in expansion of response files

Previously an error raised during an expansion of response files (including
configuration files) was ignored and only the fact of its presence was
reported to the user with generic error messages. This made it difficult to
analyze problems. For example, if a configuration file tried to read an
inexistent file, the error message said that 'configuration file cannot
be found', which is wrong and misleading.

This change enhances handling errors in the expansion so that users
could get more informative error messages.

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

21 months ago[InstCombine] reduce code duplication in visitMul(); NFC
Sanjay Patel [Sat, 29 Oct 2022 12:55:37 +0000 (08:55 -0400)]
[InstCombine] reduce code duplication in visitMul(); NFC

21 months ago[InstCombine] add tests for mul with shl operand; NFC
Sanjay Patel [Fri, 28 Oct 2022 16:05:10 +0000 (12:05 -0400)]
[InstCombine] add tests for mul with shl operand; NFC

21 months ago[ARC] Regenerate ldst.ll
Simon Pilgrim [Sat, 29 Oct 2022 13:09:52 +0000 (14:09 +0100)]
[ARC] Regenerate ldst.ll

Reported by the (experimental) arc buildbot after D136042

21 months ago[mlir] Split parser fuzzer for bytecode & text
Jacques Pienaar [Sat, 29 Oct 2022 12:42:28 +0000 (05:42 -0700)]
[mlir] Split parser fuzzer for bytecode & text

Enable fuzzing these independently. Currently still not linking in
dialects beyond Builtin.

21 months ago[DAG] Enable combineShiftOfShiftedLogic folds after type legalization
Simon Pilgrim [Sat, 29 Oct 2022 11:29:58 +0000 (12:29 +0100)]
[DAG] Enable combineShiftOfShiftedLogic folds after type legalization

This was disabled to prevent regressions, which appear to be just occurring on AMDGPU (at least in our current lit tests), which I've addressed by adding AMDGPUTargetLowering::isDesirableToCommuteWithShift overrides.

Fixes #57872

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

21 months ago[lit] Deduplicate README and longdescription, and update it
Michał Górny [Sat, 29 Oct 2022 04:44:11 +0000 (06:44 +0200)]
[lit] Deduplicate README and longdescription, and update it

Since long_description is effectively the README that's displayed
on pypi project page, combine it with the existing README file and read
the file in `setup.py`.  This is a common practice among Python
projects, to the point of declarative-style setuptools configurations
providing a shorthand for it.

While at it, update the outdated information about LLVM Bugzilla for use
of GitHub issues.

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

21 months ago[X86] WriteFShuffle256 shuffles aren't microcoded in the llvm sense
Simon Pilgrim [Sat, 29 Oct 2022 11:03:38 +0000 (12:03 +0100)]
[X86] WriteFShuffle256 shuffles aren't microcoded in the llvm sense

znver1/2 might have poor throughput for crosslane shuffles but they don't consume 100 cycles of resources

I think there was a misunderstanding between the AMD definition of microcoding (more than 2-3 uops) and LLVM (here be dragons - impossible to approximately model the instruction)

This is more yak shaving to come from D103695 - this time working out why codegen involving broadcasts gives such weird numbers

21 months ago[X86] Ensure 256-bit inlane shuffles are set to 2 uops + half rate
Simon Pilgrim [Sat, 29 Oct 2022 10:52:12 +0000 (11:52 +0100)]
[X86] Ensure 256-bit inlane shuffles are set to 2 uops + half rate

znver1 double pumps regular 256-bit shuffles (crosslane shuffles are messier....)

Fixes yet another mismatch between the numbers coming out of the script from D103695 and the znver1 scheduler model

Confirmed with the AMD SoG, Agner + instlatx64

21 months ago[JITLink][RISCV] Add names for GOT/PLT relocations
Jonas Hahnfeld [Fri, 28 Oct 2022 21:05:27 +0000 (23:05 +0200)]
[JITLink][RISCV] Add names for GOT/PLT relocations

It is confusing to see "Unrecognized edge kind" in debugging output
for supported relocations; this was probably an oversight in commit
89f546f6ba which added the support.

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

21 months ago[LoongArch] Improve the "out of range" error information reported by `adjustFixupValue`
Xiaodong Liu [Thu, 27 Oct 2022 09:42:54 +0000 (17:42 +0800)]
[LoongArch] Improve the "out of range" error information reported by `adjustFixupValue`

There are three reduplicate error messages for different conditions. I
add meaningful information to make them more informative.

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

21 months ago[docs] clang.rst: gnu++14 => gnu++17
Fangrui Song [Sat, 29 Oct 2022 07:15:24 +0000 (00:15 -0700)]
[docs] clang.rst: gnu++14 => gnu++17

21 months ago[gn build] Port 30ea3fcc4c69
LLVM GN Syncbot [Sat, 29 Oct 2022 06:45:02 +0000 (06:45 +0000)]
[gn build] Port 30ea3fcc4c69

21 months ago[clang-format][NFC] Move BracesRemover tests out of FormatTest.cpp
owenca [Thu, 27 Oct 2022 09:53:23 +0000 (02:53 -0700)]
[clang-format][NFC] Move BracesRemover tests out of FormatTest.cpp

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

21 months agoRevert "Revert "[scudo] Fix the calculating of memory group usage""
Chia-hung Duan [Fri, 28 Oct 2022 22:17:06 +0000 (22:17 +0000)]
Revert "Revert "[scudo] Fix the calculating of memory group usage""

This reverts commit 69fe7abb393ba7d6ee9c8ff1429316845b5bad37.

Fixed the arguments order while calling batchGroupBase()

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

21 months ago[clang][NFC] sync comments from declaration of InitializePreprocessor
YingChi Long [Sat, 29 Oct 2022 06:20:19 +0000 (14:20 +0800)]
[clang][NFC] sync comments from declaration of InitializePreprocessor

21 months ago[libc] Fix the return value of fread and fwrite.
Siva Chandra Reddy [Sat, 29 Oct 2022 05:41:17 +0000 (05:41 +0000)]
[libc] Fix the return value of fread and fwrite.

They were previously returning the number of bytes read. They should
instead be returning the number of objects read.

21 months ago[mlir] Fix the bazel error after c853d69ab9778fece61b0bf63a71609f437a483d
Haojian Wu [Sat, 29 Oct 2022 06:00:29 +0000 (08:00 +0200)]
[mlir] Fix the bazel error after c853d69ab9778fece61b0bf63a71609f437a483d

21 months agoARM: Fix stack warning test
Matt Arsenault [Sat, 29 Oct 2022 05:28:23 +0000 (22:28 -0700)]
ARM: Fix stack warning test

21 months agoclang: Improve errors for DiagnosticInfoResourceLimit
Matt Arsenault [Thu, 27 Oct 2022 23:28:46 +0000 (16:28 -0700)]
clang: Improve errors for DiagnosticInfoResourceLimit

Print source location info and demangle the name, compared
to the default behavior.

Several observations:

1. Specially handling this seems to give source locations
without enabling debug info, and also gives columns compared
to the backend diagnostic.

2. We're duplicating diagnostic effort in DiagnosticInfo
and clang. This feels wrong, but clang can demangle and I guess
have better debug info available? Should clang really have any of this
code? For the purposes of this diagnostic, the important piece
is just reading the source location out of the llvm::Function.

3. lld is not duplicating the same effort as clang with LTO, and
just directly printing the DiagnosticInfo as-is. e.g.

  $ clang -fgpu-rdc
lld: error: local memory (480000) exceeds limit (65536) in function '_Z12use_huge_ldsIiEvv'
lld: error: local memory (960000) exceeds limit (65536) in function '_Z12use_huge_ldsIdEvv'

  $ clang -fno-gpu-rdc
backend-resource-limit-diagnostics.hip:8:17: error: local memory (480000) exceeds limit (65536) in 'void use_huge_lds<int>()'
__global__ void use_huge_lds() {
                ^
backend-resource-limit-diagnostics.hip:8:17: error: local memory (960000) exceeds limit (65536) in 'void use_huge_lds<double>()'
2 errors generated when compiling for gfx90a.

4. Backend errors are not observed with -save-temps and -fno-gpu-rdc or -flto,
and the compile incorrectly succeeds.

5. The backend version prints error: <location info>; clang prints <location info>: error:

6. -emit-codegen-only is totally broken for AMDGPU. MC
gets a null target streamer. I do not understand why this
is a thing. This just creates a horrible edge case.
Just work around this by emitting actual code instead of blocking
this patch.

21 months agoDiagnosticInfo: Report function location for resource limits
Matt Arsenault [Thu, 27 Oct 2022 23:29:26 +0000 (16:29 -0700)]
DiagnosticInfo: Report function location for resource limits

We have some odd redundancy where clang specially handles
the stack size case. If clang prints it, the source location is first
followed by "warning". The backend diagnostic, as printed by other tools
puts "warning" first.

21 months agollvm-reduce: Fix typo
Matt Arsenault [Sat, 29 Oct 2022 02:01:09 +0000 (19:01 -0700)]
llvm-reduce: Fix typo

21 months ago[Frontend] -MP: remove blank lines
Fangrui Song [Sat, 29 Oct 2022 03:46:27 +0000 (20:46 -0700)]
[Frontend] -MP: remove blank lines

GCC 10 removed blank lines for phony targets during a refactoring.
The blank lines seems unuseful, so let's follow suit.

21 months ago[Frontend] Fix -MP when main file is <stdin>
Fangrui Song [Sat, 29 Oct 2022 03:35:29 +0000 (20:35 -0700)]
[Frontend] Fix -MP when main file is <stdin>

rC220726 had a bug: `echo "<cstdlib>" | clang -M -MP -x c++ - 2>/dev/null`
(used by glibc/configure.ac find_cxx_header) omitted a `cstdlib:` line. Instead
of filtering out `<stdin>` in `Dependencies`, retain it (so that the number of
entries does not change whether or not main file is `<stdin>`) and filter the
`PhonyTarget` output.

21 months ago[mlir][sparse] Cleaning up function names in test
wren romano [Thu, 27 Oct 2022 23:25:41 +0000 (16:25 -0700)]
[mlir][sparse] Cleaning up function names in test

The old "dumpAndRelease" names are no longer valid since the "release" part is handled separately now.

Reviewed By: Peiming

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

21 months ago[mlir][sparse] run canonicalization pass after DenseOpBufferize.
Peiming Liu [Fri, 28 Oct 2022 20:45:06 +0000 (20:45 +0000)]
[mlir][sparse] run canonicalization pass after DenseOpBufferize.

As pointed out by Matthias: "DenseBufferizationPass should be run right after TensorCopyInsertionPass. (Running it after bufferizing the sparse IR is also OK.) The reason for this is that whether copies are needed for not depends on the structure of the program (SSA use-def chains). In particular, running the canonicalizer in-between is problematic because it could introduce new RaW conflicts"

Reviewed By: aartbik

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

21 months agoFix MLIR build after D136931
Slava Zakharin [Sat, 29 Oct 2022 00:50:11 +0000 (17:50 -0700)]
Fix MLIR build after D136931

ld.lld: error: undefined symbol: mlir::extractFromI64ArrayAttr(mlir::Attribute)
>>> referenced by NVVMToLLVMIRTranslation.cpp:142
  (/llvm-project/mlir/lib/Target/LLVMIR/Dialect/NVVM/NVVMToLLVMIRTranslation.cpp:142)
>>> referenced by NVVMToLLVMIRTranslation.cpp:152
  (/llvm-project/mlir/lib/Target/LLVMIR/Dialect/NVVM/NVVMToLLVMIRTranslation.cpp:152)

21 months agollvm-reduce: Fix producing invalid reductions with landingpads
Matt Arsenault [Thu, 20 Oct 2022 05:11:18 +0000 (22:11 -0700)]
llvm-reduce: Fix producing invalid reductions with landingpads

It's not valid to simply branch to a landingpad block, so it
needs to be removed.

Also stop trying to scan forward to find a block that can be merged.
The predecessor merge rules are more complex than this. This also
would need to have considered landingpads. Just do the minimum
to delete the block, and let the simplify-cfg reduction handle
the branch chain cleanups.

21 months agollvm-reduce: Fix block reduction with unreachable blocks
Matt Arsenault [Tue, 4 Oct 2022 05:06:09 +0000 (22:06 -0700)]
llvm-reduce: Fix block reduction with unreachable blocks

Previously this would produce many invalid reductions with
"Instruction does not dominate uses" verifier errors.

This fixes issues in cases where the incoming IR
has unreachable blocks, and the resulting reduction
introduced new reachable blocks.

Have basic-blocks skip functions that have unreachable
blocks, Introduce a separate reduction which only
deletes unreachable blocks. Cleanup any newly unreachable
blocks after trimming out the requested deletions.

Includes a variety of meta-reduced tests for llvm-reduce
itself with -abort-on-invalid-reduction that were failing
on different iterations of this patch.

Bugpoint's implementation is much simpler (but currently I don't
understand how it avoids disconnecting interesting blocks from the CFG).

21 months agollvm-reduce: Don't turn switches into returns
Matt Arsenault [Wed, 19 Oct 2022 20:10:41 +0000 (13:10 -0700)]
llvm-reduce: Don't turn switches into returns

Re-use one of the existing successors as the new default.
This helps with a future patch to fix handling of unreachable
blocks.

21 months ago[clang][test] Require x86 target in a couple new tests
Ben Langmuir [Fri, 28 Oct 2022 23:59:38 +0000 (16:59 -0700)]
[clang][test] Require x86 target in a couple new tests

Attempt to fix test failures on bots that don't configure x86 target.

21 months agoclang: Add required target to test
Matt Arsenault [Fri, 28 Oct 2022 23:49:32 +0000 (16:49 -0700)]
clang: Add required target to test

21 months ago[llvm-tblgen] NFC: Simplify DecoderEmitter.
James Y Knight [Fri, 28 Oct 2022 22:38:49 +0000 (18:38 -0400)]
[llvm-tblgen] NFC: Simplify DecoderEmitter.

Currently the DecoderEmitter constructor takes a bunch of string
parameters containing bits of code to interpolate.

However, there's only two ways it can be called. The one used for most
targets which doesn't handle the SoftFail DecoderStatus (not a
problem, because they don't use SoftFail). The other mode, which is
used for ARM/AArch64, does handle SoftFail, but requires an externally
defined helper function in those targets.

This is unnecessary complication; remove the parameters, and unify
onto a single version which does support SoftFail, defining the helper
itself.

21 months ago[mlir][sparse] Fold invariant op only when it has only one use.
Peiming Liu [Fri, 28 Oct 2022 21:42:45 +0000 (21:42 +0000)]
[mlir][sparse] Fold invariant op only when it has only one use.

Reviewed By: aartbik

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

21 months agollvm-reduce: Stop checking workitem is interesting before each pass
Matt Arsenault [Mon, 24 Oct 2022 18:05:06 +0000 (11:05 -0700)]
llvm-reduce: Stop checking workitem is interesting before each pass

Each delta pass run should have guaranteed the output is still
interesting, so it should be pointless to recheck this each
iteration. I have many issues that take multiple minutes
to reproduce, so this ends up being a huge waste of time.

Also, remove broken line counting. This never worked, since
getLines was failing to open the temporary file which was just
deleted.

21 months agoAMDGPU: Register a null MC streamer for -emit-codegen-only
Matt Arsenault [Fri, 28 Oct 2022 18:49:15 +0000 (11:49 -0700)]
AMDGPU: Register a null MC streamer for -emit-codegen-only

For some reason null is a valid MC target, used from clang with
-emit-codegen-only. Previously the target streamer was null,
which was inconsistently null checked resulting in crashes
if using amdhsa.

21 months agoRevert "[AArch64] Optimize memcmp when the result is tested for [in]equality with 0"
Paul Kirth [Fri, 28 Oct 2022 21:57:23 +0000 (21:57 +0000)]
Revert "[AArch64] Optimize memcmp when the result is tested for [in]equality with 0"

This reverts commit 01ff511593d1a4920fa3c1d450ad2077661e0bdc.

It triggers an assertion failure in SelectionDAG.cpp

see https://github.com/llvm/llvm-project/issues/58675 for details.

21 months ago[lldb] Support simplified template names
Arthur Eubanks [Thu, 4 Aug 2022 00:09:40 +0000 (17:09 -0700)]
[lldb] Support simplified template names

See https://discourse.llvm.org/t/dwarf-using-simplified-template-names/58417 for background on simplified template names.

lldb doesn't work with simplified template names because it uses DW_AT_name which doesn't contain template parameters under simplified template names.

Two major changes are required to make lldb work with simplified template names.

1) When building clang ASTs for struct-like dies, we use the name as a cache key. To distinguish between different instantiations of a template class, we need to add in the template parameters.

2) When looking up types, if the requested type name contains '<' and we didn't initially find any types from the index searching the name, strip the template parameters and search the index, then filter out results with non-matching template parameters. This takes advantage of the clang AST's ability to print full names rather than doing it by ourself.

An alternative is to fix up the names in the index to contain the fully qualified name, but that doesn't respect .debug_names.

Reviewed By: labath

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

21 months ago[Driver] Use addOptInFlag/addOptOutFlag. NFC
Fangrui Song [Fri, 28 Oct 2022 23:15:14 +0000 (16:15 -0700)]
[Driver] Use addOptInFlag/addOptOutFlag. NFC

21 months ago[mlir][arm][sve] fix broken integration tests
Aart Bik [Fri, 28 Oct 2022 23:02:33 +0000 (16:02 -0700)]
[mlir][arm][sve] fix broken integration tests

Reviewed By: Peiming

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