platform/upstream/llvm.git
2 years ago[clang-format] Correctly format loops and `if` statements even if preceded with comments.
Marek Kurdej [Fri, 11 Feb 2022 13:53:36 +0000 (14:53 +0100)]
[clang-format] Correctly format loops and `if` statements even if preceded with comments.

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

Braces in loops and in `if` statements with leading (block) comments were formatted according to `BraceWrapping.AfterFunction` and not `AllowShortBlocksOnASingleLine`/`AllowShortLoopsOnASingleLine`/`AllowShortIfStatementsOnASingleLine`.

Previously, the code:
```
while (true) {
  f();
}
/*comment*/ while (true) {
  f();
}
```

was incorrectly formatted to:
```
while (true) {
  f();
}
/*comment*/ while (true) { f(); }
```

when using config:
```
BasedOnStyle: LLVM
BreakBeforeBraces: Custom
BraceWrapping:
  AfterFunction: false
AllowShortBlocksOnASingleLine: false
AllowShortLoopsOnASingleLine: false
```

and it was (correctly but by chance) formatted to:
```
while (true) {
  f();
}
/*comment*/ while (true) {
  f();
}
```

when using enabling brace wrapping after functions:
```
BasedOnStyle: LLVM
BreakBeforeBraces: Custom
BraceWrapping:
  AfterFunction: true
AllowShortBlocksOnASingleLine: false
AllowShortLoopsOnASingleLine: false
```

Reviewed By: MyDeveloperDay, HazardyKnusperkeks, owenpan

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

2 years ago[sanitizer] Fix test to tolerate chmod not working as intended
Teresa Johnson [Sun, 13 Feb 2022 16:39:59 +0000 (08:39 -0800)]
[sanitizer] Fix test to tolerate chmod not working as intended

Attempts to fix a bot failure from
634da7a1c61ee8c173e90a841eb1f4ea03caa20b on an Android bot:
https://lab.llvm.org/buildbot#builders/77/builds/14339

It appears that the chmod is not making the directory unwritable as
expected on this system for some reason. Adopt an approach used in
compiler-rt/test/fuzzer/fuzzer-dirs.test for systems with
non-functioning chmod by including illegal characters in directory.

2 years ago[X86] vector-reduce-add-sext - add sum of (sign-extended) bool vector tests
Simon Pilgrim [Sun, 13 Feb 2022 19:40:01 +0000 (19:40 +0000)]
[X86] vector-reduce-add-sext - add sum of (sign-extended) bool vector tests

2 years ago[llvm][doc] Add Aarch64 to list of architectures supporting statepoints
Markus Böck [Sun, 13 Feb 2022 10:14:42 +0000 (11:14 +0100)]
[llvm][doc] Add Aarch64 to list of architectures supporting statepoints

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

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

2 years ago[X86] Add AVX512 tests to AVX common check prefix
Simon Pilgrim [Sun, 13 Feb 2022 19:23:16 +0000 (19:23 +0000)]
[X86] Add AVX512 tests to AVX common check prefix

2 years ago[NFC][IR] Value: assert this->takeName(this)
Dmitry Vassiliev [Sun, 13 Feb 2022 18:47:37 +0000 (21:47 +0300)]
[NFC][IR] Value: assert this->takeName(this)

Need to add an assert about this->takeName(this). This restriction is already documented, so this is just an NFC check.
Without this assertion (as prescribed by original comments for this API), name deletion or down-stream assert failures may occur in other routines: e.g. at the beginning of replaceAllUsesWith() below.

Reviewed By: aeubanks

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

2 years ago[mlir][tensor] Check ops generated by InsertSliceOpCastFolder are valid
Ivan Butygin [Sun, 13 Feb 2022 14:51:59 +0000 (17:51 +0300)]
[mlir][tensor] Check ops generated by InsertSliceOpCastFolder are valid

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

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

2 years ago[OpaquePtr][ValueTracking] Check GEP source element type in isPointerOffset()
Arthur Eubanks [Sun, 13 Feb 2022 01:37:20 +0000 (17:37 -0800)]
[OpaquePtr][ValueTracking] Check GEP source element type in isPointerOffset()

Fixes a MemCpyOpt miscompile with opaque pointers.
This function can be further cleaned up, but let's just fix the miscompile first.

Reviewed By: #opaque-pointers, nikic

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

2 years ago[IR] Use default member initialization in IRBuilderBase (NFC)
Kazu Hirata [Sun, 13 Feb 2022 18:34:05 +0000 (10:34 -0800)]
[IR] Use default member initialization in IRBuilderBase (NFC)

2 years ago[Transforms] Use default member initialization in MemmoveVerifier (NFC)
Kazu Hirata [Sun, 13 Feb 2022 18:34:03 +0000 (10:34 -0800)]
[Transforms] Use default member initialization in MemmoveVerifier (NFC)

2 years ago[Transforms] Use default member initialization in Prefetch (NFC)
Kazu Hirata [Sun, 13 Feb 2022 18:34:02 +0000 (10:34 -0800)]
[Transforms] Use default member initialization in Prefetch (NFC)

2 years ago[Transforms] Use default member initialization in ConditionInfo (NFC)
Kazu Hirata [Sun, 13 Feb 2022 18:34:00 +0000 (10:34 -0800)]
[Transforms] Use default member initialization in ConditionInfo (NFC)

2 years ago[Support] Use default member initialization in circular_raw_ostream (NFC)
Kazu Hirata [Sun, 13 Feb 2022 18:33:58 +0000 (10:33 -0800)]
[Support] Use default member initialization in circular_raw_ostream (NFC)

2 years ago[Transforms] Use default member initialization in CHRStats (NFC)
Kazu Hirata [Sun, 13 Feb 2022 18:33:56 +0000 (10:33 -0800)]
[Transforms] Use default member initialization in CHRStats (NFC)

2 years ago[test][ObjectYAML][MachO] Fix assertion syntax
Keith Smiley [Sun, 13 Feb 2022 18:05:50 +0000 (10:05 -0800)]
[test][ObjectYAML][MachO] Fix assertion syntax

This wasn't running because of the missing colon

2 years agoRevert "[AArch64] Adds SUBS and ADDS instructions to the MIPeepholeOpt."
Nathan Chancellor [Sun, 13 Feb 2022 17:23:32 +0000 (10:23 -0700)]
Revert "[AArch64] Adds SUBS and ADDS instructions to the MIPeepholeOpt."

This reverts commit af45d0fd94b21620b61c8c4900b81486fd85aeb7.

This causes assertions failures when compiling the Linux kernel. See
https://reviews.llvm.org/D118663 for a reduced reproducer.

2 years ago[ObjectYAML][MachO] Add LC_FUNCTION_STARTS support
Keith Smiley [Tue, 8 Feb 2022 01:33:32 +0000 (17:33 -0800)]
[ObjectYAML][MachO] Add LC_FUNCTION_STARTS support

This adds support for encoding and decoding the LC_FUNCTION_STARTS load
command payload.

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

2 years ago[Shape] Simplify getShapeVec a bit. NFCI.
Benjamin Kramer [Sun, 13 Feb 2022 15:57:48 +0000 (16:57 +0100)]
[Shape] Simplify getShapeVec a bit. NFCI.

2 years ago[sanitizer] Check if directory exists before trying to create
Teresa Johnson [Thu, 10 Feb 2022 23:42:38 +0000 (15:42 -0800)]
[sanitizer] Check if directory exists before trying to create

Add a DirExists mechanism, modeled after FileExists. Use it to guard
creation of the report path directory.

This should avoid failures running the sanitizer in a sandbox where the
file creation attempt causes hard failures, even for an existing
directory. Problem reported on D109794 for ChromeOS in sandbox
(https://issuetracker.google.com/209296420).

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

2 years ago[X86] Add test for PR38788 missing PTEST fold
Simon Pilgrim [Sun, 13 Feb 2022 13:43:22 +0000 (13:43 +0000)]
[X86] Add test for PR38788 missing PTEST fold

2 years ago[x86] try harder to scalarize a vector load with extracted integer op uses
Sanjay Patel [Sun, 13 Feb 2022 13:21:57 +0000 (08:21 -0500)]
[x86] try harder to scalarize a vector load with extracted integer op uses

This is a retry of b4b97ec813a0 - that was reverted because it
could cause miscompiles by illegally reordering memory operations.
A new test based on #53695 is added here to verify we do not have
that same problem.

extract_vec_elt (load X), C --> scalar load (X+C)

As noted in the comment, DAGCombiner has this fold -- and the code in this
patch is adapted from DAGCombiner::scalarizeExtractedVectorLoad() -- but
x86 should benefit even if the loaded vector has other uses as long as we
apply some other x86-specific conditions. The motivating example from #50310
is shown in vec_int_to_fp.ll.

Fixes #50310
Fixes #53695

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

2 years ago[X86] Add some add reduction tests when we're extending from a smaller type
Simon Pilgrim [Sun, 13 Feb 2022 13:27:00 +0000 (13:27 +0000)]
[X86] Add some add reduction tests when we're extending from a smaller type

This often occurs when the accumulator is larger than the source vector element, such as some of the tests mentioned in Issue #42019

2 years ago[clang][sema] Use castAs<> instead of getAs<> to avoid dereference of nullptr
Simon Pilgrim [Sun, 13 Feb 2022 13:14:00 +0000 (13:14 +0000)]
[clang][sema] Use castAs<> instead of getAs<> to avoid dereference of nullptr

The pointers are referenced immediately, so assert the cast is correct instead of returning nullptr

2 years agoA significant number of our tests in C accidentally use functions
Aaron Ballman [Sun, 13 Feb 2022 13:02:46 +0000 (08:02 -0500)]
A significant number of our tests in C accidentally use functions
without prototypes. This patch converts the function signatures to have
a prototype for the situations where the test is not specific to K&R C
declarations. e.g.,

  void func();

becomes

  void func(void);

This is the ninth batch of tests being updated (there are a
significant number of other tests left to be updated).

2 years ago[LV] Drop noalias from check lines from test (NFC).
Florian Hahn [Sun, 13 Feb 2022 11:36:54 +0000 (11:36 +0000)]
[LV] Drop noalias from check lines from test (NFC).

The noalias metadata checks re not really relevant for the test and
slight changes to metadata numbering can have large knock-on effects
causing large noise in test diff.

2 years agoThe device expression must evaluate to a non-negative integer value.
Harshil Jain [Sun, 13 Feb 2022 11:18:59 +0000 (16:48 +0530)]
The device expression must evaluate to a non-negative integer value.

Device clause when it occurs with **target enter data** and **target exit data** must be declared with some non negative value. So some changes were made to evaluate the device clause argument to non negative value and throw the expected error when it takes negative value as argument.

Reviewed By: clementval

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

2 years ago[LV] Add real uses in some tests, to make them more robust.
Florian Hahn [Sun, 13 Feb 2022 09:52:49 +0000 (09:52 +0000)]
[LV] Add real uses in some tests, to make them more robust.

Add real uses to some tests, to ensure dead instructions cannot be directly
removed.

2 years ago[NFC][RFC][TableGen] Improve the comment about variable len encoder
Sheng [Sun, 13 Feb 2022 05:15:05 +0000 (13:15 +0800)]
[NFC][RFC][TableGen] Improve the comment about variable len encoder

When, for example, using "ascend" operator, I was wondering whether
the bit order of the dag argument will be reversed in ascend order
as well.

This patch clarifies it.

Reviewed By: myhsu

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

2 years ago[NFC][M68k] Fix typo
Sheng [Sun, 13 Feb 2022 05:09:33 +0000 (13:09 +0800)]
[NFC][M68k] Fix typo

2 years ago[ELF] demoteSharedSymbols: make binding more appropriate for lazy symbols. NFC
Fangrui Song [Sun, 13 Feb 2022 04:43:39 +0000 (20:43 -0800)]
[ELF] demoteSharedSymbols: make binding more appropriate for lazy symbols. NFC

The binding will matter if we remove the `sym->replace(und)` kludge from
initializeSymbols.
While here, rename the function to be more appropriate.

2 years ago[NFC][M68k] Fix indentation
Sheng [Sun, 13 Feb 2022 03:47:02 +0000 (11:47 +0800)]
[NFC][M68k] Fix indentation

2 years ago[OpenMP][Offloading] Fix infinite loop in applyToShadowMapEntries
Shilei Tian [Sun, 13 Feb 2022 03:02:47 +0000 (22:02 -0500)]
[OpenMP][Offloading] Fix infinite loop in applyToShadowMapEntries

This patch fixes the issue that the for loop in `applyToShadowMapEntries`
is infinite because `Itr` is not incremented in `CB`. Fixes #53727.

Reviewed By: jdoerfert

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

2 years ago[X86][MS] Fix the wrong alignment of vector variable arguments on Win32
Phoebe Wang [Sun, 13 Feb 2022 01:37:36 +0000 (09:37 +0800)]
[X86][MS] Fix the wrong alignment of vector variable arguments on Win32

D108887 fixed alignment mismatch by changing the caller's alignment in
ABI. However, we found some cases that still assume the alignment is
vector size. This patch fixes them to avoid the runtime crash.

Reviewed By: rnk

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

2 years ago[test][MemCpyOpt] Rename test function
Arthur Eubanks [Sun, 13 Feb 2022 01:44:51 +0000 (17:44 -0800)]
[test][MemCpyOpt] Rename test function

2 years ago[test][MemCpyOpt] Precommit test
Arthur Eubanks [Sun, 13 Feb 2022 00:52:33 +0000 (16:52 -0800)]
[test][MemCpyOpt] Precommit test

2 years ago[libc++] Remove <experimental/filesystem> header
Joe Loser [Fri, 11 Feb 2022 23:45:44 +0000 (18:45 -0500)]
[libc++] Remove <experimental/filesystem> header

`<filesystem>` header has been around for a while now, so we can safely remove
`<experimental/filesystem>` header. `_LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM`
suggests we were going to remove `<experimental/filesystem>` in llvm 11 release,
but we never did. So, remove the experimental header now, its associated tests,
and the `_LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM` macro.

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

2 years ago[SLP][X86] Add common check prefix for horizontal reduction tests
Simon Pilgrim [Sat, 12 Feb 2022 21:48:31 +0000 (21:48 +0000)]
[SLP][X86] Add common check prefix for horizontal reduction tests

2 years ago[RISCV] Fix incorrect extend type in vwmulsu combine.
Craig Topper [Sat, 12 Feb 2022 06:27:08 +0000 (22:27 -0800)]
[RISCV] Fix incorrect extend type in vwmulsu combine.

While matching widening multiply, if we matched an extend from i8->i32,
i16->i64 or i8->i64, we need to reintroduce a narrower extend. If we're
matching a vwmulsu we need to use a sext for op0 and a zext for op1.

This bug exists in LLVM 14 and will need to be backported.

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

2 years ago[clang-format] Remove unnecessary parentheses in return statements. NFC.
Marek Kurdej [Sat, 12 Feb 2022 20:25:42 +0000 (21:25 +0100)]
[clang-format] Remove unnecessary parentheses in return statements. NFC.

2 years ago[clang] MicrosoftCXXNameMangler::mangleObjCKindOfType - use castAs<> instead of getAs...
Simon Pilgrim [Sat, 12 Feb 2022 20:11:21 +0000 (20:11 +0000)]
[clang] MicrosoftCXXNameMangler::mangleObjCKindOfType - use castAs<> instead of getAs<> to avoid dereference of nullptr

The pointer is referenced in the mangleType call, so assert the cast is correct instead of returning nullptr

2 years ago[clang-tidy] SimplifyBooleanExprCheck - use cast<> instead of dyn_cast<> to avoid...
Simon Pilgrim [Sat, 12 Feb 2022 19:59:13 +0000 (19:59 +0000)]
[clang-tidy] SimplifyBooleanExprCheck - use cast<> instead of dyn_cast<> to avoid dereference of nullptr

The IfStmt pointer is always referenced inside the replaceCompoundReturnWithCondition call, so assert the cast is correct instead of returning nullptr

2 years ago[OpenMP][NFC] Simplify identifying the device bitcode library
Joseph Huber [Fri, 11 Feb 2022 21:44:17 +0000 (16:44 -0500)]
[OpenMP][NFC] Simplify identifying the device bitcode library

Now that the old device runtime has been deleted there is only a single
target that differs by the triple and the architecture. Simplify the
scheme for identifying the library but directly using the triple.

Reviewed By: JonChesterfield

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

2 years ago[libc++][nfc] Add TEST_HAS_NO_INT128.
Mark de Wever [Sat, 12 Feb 2022 19:06:21 +0000 (20:06 +0100)]
[libc++][nfc] Add TEST_HAS_NO_INT128.

This avoids using an libc++ internal macro in our tests.

D117992 removed them, but it seems new occurrences have been introduced.

2 years agoRevert "[asan] Always skip first object from dl_iterate_phdr"
Nico Weber [Sat, 12 Feb 2022 19:05:08 +0000 (14:05 -0500)]
Revert "[asan] Always skip first object from dl_iterate_phdr"

This reverts commit d75a5650dbdc595f836db4711f2a480f87243593.
Breaks asan_dlopen_test.cpp on several bots, see comments on
https://reviews.llvm.org/D119515

2 years ago[LV] Pass start value directly to emitTransformedIndex (NFC).
Florian Hahn [Sat, 12 Feb 2022 19:03:32 +0000 (19:03 +0000)]
[LV] Pass start value directly to emitTransformedIndex (NFC).

2 years agoRevert "[HWASan] Use hwasan_memalign for aligned new."
Nico Weber [Sat, 12 Feb 2022 18:56:50 +0000 (13:56 -0500)]
Revert "[HWASan] Use hwasan_memalign for aligned new."

This reverts commit 4fb7c120fed504519d167c93ed9d920aeae46fb0.
Breaks tests on Linux were system gcc doesn't support C++17
(but gcc used to build LLVM does), see https://reviews.llvm.org/D119161

2 years agoRefactor nested if else with ternary operator in CGExprScalar.cpp
phyBrackets [Sat, 12 Feb 2022 18:34:01 +0000 (00:04 +0530)]
Refactor nested if else with ternary operator in CGExprScalar.cpp

Reviewed By: rjmccall

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

2 years ago[libc++][nfc] Add TEST_HAS_NO_THREADS.
Mark de Wever [Wed, 2 Feb 2022 18:28:06 +0000 (19:28 +0100)]
[libc++][nfc] Add TEST_HAS_NO_THREADS.

This avoids using an libc++ internal macro in our tests.

Reviewed By: #libc, philnik, ldionne

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

2 years agoRevert "[RISCV] Enable shrink wrap by default"
Dimitry Andric [Sat, 12 Feb 2022 18:04:12 +0000 (19:04 +0100)]
Revert "[RISCV] Enable shrink wrap by default"

This reverts commit 5ebdb07e7eb366c20fa2d914e07a4d380975f266.

Enabling shrink wrap by default can cause assertions or crashes, and
these should first be investigated and fixed. For now, reverting the
change so it can be cherry-picked into 14.0.0 is the safest choice.

2 years ago[X86] LowerFunnelShift - enable v16i16 support
Simon Pilgrim [Sat, 12 Feb 2022 17:04:59 +0000 (17:04 +0000)]
[X86] LowerFunnelShift - enable v16i16 support

2 years ago[X86] combineAndnp - if an input has a zero (after inversion for Op0) in a vector...
Simon Pilgrim [Sat, 12 Feb 2022 16:49:00 +0000 (16:49 +0000)]
[X86] combineAndnp - if an input has a zero (after inversion for Op0) in a vector element, then we don't demand that bit/element in the other input

Similar to what we already perform in combineAnd

2 years ago[MachineSink] Inline getRegUnits
Benjamin Kramer [Sat, 12 Feb 2022 16:30:57 +0000 (17:30 +0100)]
[MachineSink] Inline getRegUnits

Reg unit sets are uniqued, so no need to wrap it in a set.

2 years ago[MachineRegisterInfo] Simplify code so it matches the description
Benjamin Kramer [Sat, 12 Feb 2022 16:30:06 +0000 (17:30 +0100)]
[MachineRegisterInfo] Simplify code so it matches the description

2 years ago[SDAG] clean up scalarizing load transform
Sanjay Patel [Sat, 12 Feb 2022 15:34:51 +0000 (10:34 -0500)]
[SDAG] clean up scalarizing load transform

I have not found a way to expose a difference for this patch in a test
because it only triggers for a one-use load, but this is the code that
was adapted into D118376 and caused miscompiles. The new code pattern
is the same as what we do in narrowExtractedVectorLoad() (reduces load
width for a subvector extract).

This removes seemingly unnecessary manual worklist management and fixes
the chain updating via "SelectionDAG::makeEquivalentMemoryOrdering()".

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

2 years ago[X86] getTargetVShiftNode - Fix Wparentheses gcc warning.
Simon Pilgrim [Sat, 12 Feb 2022 16:37:24 +0000 (16:37 +0000)]
[X86] getTargetVShiftNode - Fix Wparentheses gcc warning.

2 years ago[X86] combineAndnp - pull out repeated operands. NFC.
Simon Pilgrim [Sat, 12 Feb 2022 16:35:24 +0000 (16:35 +0000)]
[X86] combineAndnp - pull out repeated operands. NFC.

2 years ago[X86] combineAnd - add SimplifyMultipleUseDemandedBits handling to masked vector...
Simon Pilgrim [Sat, 12 Feb 2022 15:30:46 +0000 (15:30 +0000)]
[X86] combineAnd - add SimplifyMultipleUseDemandedBits handling to masked vector element analysis

Extend the existing fold to use SimplifyMultipleUseDemandedBits as well as SimplifyDemandedVectorElts/SimplifyDemandedBits when attempting to simplify based off known zero vector elements.

2 years ago[SDAG] reduce code duplication and fix formatting; NFC
Sanjay Patel [Sat, 12 Feb 2022 15:22:13 +0000 (10:22 -0500)]
[SDAG] reduce code duplication and fix formatting; NFC

2 years ago[X86] Improve uniform funnelshift/rotation amount handling
Simon Pilgrim [Sat, 12 Feb 2022 14:46:24 +0000 (14:46 +0000)]
[X86] Improve uniform funnelshift/rotation amount handling

To find uniform shift/rotation amounts, we currently use SelectionDAG::getSplatValue which creates a node that extracts the scalar value from the source vector, this makes it more difficult for later combines to remove the extraction and stay on the SIMD unit, and can be a problem when the scalar type is illegal (i.e. i64 vs v2i64 on 32-bit targets).

This patch begins to use SelectionDAG::getSplatSourceVector (which SelectionDAG::getSplatValue uses internally) and adds a new variant of getTargetVShiftNode that takes the source vector and the splat index, and adjusts the vector in place to create the zero-extended value suitable for the SSE PSLL/PSRL/PSRA uniform instructions.

I'm still addressing a number of regressions when used for normal vector shifts, so I've just handled the funnelshift/rotation lowering for this first patch. I can then focus on the yak shaving (SimplifyDemandedBits/Elts in particular) necessary to always use SelectionDAG::getSplatSourceVector.

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

2 years ago[AffineMap] Move result exprs into trailing storage. NFCI.
Benjamin Kramer [Sat, 12 Feb 2022 14:23:41 +0000 (15:23 +0100)]
[AffineMap] Move result exprs into trailing storage. NFCI.

2 years ago[X86] Regenerate AVG combines with separate AVX1/AVX2 check prefixes
Simon Pilgrim [Sat, 12 Feb 2022 14:15:57 +0000 (14:15 +0000)]
[X86] Regenerate AVG combines with separate AVX1/AVX2 check prefixes

2 years ago[X86] Enable vector splitting of ISD::AVGCEILU nodes on AVX1 and non-BWI targets
Simon Pilgrim [Sat, 12 Feb 2022 14:04:55 +0000 (14:04 +0000)]
[X86] Enable vector splitting of ISD::AVGCEILU nodes on AVX1 and non-BWI targets

2 years agoUse AffineMap::getSliceMap where applicable. NFCI.
Benjamin Kramer [Sat, 12 Feb 2022 13:19:35 +0000 (14:19 +0100)]
Use AffineMap::getSliceMap where applicable. NFCI.

2 years ago[llvm] [cmake] Fix finding modern ounit2
Michał Górny [Sun, 6 Feb 2022 14:58:32 +0000 (15:58 +0100)]
[llvm] [cmake] Fix finding modern ounit2

Apparently modern versions of ounit2 can only be found as "ounit2"
rather than "oUnit" version 2.  Update the CMake check to support both
variants.  This makes the OCaml tests run again with ounit2-2.2.4.

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

2 years agoUse functions with prototypes when appropriate; NFC
Aaron Ballman [Sat, 12 Feb 2022 12:23:43 +0000 (07:23 -0500)]
Use functions with prototypes when appropriate; NFC

A significant number of our tests in C accidentally use functions
without prototypes. This patch converts the function signatures to have
a prototype for the situations where the test is not specific to K&R C
declarations. e.g.,

  void func();

becomes

  void func(void);

This is the eighth batch of tests being updated (there are a
significant number of other tests left to be updated).

2 years ago[clang-tidy] ContainerSizeEmptyCheck::check - simplify isa<> and dyn_cast<> repeated...
Simon Pilgrim [Sat, 12 Feb 2022 11:31:27 +0000 (11:31 +0000)]
[clang-tidy] ContainerSizeEmptyCheck::check - simplify isa<> and dyn_cast<> repeated calls

Just use dyn_cast<> to determine literal + container values from the binop

2 years ago[clang-doc] populateParentNamespaces - use cast<> instead of dyn_cast<> to avoid...
Simon Pilgrim [Sat, 12 Feb 2022 11:28:50 +0000 (11:28 +0000)]
[clang-doc] populateParentNamespaces - use cast<> instead of dyn_cast<> to avoid dereference of nullptr

The pointer is referenced immediately, so assert the cast is correct instead of returning nullptr

It's only later iterations of the loop where the getParent() call might return nullptr

2 years ago[clang][sema] checkNoThrow - use cast<> instead of dyn_cast<> to avoid dereference...
Simon Pilgrim [Sat, 12 Feb 2022 11:18:49 +0000 (11:18 +0000)]
[clang][sema] checkNoThrow - use cast<> instead of dyn_cast<> to avoid dereference of nullptr

The pointer is referenced immediately, so assert the cast is correct instead of returning nullptr

2 years ago[clang][sema] Sema::CheckFreeArguments - use cast<> instead of dyn_cast<> to avoid...
Simon Pilgrim [Sat, 12 Feb 2022 11:17:02 +0000 (11:17 +0000)]
[clang][sema] Sema::CheckFreeArguments - use cast<> instead of dyn_cast<> to avoid dereference of nullptr

The pointer is referenced immediately, so assert the cast is correct instead of returning nullptr

2 years ago[clang][sema] TryStaticCast - use castAs<> instead of getAs<> to avoid dereference...
Simon Pilgrim [Sat, 12 Feb 2022 11:14:19 +0000 (11:14 +0000)]
[clang][sema] TryStaticCast - use castAs<> instead of getAs<> to avoid dereference of nullptr

The pointer is referenced immediately, so assert the cast is correct instead of returning nullptr

2 years ago[clang-tidy] RedundantControlFlowCheck::issueDiagnostic - use cast<> instead of dyn_c...
Simon Pilgrim [Sat, 12 Feb 2022 11:05:59 +0000 (11:05 +0000)]
[clang-tidy] RedundantControlFlowCheck::issueDiagnostic - use cast<> instead of dyn_cast<> to avoid dereference of nullptr

The pointer is referenced immediately, so assert the cast is correct instead of returning nullptr

2 years ago[clang-tidy] FunctionASTVisitor::TraverseStmt - use cast<> instead of dyn_cast<>...
Simon Pilgrim [Sat, 12 Feb 2022 11:04:20 +0000 (11:04 +0000)]
[clang-tidy] FunctionASTVisitor::TraverseStmt - use cast<> instead of dyn_cast<> to avoid dereference of nullptr

The pointer is referenced immediately, so assert the cast is correct instead of returning nullptr

2 years ago[clang-tidy] NoexceptMoveConstructorCheck::check - use castAs<> instead of getAs...
Simon Pilgrim [Sat, 12 Feb 2022 10:57:09 +0000 (10:57 +0000)]
[clang-tidy] NoexceptMoveConstructorCheck::check - use castAs<> instead of getAs<> to avoid dereference of nullptr

The pointer is referenced immediately, so assert the cast is correct instead of returning nullptr

2 years ago[clang-tidy] UseNoexceptCheck::check - use cast<> instead of dyn_cast<> to avoid...
Simon Pilgrim [Sat, 12 Feb 2022 10:51:48 +0000 (10:51 +0000)]
[clang-tidy] UseNoexceptCheck::check - use cast<> instead of dyn_cast<> to avoid dereference of nullptr

The pointer is referenced immediately, so assert the cast is correct instead of returning nullptr

2 years ago[clang-tidy] getOutermostNamespace - remove redundant nullptr check
Simon Pilgrim [Sat, 12 Feb 2022 10:49:54 +0000 (10:49 +0000)]
[clang-tidy] getOutermostNamespace - remove redundant nullptr check

The pointer is always dereferenced

2 years ago[clang-tidy] ProBoundsConstantArrayIndexCheck::check - use cast<> instead of dyn_cast...
Simon Pilgrim [Sat, 12 Feb 2022 10:43:21 +0000 (10:43 +0000)]
[clang-tidy] ProBoundsConstantArrayIndexCheck::check - use cast<> instead of dyn_cast<> to avoid dereference of nullptr

The pointer is referenced immediately, so assert the cast is correct instead of returning nullptr

2 years ago[clang-tidy] checkOverridingFunctionReturnType - use castAs<> instead of getAs<>...
Simon Pilgrim [Sat, 12 Feb 2022 10:41:43 +0000 (10:41 +0000)]
[clang-tidy] checkOverridingFunctionReturnType - use castAs<> instead of getAs<> to avoid dereference of nullptr

The pointers are referenced immediately, so assert the cast is correct instead of returning nullptr

2 years agoRevert "try to fix windows build after 73e585e44d" and
Douglas Yung [Sat, 12 Feb 2022 07:42:29 +0000 (23:42 -0800)]
Revert "try to fix windows build after 73e585e44d" and
Revert "Reland "[lld/coff] Make lld-link work in a non-MSVC shell, add /winsysroot:""

This reverts commit 0574b5fc657451c9d13d3f6d8fe14ea15c23a681 and 73e585e44d68cf77e2e3274e98c9615156a7d909.

This change is causing the test Driver/cl-options.c to fail on Windows buildbots.
https://lab.llvm.org/staging/#/builders/204/builds/1343

2 years ago[RISCV] LUI used for address computation should not isAsCheapAsAMove
Haocong.Lu [Sat, 12 Feb 2022 07:14:31 +0000 (07:14 +0000)]
[RISCV] LUI used for address computation should not isAsCheapAsAMove

A LUI instruction with flag RISCVII::MO_HI is usually used in conjunction
with ADDI, and jointly complete address computation. To bind the cost
evaluation of address computation, the LUI should not be regarded as a cheap
 move separately, which is consistent with ADDI.

In this test case, it improves the unroll-loop code that the rematerialization
of array's base address miss MachineCSE with Heuristics #1 at isProfitableToCSE.

Reviewed By: asb, frasercrmck

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

2 years ago[RISCV][test] Precommit a test of CSE within an unroll loop
Haocong.Lu [Sat, 12 Feb 2022 06:28:36 +0000 (06:28 +0000)]
[RISCV][test] Precommit a test of CSE within an unroll loop

Reviewed By: asb, frasercrmck

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

2 years ago[libc][Obvious][NFC] Move CPP tests to the correct nested directory.
Siva Chandra Reddy [Sat, 12 Feb 2022 06:14:46 +0000 (06:14 +0000)]
[libc][Obvious][NFC] Move CPP tests to the correct nested directory.

2 years ago[lld-macho] Unset ExportDynamic where possible for LTO
Jez Ng [Sat, 12 Feb 2022 03:24:09 +0000 (22:24 -0500)]
[lld-macho] Unset ExportDynamic where possible for LTO

By unsetting this property, we are now able to internalize more symbols
during LTO. I compared the output of `-save-temps` for both LLD and
ld64, and we now match ld64's behavior as far as `lto-internalize.ll` is
concerned.

(Thanks @smeenai for working on an initial version of this diff!)

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

Reviewed By: #lld-macho, thakis

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

2 years ago[AArch64] Adds SUBS and ADDS instructions to the MIPeepholeOpt.
Micah Weston [Sat, 12 Feb 2022 03:11:50 +0000 (03:11 +0000)]
[AArch64] Adds SUBS and ADDS instructions to the MIPeepholeOpt.

Implements ADDS/SUBS 24-bit immediate optimization using the
MIPeepholeOpt pass. This follows the pattern:

Optimize ([adds|subs] r, imm) -> ([ADDS|SUBS] ([ADD|SUB] r, #imm0, lsl #12), #imm1),
if imm == (imm0<<12)+imm1. and both imm0 and imm1 are non-zero 12-bit unsigned
integers.

Optimize ([adds|subs] r, imm) -> ([SUBS|ADDS] ([SUB|ADD] r, #imm0, lsl #12), #imm1),
if imm == -(imm0<<12)-imm1, and both imm0 and imm1 are non-zero 12-bit unsigned
integers.

The SplitAndOpcFunc type had to change the return type to an Opcode pair so that
the first add/sub is the regular instruction and the second is the flag setting
instruction. This required updating the code in the AND case.

Testing:

I ran a two stage bootstrap with this code.
Using the second stage compiler, I verified that the negation of an ADDS to SUBS
or vice versa is a valid optimization. Example V == -0x111111.

Reviewed By: dmgreen

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

2 years ago[RISCV][NFC] Move some combine patterns to DAG combine.
Chenbing.Zheng [Sat, 12 Feb 2022 02:52:12 +0000 (02:52 +0000)]
[RISCV][NFC] Move some combine patterns to DAG combine.

Move some combine patterns to DAG combine,and
it dealt with fixme left in RISCVInstrInfoZb.td.

Reviewed By: craig.topper

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

2 years ago[HWASAN] regression test we do not instrument dynamic allocas
Florian Mayer [Sat, 12 Feb 2022 00:33:01 +0000 (16:33 -0800)]
[HWASAN] regression test we do not instrument dynamic allocas

Reviewed By: browneee

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

2 years ago[flang] Fix edge case in USE-associated generics
Peter Klausler [Tue, 8 Feb 2022 21:39:59 +0000 (13:39 -0800)]
[flang] Fix edge case in USE-associated generics

It is generally an error when a USE-associated name clashes
with a name defined locally, but not in all cases; a generic
interface can be both USE-associated and locally defined.
This works, but not when there is also a local subprogram
with the same name, which is valid when that subprogram is
a specific of the local generic.  A bogus error issues at
the point of the USE because name resolution will have already
defined a symbol for the local subprogram.

The solution is to collect the names of local generics when
creating the program tree, and then create their symbols as
well if their names are also local subprograms, prior to any
USE association processing.

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

2 years ago[Mach-O][NFC] Reorder map file tests
Roger Kim [Sat, 12 Feb 2022 00:40:53 +0000 (19:40 -0500)]
[Mach-O][NFC] Reorder map file tests

We are just grouping the files and the tests together.

Reviewed By: int3, #lld-macho

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

2 years agoPrint C-string literals in mapfile
Roger Kim [Sat, 12 Feb 2022 00:33:23 +0000 (19:33 -0500)]
Print C-string literals in mapfile

This diff has the C-string literals printed into the mapfile in the symbol table like how ld64 does.

Here is what ld64's mapfile looks like with C-string literals:
```
# Path: out
# Arch: x86_64
# Object files:
[  0] linker synthesized
[  1] foo.o
# Sections:
# Address       Size            Segment Section
0x100003F7D     0x0000001D      __TEXT  __text
0x100003F9A     0x0000001E      __TEXT  __cstring
0x100003FB8     0x00000048      __TEXT  __unwind_info
# Symbols:
# Address       Size            File  Name
0x100003F7D     0x0000001D      [  1] _main
0x100003F9A     0x0000000E      [  1] literal string: Hello world!\n
0x100003FA8     0x00000010      [  1] literal string: Hello, it's me\n
0x100003FB8     0x00000048      [  0] compact unwind info
```

Here is what the new lld's Mach-O mapfile looks like:
```
# Path: /Users/rgr/local/llvm-project/build/Debug/tools/lld/test/MachO/Output/map-file.s.tmp/c-string-liter
al-out
# Arch: x86_64
# Object files:
[  0] linker synthesized
[  1] /Users/rgr/local/llvm-project/build/Debug/tools/lld/test/MachO/Output/map-file.s.tmp/c-string-literal
.o
# Sections:
# Address       Size            Segment Section
0x1000002E0     0x0000001D      __TEXT  __text
0x1000002FD     0x0000001D      __TEXT  __cstring
# Symbols:
# Address           File  Name
0x1000002E0     [  1] _main
0x1000002FD     [  1] literal string: Hello world!\n
0x10000030B     [  1] literal string: Hello, it's me\n
```

Reviewed By: #lld-macho, int3

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

2 years ago[NFC] [MTE] Use helpers for stack tagging.
Florian Mayer [Sat, 12 Feb 2022 00:01:37 +0000 (16:01 -0800)]
[NFC] [MTE] Use helpers for stack tagging.

Reviewed By: eugenis

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

2 years ago[hwasan] keep debug intrinsicts in AllocaInfo.
Florian Mayer [Fri, 11 Feb 2022 23:46:37 +0000 (15:46 -0800)]
[hwasan] keep debug intrinsicts in AllocaInfo.

Reviewed By: eugenis

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

2 years ago[OpenMP] libomp: fix UB when LIBOMP_NUM_HIDDEN_HELPER_THREADS=1.
AndreyChurbanov [Sat, 12 Feb 2022 00:00:38 +0000 (03:00 +0300)]
[OpenMP] libomp: fix UB when LIBOMP_NUM_HIDDEN_HELPER_THREADS=1.

The __kmp_hidden_helper_threads_num set to N+1 if user requested N threads.
Thus number of worker hidden helper threads corresponds to user request,
main thread of helper team excluded as it does not participate in actual work.
This also fixes divide-by-0 issue in the code.

Fixes #48656

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

2 years ago[flang] Avoid bogus error for specification expression
Peter Klausler [Tue, 8 Feb 2022 18:08:23 +0000 (10:08 -0800)]
[flang] Avoid bogus error for specification expression

When a scope's symbol has characteriztics whose specification
expressions depend on other non-constant symbols in the same scope,
f18 rightfully emits an error.  However, in the case of usage in
specification expressions involving host association, the program is not
invalid.  This can arise, for example, in the case of an internal
function whose result's attributes use host-associated variables.

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

2 years agoRevert "[Preprocessor] Reduce the memory overhead of `#define` directives"
Alex Lorenz [Fri, 11 Feb 2022 23:53:09 +0000 (15:53 -0800)]
Revert "[Preprocessor] Reduce the memory overhead of `#define` directives"

This reverts commit 0d9b91524ea4db3760791bba15773c386a26d8ec.

This change broke LLDB's build. I will need to recommit after fixing LLDB.

2 years ago[flang] Change internal errors in RESHAPE runtime routine to user errors
Peter Steinfeld [Fri, 11 Feb 2022 22:44:42 +0000 (14:44 -0800)]
[flang] Change internal errors in RESHAPE runtime routine to user errors

There are several checks in the runtime routine for the RESHAPE
intrinsic.  Some checks verify things that should have been checked at
compile time while others represent user errors.

This update changes the checks for user errors into calls to "Crash"
which include information about the failing check.  This identifies them
as user errors rather than compiler errors.

I also verified that the checks that remain as internal errors are also
checked by the front end.  I added a test to the front end's RESHAPE
test to complete the checks.

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

2 years ago[libc++] Use _LIBCPP_NO_UNIQUE_ADDRESS for base in join_view
Joe Loser [Tue, 8 Feb 2022 02:33:11 +0000 (21:33 -0500)]
[libc++] Use _LIBCPP_NO_UNIQUE_ADDRESS for base in join_view

Despite the comment saying `[[no_unique_address]]` on the `__base_` data member
makes clang crash, this does not seem to be true on CI. So, mark `__base_` with
`_LIBCPP_NO_UNIQUE_ADDRESS`.

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

2 years ago[lldb] Pin the shared cache when iterating over its images
Jonas Devlieghere [Fri, 11 Feb 2022 23:25:12 +0000 (15:25 -0800)]
[lldb] Pin the shared cache when iterating over its images

Use the dyld_shared_cache_(un)pin_mapping SPI to map the whole shared
cache in memory (if possible) to avoid repeated calls to mmap.

rdar://81189015

2 years ago[tsan] Make __fxstat code path glibc only
Fangrui Song [Fri, 11 Feb 2022 23:23:18 +0000 (15:23 -0800)]
[tsan] Make __fxstat code path glibc only

This fixes Linux musl build after D118423.

2 years ago[libc++][ranges][NFC] Refactor tests for `ranges::{begin,end}`.
Konstantin Varlamov [Fri, 11 Feb 2022 23:15:10 +0000 (15:15 -0800)]
[libc++][ranges][NFC] Refactor tests for `ranges::{begin,end}`.

- add some test cases for `cbegin`/`cend`;
- make class definitions generally follow the order in which they are
  used;
- add a missing include.

Reviewed By: philnik

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

2 years ago[debug-info] If one sees a spill with a dbg.addr use, salvageDebugInfo upon it and...
Michael Gottesman [Mon, 7 Feb 2022 21:05:30 +0000 (13:05 -0800)]
[debug-info] If one sees a spill with a dbg.addr use, salvageDebugInfo upon it and don't hoist it.

This ensures that if we have a dbg.addr in a coroutine funclet that is on one of
our function arguments, that the dbg.addr is not mapped to undef and also that
later it isn't hoisted to the front of the basic block. Instead it remains at
its original cloned location.

rdar://83957028

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

2 years agotry to fix windows build after 73e585e44d
Nico Weber [Fri, 11 Feb 2022 23:04:10 +0000 (18:04 -0500)]
try to fix windows build after 73e585e44d