platform/upstream/llvm.git
14 months ago[libc++] Fix __verbose_abort in C++11
Louis Dionne [Thu, 27 Apr 2023 17:54:09 +0000 (13:54 -0400)]
[libc++] Fix __verbose_abort in C++11

__use() can't be marked as constexpr in C++11 because it returns void,
which is not a literal type. But it turns out that we just don't need
to define it at all, since it's never called outside of decltype.

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

14 months ago[NFC][CLANG] Fix coverity remarks about large copy by values
Manna, Soumi [Fri, 28 Apr 2023 18:53:43 +0000 (11:53 -0700)]
[NFC][CLANG] Fix coverity remarks about large copy by values

Reported By Static Analyzer Tool, Coverity:

Big parameter passed by value
Copying large values is inefficient, consider passing by reference; Low, medium, and high size thresholds for detection can be adjusted.

1. Inside "CodeGenModule.cpp" file, in clang::CodeGen::CodeGenModule::EmitBackendOptionsMetadata(clang::CodeGenOptions): A very large function call parameter exceeding the high threshold is passed by value.

pass_by_value: Passing parameter CodeGenOpts of type clang::CodeGenOptions const (size 2168 bytes) by value, which exceeds the high threshold of 512 bytes.

2. Inside "SemaType.cpp" file, in IsNoDerefableChunk(clang::DeclaratorChunk): A large function call parameter exceeding the low threshold is passed by value.

pass_by_value: Passing parameter Chunk of type clang::DeclaratorChunk (size 176 bytes) by value, which exceeds the low threshold of 128 bytes.

3. Inside "CGNonTrivialStruct.cpp" file, in <unnamed>::getParamAddrs<1ull, <0ull...>>(std::integer_sequence<unsigned long long, T2...>, std::array<clang::CharUnits, T1>, clang::CodeGen::FunctionArgList, clang::CodeGen::CodeGenFunction *): A large function call parameter exceeding the low threshold is passed by value.

.i. pass_by_value: Passing parameter Args of type clang::CodeGen::FunctionArgList (size 144 bytes) by value, which exceeds the low threshold of 128 bytes.

4. Inside "CGGPUBuiltin.cpp" file, in <unnamed>::containsNonScalarVarargs(clang::CodeGen::CodeGenFunction *, clang::CodeGen::CallArgList): A very large function call parameter exceeding the high threshold is passed by value.

i. pass_by_value: Passing parameter Args of type clang::CodeGen::CallArgList (size 1176 bytes) by value, which exceeds the high threshold of 512 bytes.

Reviewed By: tahonermann

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

14 months ago[libc++] Clean up pair's constructors and assignment operators
Louis Dionne [Tue, 7 Feb 2023 23:21:08 +0000 (15:21 -0800)]
[libc++] Clean up pair's constructors and assignment operators

This patch makes std::pair's constructors and assignment operators
closer to conforming in C++23. The only missing bit I am aware of
now is `reference_constructs_from_temporary_v` checks, which we
don't have the tools for yet.

This patch also refactors a long-standing non-standard extension where
we'd provide constructors for tuple-like types in all standard modes. The
criteria for being a tuple-like type are different from pair-like types
as introduced recently in the standard, leading to a lot of complexity
when trying to implement recent papers that touch the pair constructors.

After this patch, the pre-C++23 extension is provided in a self-contained
block so that we can easily deprecate and eventually remove the extension
in future releases.

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

14 months ago[flang][openacc][NFC] Cleanup enter data lowering
Valentin Clement [Fri, 28 Apr 2023 18:50:47 +0000 (11:50 -0700)]
[flang][openacc][NFC] Cleanup enter data lowering

Remove copyinOperands, createOperands, createZeroOperands, attachOperands
SmallVectors as they are not used anymore.
The op itself cannot be cleanup yet because
`mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp`
still depends on it. The final clean up on the op will be down once
the translation uses the new data operand operations.

Reviewed By: vzakhari

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

14 months ago[Flang] Add a missing case for bfloat
Kiran Chandramohan [Fri, 28 Apr 2023 18:37:52 +0000 (18:37 +0000)]
[Flang] Add a missing case for bfloat

A case was missed for the bfloat type in the getRealType function
in FIRBuilder. This can cause a crash in some situations like in
the provided test. The patch adds the missing case.

Reviewed By: vzakhari

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

14 months ago[Clang][Doc] Added an open project for improving command line docs
Shivam Gupta [Fri, 28 Apr 2023 17:59:52 +0000 (23:29 +0530)]
[Clang][Doc] Added an open project for improving command line docs

There seems to be a lot of documentation is missing
for different command line flags uses.
This create confusion with same looking options, better to
document clearly their uses.

Reviewed By: aaron.ballman

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

14 months ago[mlir][arith] Add patterns to commute extension over vector extraction
Jakub Kuderski [Fri, 28 Apr 2023 17:48:48 +0000 (13:48 -0400)]
[mlir][arith] Add patterns to commute extension over vector extraction

This moves zero/sign-extension ops closer to their use and exposes more
narrowing optimization opportunities.

Reviewed By: antiagainst

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

14 months ago[clangd] Hover: resolve forwarding parameters for CalleeArgInfo
Tom Praschan [Sat, 8 Apr 2023 12:04:47 +0000 (14:04 +0200)]
[clangd] Hover: resolve forwarding parameters for CalleeArgInfo

This uses the logic added in D124690

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

14 months ago[Driver] Pass --target2= to linker from baremetal toolchain
Mikhail Maltsev [Fri, 28 Apr 2023 17:30:49 +0000 (18:30 +0100)]
[Driver] Pass --target2= to linker from baremetal toolchain

According to the GNU ld manual
https://sourceware.org/binutils/docs/ld/ARM.html#ARM the R_ARM_TARGET2
relocation (used in exception handling tables) is treated differently
depending on the target. By default, LLD treats R_ARM_TARGET2 as
R_ARM_GOT_PREL (--target2=got-rel), which is correct for Linux but not
for embedded targets.

This patch adds --target2=rel to linker options in the baremetal
toolchain driver so that on baremetal targets, R_ARM_TARGET2 is
treated as R_ARM_REL32. Such behavior is compatible with GNU ld and
unwinding libraries (e.g., libuwind).

Reviewed By: peter.smith, phosek

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

14 months ago[NFC] Fix a mem-sanitizer found issue in AutoType
Erich Keane [Fri, 28 Apr 2023 16:54:28 +0000 (09:54 -0700)]
[NFC] Fix a mem-sanitizer found issue in AutoType

We only need the list of constriant template arguments when we have a
valid constraint.  We give up on merging the auto-type constraints if
the template arguments don't match, but neglected to clear the
collection of template arguments.  The result was we had an AutoType
where we initialized the number of template arguments, but never
initialized the template arguments themselves.

This patch adds an assert to catch this in the future, plus ensures we
clear out the vector so we don't try to create the AutoType incorrectly.

14 months ago[NFC][SLP] Cleanup: Moves code that changes the reduction root into a separate function.
Vasileios Porpodas [Thu, 27 Apr 2023 18:22:12 +0000 (11:22 -0700)]
[NFC][SLP] Cleanup: Moves code that changes the reduction root into a separate function.

This makes `matchAssociativeReduction()` a bit simpler.

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

14 months ago[sanitizer] Remove crypt and crypt_r interceptors
Fangrui Song [Fri, 28 Apr 2023 16:59:17 +0000 (09:59 -0700)]
[sanitizer] Remove crypt and crypt_r interceptors

From Florian Weimer's D144073

> On GNU/Linux (glibc), the crypt and crypt_r functions are not part of the main shared object (libc.so.6), but libcrypt (with multiple possible sonames). The sanitizer libraries do not depend on libcrypt, so it can happen that during sanitizer library initialization, no real implementation will be found because the crypt, crypt_r functions are not present in the process image (yet). If its interceptors are called nevertheless, this results in a call through a null pointer when the sanitizer library attempts to forward the call to the real implementation.
>
> Many distributions have already switched to libxcrypt, a library that is separate from glibc and that can be build with sanitizers directly (avoiding the need for interceptors). This patch disables building the interceptor for glibc targets.

Let's remove crypt and crypt_r interceptors (D68431) to fix issues with
newer glibc.

For older glibc, msan will not know that an uninstrumented crypt_r call
initializes `data`, so there is a risk for false positives. However, with some
codebase survey, I think crypt_r uses are very few and the call sites typically
have a `memset(&data, 0, sizeof(data));` anyway.

Fix https://github.com/google/sanitizers/issues/1365
Related: https://bugzilla.redhat.com/show_bug.cgi?id=2169432

Reviewed By: #sanitizers, fweimer, thesamesam, vitalybuka

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

14 months agoHost: generalise `GetXcodeSDKPath`
Saleem Abdulrasool [Fri, 28 Apr 2023 16:29:19 +0000 (09:29 -0700)]
Host: generalise `GetXcodeSDKPath`

This generalises the GetXcodeSDKPath hook to a GetSDKRoot path which
will be re-used for the Windows support to compute a language specific
SDK path on the platform. Because there may be other options that we
wish to use to compute the SDK path, sink the XcodeSDK parameter into
a structure which can pass a disaggregated set of options. Furthermore,
optionalise the parameter as Xcode is not available for all platforms.

Differential Revision: https://reviews.llvm.org/D149397
Reviewed By: JDevlieghere

14 months ago[flang][hlfir] Fixed hlfir.assign codegen for polymorphic LHS.
Slava Zakharin [Fri, 28 Apr 2023 16:07:23 +0000 (09:07 -0700)]
[flang][hlfir] Fixed hlfir.assign codegen for polymorphic LHS.

The RHS cannot be casted to the LHS type, when LHS is polymorphic.
With this change we will use the RHS type for emboxing with special
hadling for i1 type.

I created https://github.com/llvm/llvm-project/issues/62419 for the
AllocaOp generated during HLFIRtoFir conversion.

Reviewed By: jeanPerier

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

14 months agoHandle `select` in programUndefinedIfPoison.
Justin Lebar [Fri, 28 Apr 2023 06:31:26 +0000 (23:31 -0700)]
Handle `select` in programUndefinedIfPoison.

If both the true and false operands of a `select` are poison, then the `select`
is poison.

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

14 months ago[flang][hlfir] Fixed length-one assignment.
Slava Zakharin [Fri, 28 Apr 2023 15:50:55 +0000 (08:50 -0700)]
[flang][hlfir] Fixed length-one assignment.

Assignment from a character dummy argument to a length-one character
variable resulted in illegal fir.convert:
  %0 = fir.load %unboxed_dummy : !fir.ref<!fir.char<1,?>>
  %1 = fir.convert %0 : (!fir.char<1,?>) -> !fir.char<1>
  fir.store %1 to %local : !fir.ref<!fir.char<1>>

This change fixes the length-one assignment code to use proper casts.

For character dummy arguments with constant length we will now also
type cast the unboxed reference to the character type with constant length
during the lowering:
  fir.convert %x : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.char<1,8>>

I also adjusted the length-one assignment recognition so that in case
of same-length assignment we recognize length-one from either LHS or RHS
data types.

Reviewed By: jeanPerier

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

14 months ago[flang][hlfir] Fixed actual argument type for passing to poly dummy.
Slava Zakharin [Fri, 28 Apr 2023 00:45:06 +0000 (17:45 -0700)]
[flang][hlfir] Fixed actual argument type for passing to poly dummy.

The `none` type cannot be used for creating AssociateOp for the actual
argument. I think it should be always okay to compute the storage
data type based on the actual argument expression.

14 months ago[mlir][spirv] Fix nullptr dereference in UnifyAliasedResource
Jakub Kuderski [Fri, 28 Apr 2023 15:39:22 +0000 (11:39 -0400)]
[mlir][spirv] Fix nullptr dereference in UnifyAliasedResource

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

Reviewed By: antiagainst

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

14 months ago[RISCV] Introduce unaligned-vector-mem feature
Philip Reames [Fri, 28 Apr 2023 15:16:48 +0000 (08:16 -0700)]
[RISCV] Introduce unaligned-vector-mem feature

This allows us to model and thus test transforms which are legal only when a vector load with less than element alignment are supported. This was originally part of D126085, but was split out as we didn't have a good example of such a transform. As can be seen in the test diffs, we have the recently added concat_vector(loads) -> strided_load transform (from D147713) which now benefits from the unaligned support.

While making this change, I realized that we actually *do* support unaligned vector loads and stores of all types via conversion to i8 element type. For contiguous loads and stores without masking, we actually already implement this in the backend - though we don't tell the optimizer that. For indexed, lowering to i8 requires complicated addressing. For indexed and segmented, we'd have to use indexed. All around, doesn't seem worthwhile pursuing, but makes for an interesting observation.

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

14 months ago[llvm-gsymutil] Add gsymutil to llvm driver build
Alex Brachet [Fri, 28 Apr 2023 15:15:16 +0000 (15:15 +0000)]
[llvm-gsymutil] Add gsymutil to llvm driver build

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

14 months ago[RISCV] Consolidate legality checking for strided load/store [nfc]
Philip Reames [Fri, 28 Apr 2023 15:07:28 +0000 (08:07 -0700)]
[RISCV] Consolidate legality checking for strided load/store [nfc]

Note that the strided load from concat_vector combine was using the wrong legality test. It happened to work out as the alignment requirement is based on the scalar type either way, but unless I'm missing something allowsMisalignedAccess is expecting a contiguous memory access.

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

14 months ago[SCEV] Skip instrs with non-scevable types in visitAndClearUsers.
Florian Hahn [Fri, 28 Apr 2023 14:37:32 +0000 (15:37 +0100)]
[SCEV] Skip instrs with non-scevable types in visitAndClearUsers.

No SCEVs are formed for instructions with non-scevable types, so no
other SCEV expressions can depend on them. Skip those instructions and
their users when invalidating SCEV expressions.

Depends on D144847.

Reviewed By: mkazantsev

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

14 months ago[SCEV] Add tests for ptrtoint with different globals.
Florian Hahn [Fri, 28 Apr 2023 14:29:07 +0000 (15:29 +0100)]
[SCEV] Add tests for ptrtoint with different globals.

14 months ago[ARM] Enable shouldFoldSelectWithIdentityConstant for MVE
David Green [Fri, 28 Apr 2023 13:57:51 +0000 (14:57 +0100)]
[ARM] Enable shouldFoldSelectWithIdentityConstant for MVE

We already have tablegen patterns for a lot of these, but performing the
combine earlier in DAG can help in a few extra cases.

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

14 months ago[EarlyCSE] Do not CSE convergent calls in different basic blocks
Jay Foad [Thu, 27 Apr 2023 12:43:11 +0000 (13:43 +0100)]
[EarlyCSE] Do not CSE convergent calls in different basic blocks

"convergent" is documented as meaning that the call cannot be made
control-dependent on more values, but in practice we also require that
it cannot be made control-dependent on fewer values, e.g. it cannot be
hoisted out of the body of an "if" statement.

In code like this, if we allow CSE to combine the two calls:

  x = convergent_call();
  if (cond) {
    y = convergent_call();
    use y;
  }

then we get this:

  x = convergent_call();
  if (cond) {
    use x;
  }

This is conceptually equivalent to moving the second call out of the
body of the "if", up to the location of the first call, so it should be
disallowed.

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

14 months ago[CSE] Precommit an AMDGPU test case for D149348
Jay Foad [Thu, 27 Apr 2023 13:45:32 +0000 (14:45 +0100)]
[CSE] Precommit an AMDGPU test case for D149348

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

14 months ago[OpenMP] Add missing -L to libomptarget tests
Joel E. Denny [Fri, 28 Apr 2023 13:47:39 +0000 (09:47 -0400)]
[OpenMP] Add missing -L to libomptarget tests

Without this patch, if an incompatible libomptarget.so is present in a
system directory, such as /usr/lib64, check-openmp fails many
libomptarget tests with linking errors.  The problem appears to have
started at D129875, which landed as dc52712a0632.  This patch extends
the libomptarget test suite config with a -L for the current build
directory of libomptarget.so.

Reviewed By: jhuber6, JonChesterfield

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

14 months ago[SCEV] Use SmallDenseMap in SCEVRewriteVisitor (NFC)
Nikita Popov [Fri, 28 Apr 2023 12:37:29 +0000 (14:37 +0200)]
[SCEV] Use SmallDenseMap in SCEVRewriteVisitor (NFC)

14 months ago[AIX][llvm-ar] Use the Correct Kind for Bitcode File Inputs
Qiongsi Wu [Fri, 28 Apr 2023 12:42:51 +0000 (08:42 -0400)]
[AIX][llvm-ar] Use the Correct Kind for Bitcode File Inputs

On AIX, when the input files are LLVM bitcode files, `llvm-ar` should set the archive kind to `K_AIXBIG` as well, instead of leaving it to the default `K_GNU`.

Reviewed By: daltenty

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

14 months ago[AArch64] Add preserve_all calling convention.
Daniel Kiss [Fri, 28 Apr 2023 12:01:51 +0000 (14:01 +0200)]
[AArch64] Add preserve_all calling convention.

Clang accepts preserve_all for AArch64 while it is missing form the backed.

Fixes #58145

Reviewed By: efriedma

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

14 months ago[ARM] Update and regenerate pred-selectop test. NFC
David Green [Fri, 28 Apr 2023 12:47:14 +0000 (13:47 +0100)]
[ARM] Update and regenerate pred-selectop test. NFC

Shift and fdiv tests have been added to show the reverse transform.

14 months ago[SCEV] Don't invalidate past dependency-breaking instructions
Nikita Popov [Thu, 27 Apr 2023 07:36:35 +0000 (09:36 +0200)]
[SCEV] Don't invalidate past dependency-breaking instructions

When invalidating a value, we walk all users of that value and
invalidate them as well. This can be very expensive for large use
graphs.

However, we only need to invalidate a user U of instruction I if
SCEV(U) can depend on SCEV(I). This is not the case if U is an
instruction that always produces a SCEVUnknown, such as a load.
If the load pointer operand is invalidated, there is no need to
invalidate the load result, which is completely unrelated from a
SCEV perspective.

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

14 months ago[LICM] Don't duplicate instructions just because they're free
Nikita Popov [Wed, 26 Apr 2023 08:00:42 +0000 (10:00 +0200)]
[LICM] Don't duplicate instructions just because they're free

D37076 makes LICM duplicate instructions into exit blocks if the
instruction is free. For GEPs, the motivation appears to be that
this allows the GEP to be folded into addressing modes, while
non-foldable users outside the loop might prevent this. TBH I don't
think LICM is the place to do this (why doesn't CGP apply this
heuristic itself?) but at least I understand the motivation.

However, the transform is also applied to all other "free"
instructions, which are just that (removed during lowering and not
"folded" in some way). For such instructions, this transform seems
somewhere between useless, counter-productive (undoing CSE/GVN) and
actively incorrect. For example, this transform can duplicate freeze
instructions, which is illegal.

This patch limits the transform to just foldable GEPs, though we
might want to drop it from LICM entirely as a followup.

This is a small compile-time improvement, because querying TTI cost
model for every single instruction is expensive.

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

14 months agoRevert "[BOLT] Parallelize legacy profile merging"
Yi Kong [Fri, 28 Apr 2023 12:24:52 +0000 (21:24 +0900)]
Revert "[BOLT] Parallelize legacy profile merging"

This reverts commit 35af20d9e036deeed250b73fd3ae86d6455173c5.

The patch caused a test failure.

14 months ago[PGO] Fix expensive test compilation error
Christian Ulmann [Fri, 28 Apr 2023 12:10:47 +0000 (12:10 +0000)]
[PGO] Fix expensive test compilation error

This commit fixes a compilation error introduced in
https://reviews.llvm.org/D149361

Reviewed By: gysit

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

14 months ago[LV] Add tests for integer min max with index reduction pattern. (NFC)
Mel Chen [Thu, 23 Mar 2023 09:01:29 +0000 (02:01 -0700)]
[LV] Add tests for integer min max with index reduction pattern. (NFC)

The test case for signed max with index, include strict and non-strict
max.

Reviewed By: fhahn

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

14 months ago[VPlan] Turn Plan entry node into VPBasicBlock (NFCI).
Florian Hahn [Fri, 28 Apr 2023 11:29:05 +0000 (12:29 +0100)]
[VPlan] Turn Plan entry node into VPBasicBlock (NFCI).

The entry to the plan is the preheader of the vector loop and
guaranteed to be a VPBasicBlock. Make sure this is the case by
adjusting the type.

Reviewed By: Ayal

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

14 months ago[clang] Diagnose shadowing of lambda's template parameter by a capture
Mariya Podchishchaeva [Fri, 28 Apr 2023 10:26:35 +0000 (06:26 -0400)]
[clang] Diagnose shadowing of lambda's template parameter by a capture

expr.prim.lambda.capture p5 says:
If an identifier in a capture appears as the declarator-id of a parameter of
the lambda-declarator's parameter-declaration-clause or as the name of a
template parameter of the lambda-expression's template-parameter-list,
the program is ill-formed.
and also has the following example:
```
auto h = [y = 0]<typename y>(y) { return 0; };
```
which now results in
```
error: declaration of 'y' shadows template parameter
  auto l1 = [y = 0]<typename y>(y) { return 0; };
             ^
note: template parameter is declared here
  auto l1 = [y = 0]<typename y>(y) { return 0; };
                             ^
```

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

Reviewed By: shafik, cor3ntin

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

14 months agoRe-apply "[Passes] Remove legacy PM versions of InstructionNamer and MetaRenamer"
Bjorn Pettersson [Sun, 16 Apr 2023 21:17:58 +0000 (23:17 +0200)]
Re-apply "[Passes] Remove legacy PM versions of InstructionNamer and MetaRenamer"

A new attempt after removing uses of -instnamer in polly lit tests
in D148530.

14 months ago[polly] Drop redundant use of -instnamer in polly MemAccess lit tests
Bjorn Pettersson [Mon, 17 Apr 2023 14:07:15 +0000 (16:07 +0200)]
[polly] Drop redundant use of -instnamer in polly MemAccess lit tests

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

14 months ago[RISCV] Fix labels in fixed-vectors-fp test
Luke Lau [Fri, 28 Apr 2023 11:00:47 +0000 (12:00 +0100)]
[RISCV] Fix labels in fixed-vectors-fp test

14 months agoReland D147337 "[tsan] Add debugging interfaces into interface header."
Pierre Gousseau [Mon, 17 Apr 2023 14:32:57 +0000 (14:32 +0000)]
Reland D147337 "[tsan] Add debugging interfaces into interface header."

This change the types to match the ones used in:
Darwin/debug_external.cpp
debugging.cpp

Reviewed By: vitalybuka

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

14 months ago[TEST][LICM] Add test cases on widenable condition hoisting opportunity
Max Kazantsev [Fri, 28 Apr 2023 10:52:54 +0000 (17:52 +0700)]
[TEST][LICM] Add test cases on widenable condition hoisting opportunity

Patch by Aleksandr Popov!

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

14 months agoReapply D146987 "[Assignment Tracking] Enable by default"
OCHyams [Fri, 28 Apr 2023 08:43:50 +0000 (09:43 +0100)]
Reapply D146987 "[Assignment Tracking] Enable by default"

See https://discourse.llvm.org/t/rfc-enable-assignment-tracking/69399

This sets the -Xclang -fexperimental-assignment-tracking flag to the value
enabled which means it will be enabled so long as none of the following are
true: it's an LTO build, LLDB debugger tuning has been specified, or it's an O0
build (no work is done in any case if -g is not specified or -gmlt is used).

This reverts commit 0ba922f600469df273c753f873668e41025487c0 which reverts
https://reviews.llvm.org/D146987

14 months ago[OpenMP] Add LIT test on task depend clause
Animesh Kumar [Thu, 23 Mar 2023 09:28:01 +0000 (14:58 +0530)]
[OpenMP] Add LIT test on task depend clause

The working of depend clause with iterator modifier
can be correctly tested by means of execution tests
and not at the LLVM IR level. These tests
are imported/inspired from the SOLLVE tests.

SOLLVE repo: https://github.com/SOLLVE/sollve_vv

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

14 months ago[AArch64] Add support for efficient bitcast in vector truncate store.
Lawrence Benson [Fri, 28 Apr 2023 10:19:45 +0000 (11:19 +0100)]
[AArch64] Add support for efficient bitcast in vector truncate store.

Following the changes in D145301, we now also support the efficient bitcast
when storing the bool vector. Previously, this was expanded.

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

14 months agoRevert "[LLD][ELF] Fix compressed-debug-level test on SystemZ"
Ulrich Weigand [Fri, 28 Apr 2023 10:17:44 +0000 (12:17 +0200)]
Revert "[LLD][ELF] Fix compressed-debug-level test on SystemZ"

This reverts commit f2404d589ece81b029c607af011c372d52bff8d2,
which causes failures on Windows.

14 months ago[LCSSA] Don't invalidate entire loop in SCEV
Nikita Popov [Thu, 27 Apr 2023 09:36:21 +0000 (11:36 +0200)]
[LCSSA] Don't invalidate entire loop in SCEV

We already invalidate each individual instruction for which LCSSA
is formed in formLCSSAForInstructions(), so I don't see a reason
why we would need to invalidate the entire loop on top of that.

I believe we also no longer need the instruction-level invalidation
now that SCEV looks through LCSSA phis, but I'll leave that for a
separate patch, as it's less obvious.

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

14 months ago[LangRef] Update shufflevector's semantics to return poison if the mask is undef
ManuelJBrito [Thu, 27 Apr 2023 17:11:14 +0000 (18:11 +0100)]
[LangRef] Update shufflevector's semantics to return poison if the mask is undef

This patch changes the shufflevector's semantics to yield poison if the mask is undefined.
This allows the extraction of shufflevectors while also opening the door for more
optimization opportunities due to the fact that poison is more undefined than undef.

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

14 months ago[LV] Add tests for #60831.
Florian Hahn [Fri, 28 Apr 2023 09:42:01 +0000 (10:42 +0100)]
[LV] Add tests for #60831.

Also contains an extra test mentioned in D144434.

14 months ago[AArch64][FastISel] Handle CRC32 intrinsics
Alexis Engelke [Fri, 21 Apr 2023 12:15:04 +0000 (14:15 +0200)]
[AArch64][FastISel] Handle CRC32 intrinsics

With a similar reason as D148023; some applications make heavy use of
the CRC32 intrinsic (e.g., as part of a hash function) and therefore
benefit from avoiding frequent SelectionDAG fallbacks. In our
application, we get a 2% compile-time improvement.

Reviewed By: efriedma

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

14 months ago[VP] Add more functional SD opcodes to definitions
Luke Lau [Mon, 17 Apr 2023 09:56:56 +0000 (10:56 +0100)]
[VP] Add more functional SD opcodes to definitions

This defines more equivalent base SD opcodes for various VP nodes, so
that getVPForBaseOpcode can do more lookups of VP-equivalent operations.

Reviewed By: frasercrmck

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

14 months ago[RISCV] Add tests for illegal fixed length vectors that need widened
Luke Lau [Fri, 14 Apr 2023 18:49:41 +0000 (19:49 +0100)]
[RISCV] Add tests for illegal fixed length vectors that need widened

Reviewed By: craig.topper

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

14 months ago[SimplifyCFG] Improve the way hoisting skips over non-matching instructions
Jay Foad [Thu, 27 Apr 2023 15:55:24 +0000 (16:55 +0100)]
[SimplifyCFG] Improve the way hoisting skips over non-matching instructions

D129370 introduced the idea that hoisting could skip over non-matching
instructions and continue to look for matching (hoistable) instructions,
but certain types of mismatch still aborted the whole hoisting attempt.

Fix this by splitting out some of the instruction matching checks into a
helper function.

Also forbid hoisting allocas past stacksave/stackrestore, completing the
fix started in D133730, to avoid regressing tests.

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

14 months ago[SCEV] Replace IsAvailableOnEntry with block disposition
Nikita Popov [Thu, 27 Apr 2023 13:11:02 +0000 (15:11 +0200)]
[SCEV] Replace IsAvailableOnEntry with block disposition

As far as I understand, the IsAvailableOnEntry() function basically
implements the same functionality as the properlyDominates() block
disposition. The primary difference (apart from a weaker
implementation) seems to be in this comment at the top:

    // Checks if the SCEV S is available at BB.  S is considered available at BB
    // if S can be materialized at BB without introducing a fault.

However, I don't really understand why there would be such a
requirement. It's my understanding that SCEV explicitly does not
care about trapping udiv instructions itself, and it's the job of
SCEVExpander's isSafeToExpand() to make sure these don't get
expanded if they may trap.

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

14 months ago[hwasan] fix false positive when hwasan-match-all-tag flag is enabled and short granu...
Enna1 [Fri, 28 Apr 2023 08:59:41 +0000 (16:59 +0800)]
[hwasan] fix false positive when hwasan-match-all-tag flag is enabled and short granules are used

When hwasan-match-all-tag flag is enabled and short granules are used, at the point checking if this is a short tag case, the tag from pointer is stored in X16 register,
which breaks the assumption that tag from shadow memory is stored in X16 register, this will cause a false positive.

Reviewed By: vitalybuka

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

14 months ago[hwasan][test] add test for hwasan-check-memaccess when hwasan-match-all-tag flag...
Enna1 [Fri, 28 Apr 2023 08:56:40 +0000 (16:56 +0800)]
[hwasan][test] add test for hwasan-check-memaccess when hwasan-match-all-tag flag and short granules both used

Reviewed By: vitalybuka

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

14 months agoRevert "[flang][driver] Allow main program to be in an archive"
Andrzej Warzynski [Fri, 28 Apr 2023 08:39:27 +0000 (09:39 +0100)]
Revert "[flang][driver] Allow main program to be in an archive"

This reverts commit 876df74dd47196a9ca3b4fff21ffb5441491a0a0.

My understanding (based on https://reviews.llvm.org/D149429) is that
this patch has caused all of Flang's buildbots to fail. I'm not really
able to verify 100% as the buildbot UI is incredibly slow ATM. I am
reverting either way so that we can discuss the right solution offline.

14 months ago[Assignment Tracking] Check getTypeSizeInBits result for scalable vector types
OCHyams [Fri, 28 Apr 2023 07:46:22 +0000 (08:46 +0100)]
[Assignment Tracking] Check getTypeSizeInBits result for scalable vector types

Without this patch, in `getAssignmentInfo` the result of `getTypeSizeInBits` is
cast to `uint64_t`, which a) is an operation that will eventually be
unsupported by the API according to the comments, and b) causes an assertion
failure if the type is a scalable vector. Don't cast the `TypeSize` to
`uint64_t` and check `isScalable` before getting the fixed size.

This can result in incorrect variable locations, see llvm.org/PR62346 (but is
better than crashing).

Reviewed By: paulwalker-arm

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

14 months agoMC: Use parseEOL
Fangrui Song [Fri, 28 Apr 2023 07:52:33 +0000 (00:52 -0700)]
MC: Use parseEOL

The diagnostics have changed from "unexpected token" to clearer "expected newline"

14 months ago[NFC][HWASAN] Use named const instead of 0xf
Vitaly Buka [Fri, 28 Apr 2023 07:44:46 +0000 (00:44 -0700)]
[NFC][HWASAN] Use named const instead of 0xf

14 months agoRISCVAsmParser: Simplify with parseToken. NFC
Fangrui Song [Fri, 28 Apr 2023 07:41:58 +0000 (00:41 -0700)]
RISCVAsmParser: Simplify with parseToken. NFC

14 months ago[NFC][HWASAN] Remove unnecessary untag
Vitaly Buka [Fri, 28 Apr 2023 07:24:34 +0000 (00:24 -0700)]
[NFC][HWASAN] Remove unnecessary untag

Looks like HWASAN_ALIASING_MODE work around.
But any tagged pointer should be mapped, so load
should work.

14 months ago[NFC]Fix 2 logic dead code
Wang, Xin10 [Fri, 28 Apr 2023 07:02:30 +0000 (03:02 -0400)]
[NFC]Fix 2 logic dead code

First, in CodeGenPrepare.cpp, line 6891, the VectorCond will always be false
because if not function will return at 6888.
Second, in SelectionDAGBuilder.cpp, line 5443, getSExtValue() will return
value as int type, but now we use unsigned Val to maintain it, which make the
if condition at 5452 meaningless.

Reviewed By: skan

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

14 months ago[ValueTracking] Add logic for `fshl/fshr(A, B, C) != 0` if `A == B && A ! = 0`
Noah Goldstein [Fri, 28 Apr 2023 06:18:20 +0000 (01:18 -0500)]
[ValueTracking] Add logic for `fshl/fshr(A, B, C) != 0` if `A == B && A ! = 0`

Having `A == B` is quite common for rotate patterns.

Alive2 Links:
    - https://alive2.llvm.org/ce/z/mPXi9c
    - https://alive2.llvm.org/ce/z/UfDHoI

Reviewed By: nikic

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

14 months ago[ValueTracking] Add tests for proving `fshr`/`fshl` is non-zero; NFC
Noah Goldstein [Wed, 26 Apr 2023 20:45:02 +0000 (15:45 -0500)]
[ValueTracking] Add tests for proving `fshr`/`fshl` is non-zero; NFC

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

14 months ago[MLGO] Replace explicit shape with initializer list.
Jacob Hegna [Fri, 28 Apr 2023 06:21:46 +0000 (06:21 +0000)]
[MLGO] Replace explicit shape with initializer list.

14 months ago[IVDescriptors] Add assert to isInductionPhi to check for invalid Phis
Vedant Paranjape [Mon, 24 Apr 2023 06:20:12 +0000 (06:20 +0000)]
[IVDescriptors] Add assert to isInductionPhi to check for invalid Phis

Phis that are present inside loop headers can only be Induction Phis
legally. This patch adds an assertion to isInductionPhi which checks for
the said legality and it also updates the docs of the said function to
reflect the given legality.

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

14 months ago[flang][openacc] Generate acc.bound op when local array is passed without subscript
Valentin Clement [Fri, 28 Apr 2023 04:02:11 +0000 (21:02 -0700)]
[flang][openacc] Generate acc.bound op when local array is passed without subscript

Add support to generate the acc.bound operation when the array is passed without
any subscripts. Without this patch, no bound is generated.

Reviewed By: razvanlupusoru

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

14 months ago[lld][ELF] Support relocations R_AVR_LO8_LDI_GS/R_AVR_HI8_LDI_GS
Ben Shi [Wed, 29 Mar 2023 03:55:54 +0000 (11:55 +0800)]
[lld][ELF] Support relocations R_AVR_LO8_LDI_GS/R_AVR_HI8_LDI_GS

Relocations R_AVR_LO8_LDI_GS/R_AVR_HI8_LDI_GS (indirect calls
via function pointers) only cover range 128KiB. They are
equivalent to R_AVR_LO8_LDI_PM/R_AVR_HI8_LDI_PM within this
range.

But for function addresses beyond this range, GNU-ld emits
trampolines. And this patch implements corresponding thunks
for them in lld.

Reviewed By: MaskRay

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

14 months ago[hwasan] Fix -Wunneeded-internal-declaration by declaring static inline
Thurston Dang [Fri, 28 Apr 2023 02:50:09 +0000 (02:50 +0000)]
[hwasan] Fix -Wunneeded-internal-declaration by declaring static inline

https://reviews.llvm.org/D149386 caused a buildbot error (https://lab.llvm.org/buildbot#builders/37/builds/21766):

'In file included from /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/hwasan/hwasan_interceptors.cpp:18:
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/hwasan/hwasan_checks.h:128:53: error: 'static' function 'PossiblyShortTagMatches' declared in header file should be declared 'static inline' [-Werror,-Wunneeded-internal-declaration]
__attribute__((always_inline, nodebug)) static bool PossiblyShortTagMatches('

This patch simply adds the inline annotation.

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

14 months ago[mlir][tensor] Add transform to make tensor.pad loop-independent
Matthias Springer [Fri, 28 Apr 2023 01:34:03 +0000 (10:34 +0900)]
[mlir][tensor] Add transform to make tensor.pad loop-independent

Add a transform to make `tensor.pad` and `tensor.empty` ops independent of SCF loop IVs. Such ops can then be hoisted.

E.g.:
```
scf.for %iv = %lb to %ub step %step {
  %high = affine.apply affine_map<(d0)[s0] -> (s0 - d0)> (%i)[%ub]
  %p = tensor.pad %t low[5] high[%high] ...
  ...
}
```
Is transformed to:
```
%high_new = affine.apply affine_map<()[s0, s1] -> (-s0 + s1)> ()[%lb, %ub]
%p_hoistable = tensor.pad %t low[5] high[%high_new]
%dim = tensor.dim %t, %c0
%size = affine.apply affine_map<(d0)[s0, s1] -> (-d0 + s0 + s1 + 5)>(%iv)[%ub, %dim]
%slice = tensor.extract_slice %p_hoistable [0] [%size] [1]
```

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

14 months agoRevert "[CodeGenPrepare] Estimate liveness of loop invariants when checking for addre...
Jordan Rupprecht [Fri, 28 Apr 2023 02:16:32 +0000 (19:16 -0700)]
Revert "[CodeGenPrepare] Estimate liveness of loop invariants when checking for address folding profitability"

This reverts commit 5344d8e10bb7d8672d4bfae8adb010465470d51b.

It causes non-determinism when building clang. See the review thread on D143897.

14 months ago[flang][driver] Allow main program to be in an archive
Shao-Ce SUN [Tue, 25 Apr 2023 07:18:29 +0000 (15:18 +0800)]
[flang][driver] Allow main program to be in an archive

Add --undefined=_QQmain to the link line, so that a Fortran main program
will be included in the link job even if it is in an archive (unless we
are building a shared object). For now, this is only applied to the Gnu
toolchain.

We also add a section on the linker invocation to docs/FlangDriver.md.

The new tests require llvm-ar to construct an archive we can include in
the link job. This is a new dependency for flang/test (which already
depends on similar tools such as llvm-objdump).

See discussions in
https://github.com/llvm/llvm-project/issues/54787
which this patch fixes.

Reviewed By: awarzynski

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

14 months ago[libc] Implement `exit` for the GPU partially
Joseph Huber [Thu, 27 Apr 2023 18:05:29 +0000 (13:05 -0500)]
[libc] Implement `exit` for the GPU partially

This patch implements the `exit` function on the GPU. This required
breaking the entrypoints calling eachother on `linux` since this doesn't
work with a non-aliased target. This is only partial support because
full support requires a malloc / free implementation for the exit
callbacks array.

Reviewed By: sivachandra

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

14 months ago[libc] Support the `abs` functions in the GPU libc.
Joseph Huber [Thu, 27 Apr 2023 01:46:02 +0000 (20:46 -0500)]
[libc] Support the `abs` functions in the GPU libc.

This patch simply enables building the integer `abs` functions for the
GPU.

Reviewed By: sivachandra

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

14 months ago[libc] Support the string conversion methods on the GPU
Joseph Huber [Wed, 26 Apr 2023 23:37:30 +0000 (18:37 -0500)]
[libc] Support the string conversion methods on the GPU

This patch enables us to use the existing `libc` support for string
conversion functions on the GPU. This required setting the `fenv_t` and
long double configuration. As far as I am aware, long doubles are
converted to doubles on the GPU and the floating point environment is
just an `uint32_t`.

This code is still untested as we are still working out how to run the
unit tests on the GPU.

Reviewed By: michaelrj

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

14 months agoFix EBO on std::optional and std::variant when targeting the MSVC ABI
Eric Fiselier [Fri, 28 Apr 2023 01:04:04 +0000 (21:04 -0400)]
Fix EBO on std::optional and std::variant when targeting the MSVC ABI

Committing on behalf of davidben. Reviewed as D146190

Patch originally by Jan Dörrie in https://reviews.llvm.org/D120064. I've just updated it to include tests, and update documentation that MSVC ABI is not stable.

In the current implementation both `std::optional` and `std::variant` don't perform the EBO on MSVC's ABI. This is because both classes inherit from multiple empty base classes, which breaks the EBO for MSVC. This patch fixes this issue by applying the `empty_bases` declspec attribute, which is already used to fix a similar issue for `std::tuple`.

See https://reviews.llvm.org/D120064 for discussion on MSVC ABI stability. From the discussion, libc++ doesn't have users that expect a stable ABI on MSVC. The fix is thus applied unconditionally to benefit more users. Documentation has been updated to reflect this.

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

14 months agoMake the TSan report capture data structure anonymous.
Jim Ingham [Fri, 28 Apr 2023 00:36:31 +0000 (17:36 -0700)]
Make the TSan report capture data structure anonymous.

This was using `struct data` which is way to common a name to use in
an lldb expression, and was causing occasional failures in the
TSan report gatherer.  The structure doesn't need to have a tag,
so remove it to avoid future problems.

The same job was done for the other sanitizers in D145569, but this
one was overlooked.

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

14 months ago[SLP][NFC]Fix a warning because of the missing parens, NFC.
Alexey Bataev [Thu, 27 Apr 2023 23:33:58 +0000 (16:33 -0700)]
[SLP][NFC]Fix a warning because of the missing parens, NFC.

14 months ago[sanitizer] use the right type for sizeof
Wu, Yingcong [Thu, 27 Apr 2023 23:46:42 +0000 (16:46 -0700)]
[sanitizer] use the right type for sizeof

`x_aliases` is an array of string, so to calculate its size, it should
be <size-of-array> times <size-of-element>, which should be
`sizeof(char*)` instead of `sizeof(char**)`.

Reviewed By: vitalybuka

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

14 months ago[MLGO] Fix build error concerning ScalarShape.
Jacob Hegna [Thu, 27 Apr 2023 23:41:59 +0000 (23:41 +0000)]
[MLGO] Fix build error concerning ScalarShape.

14 months ago[AMDGPU] Track liveins for max-ilp-sched-strategy
Jeffrey Byrnes [Thu, 27 Apr 2023 15:45:29 +0000 (08:45 -0700)]
[AMDGPU] Track liveins for max-ilp-sched-strategy

Even if optimizing for ILP, it is still useful to track RP to avoid spilling. Given that, we need to maintin consistent liveness state with the RP tracker. This patch makes RP tracking consistent by updating for liveins.

Otherwise, we should completely eliminate RP tracking for this scheduler (checkScheduling, initCandidate).

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

14 months ago[Clang][Sema] Add a temporary workaround in SemaConcept.cpp
Alexander Shaposhnikov [Thu, 27 Apr 2023 23:34:03 +0000 (23:34 +0000)]
[Clang][Sema] Add a temporary workaround in SemaConcept.cpp

This commit adds FIXME and a temporary workaround to repair
CUDA build bots after e3b1083e00e62f.

14 months ago[hwasan] Enable common syscall interceptors
Thurston Dang [Thu, 27 Apr 2023 22:05:46 +0000 (22:05 +0000)]
[hwasan] Enable common syscall interceptors

This adds the sanitizer_common syscall hooks to HWASan and also defines
the COMMON_SYSCALL_PRE_{READ/WRITE}_RANGE macros.

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

14 months agoAdjust macros which define the ML inlining features.
Jacob Hegna [Thu, 27 Apr 2023 21:33:56 +0000 (21:33 +0000)]
Adjust macros which define the ML inlining features.

This aligns the inlining macros more closely with how the regalloc
macros are defined.

 - Explicitly specify the dtype/shape
 - Remove separate names for python/C++
 - Add docstring for inline cost features

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

14 months agolldb: Fix usage of sve functions on arm64
Manoj Gupta [Wed, 19 Apr 2023 22:49:17 +0000 (15:49 -0700)]
lldb: Fix usage of sve functions on arm64

Use correct internal sve functions for arm64.
Otherwise, when cross-compling lld for AArch64 there are build
errors like:
NativeRegisterContextLinux_arm64.cpp:936:11:
   error: use of undeclared identifier 'sve_vl_valid
NativeRegisterContextLinux_arm64.cpp:63:28:
    error: variable has incomplete type 'struct user_sve_header'

Reviewed By: omjavaid

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

14 months ago[profiling] Improve error message for raw profile header mismatches
Jessica Paquette [Thu, 27 Apr 2023 17:32:36 +0000 (10:32 -0700)]
[profiling] Improve error message for raw profile header mismatches

When a user uses a mismatched clang + llvm-profdata, they didn't get a very
informative error message. It would just say "unsupported version".

As a result, users are often confused as to what they are supposed to do and
tend to assume that it's a bug in the profiling runtime.

This patch improves the error message by:

- Adding a new class of error (`raw_profile_version_mismatch`) to make it clear
  that, specifically, the *raw profile* version is unsupported because of a
  tool mismatch.

- Adding an error message that tells the user which raw profile version was
  encountered, which version was expected, and instructs them to align their
  tool versions.

To support this, this patch also updates `InstrProfError::take` to also
propagate the optional error message.

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

14 months ago[gwp_asan] Exclude recoverable tests on Fuchsia
Caslyn Tonelli [Wed, 26 Apr 2023 22:15:21 +0000 (22:15 +0000)]
[gwp_asan] Exclude recoverable tests on Fuchsia

Signal handlers used by recoverable tests are unsupported on Fuchsia.

Exclude the set of tests that test recoverable code paths (i.e.
BacktraceGuardedPoolAllocator tests in recoverable.cpp) and always set
the `Recoverable` testing bool to `false` on the Fuchsia platform.

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

14 months ago[Clang][Sema] Fix comparison of constraint expressions
Alexander Shaposhnikov [Thu, 27 Apr 2023 21:33:32 +0000 (21:33 +0000)]
[Clang][Sema] Fix comparison of constraint expressions

This diff switches the approach to comparison of constraint expressions
to the new one based on template args substitution.
It continues the effort to fix our handling of out-of-line definitions
of constrained templates.
This is a recommit of 60bee9ff5445.

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

14 months ago[Clang] Add tests and mark as implemented WG14-N2728
Tom Honermann [Mon, 24 Apr 2023 20:27:26 +0000 (13:27 -0700)]
[Clang] Add tests and mark as implemented WG14-N2728

This change expands testing of UTF-8, UTF-16, and UTF-32 character and string
literals as validation that WG14 N2728 (char16_t & char32_t string literals
shall be UTF-16 & UTF-32) has been implemented.

Reviewed By: cor3ntin, aaron.ballman

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

14 months ago[libc++] Use __is_convertible built-in when available
Roland McGrath [Thu, 27 Apr 2023 21:18:18 +0000 (14:18 -0700)]
[libc++] Use __is_convertible built-in when available

https://github.com/llvm/llvm-project/issues/62396 reports that
GCC 13 barfs on parsing <type_traits> because of the declarations
of `struct __is_convertible`.  In GCC 13, `__is_convertible` is a
built-in, but `__is_convertible_to` is not.  Clang has both, so
using either should be fine.

Reviewed By: #libc, philnik

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

14 months ago[clang][driver] Enable MisExpect diagnostics flag outside of CC1
Paul Kirth [Tue, 25 Apr 2023 21:13:51 +0000 (21:13 +0000)]
[clang][driver] Enable MisExpect diagnostics flag outside of CC1

Previously we only accepted the `-fdiagnostics-misexpect-tolerance=` at
CC1, when it should have been handled identically to
`-fdiagnostics-hotness-threshold=`. It should not have been required to
pass this flag w/ `-Xclang` as reported here:
https://reviews.llvm.org/D115907#inline-1440745

Reviewed By: hans, phosek

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

14 months ago[CodeGen][MachineLastInstrsCleanup] fix INLINEASM_BR hazard
Nick Desaulniers [Thu, 27 Apr 2023 20:39:54 +0000 (13:39 -0700)]
[CodeGen][MachineLastInstrsCleanup] fix INLINEASM_BR hazard

If the removable definition resides in an INLINEASM_BR target, the
reuseable candidate might not dominate the INLINEASM_BR.

   bb0:
      INLINEASM_BR &"" %bb.1
      renamable $x8 = MOVi64imm 29273397577910035
      B %bb.2
      ...
    bb1:
      renamable $x8 = MOVi64imm 29273397577910035
      renamable $x8 = ADDXri killed renamable $x8, 2048, 0
    bb2:

Removing the second mov is a hazard when the inline asm branches to bb1.

Skip such replacements when the to be removed instruction is in the
target of such an INLINEASM_BR instruction.

We could get more aggressive about this in the future, but for now
simply abort.

This is causing a boot failure on linux-4.19.y branches of the LTS Linux
kernel for ARCH=arm64 with CONFIG_RANDOMIZE_BASE=y (KASLR) and
CONFIG_UNMAP_KERNEL_AT_EL0=y (KPTI).

Link: https://reviews.llvm.org/D123394
Link: https://github.com/ClangBuiltLinux/linux/issues/1837
Thanks to @nathanchance for the report, and @ardb for debugging.

Reviewed By: efriedma

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

14 months ago[CodeGen] precommit machine-latecleanup test
Nick Desaulniers [Thu, 27 Apr 2023 20:39:45 +0000 (13:39 -0700)]
[CodeGen] precommit machine-latecleanup test

Demonstrates a hazard in machine-latecleanup.

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

14 months ago[gn build] Port bf199576f931
LLVM GN Syncbot [Thu, 27 Apr 2023 20:33:13 +0000 (20:33 +0000)]
[gn build] Port bf199576f931

14 months ago[libc++][PSTL][NFC] Rename to `pstl/` to `__pstl/`
Nikolas Klauser [Wed, 26 Apr 2023 17:55:41 +0000 (10:55 -0700)]
[libc++][PSTL][NFC] Rename  to `pstl/` to `__pstl/`

Reviewed By: ldionne, #libc

Spies: sstefan1, pcwang-thead, jplehr, libcxx-commits, arichardson, mgrang, miyuki

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

14 months ago[PGO]Implement metadata combine for 'branch_weights' of direct
Mingming Liu [Fri, 21 Apr 2023 06:44:42 +0000 (23:44 -0700)]
[PGO]Implement metadata combine for 'branch_weights' of direct
callsites when none of the instructions folds the rest away.

- Merge cases are added for simplify-cfg {sink,hoist}, based on https://gcc.godbolt.org/z/avGvc38W7 and https://gcc.godbolt.org/z/dbWbjGhaE
- When one instruction folds the others in, do not update branch_weights
  with sum (see test/Transforms/GVN/calls-readonly.ll)

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

14 months ago[MLIR][LLVM] Add accessor for LLVMModule and invoke convertDialectAttributes on GlobalOps
Andrew Gozillon [Thu, 27 Apr 2023 19:44:19 +0000 (14:44 -0500)]
[MLIR][LLVM] Add accessor for LLVMModule and invoke convertDialectAttributes on GlobalOps

This patch seeks to do two things add an accessor method to
retrieve the ModuleTranslations contained LLVM Module for direct
usage by dialects that are being lowered to LLVM-IR. One particular
use case for this is in the OpenMP Dialect, when interfacing
with the OMPIRBuilder in certain cases it is useful to be able
to access the LLVM Module directly.

The second is invoking convertDialectAttributes on GlobalOp's
so as to be able to lower dialect specific attributes that are
applied or lowered onto GlobalOp's.

Reviewers: ftynse

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

14 months ago[PGO] Fix dead StringRef access
Christian Ulmann [Thu, 27 Apr 2023 19:40:23 +0000 (19:40 +0000)]
[PGO] Fix dead StringRef access

This commit fixes a dead StringRef access introduced in
https://reviews.llvm.org/D149324