platform/upstream/llvm.git
23 months ago[mlir] Remove clone methods from DPS interface.
Alexander Belyaev [Wed, 23 Nov 2022 17:17:13 +0000 (18:17 +0100)]
[mlir] Remove clone methods from DPS interface.

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

23 months agoAdd the ability to see when a type in incomplete.
Greg Clayton [Mon, 10 Oct 2022 23:30:49 +0000 (16:30 -0700)]
Add the ability to see when a type in incomplete.

-flimit-debug-info and other compiler options might end up removing debug info that is needed for debugging. LLDB marks these types as being forcefully completed in the metadata in the TypeSystem. These types should have been complete in the debug info but were not because the compiler omitted them to save space. When we can't find a suitable replacement for the type, we should let the user know that these types are incomplete to indicate there was an issue instead of just showing nothing for a type.

The solution is to display presented in this patch is to display "<incomplete type>" as the summary for any incomplete types. If there is a summary string or function that is provided for a type, but the type is currently forcefully completed, the installed summary will be ignored and we will display "<incomplete type>". This patch also exposes the ability to ask a SBType if it was forcefully completed with:

  bool SBType::IsTypeForcefullyCompleted();

This will allow the user interface for a debugger to also detect this issue and possibly mark the variable display up on some way to indicate to the user the type is incomplete.

To show how this is diplayed, we can look at the existing output first for the example source file from the file: lldb/test/API/functionalities/limit-debug-info/main.cpp

(lldb) frame variable inherits_from_one inherits_from_two one_as_member two_as_member array_of_one array_of_two shadowed_one
(InheritsFromOne) ::inherits_from_one = (member = 47)
(InheritsFromTwo) ::inherits_from_two = (member = 47)
(OneAsMember) ::one_as_member = (one = member::One @ 0x0000000100008028, member = 47)
(TwoAsMember) ::two_as_member = (two = member::Two @ 0x0000000100008040, member = 47)
(array::One [3]) ::array_of_one = ([0] = array::One @ 0x0000000100008068, [1] = array::One @ 0x0000000100008069, [2] = array::One @ 0x000000010000806a)
(array::Two [3]) ::array_of_two = ([0] = array::Two @ 0x0000000100008098, [1] = array::Two @ 0x0000000100008099, [2] = array::Two @ 0x000000010000809a)
(ShadowedOne) ::shadowed_one = (member = 47)
(lldb) frame variable --show-types inherits_from_one inherits_from_two one_as_member two_as_member array_of_one array_of_two shadowed_one
(InheritsFromOne) ::inherits_from_one = {
  (int) member = 47
}
(InheritsFromTwo) ::inherits_from_two = {
  (int) member = 47
}
(OneAsMember) ::one_as_member = {
  (member::One) one = {}
  (int) member = 47
}
(TwoAsMember) ::two_as_member = {
  (member::Two) two = {}
  (int) member = 47
}
(array::One [3]) ::array_of_one = {
  (array::One) [0] = {}
  (array::One) [1] = {}
  (array::One) [2] = {}
}
(array::Two [3]) ::array_of_two = {
  (array::Two) [0] = {}
  (array::Two) [1] = {}
  (array::Two) [2] = {}
}
(ShadowedOne) ::shadowed_one = {
  (int) member = 47
}

With this patch in place we can now see any classes that were forcefully completed to let us know that we are missing information:

(lldb) frame variable inherits_from_one inherits_from_two one_as_member two_as_member array_of_one array_of_two shadowed_one
(InheritsFromOne) ::inherits_from_one = (One = <incomplete type>, member = 47)
(InheritsFromTwo) ::inherits_from_two = (Two = <incomplete type>, member = 47)
(OneAsMember) ::one_as_member = (one = <incomplete type>, member = 47)
(TwoAsMember) ::two_as_member = (two = <incomplete type>, member = 47)
(array::One[3]) ::array_of_one = ([0] = <incomplete type>, [1] = <incomplete type>, [2] = <incomplete type>)
(array::Two[3]) ::array_of_two = ([0] = <incomplete type>, [1] = <incomplete type>, [2] = <incomplete type>)
(ShadowedOne) ::shadowed_one = (func_shadow::One = <incomplete type>, member = 47)
(lldb) frame variable --show-types inherits_from_one inherits_from_two one_as_member two_as_member array_of_one array_of_two shadowed_one
(InheritsFromOne) ::inherits_from_one = {
  (One) One = <incomplete type> {}
  (int) member = 47
}
(InheritsFromTwo) ::inherits_from_two = {
  (Two) Two = <incomplete type> {}
  (int) member = 47
}
(OneAsMember) ::one_as_member = {
  (member::One) one = <incomplete type> {}
  (int) member = 47
}
(TwoAsMember) ::two_as_member = {
  (member::Two) two = <incomplete type> {}
  (int) member = 47
}
(array::One[3]) ::array_of_one = {
  (array::One) [0] = <incomplete type> {}
  (array::One) [1] = <incomplete type> {}
  (array::One) [2] = <incomplete type> {}
}
(array::Two[3]) ::array_of_two = {
  (array::Two) [0] = <incomplete type> {}
  (array::Two) [1] = <incomplete type> {}
  (array::Two) [2] = <incomplete type> {}
}
(ShadowedOne) ::shadowed_one = {
  (func_shadow::One) func_shadow::One = <incomplete type> {}
  (int) member = 47
}

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

23 months ago[WebAssembly] Remove unnecessary GEP insts from table tests
Paulo Matos [Tue, 22 Nov 2022 14:58:58 +0000 (15:58 +0100)]
[WebAssembly] Remove unnecessary GEP insts from table tests

Removes the unnecessary GEP instructions from WebAssembly Table tests.

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

23 months agoCloneModule: Handling cloning ifuncs
Matt Arsenault [Tue, 22 Nov 2022 19:53:43 +0000 (14:53 -0500)]
CloneModule: Handling cloning ifuncs

This is tested in a future llvm-reduce patch.

23 months ago[AArch64][SME]: Generate streaming-compatible code for int-minmax, fp-minmax
Hassnaa Hamdi [Wed, 23 Nov 2022 15:48:46 +0000 (15:48 +0000)]
[AArch64][SME]: Generate streaming-compatible code for int-minmax, fp-minmax

1-To generate code compatible to streaming mode:
 - enable custom lowering for SMIN, SMAX, UMIN, UMAX,
   FMAXNUM, FMINNUM, FMAXIMUM, FMINIMUM.
2-Testing files:
 - int-minmax.ll
 - fp-minmax.ll

Reviewed By: david-arm, sdesmalen

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

23 months ago[AArch64][SME]: Add precursory tests for D138292
Hassnaa Hamdi [Fri, 18 Nov 2022 13:42:38 +0000 (13:42 +0000)]
[AArch64][SME]: Add precursory tests for D138292

Add testing files:
- int-minmax.ll
- fp-minmax.ll

23 months ago[libc++][NFC] Fix documentation build
Louis Dionne [Wed, 23 Nov 2022 15:31:21 +0000 (10:31 -0500)]
[libc++][NFC] Fix documentation build

23 months agoRevert "Make -fsanitize=scudo use scudo_standalone. Delete check-scudo."
Hans Wennborg [Wed, 23 Nov 2022 15:07:07 +0000 (16:07 +0100)]
Revert "Make -fsanitize=scudo use scudo_standalone. Delete check-scudo."

It broke the build, see comments on code review.

> Leaves the implementation and tests files in-place for right now, but
> deletes the ability to build the old sanitizer-common based scudo. This
> has been on life-support for a long time, and the newer scudo_standalone
> is much better supported and maintained.
>
> Also patches up some GWP-ASan wording, primarily related to the fact
> that -fsanitize=scudo now is scudo_standalone, and therefore the way to
> reference the GWP-ASan options through the environment variable has
> changed.
>
> Future follow-up patches will delete the original scudo, and migrate all
> its tests over to be part of the scudo_standalone test suite.
>
> Reviewed By: vitalybuka
>
> Differential Revision: https://reviews.llvm.org/D138157

This reverts commit ab1a5991fe765d71c0f3262f25726d6b4d66a545.

23 months ago[SystemZ] Extend combineGET_CCMASK() to handle a truncated SELECT_CCMASK.
Jonas Paulsson [Fri, 18 Nov 2022 20:22:01 +0000 (15:22 -0500)]
[SystemZ]  Extend combineGET_CCMASK() to handle a truncated SELECT_CCMASK.

In cases where the SELECT_CCMASK has an additional user of the carry, a
truncated SELECT_CCMASK may result as the input to the GET_CCMASK, which need
to be recognized.

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

Reviewed By: Ulrich Weigand

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

23 months ago[analyzer] getBinding should auto-detect type only if it was not given
Balazs Benics [Wed, 23 Nov 2022 14:52:11 +0000 (15:52 +0100)]
[analyzer] getBinding should auto-detect type only if it was not given

Casting a pointer to a suitably large integral type by reinterpret-cast
should result in the same value as by using the `__builtin_bit_cast()`.
The compiler exploits this: https://godbolt.org/z/zMP3sG683

However, the analyzer does not bind the same symbolic value to these
expressions, resulting in weird situations, such as failing equality
checks and even results in crashes: https://godbolt.org/z/oeMP7cj8q

Previously, in the `RegionStoreManager::getBinding()` even if `T` was
non-null, we replaced it with `TVR->getValueType()` in case the `MR` was
`TypedValueRegion`.
It doesn't make much sense to auto-detect the type if the type is
already given. By not doing the auto-detection, we would just do the
right thing and perform the load by that type.
This means that we will cast the value to that type.

So, in this patch, I'm proposing to do auto-detection only if the type
was null.

Here is a snippet of code, annotated by the previous and new dump values.
`LocAsInteger` should wrap the `SymRegion`, since we want to load the
address as if it was an integer.
In none of the following cases should type auto-detection be triggered,
hence we should eventually reach an `evalCast()` to lazily cast the loaded
value into that type.

```lang=C++
void LValueToRValueBitCast_dumps(void *p, char (*array)[8]) {
  clang_analyzer_dump(p);     // remained: &SymRegion{reg_$0<void * p>}
  clang_analyzer_dump(array); // remained: {{&SymRegion{reg_$1<char (*)[8] array>}
  clang_analyzer_dump((unsigned long)p);
  // remained: {{&SymRegion{reg_$0<void * p>} [as 64 bit integer]}}
  clang_analyzer_dump(__builtin_bit_cast(unsigned long, p));     <--------- change #1
  // previously: {{&SymRegion{reg_$0<void * p>}}}
  // now:        {{&SymRegion{reg_$0<void * p>} [as 64 bit integer]}}
  clang_analyzer_dump((unsigned long)array); // remained: {{&SymRegion{reg_$1<char (*)[8] array>} [as 64 bit integer]}}
  clang_analyzer_dump(__builtin_bit_cast(unsigned long, array)); <--------- change #2
  // previously: {{&SymRegion{reg_$1<char (*)[8] array>}}}
  // now:        {{&SymRegion{reg_$1<char (*)[8] array>} [as 64 bit integer]}}
}
```

Reviewed By: xazax.hun

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

23 months ago[libc++] Remove default definition of std::char_traits
Louis Dionne [Thu, 17 Nov 2022 15:47:18 +0000 (10:47 -0500)]
[libc++] Remove default definition of std::char_traits

This patch removes the base template implementation for std::char_traits.
If my reading of http://eel.is/c++draft/char.traits is correct, the
Standard mandates that the library provides specializations for several
types like char and wchar_t, but not any implementation in the base
template. Indeed, such an implementation is bound to be incorrect for
most types anyways, since things like `eof()` and `int_type` will definitely
have to be customized.

Since the base template implementation should not have worked for anyone,
this shouldn't be a breaking change (I expect that anyone defining a
custom character type today will already have to provide their own
specialization of char_traits). However, since we're aware of some users
of char_traits for unsigned char and signed char, we're keeping those two
specializations around for two releases to give people some time to migrate.

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

23 months ago[libc++] Add missing __has_include checks for C headers not provided by libc++
Louis Dionne [Tue, 22 Nov 2022 18:42:33 +0000 (13:42 -0500)]
[libc++] Add missing __has_include checks for C headers not provided by libc++

This makes the library consistent in how it handles C library headers. For C headers provided by libc++,
we unconditionally include <foo.h> from <cfoo>, and then <foo.h> conditionally include_next <foo.h>.
For headers not provided by libc++, <cfoo> conditionally includes the system's <foo.h> directly.

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

23 months ago[lld/mac] Reorder an assert() and a printArchiveMemberLoad() call
Nico Weber [Wed, 23 Nov 2022 14:40:17 +0000 (09:40 -0500)]
[lld/mac] Reorder an assert() and a printArchiveMemberLoad() call

No behavior difference in practice, but makes it possible to use `-t`
for debugging when that assert fails.

23 months ago[flang] Fix unittests in standalone build for third-party move
Michał Górny [Wed, 23 Nov 2022 12:19:47 +0000 (13:19 +0100)]
[flang] Fix unittests in standalone build for third-party move

Update external unittest rules for flang standalone builds to account
for the unittest components (gtest, gmock) being moved to `third-party`
directory, in a11cd0d94ed3cabf0998a0289aead05da94c86eb.

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

23 months ago[LLDB][RISCV] Add RV32F instruction support for EmulateInstructionRISCV
Emmmer [Sun, 6 Nov 2022 13:36:44 +0000 (21:36 +0800)]
[LLDB][RISCV] Add RV32F instruction support for EmulateInstructionRISCV

Add:

- RV32F instruction set.
- corresponding unittests.

Further work:

- RV32FC, RV64F and RV64FC instructions support.
- update execution exceptions to fcsr register in RVM instructions.

Reviewed By: DavidSpickett

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

23 months ago[Assignment Tracking] Fix DbgVariableIntrinsic::replaceVariableLocationOp
OCHyams [Wed, 23 Nov 2022 13:32:53 +0000 (13:32 +0000)]
[Assignment Tracking] Fix DbgVariableIntrinsic::replaceVariableLocationOp

Fix replaceVariableLocationOp unconditionally replacing the first operand of a
dbg.assign.

Reviewed By: jryans

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

23 months agoUtils: Fix deleting calls to null in non-0 address spaces
Matt Arsenault [Wed, 23 Nov 2022 04:59:26 +0000 (23:59 -0500)]
Utils: Fix deleting calls to null in non-0 address spaces

23 months ago[libc++][NFC] Use if-else chain instead of match, which is a Python 3.10 construct
Louis Dionne [Wed, 23 Nov 2022 13:49:01 +0000 (08:49 -0500)]
[libc++][NFC] Use if-else chain instead of match, which is a Python 3.10 construct

23 months ago[VectorCombine] Enable scalarizeBinopOrCmp for scalable vectors
Matt Devereau [Wed, 23 Nov 2022 07:51:42 +0000 (07:51 +0000)]
[VectorCombine] Enable scalarizeBinopOrCmp for scalable vectors

This reverts a change to exclude scalarizeBinopOrCmp in VectorCombine for
scalable vectors which caused poor scalable Binop codegen.

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

23 months ago[mlir][utils] Fix invalid reshapes in ComposeCollapseOfExpandOp
Matthias Springer [Wed, 23 Nov 2022 10:56:07 +0000 (11:56 +0100)]
[mlir][utils] Fix invalid reshapes in ComposeCollapseOfExpandOp

Do not generate CollapseShapeOps/ExpandShapeOps that have the same source and result shape. Generate casts instead. Such reshapes became invalid with D138498.

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

23 months ago[include-cleaner] Show includes matched by refs in HTML report.
Sam McCall [Thu, 17 Nov 2022 17:06:28 +0000 (18:06 +0100)]
[include-cleaner] Show includes matched by refs in HTML report.

Demo: https://htmlpreview.github.io/?https://gist.githubusercontent.com/sam-mccall/ecee6869e37af3db28089b64d8dce806/raw/8736e64c45af411e2c2d72adaed2dfc4410a5b36/ASTTests.html%25202

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

23 months agoRevert "Add runToBinaryEntry option for lldb-vscode"
Pavel Labath [Wed, 23 Nov 2022 11:22:03 +0000 (12:22 +0100)]
Revert "Add runToBinaryEntry option for lldb-vscode"

This reverts commit f0c16f89124f2dc0630162ff9ea23934f5b2b75b because it
breaks linux and mac bots.

23 months agoRevert "[SROA] `isVectorPromotionViable()`: memory intrinsics operate on vectors...
Benjamin Kramer [Wed, 23 Nov 2022 12:02:58 +0000 (13:02 +0100)]
Revert "[SROA] `isVectorPromotionViable()`: memory intrinsics operate on vectors of bytes"

This reverts commit cf624b23bc5d5a6161706d1663def49380ff816a. It
triggers crashes in clang, see the comments on github on the original
change.

23 months ago[AArch64] Add Host identifiers for cortex-a55, cortex-a510, cortex-a710 and cortex-x2.
David Green [Wed, 23 Nov 2022 12:10:54 +0000 (12:10 +0000)]
[AArch64] Add Host identifiers for cortex-a55, cortex-a510, cortex-a710 and cortex-x2.

I noticed these were missing, so this adds Host identifiers for
cortex-a55, cortex-a510, cortex-a710 and cortex-x2, taken from their
respective TRMs.

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

23 months ago[AArch64] Optimize cmp chain before legalization
zhongyunde [Wed, 23 Nov 2022 11:43:29 +0000 (19:43 +0800)]
[AArch64] Optimize cmp chain before legalization

* For case bcmp9, there is extras AND and EXTEND int the chain of OR/XOR,
  which prevent the transform, so enable the optimize before legalization.

* The key IR frag related:
      t37: i32,ch = load<(load (s8) from %ir.4), anyext from i8> t0, t11, undef:i64
        t12: i64 = add t4, Constant:i64<8>
      t38: i32,ch = load<(load (s8) from %ir.5), anyext from i8> t0, t12, undef:i64
    t39: i32 = xor t37, t38
  t40: i64 = any_extend t39
t42: i64 = and t40, Constant:i64<255>

Depends on D138398 to fix combine_setcc_glue

Reviewed By: dmgreen, bcl5980
Differential Revision: https://reviews.llvm.org/D137936

23 months ago[CostModel][X86] Fix permute latency cost
Haohai Wen [Wed, 23 Nov 2022 10:56:07 +0000 (18:56 +0800)]
[CostModel][X86] Fix permute latency cost

Avx512 permute latency should be 3 instead of 1.

Reviewed By: RKSimon

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

23 months agoReland "[CGObjC] Add run line for release mode in test arc-exceptions-seh.mm (NFC)"
Stefan Gränitz [Wed, 23 Nov 2022 10:03:57 +0000 (11:03 +0100)]
Reland "[CGObjC] Add run line for release mode in test arc-exceptions-seh.mm (NFC)"

This reverts commit a37807ac8a3e9d2880a483940dcd33194f354bf8.

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

23 months ago[ObjC][ARC] Fix UB in ObjCARCOpt with -enable-objc-arc-opts=false
Stefan Gränitz [Wed, 23 Nov 2022 10:19:13 +0000 (11:19 +0100)]
[ObjC][ARC] Fix UB in ObjCARCOpt with -enable-objc-arc-opts=false

When ObjCARCOpt::run() returned early, Changed and CFGChanged were never initialized. CFGChanged is read unconditionally afterwards. This came up in the course of D137942.

23 months ago[bazel] Add missing dependencies after 7a69a9d7ae
Benjamin Kramer [Wed, 23 Nov 2022 09:45:15 +0000 (10:45 +0100)]
[bazel] Add missing dependencies after 7a69a9d7ae

23 months ago[libc++] Fix __regex_word value when using newlib/picolibc
Alex Richardson [Mon, 20 Jun 2022 14:44:57 +0000 (15:44 +0100)]
[libc++] Fix __regex_word value when using newlib/picolibc

The ctype mask for newlib/picolibc is fully saturated, so __regex_word
has to overlap with one of the values. This commit uses the same workaround
as bionic did (uint16_t for char_class_type inside regex_traits). It
should be possible to have libc++ provide the default rune table instead,
but that will require a new mechanism to detect newlib inside __config
since the header defining the newlib/picolibc macros has not been included
yet inside __config. Doing it this way also avoids duplicating the ctype
table for newlib, reducing the global data size.

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

23 months ago[SelectionDAG] Remove deprecated MemSDNode->getAlignment()
Alex Richardson [Mon, 21 Nov 2022 12:46:00 +0000 (12:46 +0000)]
[SelectionDAG] Remove deprecated MemSDNode->getAlignment()

I noticed a an assertion error when building MIPS code that loaded from
NULL. Loading from NULL ends up being a load with maximum alignment, and
due to integer truncation the value maximum was interpreted as 0 and the
assertion in MipsDAGToDAGISel::Select() failed. This previously happened
to work, but the maximum alignment was increased in
df84c1fe78130a86445d57563dea742e1b85156a, so it no longer fits into a 32
bit integer.
Instead of just fixing the one MIPS case, this patch removes all uses of
the deprecated getAlignment() call and replaces them with getAlign().

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

23 months ago[ASTContext][NFC] Remove getTargetAddressSpace(Qualifiers Q)
Alex Richardson [Tue, 22 Nov 2022 10:01:18 +0000 (10:01 +0000)]
[ASTContext][NFC] Remove getTargetAddressSpace(Qualifiers Q)

This simply calls getTargetAddressSpace(Q.getAddressSpace()) and there
are only two callers, so adjust those caller instead.

23 months ago[clang][RISCV][NFC] Prevent data race in RVVType::computeType
Kito Cheng [Mon, 21 Nov 2022 14:18:54 +0000 (22:18 +0800)]
[clang][RISCV][NFC] Prevent data race in RVVType::computeType

Introduce a RVVTypeCache to hold the cache instead of using a local
static variable to maintain a cache.

Also made construct of RVVType to private, make sure that could be only
created by a cache manager.

Reviewed By: sammccall

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

23 months agoAdd RegionBranchOpInterface for AffineIf Op
Akshay Baviskar [Wed, 23 Nov 2022 08:16:18 +0000 (13:46 +0530)]
Add RegionBranchOpInterface for AffineIf Op

Adds RegionBranchOpInterface for AffineIf Op and tests it
using buffer deallocation pass.

Reviewed By: bondhugula

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

23 months ago[mlir][tensor/memref] Disallow Collapse/ExpandShapeOps that do not reduce/increase...
Matthias Springer [Wed, 23 Nov 2022 08:19:00 +0000 (09:19 +0100)]
[mlir][tensor/memref] Disallow Collapse/ExpandShapeOps that do not reduce/increase the rank

CollapseShapeOp/ExpandShapeOp that do not change the rank (or increase/reduce it) are invalid.

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

23 months ago[NFC][mlir] VectorUtils / IndexingUtils simplifications and cleanups
Nicolas Vasilache [Tue, 22 Nov 2022 10:55:58 +0000 (02:55 -0800)]
[NFC][mlir] VectorUtils / IndexingUtils simplifications and cleanups

This revision refactors and cleans up a bunch of infra related to vector, shapes and indexing into more reusable APIs.

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

23 months ago[SCEV][NFC] Fix typo in comment
Max Kazantsev [Wed, 23 Nov 2022 07:38:24 +0000 (14:38 +0700)]
[SCEV][NFC] Fix typo in comment

23 months agoAdd MC support of RISCV Zcf Extension
WuXinlong [Tue, 22 Nov 2022 09:35:36 +0000 (17:35 +0800)]
Add MC support of RISCV Zcf Extension

This patch add the instructions of Zcf extension.

Zcf is a subset of C Ext which include the single-precision floating-point instructions.

Reviewed By: craig.topper

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

23 months agolibclc: Use cmake files instead of llvm-config
Tom Stellard [Wed, 23 Nov 2022 06:56:55 +0000 (22:56 -0800)]
libclc: Use cmake files instead of llvm-config

Reviewed By: mgorny

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

23 months ago[cmake] Fix Findzstd.cmake to handle OpenBSD shared libraries
Michał Górny [Sat, 19 Nov 2022 19:54:54 +0000 (20:54 +0100)]
[cmake] Fix Findzstd.cmake to handle OpenBSD shared libraries

Fix Findzstd CMake to handle shared libraries on OpenBSD correctly.
This userland does not use shared library symlinks without SOVERSION,
so the result of find_library() does not ever end with
zstd_SHARED_LIBRARY_SUFFIX.  To work around this, reverse the logic
to compare the result against zstd_STATIC_LIBRARY_SUFFIX and assume
shared library otherwise.

While at it, fix the conditions not to fall back to "result is static
library" path if it actually was recognized as a shared library but
zstd_shared target already existed.

Fixes #59056

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

23 months ago[ELF] createSyntheticSections: simplify config->relocatable. NFC
Fangrui Song [Wed, 23 Nov 2022 04:09:15 +0000 (20:09 -0800)]
[ELF] createSyntheticSections: simplify config->relocatable. NFC

We can add .riscv.attributes synthetic section here in the future.

23 months ago[RISCV] Add callback plumbing for getArithmeticInstrCost [nfc]
Philip Reames [Wed, 23 Nov 2022 02:51:23 +0000 (18:51 -0800)]
[RISCV] Add callback plumbing for getArithmeticInstrCost [nfc]

Most of the code for this was taken from https://reviews.llvm.org/D133552, with one bug fix by me.  I'm landing the plumbing so that we can focus on the cost model pieces in the review.

23 months ago[MachO][ObjCopy] Handle exports trie in LC_DYLD_INFO and LC_DYLD_EXPORTS_TRIE
Daniel Rodríguez Troitiño [Wed, 23 Nov 2022 02:27:23 +0000 (18:27 -0800)]
[MachO][ObjCopy] Handle exports trie in LC_DYLD_INFO and LC_DYLD_EXPORTS_TRIE

The exports trie used to be pointed by the information in LC_DYLD_INFO,
but when chained fixups are present, the exports trie is pointed by
LC_DYLD_EXPORTS_TRIE instead.

Modify ObjCopy code to calculate the right offset and size needed
depending on the existence of LC_DYLD_INFO or LC_DYLD_EXPORTS_TRIE, read
the exports from either of those places, and write the export
information as pointed to either of those places.

Depends on D134571.

Reviewed By: alexander-shaposhnikov

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

23 months agoGlobalIFunc: Make ifunc respect function address spaces
Matt Arsenault [Wed, 23 Nov 2022 02:02:20 +0000 (21:02 -0500)]
GlobalIFunc: Make ifunc respect function address spaces

23 months agoInstCombine: Fold some identities for canonicalize
Matt Arsenault [Fri, 11 Nov 2022 19:54:55 +0000 (11:54 -0800)]
InstCombine: Fold some identities for canonicalize

Equality is directly stated as true in the LangRef,
and I believe this works for every compare type.

23 months agoInstCombine: Add baseline tests for canonicalize identities
Matt Arsenault [Fri, 11 Nov 2022 19:24:09 +0000 (11:24 -0800)]
InstCombine: Add baseline tests for canonicalize identities

23 months ago[CostModel][X86] Add CostKinds test coverage for shufflevector instruction
Haohai Wen [Wed, 23 Nov 2022 01:40:50 +0000 (09:40 +0800)]
[CostModel][X86] Add CostKinds test coverage for shufflevector instruction

Reviewed By: RKSimon

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

23 months ago[AMDGPU][InsertWaits] No wait for WAW for global/scratch_load
Ruiling Song [Mon, 21 Nov 2022 07:33:18 +0000 (15:33 +0800)]
[AMDGPU][InsertWaits] No wait for WAW for global/scratch_load

global/scratch_load will return in order they are issued. No
need to insert a s_waitcnt for WAW hazard.

Reviewed By: foad

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

23 months ago[MachO] Support exports trie in both LC_DYLD_INFO and LC_DYLD_EXPORTS_TRIE
Daniel Rodríguez Troitiño [Tue, 22 Nov 2022 23:12:27 +0000 (15:12 -0800)]
[MachO] Support exports trie in both LC_DYLD_INFO and LC_DYLD_EXPORTS_TRIE

The exports trie used to be pointed by the information in LC_DYLD_INFO,
but when chained fixups are present, the exports trie is pointed by
LC_DYLD_EXPORTS_TRIE instead.

Modify the Object library to give access to the information pointed by
each of the load commands, and to fallback from one into the other when
the exports are requested.

Modify ObjectYAML to support dumping the export trie when pointed by
LC_DYLD_EXPORTS_TRIE and to parse the existence of a export trie also
when the load command is present.

This is a split of D134250 with improvements on top.

Reviewed By: alexander-shaposhnikov

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

23 months ago[X86] Use lock add/sub/or/and/xor for cases that we only care about the EFLAGS (negat...
Phoebe Wang [Wed, 23 Nov 2022 01:05:59 +0000 (09:05 +0800)]
[X86] Use lock add/sub/or/and/xor for cases that we only care about the EFLAGS (negated cases)

This fixes #58685

Reviewed By: RKSimon

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

23 months ago[NFC][DirectX backend] Update header to fix build error.
Xiang Li [Wed, 23 Nov 2022 01:34:45 +0000 (17:34 -0800)]
[NFC][DirectX backend] Update header to fix build error.

Fix build error caused by createPrintModulePass moving to diffrent
header.

23 months ago[AVR] Fix wrong ABI of AVRTiny.
Ben Shi [Thu, 17 Nov 2022 12:35:55 +0000 (20:35 +0800)]
[AVR] Fix wrong ABI of AVRTiny.

A scalar which exceeds 4 bytes should be returned via stack, other
than via registers, on an AVRTiny device.

Reviewed By: aykevl

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

23 months ago[bolt] Stop setting config.llvm_plugin_ext in lit.site.cfg.py.in
Nico Weber [Fri, 18 Nov 2022 21:02:34 +0000 (16:02 -0500)]
[bolt] Stop setting config.llvm_plugin_ext in lit.site.cfg.py.in

config.llvm_plugin_ext is used by lit to set the %pluginext
substitution. bolt's tests don't use %pluginext, so they don't
need to set config.llvm_plugin_ext.

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

23 months ago[DAGCombiner] fold or (xor x, y),? patterns
chenglin.bi [Wed, 23 Nov 2022 01:27:26 +0000 (09:27 +0800)]
[DAGCombiner] fold or (xor x, y),? patterns

or (xor x, y), x --> or x, y
or (xor x, y), y --> or x, y
or (xor x, y), (and x, y) --> or x, y
or (xor x, y), (or x, y) --> or x, y

Reviewed By: foad

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

23 months ago[PPC] Undefine __ppc64__ to match GCC
Fangrui Song [Wed, 23 Nov 2022 01:01:39 +0000 (17:01 -0800)]
[PPC] Undefine __ppc64__ to match GCC

GCC only defines `__ppc64__` for darwin while the darwin support has been
removed from llvm-project. The existence of `__ppc64__` makes some software
think we are compiling for big-endian PowerPC Mac; also it lures users to write
code which is not portable to GCC.

It is straightforward if a distro wants to keep the macro: add
`-D__ppc64__=1` to a Clang configuration file.

Reviewed By: thesamesam, nemanjai

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

23 months ago[mlir][sparse] fix compiler warning when using release build.
Peiming Liu [Wed, 23 Nov 2022 00:43:10 +0000 (00:43 +0000)]
[mlir][sparse] fix compiler warning when using release build.

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

23 months agoApply clang-tidy fixes for readability-simplify-boolean-expr in CSE.cpp (NFC)
Mehdi Amini [Thu, 17 Nov 2022 10:40:56 +0000 (10:40 +0000)]
Apply clang-tidy fixes for readability-simplify-boolean-expr in CSE.cpp (NFC)

23 months agoApply clang-tidy fixes for llvm-include-order in FileUtilities.cpp (NFC)
Mehdi Amini [Thu, 17 Nov 2022 10:15:21 +0000 (10:15 +0000)]
Apply clang-tidy fixes for llvm-include-order in FileUtilities.cpp (NFC)

23 months ago[asan] Don't demangle __odr_asan_gen_* symbols
Fangrui Song [Wed, 23 Nov 2022 00:47:33 +0000 (16:47 -0800)]
[asan] Don't demangle __odr_asan_gen_* symbols

This relands the ODR indicator part of D138095 (reverted by 06c74b5e7367b41e9b4ea3d74c971aace5681fb8):
a `__odr_asan_gen_*` symbol should use a mangled name as its associated symbol does.

23 months ago[BOLT][DWARF] Re-enable DWARF5 for asm-func-debug tests
Alexander Yermolovich [Wed, 23 Nov 2022 00:28:11 +0000 (16:28 -0800)]
[BOLT][DWARF] Re-enable DWARF5 for asm-func-debug tests

Now that BOLT supports DWARF5 re-enabling it for these two tests. This is update
to https://reviews.llvm.org/D125366

Reviewed By: rafauler

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

23 months agoRevert D138095 Use InernalAlloc in DemangleCXXABI
Fangrui Song [Wed, 23 Nov 2022 00:29:24 +0000 (16:29 -0800)]
Revert D138095 Use InernalAlloc in DemangleCXXABI

Broke 2/3 tests on macOS which seem to be related to
`free(demangled_name)` in DemangleCXXABI.

23 months ago[SROA] `isVectorPromotionViable()`: avoid allowing overly large vectors
Roman Lebedev [Wed, 23 Nov 2022 00:21:25 +0000 (03:21 +0300)]
[SROA] `isVectorPromotionViable()`: avoid allowing overly large vectors

Otherwise, `compiler-rt/test/asan/TestCases/pr33372.cpp` fails with an assertion:
```
clang-16: /repositories/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:11988: void llvm::SelectionDAG::createOperands(llvm::SDNode *, ArrayRef<llvm::SDValue>): Assertion `SDNode::getMaxNumOperands() >= Vals.size() && "too many operands to fit into SDNode"' failed.
```
I'm not sure if this should be even more conservative,
or if we have a named constant for this in middle-end.

23 months ago[AVR][Clang] Implement __AVR_HAVE_*__ macros
Ayke van Laethem [Mon, 7 Nov 2022 17:46:38 +0000 (18:46 +0100)]
[AVR][Clang] Implement __AVR_HAVE_*__ macros

These macros are defined in avr-gcc and are useful when working with
assembly. For example, startup code needs to copy the contents of .data
from flash to RAM, but should use elpm (instead of lpm) on devices with
more than 64kB flash. Without __AVR_HAVE_ELPM__, there is no way to know
whether the elpm instruction is supported.

This partially fixes https://github.com/llvm/llvm-project/issues/56157.

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

23 months ago[mlir][sparse] make resolve cycle works with affine expressions.
Peiming Liu [Thu, 17 Nov 2022 01:46:15 +0000 (01:46 +0000)]
[mlir][sparse] make resolve cycle works with affine expressions.

Reviewed By: aartbik

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

23 months ago[mlir][sparse] support affine expression on sparse dimensions (codegen implementation)
Peiming Liu [Thu, 17 Nov 2022 01:23:57 +0000 (01:23 +0000)]
[mlir][sparse] support affine expression on sparse dimensions (codegen implementation)

Reviewed By: aartbik

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

23 months ago[mlir][sparse] support affine expression on sparse dimensions (analysis implementation)
Peiming Liu [Thu, 17 Nov 2022 01:20:11 +0000 (01:20 +0000)]
[mlir][sparse] support affine expression on sparse dimensions (analysis implementation)

Reviewed By: aartbik

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

23 months agoFix lto AddStream callsite in gold plugin.
Zequan Wu [Tue, 22 Nov 2022 23:46:49 +0000 (15:46 -0800)]
Fix lto AddStream callsite in gold plugin.

23 months ago[SROA] `isVectorPromotionViable()`: memory intrinsics operate on vectors of bytes
Roman Lebedev [Tue, 22 Nov 2022 22:28:32 +0000 (01:28 +0300)]
[SROA] `isVectorPromotionViable()`: memory intrinsics operate on vectors of bytes

Now, there's a big caveat here - these bytes
are abstract bytes, not the i8 we have in LLVM,
so strictly speaking this is not exactly legal,
see e.g. https://github.com/AliveToolkit/alive2/issues/860
^ the "bytes" "could" have been a pointer,
and loading it as an integer inserts an implicit ptrtoint.

But at the same time,
InstCombine's `InstCombinerImpl::SimplifyAnyMemTransfer()`
would expand a memtransfer of 1/2/4/8 bytes
into integer-typed load+store,
so this isn't exactly a new problem.

Note that in memory, poison is byte-wise,
so we really can't widen elements,
but SROA seems to be inconsistent here.

Fixes #59116.

23 months ago[NFC][AMDGPU] Rewrite two test files to avoid completely simplifying away after next...
Roman Lebedev [Tue, 22 Nov 2022 22:25:49 +0000 (01:25 +0300)]
[NFC][AMDGPU] Rewrite two test files to avoid completely simplifying away after next patch

23 months ago[NFC][SROA] Autogenerate check lines in some tests being affected by upcoming change
Roman Lebedev [Mon, 21 Nov 2022 22:05:49 +0000 (01:05 +0300)]
[NFC][SROA] Autogenerate check lines in some tests being affected by upcoming change

23 months ago[NFC][SROA] Add some more tests for vector promotion
Roman Lebedev [Mon, 21 Nov 2022 22:01:25 +0000 (01:01 +0300)]
[NFC][SROA] Add some more tests for vector promotion

23 months ago[libcxx] Add _LIBCPP_NODEBUG to std::conditional related typedfs
David Blaikie [Wed, 3 Aug 2022 17:13:42 +0000 (17:13 +0000)]
[libcxx] Add _LIBCPP_NODEBUG to std::conditional related typedfs

Looks like std::conditional wasn't included in 14d4869209cc8ff9a53aaa5a59d6409fbc1c5f5d
(& maybe other typedefs that should be using this technique either got
missed or have regressed since that change was made)

This was noticed by a 1.4% clang.dwp regression due to
f4fb72e6d4cee1097e6606e66232fe55e793cd86 introducing more instantiations
of std::conditional - this change reduces that regression to 0.6% at
least.

I'm also looking at other instantiations caused by that change that
might be able to be addressed - but a quick grep shows ~200 "type"
typedefs missing _LIBCPP_NODEBUG, so maybe a systematic application of
the typedef might be suitable?

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

23 months agoRefactor AsmPrinterHandler callbacks. NFCI.
James Y Knight [Tue, 22 Nov 2022 18:35:43 +0000 (13:35 -0500)]
Refactor AsmPrinterHandler callbacks. NFCI.

The existing behaviors and callbacks were overlapping and had very
confusing semantics: beginBasicBlock/endBasicBlock were not always
called, beginFragment/endFragment seemed like they were meant to mean
the same thing, but were slightly different, etc. This resulted in
confusing semantics, virtual method overloads, and control flow.

Remove the above, and replace with new beginBasicBlockSection and
endBasicBlockSection callbacks. And document them.

These are always called before the first and after the last blocks in
a function, even when basic-block-sections are disabled.

23 months agoAdd generic KCFI operand bundle lowering
Sami Tolvanen [Thu, 18 Aug 2022 23:53:09 +0000 (23:53 +0000)]
Add generic KCFI operand bundle lowering

The KCFI sanitizer emits "kcfi" operand bundles to indirect
call instructions, which the LLVM back-end lowers into an
architecture-specific type check with a known machine instruction
sequence. Currently, KCFI operand bundle lowering is supported only
on 64-bit X86 and AArch64 architectures.

As a lightweight forward-edge CFI implementation that doesn't
require LTO is also useful for non-Linux low-level targets on
other machine architectures, add a generic KCFI operand bundle
lowering pass that's only used when back-end lowering support is not
available and allows -fsanitize=kcfi to be enabled in Clang on all
architectures.

This relands commit eb2a57ebc7aaad551af30462097a9e06c96db925 with
fixes.

Reviewed By: nickdesaulniers, MaskRay

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

23 months agoFix lto AddStreamFn in gold plugin.
Zequan Wu [Tue, 22 Nov 2022 22:59:43 +0000 (14:59 -0800)]
Fix lto AddStreamFn in gold plugin.

23 months ago[mlir][sparse] support constant affine expression on dense dimension
Peiming Liu [Wed, 16 Nov 2022 23:18:16 +0000 (23:18 +0000)]
[mlir][sparse] support constant affine expression on dense dimension

Reviewed By: aartbik

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

23 months ago[lit][AIX] Add LIBPATH to pass through env vars
David Tenty [Fri, 18 Nov 2022 23:33:12 +0000 (18:33 -0500)]
[lit][AIX] Add LIBPATH to pass through env vars

AIX uses LIBPATH to specify the library search path in addition to
LD_LIBRARY_PATH, and a lot of users / tooling will use it
preferentially. In lit we currently pass through LD_LIBRARY_PATH but not
LIBPATH in the env on AIX, this patch corrects this inconsistency.

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

23 months agoAdd runToBinaryEntry option for lldb-vscode
Jeffrey Tan [Fri, 30 Sep 2022 18:38:02 +0000 (11:38 -0700)]
Add runToBinaryEntry option for lldb-vscode

This patch adds a new runToBinaryEntry option which sets a one-shot breakpoint
at program entry. This option is useful for synchronizing module loading with
dynamic loader to measure debugger startup performance:  when program entry
one-short breakpoint hits most of the dependency modules should have been
loaded so this provides a good sample point for debugger startup time.

More explicitly for lldb-vscode, when this option is enabled, "Initialized" DAP
event is synchronously sent after most dependency modules are loaded.

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

23 months agoReland "[LTO][COFF] Use bitcode file names in lto native object file names."
Zequan Wu [Tue, 22 Nov 2022 21:46:42 +0000 (13:46 -0800)]
Reland "[LTO][COFF] Use bitcode file names in lto native object file names."

This reverts commit 34108082947c964ae9bbfcd9808f2fd31c0d672f with fixes.

23 months agoFix localCache in gold plugin.
Zequan Wu [Tue, 22 Nov 2022 21:42:54 +0000 (13:42 -0800)]
Fix localCache in gold plugin.

23 months agoRevert "Reland "[LTO][COFF] Use bitcode file names in lto native object file names.""
Roman Lebedev [Tue, 22 Nov 2022 21:39:11 +0000 (00:39 +0300)]
Revert "Reland "[LTO][COFF] Use bitcode file names in lto native object file names.""

Breaks build of LLVMgold here:
```
/repositories/llvm-project/llvm/tools/gold/gold-plugin.cpp:1108:19: error: no matching function for call to 'localCache'
    Cache = check(localCache("ThinLTO", "Thin", options::cache_dir, AddBuffer));
                  ^~~~~~~~~~
/repositories/llvm-project/llvm/include/llvm/Support/Caching.h:72:21: note: candidate function not viable: no known conversion from '(lambda at /repositories/llvm-project/llvm/tools/gold/gold-plugin.cpp:1102:20)' to 'llvm::AddBufferFn' (aka 'function<void (unsigned int, const llvm::Twine &, std::unique_ptr<MemoryBuffer>)>') for 4th argument
Expected<FileCache> localCache(
                    ^
/repositories/llvm-project/llvm/tools/gold/gold-plugin.cpp:1110:18: error: no viable conversion from '(lambda at /repositories/llvm-project/llvm/tools/gold/gold-plugin.cpp:1094:20)' to 'llvm::AddStreamFn' (aka 'function<Expected<std::unique_ptr<CachedFileStream>> (unsigned int, const llvm::Twine &)>')
  check(Lto->run(AddStream, Cache));
                 ^~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_function.h:375:7: note: candidate constructor not viable: no known conversion from '(lambda at /repositories/llvm-project/llvm/tools/gold/gold-plugin.cpp:1094:20)' to 'std::nullptr_t' for 1st argument
      function(nullptr_t) noexcept
      ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_function.h:386:7: note: candidate constructor not viable: no known conversion from '(lambda at /repositories/llvm-project/llvm/tools/gold/gold-plugin.cpp:1094:20)' to 'const std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream>> (unsigned int, const llvm::Twine &)> &' for 1st argument
      function(const function& __x)
      ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_function.h:404:7: note: candidate constructor not viable: no known conversion from '(lambda at /repositories/llvm-project/llvm/tools/gold/gold-plugin.cpp:1094:20)' to 'std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream>> (unsigned int, const llvm::Twine &)> &&' for 1st argument
      function(function&& __x) noexcept
      ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_function.h:435:2: note: candidate template ignored: requirement '_Callable<(lambda at /repositories/llvm-project/llvm/tools/gold/gold-plugin.cpp:1094:20) &, (lambda at /repositories/llvm-project/llvm/tools/gold/gold-plugin.cpp:1094:20), std::__invoke_result<(lambda at /repositories/llvm-project/llvm/tools/gold/gold-plugin.cpp:1094:20) &, unsigned int, const llvm::Twine &>>::value' was not satisfied [with _Functor = (lambda at /repositories/llvm-project/llvm/tools/gold/gold-plugin.cpp:1094:20) &]
        function(_Functor&& __f)
        ^
/repositories/llvm-project/llvm/include/llvm/LTO/LTO.h:278:25: note: passing argument to parameter 'AddStream' here
  Error run(AddStreamFn AddStream, FileCache Cache = nullptr);
                        ^

```

This reverts commit 387620aa8cea33174b6c1fb80c1af713fee732ac.

23 months ago[libc++] Replace __ppc64__ with __powerpc64__ and fix is_iec559 for non-ibm128
Fangrui Song [Tue, 22 Nov 2022 21:33:34 +0000 (13:33 -0800)]
[libc++] Replace __ppc64__ with __powerpc64__ and fix is_iec559 for non-ibm128

The lowercase `__ppc64__` is not defined by non-darwin powerpc64 GCC, therefore
it lures users to write code which is not portable to GCC. Migrate to
`__powerpc64__` in preparation for undefining `__ppc64__`. `__powerpc64__` is
much more common than `__PPC64__`.

Update alignment_of.pass.cpp to use 1 unconditionally:
on powerpc-unknown-linux-gnu `alignof(bool) = _Alignof(bool) = __alignof(bool) = 1`.
The value 4 might be derived from an ancient Clang.

Change is_iec559 to true when long double uses uses IEEE 754 quadruple or double
precision (i.e. not ibm128).

Reviewed By: #libc, thesamesam, ldionne

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

23 months ago[libc++][NFC] Add missing #ifdef for TEST_HAS_NO_WIDE_CHARACTERS
Louis Dionne [Tue, 22 Nov 2022 21:26:43 +0000 (16:26 -0500)]
[libc++][NFC] Add missing #ifdef for TEST_HAS_NO_WIDE_CHARACTERS

23 months agoXFAIL hidden-duplicates.m for AIX and zOS
Nancy Wang [Tue, 22 Nov 2022 19:31:51 +0000 (14:31 -0500)]
XFAIL hidden-duplicates.m for AIX and zOS

as this is failing on the build bots:

https://lab.llvm.org/buildbot/#/builders/214/builds/4442/steps/6/logs/FAIL__Clang__hidden-duplicates_m

and is being investigate under https://reviews.llvm.org/D130327.

23 months ago[SROA] `isVectorPromotionViable()`: integer-ify non-pointer non-common types
Roman Lebedev [Tue, 22 Nov 2022 21:04:06 +0000 (00:04 +0300)]
[SROA] `isVectorPromotionViable()`: integer-ify non-pointer non-common types

This rectifies a FIXME that dates all the way back
to 2014 about not doing so due to the backend issues.

Presumably sufficient amount of time has passes
and all the known issues have been addressed,
or at least we will find out of there are some left...

23 months ago[SROA] `isVectorPromotionViable()`: pointer-ness is sticky
Roman Lebedev [Tue, 22 Nov 2022 16:54:39 +0000 (19:54 +0300)]
[SROA] `isVectorPromotionViable()`: pointer-ness is sticky

As it has been established previously by precedent,
if we see a pointer type, then that is the type we must use.
Essentially, we don't want to introduce `inttoptr`'s.

23 months ago[AMDGPU] More cleanup after D117544. NFC.
Jay Foad [Tue, 22 Nov 2022 18:40:22 +0000 (18:40 +0000)]
[AMDGPU] More cleanup after D117544. NFC.

23 months ago[ELF] -r: don't define _TLS_MODULE_BASE_
Fangrui Song [Tue, 22 Nov 2022 20:59:45 +0000 (12:59 -0800)]
[ELF] -r: don't define _TLS_MODULE_BASE_

_TLS_MODULE_BASE_ is supposed to be defined by the final link. Defining it in a
relocatable link may render the final link value incorrect.

GNU ld i386/x86-64 have the same issue: https://sourceware.org/bugzilla/show_bug.cgi?id=29820

23 months ago[Sema] check InitListExpr format strings like {"foo"}
Yingchi Long [Fri, 11 Nov 2022 14:45:08 +0000 (22:45 +0800)]
[Sema] check InitListExpr format strings like {"foo"}

Adds InitListExpr case in format string checks.

e.g.

    int sprintf(char *__restrict, const char * __restrict, ...);

    int foo()
    {
        char data[100];
        constexpr const char* fmt2{"%d"};  // no-warning
        sprintf(data, fmt2, 123);
    }

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

Reviewed By: aaron.ballman

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

23 months ago[ELF] -r: don't define __global_pointer$
Fangrui Song [Tue, 22 Nov 2022 20:37:51 +0000 (12:37 -0800)]
[ELF] -r: don't define __global_pointer$

This symbol is supposed to be defined by the final executable link. The new
behavor matches GNU ld.

23 months ago[X86] Don't lower f16->f80 fpext to libcall on darwin.
Davide Italiano [Tue, 22 Nov 2022 20:29:44 +0000 (12:29 -0800)]
[X86] Don't lower f16->f80 fpext to libcall on darwin.

We don't provide __extendhfxf2, and only have the soft-float
__extendhfsf2 in compiler-rt.  This only changed recently with
655ba9c8a1d2, so this patch reverts back to the previous behavior.

However, the f80->f16 fptrunc is not easily implementable without
the compiler-rt __truncxfhf2, but that has always been true, and
isn't an immediate regression.

Patch by Ahmed Bougacha.

rdar://102194995

23 months ago[llvm-mca] Fix class dominance warnings for parseCodeRegions
Michael Maitland [Tue, 22 Nov 2022 00:02:47 +0000 (16:02 -0800)]
[llvm-mca] Fix class dominance warnings for parseCodeRegions

Fixes issue [59091](https://github.com/llvm/llvm-project/issues/59091).

`CodeRegionGenerator::parseCodeRegions` is implemented by `AsmCodeRegionGenerator`.
If it were to be implemented in `AnalysisRegionGenerator` or `InstrumentRegionGenerator`,
then `parseCodeRegions` from an `AsmAnalysisRegionGenerator` or `AsmInstrumentRegionGenerator`
object would be ambiguous. To solve this, `AsmAnalysisRegionGenerator` and
`AsmInstrumentRegionGenerator` qualify their call to `AsmCodeRegionGenerator::parseCodeRegions`.

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

23 months ago[libcxxabi] Always use thread_local for cxa_exception_storage
Shoaib Meenai [Mon, 21 Nov 2022 23:59:42 +0000 (15:59 -0800)]
[libcxxabi] Always use thread_local for cxa_exception_storage

This was previously guarded by HAS_THREAD_LOCAL, which was never set by
CMake and had to be specified manually. Android has been setting this to
solve https://github.com/android/ndk/issues/1200 [1], but every compiler
and platform libc++abi supports should have thread_local by now, so we
can just get rid of the fallback implementation and simplify things
significantly (including removing the now unused fallback calloc).

[1] https://android-review.googlesource.com/c/toolchain/llvm-project/+/1285596

Reviewed By: #libc_abi, MaskRay, ldionne

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

23 months ago[Hexagon] Add missing patterns for select
Ikhlas Ajbar [Tue, 22 Nov 2022 20:19:36 +0000 (12:19 -0800)]
[Hexagon] Add missing patterns for select

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

23 months ago[VectorCombine] Don't touch instruction after foldSingleElementStore, it might be...
Benjamin Kramer [Tue, 22 Nov 2022 20:12:42 +0000 (21:12 +0100)]
[VectorCombine] Don't touch instruction after foldSingleElementStore, it might be deleted

Use after free found by asan.

23 months agoMake -fsanitize=scudo use scudo_standalone. Delete check-scudo.
Mitch Phillips [Tue, 22 Nov 2022 18:27:46 +0000 (10:27 -0800)]
Make -fsanitize=scudo use scudo_standalone. Delete check-scudo.

Leaves the implementation and tests files in-place for right now, but
deletes the ability to build the old sanitizer-common based scudo. This
has been on life-support for a long time, and the newer scudo_standalone
is much better supported and maintained.

Also patches up some GWP-ASan wording, primarily related to the fact
that -fsanitize=scudo now is scudo_standalone, and therefore the way to
reference the GWP-ASan options through the environment variable has
changed.

Future follow-up patches will delete the original scudo, and migrate all
its tests over to be part of the scudo_standalone test suite.

Reviewed By: vitalybuka

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

23 months agoRevert "[CGObjC] Add run line for release mode in test arc-exceptions-seh.mm (NFC)"
Stefan Gränitz [Tue, 22 Nov 2022 19:51:09 +0000 (20:51 +0100)]
Revert "[CGObjC] Add run line for release mode in test arc-exceptions-seh.mm (NFC)"

This reverts commit 01023bfcd33f922ed8c934ce563e54abe8bfe246. The extended test now triggers undefined behavior:
```
/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp:577:41: runtime error: load of value 180, which is not a valid value for type 'bool'
    #0 0xaaaae3333a30 in hasCFGChanged /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp:577:41
    #1 0xaaaae3333a30 in llvm::ObjCARCOptPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp:2494:26
    ...
```

23 months ago[ELF] addRelIpltSymbols: make it explicit some passes are for non-relocatable links...
Fangrui Song [Tue, 22 Nov 2022 19:38:57 +0000 (11:38 -0800)]
[ELF] addRelIpltSymbols: make it explicit some passes are for non-relocatable links. NFC

and prepare for __global_pointer$ and _TLS_MODULE_BASE_ fix.

23 months ago[CHR] Add a threshold for the code duplication
Rong Xu [Tue, 22 Nov 2022 19:22:38 +0000 (11:22 -0800)]
[CHR] Add a threshold for the code duplication

ControlHeightReduction (CHR) clones the code region to reduce the
branches in the hot code path. The number of clones is linear to the
depth of the region.

Currently it does not have control over the code size increase. We are
seeing one ~9000 BB functions get expanded to ~250000 BBs, an 25x
increase. This creates a big compile time issue for the downstream
optimizations.

This patch adds a cap for number of clones for one region.

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

23 months ago[libc++][math.h][NFC] Refactor enable_ifs
Nikolas Klauser [Fri, 4 Nov 2022 19:08:56 +0000 (20:08 +0100)]
[libc++][math.h][NFC] Refactor enable_ifs

Reviewed By: ldionne, Mordante, #libc

Spies: EricWF, libcxx-commits

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