platform/upstream/llvm.git
2 years ago[DAG] visitSMUL_LOHI/visitUMUL_LOHI - ensure we canonicalize constants to the RHS
Simon Pilgrim [Sun, 24 Jul 2022 15:09:52 +0000 (16:09 +0100)]
[DAG] visitSMUL_LOHI/visitUMUL_LOHI - ensure we canonicalize constants to the RHS

2 years ago[X86] Autogenerate some of the fp128 tests. NFC
Amaury Séchet [Sun, 24 Jul 2022 14:32:36 +0000 (14:32 +0000)]
[X86] Autogenerate some of the fp128 tests. NFC

2 years ago[DAG] getNode - assert that SMUL_LOHI/UMUL_LOHI nodes have the correct ops + types
Simon Pilgrim [Sun, 24 Jul 2022 14:23:13 +0000 (15:23 +0100)]
[DAG] getNode - assert that SMUL_LOHI/UMUL_LOHI nodes have the correct ops + types

2 years ago[X86] Regenerate hoist-and-by-const-from-lshr-in-eqcmp-zero.ll with common SSE2 prefix
Simon Pilgrim [Sun, 24 Jul 2022 13:48:18 +0000 (14:48 +0100)]
[X86] Regenerate hoist-and-by-const-from-lshr-in-eqcmp-zero.ll with common SSE2 prefix

2 years ago[Clang] Add missing paper revisions in the release notes [NFC]
Corentin Jabot [Sun, 24 Jul 2022 14:24:11 +0000 (16:24 +0200)]
[Clang] Add missing paper revisions in the release notes [NFC]

2 years ago[clang] Fix incorrect constant folding of `if consteval`
Corentin Jabot [Sun, 24 Jul 2022 06:55:49 +0000 (08:55 +0200)]
[clang] Fix incorrect constant folding of `if consteval`

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

`if consteval` was evaluated incorrectly when in a
non-constant context that could be constant-folded.

Reviewed By: aaron.ballman

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

2 years ago[Clang] De-deprecate volatile compound operations
Corentin Jabot [Sat, 23 Jul 2022 12:38:48 +0000 (14:38 +0200)]
[Clang] De-deprecate volatile compound operations

As per P2327R1,

|=, &= and ^= are no longer deprecated in all languages mode.

Reviewed By: aaron.ballman

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

2 years agoFix crash in ObjC codegen introduced with 5ab6ee75994d645725264e757d67bbb1c96fb2b6
David Chisnall [Sun, 24 Jul 2022 10:56:12 +0000 (11:56 +0100)]
Fix crash in ObjC codegen introduced with 5ab6ee75994d645725264e757d67bbb1c96fb2b6

5ab6ee75994d645725264e757d67bbb1c96fb2b6 assumed that if `RValue::isScalar()` returns true then `RValue::getScalarVal` will return a valid value.  This is not the case when the return value is `void` and so void message returns would crash if they hit this path.  This is triggered only for cases where the nil-handling path needs to do something non-trivial (destroy arguments that should be consumed by the callee).

Reviewed By: triplef

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

2 years ago[DAG] MaskedVectorIsZero - don't bother with (-1).isSubsetOf mask check. NFC.
Simon Pilgrim [Sun, 24 Jul 2022 12:12:21 +0000 (13:12 +0100)]
[DAG] MaskedVectorIsZero - don't bother with (-1).isSubsetOf mask check. NFC.

Just use KnownBits::isZero() to ensure all the bits are known zero.

2 years ago[DAG] SimplifyMultipleUseDemandedBits - early-out for any scalable vector types
Simon Pilgrim [Sun, 24 Jul 2022 11:59:43 +0000 (12:59 +0100)]
[DAG] SimplifyMultipleUseDemandedBits - early-out for any scalable vector types

Noticed while working to remove SelectionDAG::GetDemandedBits - we were relying on the callers to have already bailed for scalable vectors

2 years ago[DAG] SimplifyDemandedVectorElts - if every and/mul element-pair has a zero/undef...
Simon Pilgrim [Sun, 24 Jul 2022 11:00:31 +0000 (12:00 +0100)]
[DAG] SimplifyDemandedVectorElts - if every and/mul element-pair has a zero/undef then just constant fold to zero

2 years ago[X86] combineAndnp - remove unused variable. NFC.
Simon Pilgrim [Sun, 24 Jul 2022 10:32:44 +0000 (11:32 +0100)]
[X86] combineAndnp - remove unused variable. NFC.

2 years ago[X86][SSE] Enable X86ISD::ANDNP constant folding
Simon Pilgrim [Sun, 24 Jul 2022 10:07:34 +0000 (11:07 +0100)]
[X86][SSE] Enable X86ISD::ANDNP constant folding

2 years ago[X86] Don't assume an AND/ANDNP element is undef/undemanded just because one element...
Simon Pilgrim [Sun, 24 Jul 2022 09:53:38 +0000 (10:53 +0100)]
[X86] Don't assume an AND/ANDNP element is undef/undemanded just because one element is undef

For mask ops like these, the other operand's corresponding element might be zero (result = zero) - so we must demand all the bits and that element.

This appears to be what D128570 was trying to fix - both sides of the funnel shift mask of the vXi64 (legalized to v2Xi32) were incorrectly simplifying the upper 32-bit halves to undef, resulting in bad folds later on.

I intend to address the test case regressions, but this close to the release branch I'd prefer to get a fix in first.

2 years ago[MC] Remove unused renameELFSection
Fangrui Song [Sun, 24 Jul 2022 08:23:07 +0000 (01:23 -0700)]
[MC] Remove unused renameELFSection

2 years ago[MC] Delete dead zlib-gnu code and simplify writeSectionData
Fangrui Song [Sun, 24 Jul 2022 08:17:34 +0000 (01:17 -0700)]
[MC] Delete dead zlib-gnu code and simplify writeSectionData

2 years ago[clangd] Do not try to use $0 as a placeholder in completion snippets
Nathan Ridge [Mon, 18 Jul 2022 07:48:04 +0000 (03:48 -0400)]
[clangd] Do not try to use $0 as a placeholder in completion snippets

$0 can only be used as a tab stop, not as a placeholder (e.g.
`${0:expression}` is not valid)

Fixes https://github.com/clangd/clangd/issues/1190

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

2 years agoRevert "[Orc] Use default member initialization (NFC)"
Kazu Hirata [Sun, 24 Jul 2022 04:10:10 +0000 (21:10 -0700)]
Revert "[Orc] Use default member initialization (NFC)"

This reverts commit d534967b6667c468b12e9ed5e3c482f590dde633.

The patch causes build failures, such as:

https://lab.llvm.org/buildbot/#/builders/121/builds/21760

2 years ago[Hexagon] Remove unused declaration getByteVectorTy (NFC)
Kazu Hirata [Sun, 24 Jul 2022 02:40:43 +0000 (19:40 -0700)]
[Hexagon] Remove unused declaration getByteVectorTy (NFC)

The declaration was introduced without a corresponding definition on
Sep 7, 2020 in commit f5d07a05bbd41f827ccfa1bed7bfdfbab2be85dc.

2 years ago[Passes] Simplify ChangePrinter names. NFC
Fangrui Song [Sun, 24 Jul 2022 02:32:13 +0000 (19:32 -0700)]
[Passes] Simplify ChangePrinter names. NFC

2 years ago[libcxx] Remove static inline and make use of _LIBCPP_HIDE_FROM_ABI in __support...
Brad Smith [Sun, 24 Jul 2022 02:09:58 +0000 (22:09 -0400)]
[libcxx] Remove static inline and make use of _LIBCPP_HIDE_FROM_ABI in __support/xlocale/__nop_locale_mgmt.h header

Reviewed By: ldionne

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

2 years ago[Analysis] Use default member initialization (NFC)
Kazu Hirata [Sun, 24 Jul 2022 01:36:24 +0000 (18:36 -0700)]
[Analysis] Use default member initialization (NFC)

2 years ago[Orc] Use default member initialization (NFC)
Kazu Hirata [Sun, 24 Jul 2022 01:36:23 +0000 (18:36 -0700)]
[Orc] Use default member initialization (NFC)

Identified with modernize-use-default-member-init

2 years ago[RISCV] Add a continue to reduce nesting. NFC
Craig Topper [Sat, 23 Jul 2022 23:40:29 +0000 (16:40 -0700)]
[RISCV] Add a continue to reduce nesting. NFC

2 years agoclang/include/clang/module.modulemap: Mark `Tooling/Inclusions/*.inc` as textual.
NAKAMURA Takumi [Sun, 24 Jul 2022 00:28:08 +0000 (09:28 +0900)]
clang/include/clang/module.modulemap: Mark `Tooling/Inclusions/*.inc` as textual.

Fixes llvmorg-15-init-917-g46a6f5ae148a

2 years ago[CodeGen] Use range-based for loops (NFC)
Kazu Hirata [Sat, 23 Jul 2022 23:10:46 +0000 (16:10 -0700)]
[CodeGen] Use range-based for loops (NFC)

2 years ago[IPO] Use std::array for AccessKind2Accesses (NFC)
Kazu Hirata [Sat, 23 Jul 2022 22:47:53 +0000 (15:47 -0700)]
[IPO] Use std::array for AccessKind2Accesses (NFC)

Switching to std:array allow us to use fill.

While I am at it, this patch also converts one for loop to a
range-based one.

2 years ago[lldb] Adapt lldb tests to changes in 71cdb8c6f144
Augusto Noronha [Sat, 23 Jul 2022 22:37:15 +0000 (15:37 -0700)]
[lldb] Adapt lldb tests to changes in 71cdb8c6f144

2 years ago[LegacyPM] Remove {,PostInline}EntryExitInstrumenterPass
Fangrui Song [Sat, 23 Jul 2022 22:30:15 +0000 (15:30 -0700)]
[LegacyPM] Remove {,PostInline}EntryExitInstrumenterPass

Following recent changes removing non-core features of the legacy
PM/optimization pipeline.

2 years agoAutogenerate tests for win64-byval.ll . NFC
Amaury Séchet [Sat, 23 Jul 2022 21:51:50 +0000 (21:51 +0000)]
Autogenerate tests for win64-byval.ll . NFC

2 years agofix tests for commit 9df0b254d24eca098
Nuno Lopes [Sat, 23 Jul 2022 21:32:30 +0000 (22:32 +0100)]
fix tests for commit 9df0b254d24eca098

2 years ago[NFC] Switch a few uses of undef to poison as placeholders for unreachable code
Nuno Lopes [Sat, 23 Jul 2022 20:50:11 +0000 (21:50 +0100)]
[NFC] Switch a few uses of undef to poison as placeholders for unreachable code

2 years ago[Vectorize] Remove isConsecutiveLoadOrStore (NFC)
Kazu Hirata [Sat, 23 Jul 2022 20:01:14 +0000 (13:01 -0700)]
[Vectorize] Remove isConsecutiveLoadOrStore (NFC)

The last use was removed on Jan 4, 2022 in commit
95a93722db2d10753f8887cf6a61380936d32f1c.

2 years ago[AMDGPU] Remove a redundant variable (NFC)
Kazu Hirata [Sat, 23 Jul 2022 19:29:05 +0000 (12:29 -0700)]
[AMDGPU] Remove a redundant variable (NFC)

ArrayRef has operator[], so we don't need to access the contents via
data().

2 years agoConvert for_each to range-based for loops (NFC)
Kazu Hirata [Sat, 23 Jul 2022 19:17:27 +0000 (12:17 -0700)]
Convert for_each to range-based for loops (NFC)

2 years ago[Analysis] Remove a redundant return statement (NFC)
Kazu Hirata [Sat, 23 Jul 2022 18:35:19 +0000 (11:35 -0700)]
[Analysis] Remove a redundant return statement (NFC)

Identified with readability-redundant-control-flow.

2 years ago[AMDGPU] Change DEBUG_TYPE from isel to amdgpu-isel
Fangrui Song [Sat, 23 Jul 2022 18:32:02 +0000 (11:32 -0700)]
[AMDGPU] Change DEBUG_TYPE from isel to amdgpu-isel

to match all other *ISelDAGToDAG.cpp

2 years ago[TableGen] Drop an unnecessary const from a return type (NFC)
Kazu Hirata [Sat, 23 Jul 2022 18:30:23 +0000 (11:30 -0700)]
[TableGen] Drop an unnecessary const from a return type (NFC)

This patch also drops "&" that binds to a temporary.

Identified with readability-const-return-type.

2 years ago[ADT] Use default member initialization (NFC)
Kazu Hirata [Sat, 23 Jul 2022 17:50:26 +0000 (10:50 -0700)]
[ADT] Use default member initialization (NFC)

Identified with modernize-use-default-member-init.

2 years ago[flang] Correct IsHostAssociated() to be true for BLOCK constructs
Peter Klausler [Fri, 22 Jul 2022 18:51:20 +0000 (11:51 -0700)]
[flang] Correct IsHostAssociated() to be true for BLOCK constructs

The predicate IsHostAssocited() was implemented in a way that would
return true only for cases of host association into a module or inner
subprogram.  Technically, the use of a name in a BLOCK construct
that is not declared therein is considered in the Fortran standard
to also be a form of host association, and this matters when doing
error checking on DATA statements.

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

2 years ago[DAG] isSplatValue - don't attempt to merge any BITCAST sub elements if they contain...
Simon Pilgrim [Sat, 23 Jul 2022 17:38:48 +0000 (18:38 +0100)]
[DAG] isSplatValue - don't attempt to merge any BITCAST sub elements if they contain UNDEFs

We still haven't found a solution that correctly handles 'don't care' sub elements properly - given how close it is to the next release branch, I'm making this fail safe change and we can revisit this later if we can't find alternatives.

NOTE: This isn't a reversion of D128570 - it's the removal of undef handling across bitcasts entirely

Fixes #56520

2 years ago[X86] Add test case for Issue #56520
Simon Pilgrim [Sat, 23 Jul 2022 17:18:39 +0000 (18:18 +0100)]
[X86] Add test case for Issue #56520

2 years ago[flang] Clean up bogus semantic error on procedure pointer assignment
Peter Klausler [Mon, 18 Jul 2022 21:12:21 +0000 (14:12 -0700)]
[flang] Clean up bogus semantic error on procedure pointer assignment

When a procedure pointer with no interface is associated with
an EXTERNAL name with no interface information, but it is later
inferred that the procedure pointer must be a subroutine because it
appears in a CALL statement, don't complain that the EXTERNAL name
is not also known to be a subroutine.

Subroutine vs. function errors are still caught in procedure pointer
assignment compatibility checking; this fix simply ensures that those
more nuanced tests are not overridded by the attribute set equality test.

Also, leave in some code for dumping the differing attributes in legitimate
error cases that was added in the coures of debugging the specific problem.

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

2 years ago[lld-macho][nfc] Reduce nesting of code added in D130125
Jez Ng [Sat, 23 Jul 2022 16:21:46 +0000 (12:21 -0400)]
[lld-macho][nfc] Reduce nesting of code added in D130125

2 years ago[flang] Don't fold zero-length substring references
Peter Klausler [Mon, 18 Jul 2022 20:13:03 +0000 (13:13 -0700)]
[flang] Don't fold zero-length substring references

In some contexts the code looks cleaner if we fold zero-length substring
references into empty character constants, but those don't work in
variable definition contexts and can lead to bogus semantic error
messages.

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

2 years agoRevert "[NFC] Improve FileSpec internal APIs and usage in preparation for adding...
Nico Weber [Sat, 23 Jul 2022 16:31:31 +0000 (12:31 -0400)]
Revert "[NFC] Improve FileSpec internal APIs and usage in preparation for adding caching of resolved/absolute." and follow-ups

This reverts commit 9429b67b8e300e638d7828bbcb95585f85c4df4d.

It broke the build on Windows, see comments on https://reviews.llvm.org/D130309

It also reverts these follow-ups:

Revert "Fix buildbot breakage after https://reviews.llvm.org/D130309."
This reverts commit f959d815f4637890ebbacca379f1c38ab47e4e14.

Revert "Fix buildbot breakage after https://reviews.llvm.org/D130309."
This reverts commit 0bbce7a4c2d2bff622bdadd4323f93f5d90e6d24.

Revert "Cache the value for absolute path in FileSpec."
This reverts commit dabe877248b85b34878e75d5510339325ee087d0.

2 years ago[flang] Fix name of dummy argument to intrinsic NEW_LINE(A='')
Peter Klausler [Mon, 18 Jul 2022 18:30:29 +0000 (11:30 -0700)]
[flang] Fix name of dummy argument to intrinsic NEW_LINE(A='')

It should be A= but I misspelled it in the intrinsics table as X=.

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

2 years agoFix one stray `{LLVM -> CLANG}_TOOLS_INSTALL_DIR`
John Ericson [Fri, 22 Jul 2022 14:24:54 +0000 (14:24 +0000)]
Fix one stray `{LLVM -> CLANG}_TOOLS_INSTALL_DIR`

Follow up to D117977, where I missed this new usage after one rebase.

Thanks @tsteller in https://reviews.llvm.org/D117977#3670919 for
noticing.

Reviewed By: mstorsjo

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

2 years agoUse static_assert instead of assert (NFC)
Kazu Hirata [Sat, 23 Jul 2022 16:22:27 +0000 (09:22 -0700)]
Use static_assert instead of assert (NFC)

Identified with misc-static-assert.

2 years ago[lld-macho] Fold __objc_imageinfo sections
Jez Ng [Sat, 23 Jul 2022 16:11:46 +0000 (12:11 -0400)]
[lld-macho] Fold __objc_imageinfo sections

Previously, we treated it as a regular ConcatInputSection. However, ld64
actually parses its contents and uses that to synthesize a single image
info struct, generating one 8-byte section instead of `8 * number of
object files with ObjC code`.

I'm not entirely sure what impact this section has on the runtime, so I
just tried to follow ld64's semantics as closely as possible in this
diff. My main motivation though was to reduce binary size.

No significant perf change on chromium_framework on my 16-core Mac Pro:

             base           diff           difference (95% CI)
  sys_time   1.764 ± 0.062  1.748 ± 0.032  [  -2.4% ..   +0.5%]
  user_time  5.112 ± 0.104  5.106 ± 0.046  [  -0.9% ..   +0.7%]
  wall_time  6.111 ± 0.184  6.085 ± 0.076  [  -1.6% ..   +0.8%]
  samples    30             32

Reviewed By: #lld-macho, thakis

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

2 years ago[X86] matchBinaryShuffle - limit SHUFFLE(X,Y) -> OR(X,Y) cases to where X + Y are...
Simon Pilgrim [Sat, 23 Jul 2022 15:56:39 +0000 (16:56 +0100)]
[X86] matchBinaryShuffle - limit SHUFFLE(X,Y) -> OR(X,Y) cases to where X + Y are the same width as the result

Minor bit of prep work toward not unnecessarily widening shuffle operands in combineX86ShufflesRecursively, instead only widening in combineX86ShuffleChain if we actual find a match - see Issue #45319

2 years ago[lld-macho] Fix segfault when handling LTO + object file weak defs
Jez Ng [Sat, 23 Jul 2022 15:47:44 +0000 (11:47 -0400)]
[lld-macho] Fix segfault when handling LTO + object file weak defs

which occurs when there are EH frames present in the object file's weak
def.

Reviewed By: abrachet

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

2 years ago[IR] Fixed ambiguous call to llvm::report_fatal_error
Dmitry Vassiliev [Sat, 23 Jul 2022 14:28:18 +0000 (16:28 +0200)]
[IR] Fixed ambiguous call to llvm::report_fatal_error

This patch fixes the following error with MSVC 16.9.2:
llvm/lib/IR/GCStrategy.cpp(35): error C2668: 'llvm::report_fatal_error': ambiguous call to overloaded function
llvm/include/llvm/Support/ErrorHandling.h(75): note: could be 'void llvm::report_fatal_error(const llvm::Twine &,bool)'
llvm/include/llvm/Support/ErrorHandling.h(73): note: or 'void llvm::report_fatal_error(llvm::StringRef,bool)'
llvm/lib/IR/GCStrategy.cpp(35): note: while trying to match the argument list '(const std::string)'

Reviewed By: RKSimon, barannikov88

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

2 years agoUse llvm::sort instead of std::sort where possible
Dmitri Gribenko [Sat, 23 Jul 2022 13:14:14 +0000 (15:14 +0200)]
Use llvm::sort instead of std::sort where possible

llvm::sort is beneficial even when we use the iterator-based overload,
since it can optionally shuffle the elements (to detect
non-determinism). However llvm::sort is not usable everywhere, for
example, in compiler-rt.

Reviewed By: nhaehnle

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

2 years ago[Clang] Update the status of N2393 in c_status.html
Corentin Jabot [Sat, 23 Jul 2022 13:15:12 +0000 (15:15 +0200)]
[Clang] Update the status of N2393 in c_status.html

2 years agoUse the range-based overload of llvm::sort where possible
Dmitri Gribenko [Sat, 23 Jul 2022 13:07:49 +0000 (15:07 +0200)]
Use the range-based overload of llvm::sort where possible

Reviewed By: MaskRay

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

2 years ago[DAG] Move OR(AND(X,C1),AND(OR(X,Y),C2)) -> OR(AND(X,OR(C1,C2)),AND(Y,C2)) fold to...
Simon Pilgrim [Sat, 23 Jul 2022 12:11:07 +0000 (13:11 +0100)]
[DAG] Move OR(AND(X,C1),AND(OR(X,Y),C2)) -> OR(AND(X,OR(C1,C2)),AND(Y,C2)) fold to SimplifyDemandedBits

This will fix the SystemZ v3i31 memcpy regression in D77804 (with the help of D129765 as well....).

It should also allow us to /bend/ the oneuse limitation for cases where we can use demanded bits to safely peek though multiple uses of the AND ops.

2 years ago[Clang] Adjust extension warnings for #warning
Corentin Jabot [Sat, 23 Jul 2022 09:08:14 +0000 (11:08 +0200)]
[Clang] Adjust extension warnings for #warning

The #warning directive is standard in C++2b and C2x,
this adjusts the pedantic and extensions warning accordingly.

Reviewed By: aaron.ballman

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

2 years ago[Clang] Add support for Unicode identifiers (UAX31) in C2x mode.
Corentin Jabot [Sat, 23 Jul 2022 10:18:01 +0000 (12:18 +0200)]
[Clang] Add support for Unicode identifiers (UAX31) in C2x mode.

This implements
N2836 Identifier Syntax using Unicode Standard Annex 31.

The feature was already implemented for C++,
and the semantics are the same.

Unlike C++ there was, afaict, no decision to
backport the feature in older languages mode,
so C17 and earlier are not modified and the
code point tables for these language modes are conserved.

Reviewed By: aaron.ballman

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

2 years ago[bazel] Add missing dependencies after 535b507ba58e8b5f604d53ffc961be1456d229a7
Benjamin Kramer [Sat, 23 Jul 2022 11:25:23 +0000 (13:25 +0200)]
[bazel] Add missing dependencies after 535b507ba58e8b5f604d53ffc961be1456d229a7

2 years ago[DAG] SimplifyDemandedBits - pull out repeated getValueType() calls. NFC.
Simon Pilgrim [Sat, 23 Jul 2022 11:01:54 +0000 (12:01 +0100)]
[DAG] SimplifyDemandedBits - pull out repeated getValueType() calls. NFC.

2 years ago[DAG] ExpandIntRes_ADDSUB - create UADDO/USUBO instead of ADDCARRY/SUBCARRY if overfl...
Simon Pilgrim [Sat, 23 Jul 2022 10:13:37 +0000 (11:13 +0100)]
[DAG] ExpandIntRes_ADDSUB - create UADDO/USUBO instead of ADDCARRY/SUBCARRY if overflow is known to be zero

As noticed on D127115, when splitting ADD/SUB nodes we often end up with cases where overflow from the lower bits is impossible - in such cases we're better off breaking the carry chain dependency as soon as possible.

This path is being exercised by llvm/test/CodeGen/ARM/dsp-mlal.ll, although I haven't been able to get any codegen diff without a topological worklist.

2 years ago[MIPS][compiler-rt] Fix stat struct's size for O32 ABI
Dimitrije Milosevic [Sat, 23 Jul 2022 08:24:15 +0000 (10:24 +0200)]
[MIPS][compiler-rt] Fix stat struct's size for O32 ABI

Add the MIPS O32 ABI value for the stat struct's size.

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

2 years ago[DAG] computeKnownBits - add basic shift-by-parts handling
Simon Pilgrim [Sat, 23 Jul 2022 08:46:30 +0000 (09:46 +0100)]
[DAG] computeKnownBits - add basic shift-by-parts handling

Concat KnownBits from ISD::SHL_PARTS / ISD::SRA_PARTS / ISD::SRL_PARTS lo/hi operands and perform the KnownBits calculation by the shift amount on the extended type, before splitting the KnownBits based on the requested lo/hi result.

2 years agoUse callables directly in any_of, count_if, etc (NFC)
Kazu Hirata [Sat, 23 Jul 2022 07:28:31 +0000 (00:28 -0700)]
Use callables directly in any_of, count_if, etc (NFC)

2 years ago[flang] Support aint/anint for 80/128 bit in lowering
Peixin Qiao [Sat, 23 Jul 2022 06:44:20 +0000 (14:44 +0800)]
[flang] Support aint/anint for 80/128 bit in lowering

For aint/anint, LLVM conversion operations llvm.trunc and llvm.round
can support the edge case of aint(-0.) and anint(-0.). The output is -0.
and it is the same of `gfortran` and `classic flang`, while the output
of `ifort` is 0.. The `real(10)/real(16)` is not supported before.
Support it and remove the runtime functions for aint/anint.

For nint, `gfortran`, `ifort`, and LLVM Flang using llvm.lround have
different results when the magnitude of argument is more than the max of
result value range. So delay its support in lowering after more
investigations.

Reviewed By: vzakhari

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

2 years ago[mlir] Use value instead of getValue (NFC)
Kazu Hirata [Sat, 23 Jul 2022 06:33:46 +0000 (23:33 -0700)]
[mlir] Use value instead of getValue (NFC)

2 years agoUse has_value instead of hasValue (NFC)
Kazu Hirata [Sat, 23 Jul 2022 06:04:38 +0000 (23:04 -0700)]
Use has_value instead of hasValue (NFC)

2 years ago[NFC] Move function definition to cpp file
Jun Zhang [Sat, 23 Jul 2022 04:29:18 +0000 (12:29 +0800)]
[NFC] Move function definition to cpp file

Signed-off-by: Jun Zhang <jun@junz.org>
2 years ago[Attributor][FIX] HasBeenWrittenTo logic should only be used for reads
Johannes Doerfert [Sat, 23 Jul 2022 04:56:12 +0000 (23:56 -0500)]
[Attributor][FIX] HasBeenWrittenTo logic should only be used for reads

If we look at a write, we should not enact the "has been written to"
logic introduced to avoid spurious write -> read dependences. Doing so
lead to elimination of stores we needed, which is obviously bad.

2 years ago[flang] Fold calls to ISHFTC()
Peter Klausler [Sat, 16 Jul 2022 00:33:44 +0000 (17:33 -0700)]
[flang] Fold calls to ISHFTC()

The integer arithmetic template supports ISHFTC() but the
integer intrinsic folding code had yet to call it; finish
the job.

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

2 years ago[flang] Fix a warning
Kazu Hirata [Sat, 23 Jul 2022 00:56:10 +0000 (17:56 -0700)]
[flang] Fix a warning

This patch fixes:

  llvm-project/flang/lib/Semantics/expression.cpp:405:12: error:
  moving a local object in a return statement prevents copy elision
  [-Werror,-Wpessimizing-move]

2 years ago[libasan] Remove 4Mb stack limit for swapcontext unpoisoning
Ivan Trofimov [Mon, 11 Jul 2022 17:12:31 +0000 (10:12 -0700)]
[libasan] Remove 4Mb stack limit for swapcontext unpoisoning

Reviewed By: vitalybuka, eugenis

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

2 years ago[flang] Correct folding of TRANSFER(integer, character array)
Peter Klausler [Fri, 15 Jul 2022 19:15:07 +0000 (12:15 -0700)]
[flang] Correct folding of TRANSFER(integer, character array)

The code that copies data from a constant source array into a character
array constant result was failing to copy its last element if it was
only partially defined due to misalignment.

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

2 years ago[Driver] Error for -gsplit-dwarf with RISC-V linker relaxation
Fangrui Song [Sat, 23 Jul 2022 00:16:41 +0000 (17:16 -0700)]
[Driver] Error for -gsplit-dwarf with RISC-V linker relaxation

-gsplit-dwarf produces a .dwo file which will not be processed by the linker. If
.dwo files contain relocations, they will not be resolved. Therefore the
practice is that .dwo files do not contain relocations.

Address ranges and location description need to use forms/entry kinds indexing
into .debug_addr (DW_FORM_addrx/DW_RLE_startx_endx/etc), which is currently not
implemented.

There is a difficult-to-read MC error with -gsplit-dwarf with RISC-V for both -mrelax and -mno-relax.
```
% clang --target=riscv64-linux-gnu -g -gsplit-dwarf -c a.c
error: A dwo section may not contain relocations
```

We expect to fix -mno-relax soon, so report a driver error for -mrelax for now.

Link: https://github.com/llvm/llvm-project/issues/56642
Reviewed By: compnerd, kito-cheng

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

2 years ago[flang] Fix parsing and semantics for array element substring%KIND/%LEN
Peter Klausler [Fri, 22 Jul 2022 17:52:30 +0000 (10:52 -0700)]
[flang] Fix parsing and semantics for array element substring%KIND/%LEN

A type-param-inquiry of %KIND or %LEN applies to a designator, and
so must also be allowed for a substring.  F18 presently (mis)parses
instances of a type-param-inquiry as structure component references
and then fixes them in expression semantics when types are known and
we can distinguish them.  But when the base of a type-param-inquiry is
a substring of an array element, as in "charArray(i)(j:k)%len",
parsing fails.

Adjust the grammar to parse these cases, and extend expression semantics
to process the new production.

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

2 years ago[Lit] Pass through DFLTCC from the surrounding environment
Ilya Leoshkevich [Fri, 22 Jul 2022 23:38:26 +0000 (01:38 +0200)]
[Lit] Pass through DFLTCC from the surrounding environment

Many distros ship zlib with the IBM Z deflate hardware acceleration
patch [1]. Sometimes it's desirable to disable the acceleration, for
example, for reproducibility. This can be done by exporting DFLTCC=0.
llvm-lit clears this environment variable, which causes
compress-debug-sections-zlib.test fail on z15 and later machines. Add
DFLTCC to the list of variables to keep.

[1] https://github.com/madler/zlib/pull/410

Reviewed By: abrachet

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

2 years ago[clang][dataflow] Add DataflowEnvironment::dump()
Dmitri Gribenko [Fri, 22 Jul 2022 23:23:17 +0000 (01:23 +0200)]
[clang][dataflow] Add DataflowEnvironment::dump()

Start by dumping the flow condition.

Reviewed By: ymandel

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

2 years agoMove "clang/Basic/TokenKinds.h" into a separate top-level module.
Volodymyr Sapsai [Fri, 22 Jul 2022 18:43:07 +0000 (11:43 -0700)]
Move "clang/Basic/TokenKinds.h" into a separate top-level module.

Fixes modular build for clangPseudoGrammar from clang-tools-extra.

Starting from https://reviews.llvm.org/D126731 clangPseudoGrammar
doesn't depend on generated .inc headers but still depends on
"Basic/TokenKinds.h". It means clangPseudoGrammar depends on module
'Clang_Basic' which does depend on generated .inc headers. To avoid
these coarse dependencies and extra build steps, extract
"clang/Basic/TokenKinds.h" into a top-level module 'Clang_Basic_TokenKinds'.

rdar://97387951

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

2 years ago[flang] Admit trailing blanks when checking I/O specifiers
Peter Klausler [Mon, 18 Jul 2022 18:16:01 +0000 (11:16 -0700)]
[flang] Admit trailing blanks when checking I/O specifiers

Fortran specifically allows character-valued I/O specifiers
to have trailing blanks, e.g. OPEN(666,STATUS='SCRATCH ').
The runtime I/O library already handles them, but the I/O
static checks in semantics do not.

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

2 years ago[clang][dataflow] Expose stringification functions for SAT solver enums
Dmitri Gribenko [Fri, 22 Jul 2022 23:18:03 +0000 (01:18 +0200)]
[clang][dataflow] Expose stringification functions for SAT solver enums

Reviewed By: ymandel

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

2 years ago[libc++][test] Fix infinite loop when mkstemp fails
Ryan Prichard [Fri, 22 Jul 2022 23:20:47 +0000 (16:20 -0700)]
[libc++][test] Fix infinite loop when mkstemp fails

mkstemp is guaranteed to make at least TMP_MAX attempts to create the
random file, and if it can't, it fails with EEXIST. get_temp_file_name
shouldn't call mkstemp again if it fails with anything other than
EEXIST. A single mkstemp call seems sufficient.

On Android, I've seen mkstemp fail with:
 - EROFS (because cwd wasn't set to a writable filesystem)
 - EACCES (because cwd pointed to a dir owned by root, but the test
   program was running as the shell user instead)

Previously, get_temp_file_name would run forever in these situations.

See D4962 and "llvm-svn: 229035"

Reviewed By: #libc, ldionne

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

2 years ago[clang][dataflow] ArrayRef'ize debugString()
Dmitri Gribenko [Fri, 22 Jul 2022 23:13:24 +0000 (01:13 +0200)]
[clang][dataflow] ArrayRef'ize debugString()

Reviewed By: ymandel

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

2 years ago[lldb] Remote accidental logs left in TestGuiExpandThreadsTree
Augusto Noronha [Fri, 22 Jul 2022 23:06:49 +0000 (16:06 -0700)]
[lldb] Remote accidental logs left in TestGuiExpandThreadsTree

2 years ago[lldb] Disable TestGuiExpandThreadsTree
Augusto Noronha [Fri, 22 Jul 2022 22:59:58 +0000 (15:59 -0700)]
[lldb] Disable TestGuiExpandThreadsTree

2 years ago[flang] Fold SET_EXPONENT() and FRACTION()
Peter Klausler [Fri, 15 Jul 2022 21:34:32 +0000 (14:34 -0700)]
[flang] Fold SET_EXPONENT() and FRACTION()

Fold the intrinsic function SET_EXPONENT() and its special case,
FRACTION().

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

2 years agoRevert "[lldb/Fuzzer] Add fuzzer for expression evaluator"
Med Ismail Bennani [Fri, 22 Jul 2022 22:21:34 +0000 (15:21 -0700)]
Revert "[lldb/Fuzzer] Add fuzzer for expression evaluator"

This reverts commit b797834748f1954950880bf50fb78abedd4494e6, since it
breaks building Clang: https://reviews.llvm.org/D129377

2 years agoAdd a nop instruction if a section starts with landing pad for function splitter
ARCHIT SAXENA [Fri, 22 Jul 2022 22:02:16 +0000 (15:02 -0700)]
Add a nop instruction if a section starts with landing pad for function splitter

This change adds a nop instruction if section starts with landing pad. This change is like [D73739](https://reviews.llvm.org/D73739) which avoids zero offset landing pad in basic block sections.

Detailed description:
The current machine functions splitter can create ˜sections which start with a landing pad themselves. This places landing pad at offset zero from LPStart.
```
.section .text.split.foo10,"ax",@progbits
foo10.cold:                             # %lpad
.cfi_startproc
.cfi_personality 3, __gxx_personality_v0
.cfi_lsda 3, .Lexception5
.cfi_def_cfa %rsp, 16
.Ltmp11: <--- This is a Landing pad and also LP Start as it is start of this section
movq %rax, %rdi <--- first instruction is at offest 0 from LPStart
callq _Unwind_Resume@PLT

 ```
This will cause landing pad entries to become zero (.Ltmp11-foo10.cold)
```
.Lcst_begin4:
.uleb128 .Ltmp9-.Lfunc_begin2           # >> Call Site 1 <<
.uleb128 .Ltmp10-.Ltmp9                 #   Call between .Ltmp9 and .Ltmp10
.uleb128 .Ltmp11-foo10.cold  <---This is zero           #     jumps to .Ltmp11
.byte 3                               #   On action: 2
.uleb128 .Ltmp10-.Lfunc_begin2          # >> Call Site 2 <<
.uleb128 .Lfunc_end9-.Ltmp10            #   Call between .Ltmp10 and .Lfunc_end9
.byte 0                               #     has no landing pad
.byte 0                               #   On action: cleanup
.p2align 2
```
The C++ ABI somehow assumes that no landing pads point directly to LPStart (which works in the normal case since the function begin is never a landing pad), and uses LP.offset = 0 to specify no landing pad. This change adds a nop instruction at start of such sections so that such a case could be avoided. Output:
```
.section .text.split.foo10,"ax",@progbits
foo10.cold:                             # %lpad
.cfi_startproc
.cfi_personality 3, __gxx_personality_v0
.cfi_lsda 3, .Lexception5
.cfi_def_cfa %rsp, 16
nop <--- new instruction that is added
.Ltmp11:
movq %rax, %rdi
callq _Unwind_Resume@PLT
```

Reviewed By: modimo, snehasish, rahmanl

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

2 years ago[InstCombine] Improve folding of mul + icmp
Alexander Shaposhnikov [Fri, 22 Jul 2022 22:08:47 +0000 (22:08 +0000)]
[InstCombine] Improve folding of mul + icmp

This diff adds folds for patterns like X * A < B
where A, B are constants and "mul" has either "nsw" or "nuw".
(to address https://github.com/llvm/llvm-project/issues/56563).

Test plan:
1/ ninja check-llvm check-clang
2/ Bootstrapped LLVM/Clang pass tests

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

2 years ago[Driver] Report -Wunused-command-line-argument for unimplemented -mtune=
Fangrui Song [Fri, 22 Jul 2022 22:07:28 +0000 (15:07 -0700)]
[Driver] Report -Wunused-command-line-argument for unimplemented -mtune=

Most common architectures (aarch64,riscv,s390x,x86,etc) have implemented -mtune=.
Don't ignore -mtune= in generic code.

2 years ago[Driver][SystemZ] Simplify -mtune
Fangrui Song [Fri, 22 Jul 2022 21:54:27 +0000 (14:54 -0700)]
[Driver][SystemZ] Simplify -mtune

Similar to AArch64.

2 years ago[Driver][RISCV] Simplify -mtune
Fangrui Song [Fri, 22 Jul 2022 21:51:07 +0000 (14:51 -0700)]
[Driver][RISCV] Simplify -mtune

2 years ago[Driver][test] Clean up and improve some -mtune tests
Fangrui Song [Fri, 22 Jul 2022 21:37:58 +0000 (14:37 -0700)]
[Driver][test] Clean up and improve some -mtune tests

Note: we should test CHECK-NOT: "-tune-cpu" instead of CHECK-NOT: "-tune-cpu" "generic"

2 years ago[lldb/Fuzzer] Add fuzzer for expression evaluator
Chelsea Cassanova [Mon, 11 Jul 2022 21:24:50 +0000 (17:24 -0400)]
[lldb/Fuzzer] Add fuzzer for expression evaluator

This commit adds a fuzzer for LLDB's expression evaluator.
The fuzzer takes a different approach than the current fuzzers
present, and uses an approach that is currently being used for
clang fuzzers.

Instead of fuzzing the evaluator with randomly mutated
characters, protobufs are used to generate a subset of C++. This
is then converted to valid C++ code and sent to the expression
evaluator. In addition, libprotobuf_mutator is used to mutate
the fuzzer's inputs from valid C++ code to valid C++ code, rather
than mutating from valid code to total nonsense.

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

2 years ago[Driver][AArch64] Simplify -mtune
Fangrui Song [Fri, 22 Jul 2022 21:19:27 +0000 (14:19 -0700)]
[Driver][AArch64] Simplify -mtune

llvm::sys::getHostCPUName()'s return value is not empty. `-mtune=` (empty value)
has caused a driver error. So we can omit `!TuneCPU.empty()` check.

2 years ago[NVPTX] Promote i24, i40, i48 and i56 to next power-of-two register when passing
Kjetil Kjeka [Fri, 22 Jul 2022 20:59:11 +0000 (13:59 -0700)]
[NVPTX] Promote i24, i40, i48 and i56 to next power-of-two register when passing

Today llc will crash when attempting to use non-power-of-two integer types as
function arguments or returns. This patch enables passing non standard integer
values in functions by promoting them before store and truncating after load.

The main motivation of implementing this change is that rust casts small structs
(less than pointer size) into an integer of the same size. As an example, if a
struct contains three u8 then it will be passed as an i24. This patch is a step
towards enabling rust compilation to ptx while retaining the target independent
optimizations.

More context can be found in https://github.com/llvm/llvm-project/issues/55764

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

2 years agoChanged EOL to UNIX. NFC.
Artem Belevich [Fri, 22 Jul 2022 21:09:42 +0000 (14:09 -0700)]
Changed EOL to UNIX. NFC.

2 years agoCache the value for absolute path in FileSpec.
Greg Clayton [Fri, 22 Jul 2022 20:18:40 +0000 (13:18 -0700)]
Cache the value for absolute path in FileSpec.

Checking if a path is absolute can be expensive and currently the result is not cached in the FileSpec object. This patch adds caching and also code to clear the cache if the file is modified.

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

2 years agoFix buildbot breakage after https://reviews.llvm.org/D130309.
Greg Clayton [Fri, 22 Jul 2022 20:59:06 +0000 (13:59 -0700)]
Fix buildbot breakage after https://reviews.llvm.org/D130309.

2 years ago[runtimes] Add pstl to the list of default runtimes to fix the build
Nikolas Klauser [Sun, 10 Jul 2022 19:58:01 +0000 (21:58 +0200)]
[runtimes] Add pstl to the list of default runtimes to fix the build

Reviewed By: ldionne, #libc, #libc_abi

Spies: h-vetinari, sstefan1, libcxx-commits, mgorny

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