platform/upstream/llvm.git
2 years ago[ARM] Only update the successor edges for immediate predecessors of PrologueMBB
Zhiyao Ma [Tue, 3 May 2022 11:29:48 +0000 (12:29 +0100)]
[ARM] Only update the successor edges for immediate predecessors of PrologueMBB

When adjusting the function prologue for segmented stacks, only update
the successor edges of the immediate predecessors of the original
prologue.

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

2 years agoFix Clang sphinx build
Aaron Ballman [Tue, 3 May 2022 11:12:50 +0000 (07:12 -0400)]
Fix Clang sphinx build

It seems we don't have this option exposed via RST, so switching to use
generic backticks instead.

2 years ago[Windows] Fix handling of \" in program name on cmd line.
Simon Tatham [Tue, 3 May 2022 09:33:11 +0000 (10:33 +0100)]
[Windows] Fix handling of \" in program name on cmd line.

Bugzilla #47579: if you invoke clang on Windows via a pathname in
which a quoted section closes just after a backslash, e.g.

  "C:\Program Files\Whatever\"clang.exe

then cmd.exe and CreateProcess will correctly find the binary, because
when they parse the program name at the start of the command line,
they don't regard the \ before the " as having any kind of escaping
effect. This is different from the behaviour of the Windows standard C
library when it parses the rest of the command line, which would
consider that \" not to close the quoted string.

But this confuses windows::GetCommandLineArguments, because the
Windows API function GetCommandLineW() will return a command line
containing that \" sequence, and cl::TokenizeWindowsCommandLine will
tokenize the whole string according to the C library's rules. So it
will misidentify where the program name stops and the arguments start.

To fix this, I've introduced a new variant function
cl::TokenizeWindowsCommandLineFull(), intended to be applied to the
string returned from GetCommandLineW(). It parses the first word of
the command line according to CreateProcess's rules, considering \ to
never be an escaping character; thereafter, it switches over to the C
library rules for the rest of the command line.

Reviewed By: hans

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

2 years ago[Windows] Fix cmd line tokenization of unclosed quotes.
Simon Tatham [Tue, 3 May 2022 09:33:11 +0000 (10:33 +0100)]
[Windows] Fix cmd line tokenization of unclosed quotes.

When cl::TokenizeWindowsCommandLine received a command line with an
unterminated double-quoted string at the end, it would discard the
text within that string. That doesn't match the behavior of the
standard Windows C library, which will return the text in the unclosed
quoted string as an argv word.

Fixed, and added extra unit tests in that area.

In some cases (specifically the one in Bugzilla #47579) this could
cause TokenizeWindowsCommandLine to return a zero-length list of
arguments, leading to an array overrun at the call site in
windows::GetCommandLineArguments. Added a check there, for extra
safety: now windows::GetCommandLineArguments will return an error code
instead of failing an assertion.

(This change was written as part of https://reviews.llvm.org/D122914,
but split into a separate commit at the last minute at the code
reviewer's suggestion, because it's fixing an unrelated bug in the
same area. The rest of D122914 will follow in the next commit.)

2 years agotsan: fix deadlock in libbacktrace
Martin Liska [Tue, 3 May 2022 10:42:01 +0000 (12:42 +0200)]
tsan: fix deadlock in libbacktrace

Fixes deadlock seen in GCC.

Fixes: #55226

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

2 years ago[SDAG] Extract commutative helper from haveNoCommonBitsSet() (NFC)
Nikita Popov [Tue, 3 May 2022 10:20:04 +0000 (12:20 +0200)]
[SDAG] Extract commutative helper from haveNoCommonBitsSet() (NFC)

To make it easier to add additional patterns, which will generally
want to handle commuted top-level operands.

2 years ago[lldb] Fix ppc64 detection in lldb
serge-sans-paille [Mon, 2 May 2022 10:19:48 +0000 (12:19 +0200)]
[lldb] Fix ppc64 detection in lldb

Currently, ppc64le and ppc64 (defaulting to big endian) have the same
descriptor, thus the linear scan always return ppc64le. Handle that through
subtype.

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

2 years ago[SLP][X86] Add test case for Issue #48223
Simon Pilgrim [Tue, 3 May 2022 10:01:47 +0000 (11:01 +0100)]
[SLP][X86] Add test case for Issue #48223

2 years ago[AArch64][SVE] Only fold frame indexes referencing SVE objects into SVE loads/stores
Bradley Smith [Tue, 26 Apr 2022 12:19:32 +0000 (12:19 +0000)]
[AArch64][SVE] Only fold frame indexes referencing SVE objects into SVE loads/stores

Currently we always fold frame indexes into SVE load/store instructions,
however these instructions can only encode VL scaled offests. This means
that when we are accessing a fixed length stack object with these
instructions, the folded in frame index gets pulled back out during frame
lowering. This can cause issues when we have no spare registers and no
emergency spill slot.

Rather than causing issues like this, don't fold in frame indexes that
reference fixed length objects.

Fixes: #55041

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

2 years agosanitizer: use pragma clang conditionally
Martin Liska [Tue, 3 May 2022 08:19:20 +0000 (10:19 +0200)]
sanitizer: use pragma clang conditionally

Use the pragma only when __clang__ is defined.

Fixes:
sanitizer_common_libcdep.cpp:101: warning: ignoring ‘#pragma clang diagnostic’ [-Wunknown-pragmas]

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

2 years ago[ValueTracking] A and (B & ~A) have no common bits set
Nikita Popov [Mon, 2 May 2022 16:21:00 +0000 (18:21 +0200)]
[ValueTracking] A and (B & ~A) have no common bits set

This extends haveNoCommonBitsSet() to two additional cases, allowing
the following folds:

 * `A + (B & ~A)` --> `A | (B & ~A)`
    (https://alive2.llvm.org/ce/z/crxxhN)
 * `A + ((A & B) ^ B)` --> `A | ((A & B) ^ B)`
    (https://alive2.llvm.org/ce/z/A_wsH_)

These should further fold to just `A | B`, though this currently
only works in the first case.

The reason why the second fold is necessary is that we consider
this to be the canonical form if B is a constant. (I did check
whether we can change that, but it looks like a number of folds
depend on the current canonicalization, so I ended up adding both
patterns here.)

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

2 years ago[mlir] improve and test TransformState::Extension
Alex Zinenko [Mon, 2 May 2022 16:22:19 +0000 (18:22 +0200)]
[mlir] improve and test TransformState::Extension

Add the mechanism for TransformState extensions to update the mapping between
Transform IR values and Payload IR operations held by the state. The mechanism
is intentionally restrictive, similarly to how results of the transform op are
handled.

Introduce test ops that exercise a simple extension that maintains information
across the application of multiple transform ops.

Reviewed By: nicolasvasilache

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

2 years agoIn MSVC compatibility mode, friend function declarations behave as function declarations
Fred Tingaud [Tue, 3 May 2022 07:29:16 +0000 (09:29 +0200)]
In MSVC compatibility mode, friend function declarations behave as function declarations

Before C++20, MSVC treated any friend function declaration as a function declaration, so the following code would compile despite funGlob being declared after its first call:

```
class Glob {
public:
  friend void funGlob();

  void test() {
    funGlob();
  }
};

void funGlob() {}
```
This proposed patch mimics the MSVC behavior when in MSVC compatibility mode

Reviewed By: rnk

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

2 years agosanitizer: support GCC's fallthrough attribute
Martin Liska [Tue, 3 May 2022 08:54:06 +0000 (10:54 +0200)]
sanitizer: support GCC's fallthrough attribute

Fixes:
sanitizer_stack_store.cpp:257:13: warning: this statement may fall through [-Wimplicit-fallthrough=]

when being built with GCC.

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

2 years ago[Analyzer] Fix assumptions about const field with member-initializer
Marco Antognini [Wed, 27 Apr 2022 12:51:57 +0000 (14:51 +0200)]
[Analyzer] Fix assumptions about const field with member-initializer

Essentially, having a default member initializer for a constant member
does not necessarily imply the member will have the given default value.

Remove part of a2e053638bbf ([analyzer] Treat more const variables and
fields as known contants., 2018-05-04).

Fix #47878

Reviewed By: r.stahl, steakhal

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

2 years ago[LoopVectorize] Support reductions that store intermediary result
Igor Kirillov [Wed, 15 Sep 2021 18:42:01 +0000 (19:42 +0100)]
[LoopVectorize] Support reductions that store intermediary result

Adds ability to vectorize loops containing a store to a loop-invariant
address as part of a reduction that isn't converted to SSA form due to
lack of aliasing info. Runtime checks are generated to ensure the store
does not alias any other accesses in the loop.

Ordered fadd reductions are not yet supported.

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

2 years ago[clang-format] Add a regression test for aligning macros with keywords.
Marek Kurdej [Tue, 3 May 2022 09:08:34 +0000 (11:08 +0200)]
[clang-format] Add a regression test for aligning macros with keywords.

Test from issue https://github.com/llvm/llvm-project/issues/54953.

2 years ago[mlir][MemRef] Return `0` for the canonical strided layout expr of a 0d memref
Benjamin Kramer [Mon, 2 May 2022 19:18:37 +0000 (21:18 +0200)]
[mlir][MemRef] Return `0` for the canonical strided layout expr of a 0d memref

There can't be any strides, and the offset for the canonical expr is
always 0. Fixes #55229.

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

2 years ago[DebugInfo][InstrRef] Don't generate redundant DBG_PHIs
Jeremy Morse [Tue, 3 May 2022 08:42:27 +0000 (09:42 +0100)]
[DebugInfo][InstrRef] Don't generate redundant DBG_PHIs

In SelectionDAG, DBG_PHI instructions are created to "read" physreg values
and give them an instruction number, when they can't be traced back to a
defining instruction. The most common scenario if arguments to a function.
Unfortunately, if you have 100 inlined methods, each of which has the same
"this" pointer, then the 100 dbg.value instructions become 100
DBG_INSTR_REFs plus 100 DBG_PHIs, where only one DBG_PHI would suffice.

This patch adds a vreg cache for MachienFunction::salvageCopySSA, if we've
already traced a value back to the start of a block and created a DBG_PHI
then it allows us to re-use the DBG_PHI, as well as reducing work.

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

2 years ago[NFC] Minimal refactor of TTI to avoid clangsa complaint
Markus Lavin [Tue, 3 May 2022 08:20:09 +0000 (10:20 +0200)]
[NFC] Minimal refactor of TTI to avoid clangsa complaint

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

2 years ago[LV][SLP] Mark fptosi_sat as vectorizable
David Green [Tue, 3 May 2022 08:32:34 +0000 (09:32 +0100)]
[LV][SLP] Mark fptosi_sat as vectorizable

This adds fptosi_sat and fptoui_sat to the list of trivially
vectorizable functions, mainly so that the loop vectorizer can vectorize
the instruction. Marking them as trivially vectorizable also allows them
to be SLP vectorized, and Scalarized.

The signature of a fptosi_sat requires two type overrides
(@llvm.fptosi.sat.v2i32.v2f32), unlike other intrinsics that often only
take a single. This patch alters hasVectorInstrinsicOverloadedScalarOpd
to isVectorIntrinsicWithOverloadTypeAtArg, so that it can mark the first
operand of the intrinsic as a overloaded (but not scalar) operand.

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

2 years ago[lldb] Fix nondeterminism in DWARFIndexCachingTest
Pavel Labath [Tue, 3 May 2022 08:28:47 +0000 (10:28 +0200)]
[lldb] Fix nondeterminism in DWARFIndexCachingTest

The entries in the input map need to be sorted as well, as there's no
guarantee that the entries (ConstStrings) will be inserted in the proper
order.

2 years ago[docs] PCH usage documentation update
Ivan Murashko [Sat, 30 Apr 2022 20:42:08 +0000 (21:42 +0100)]
[docs] PCH usage documentation update

The documentation has an incorrect example of PCH files usage via `-include` option. The possibility has not been available since [llvm-svn: 174385](https://reviews.llvm.org/rG48b72d81c8968f3d342557582db986a60aef2c54).

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

2 years ago[X86][AMX] Add mayLoad/mayStore property for AMX instructions.
Luo, Yuanke [Tue, 3 May 2022 06:48:22 +0000 (14:48 +0800)]
[X86][AMX] Add mayLoad/mayStore property for AMX instructions.

2 years agoRevert "tsan: model atomic read for failing CAS"
Vitaly Buka [Tue, 3 May 2022 05:26:48 +0000 (22:26 -0700)]
Revert "tsan: model atomic read for failing CAS"

https://lab.llvm.org/buildbot/#/builders/70/builds/21206 hangs.

This reverts commit 2fec52a40261ecab7fc621184159f464c67dcfa4.

2 years ago[mlir] Create lbOperands before op.setLowerBound
Vitaly Buka [Wed, 27 Apr 2022 23:51:24 +0000 (16:51 -0700)]
[mlir] Create lbOperands before op.setLowerBound

To fix msan report like https://reviews.llvm.org/P8284

Reviewed By: rriddle

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

2 years ago[lldb] Make GetSharedModuleWithLocalCache consider the device support directory
Jonas Devlieghere [Mon, 2 May 2022 19:53:38 +0000 (12:53 -0700)]
[lldb] Make GetSharedModuleWithLocalCache consider the device support directory

Make GetSharedModuleWithLocalCache consider the device support
directory. In the past we only needed the device support directory to
debug remote processes. Since the introduction of Apple Silicon and
Rosetta this stopped being true.

When debugging a Rosetta process on macOS we need to consider the
Rosetta expanded shared cache. This patch and it dependencies move that
logic out of PlatfromRemoteDarwinDevice into a new abstract class called
PlatfromDarwinDevice. The new platform sit in between PlatformDarwin and
PlatformMacOSX and PlatformRemoteDarwinDevice and has all the necessary
logic to deal with the device support directory.

Technically I could have moved everything in PlatfromDarwinDevice into
PlatfromDarwin but decided that this logic is sufficiently self
contained that it warrants its own abstraction.

rdar://91966349

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

2 years ago[RISCV] Precommit test cases for (uaddo X, C)
Hsiangkai Wang [Thu, 28 Apr 2022 09:02:54 +0000 (09:02 +0000)]
[RISCV] Precommit test cases for (uaddo X, C)

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

2 years ago[RISCV][TargetLowering] Special case overflow expansion for (uaddo X, C).
Hsiangkai Wang [Thu, 28 Apr 2022 23:14:48 +0000 (23:14 +0000)]
[RISCV][TargetLowering] Special case overflow expansion for (uaddo X, C).

Follow-up to D122933.

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

2 years ago[RISCV] Add isCommutable to FADD/FMUL/FMIN/FMAX/FEQ.
Craig Topper [Tue, 3 May 2022 02:43:05 +0000 (19:43 -0700)]
[RISCV] Add isCommutable to FADD/FMUL/FMIN/FMAX/FEQ.

Reviewed By: arcbbb

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

2 years ago[AMDGPU] Fix scalar_to_vector for v8i16/v8f16
hsmahesha [Mon, 2 May 2022 20:55:07 +0000 (02:25 +0530)]
[AMDGPU] Fix scalar_to_vector for v8i16/v8f16

so that the stack access is avoided.

Reviewed By: rampitec

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

2 years ago[AMDGPU][NFC] Make lowerINSERT_VECTOR_ELT() more readable
hsmahesha [Sun, 1 May 2022 07:07:48 +0000 (12:37 +0530)]
[AMDGPU][NFC] Make lowerINSERT_VECTOR_ELT() more readable

by moving around the code and by adding more comments, which would
later help during any required clean-up.

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

2 years ago[RISCV] Fix incorrect codegen for masked vmsge{u}.vx with mask agnostic.
Zakk Chen [Tue, 3 May 2022 00:08:23 +0000 (17:08 -0700)]
[RISCV] Fix incorrect codegen for masked vmsge{u}.vx with mask agnostic.

The result was totally wrong.
We could use mask undisturbed result to emulate the mask agnostic result.

Reviewed By: craig.topper

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

2 years ago[gn build] Port 41c0ff1e740b
LLVM GN Syncbot [Tue, 3 May 2022 00:35:04 +0000 (00:35 +0000)]
[gn build] Port 41c0ff1e740b

2 years ago[lldb] Move GetSharedModuleWithLocalCache to PlatformDarwinDevice (NFC)
Jonas Devlieghere [Mon, 2 May 2022 19:52:39 +0000 (12:52 -0700)]
[lldb] Move GetSharedModuleWithLocalCache to PlatformDarwinDevice (NFC)

Refactoring in preparation of D124801.

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

2 years ago[lldb] Hoist device support out of PlatformRemoteDarwinDevice (NFC)
Jonas Devlieghere [Mon, 2 May 2022 16:03:58 +0000 (09:03 -0700)]
[lldb] Hoist device support out of PlatformRemoteDarwinDevice (NFC)

Refactoring in preparation of D124801.

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

2 years ago[lldb] Remove unused PlatformRemoteDarwinDevice::FindFileInAllSDKs
Jonas Devlieghere [Mon, 2 May 2022 23:21:21 +0000 (16:21 -0700)]
[lldb] Remove unused PlatformRemoteDarwinDevice::FindFileInAllSDKs

As far as I can tell this function is unused both upstream and
downstream.

2 years ago[lldb] Remove PlatformRemoteMacOSX::GetFileWithUUID overload (NFC)
Jonas Devlieghere [Mon, 2 May 2022 23:12:38 +0000 (16:12 -0700)]
[lldb] Remove PlatformRemoteMacOSX::GetFileWithUUID overload (NFC)

There's no reason PlatformRemoteMacOSX has to override GetFileWithUUID.

2 years ago[Driver][test] Remove clang{{.*}} when testing -cc1 command lines
Weverything [Tue, 3 May 2022 00:08:20 +0000 (17:08 -0700)]
[Driver][test] Remove clang{{.*}} when testing -cc1 command lines

The majority of tests omit testing "clang" for -cc1 command lines. In addition,
some distributions symlink %clang to an executable with a content hash based
filename so clang{{.*}} check won't work.

With this change, we can remove many -no-canonical-prefixes whose purpose was to
make the tests pass on such distributions.

2 years ago[DAGCombiner] reassociationCanBreakAddressingModePattern should check uses of the...
Craig Topper [Mon, 2 May 2022 23:21:50 +0000 (16:21 -0700)]
[DAGCombiner] reassociationCanBreakAddressingModePattern should check uses of the outer add.

When looking for memory uses,
reassociationCanBreakAddressingModePattern should check uses of
the outer ADD rather than the inner ADD. We want to know if the
two ops we're reassociating are used by a load/store.

In practice, the existing check usually works because CodeGenPrepare
will make one of the load/stores have an offset of 0 relative to
split GEP. That will make the inner add have a memory use.

To test this, I've manually split the GEPs so there is no 0 offset
store.

This issue was recently discussed in the original review D60294.

Reviewed By: luismarques

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

2 years agoAdd transparency report.
Tanya Lattner [Mon, 2 May 2022 23:29:15 +0000 (16:29 -0700)]
Add transparency report.

2 years ago[mlir][LLVMIR] Add support for translating FCmp & FP constants
Min-Yih Hsu [Thu, 21 Apr 2022 00:46:16 +0000 (17:46 -0700)]
[mlir][LLVMIR] Add support for translating FCmp & FP constants

This patch add supports for translating FCmp and more kinds of FP
constants in addition to 32 & 64-bit ones. However, we can't express
ppc_fp128 constants right now because the semantics for its underlying
APFloat is `S_PPCDoubleDouble` but mlir::FloatType doesn't support such
semantics right now.

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

2 years ago[NFC] Add missing switch cases
Chris Bieneman [Mon, 2 May 2022 23:13:07 +0000 (18:13 -0500)]
[NFC] Add missing switch cases

This silences warnings encountered on some bots.

2 years agoAMDGPU/SDAG: Factor out the fold (add (mul x, y), y) --> mad_[iu]64_[iu]32
Nicolai Hähnle [Wed, 13 Apr 2022 01:37:44 +0000 (20:37 -0500)]
AMDGPU/SDAG: Factor out the fold (add (mul x, y), y) --> mad_[iu]64_[iu]32

Refactor to simplify a follow-up change.

No functional change intended. However, there is a rather subtle logic
change: the subsequent combines (e.g. reassociation) are skipped *always*
when one of the operands of the add is a mul, instead of only when
additionally mad64_32 etc. are available. This change makes sense because
the subsequent combines should never apply when one of the operands is a
mul.

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

2 years ago[gn build] Port 4070aa01561c
LLVM GN Syncbot [Mon, 2 May 2022 22:32:10 +0000 (22:32 +0000)]
[gn build] Port 4070aa01561c

2 years agoRevert "[DeadArgElim] Set unused arguments for internal functions"
Vitaly Buka [Mon, 2 May 2022 22:10:26 +0000 (15:10 -0700)]
Revert "[DeadArgElim] Set unused arguments for internal functions"

Breaks bots, see https://reviews.llvm.org/D124699

This reverts commit e547a333a43348a8a7ec9460f37696ecc5453e56.

2 years ago[Object][DX] Identify DXBC file magic
Chris Bieneman [Mon, 2 May 2022 21:23:16 +0000 (16:23 -0500)]
[Object][DX] Identify DXBC file magic

This adds support to llvm::identify_magic to detect DXBC and classify
it as the dxcontainer format.

2 years agofix warning caused by ef4ecc3ceffcf3ef129640c813f823c974f9ba22
Bardia Mahjour [Mon, 2 May 2022 21:06:00 +0000 (17:06 -0400)]
fix warning caused by ef4ecc3ceffcf3ef129640c813f823c974f9ba22

2 years ago[sanitizer] Use canonical syscalls everywhere
Evgenii Stepanov [Thu, 21 Apr 2022 22:17:29 +0000 (15:17 -0700)]
[sanitizer] Use canonical syscalls everywhere

These "new" syscalls have been added in 2.6.16, more than 16 years ago.
Surely that's enough time to migrate. Glibc 2.33 is using them on both
i386 and x86_64. Android has an selinux filter to block the legacy
syscalls in the apps.

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

2 years ago[LoopCacheAnalysis] Consider dimension depth of the subscript reference when calculat...
Bardia Mahjour [Mon, 2 May 2022 20:49:10 +0000 (16:49 -0400)]
[LoopCacheAnalysis] Consider dimension depth of the subscript reference when calculating cost

Reviewed By: congzhe, etiotto

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

2 years ago[memprof] Only insert dynamic shadow load when needed
Teresa Johnson [Mon, 2 May 2022 19:38:27 +0000 (12:38 -0700)]
[memprof] Only insert dynamic shadow load when needed

We don't need to insert a load of the dynamic shadow address unless there
are interesting memory accesses to profile.

Split out of D124703.

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

2 years ago[NFC] Fixing error on some versions of GCC
Chris Bieneman [Mon, 2 May 2022 20:16:21 +0000 (15:16 -0500)]
[NFC] Fixing error on some versions of GCC

Some versions of GCC don't implicitly move Error to Expected.

2 years ago[flang] Fix semantics check for RETURN statement
Emil Kieri [Mon, 2 May 2022 16:17:39 +0000 (18:17 +0200)]
[flang] Fix semantics check for RETURN statement

The RETURN statement is allowed in functions and subroutines, but not
in main programs. It is however a common extension, which we also
implement, to allow RETURN from main programs -- we only issue a
portability warning when -pedantic or -std=f2018 are set.

This patch fixes false positives for this portability warning, where it
was triggered also when RETURN was present in functions or subroutines.

Fixexs #55080

Reviewed By: PeteSteinfeld

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

2 years ago[NFC] Fix warning reported on bots
Chris Bieneman [Mon, 2 May 2022 20:02:10 +0000 (15:02 -0500)]
[NFC] Fix warning reported on bots

2 years ago[SLP][NFC]Minor code changes for better readability, NFC.
Alexey Bataev [Mon, 2 May 2022 19:57:34 +0000 (12:57 -0700)]
[SLP][NFC]Minor code changes for better readability, NFC.

2 years ago[clangd] Add inlay hints for mutable reference parameters
Tobias Ribizel [Mon, 2 May 2022 19:56:40 +0000 (15:56 -0400)]
[clangd] Add inlay hints for mutable reference parameters

Add a & prefix to all parameter inlay hints that refer to a non-const l-value reference. That makes it easier to identify them even if semantic highlighting is not used (where this is already available)

Reviewed By: nridge

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

2 years ago[NFC] Rename `FixedLenDecoderEmitter` as `DecoderEmitter`
Sheng [Mon, 2 May 2022 19:36:07 +0000 (03:36 +0800)]
[NFC] Rename `FixedLenDecoderEmitter` as `DecoderEmitter`

Since now we are able to handle both fixed length & variable
length instructions.

Reviewed By: myhsu

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

2 years ago[TableGen] Add support for variable length instruction in decoder generator
Sheng [Mon, 2 May 2022 19:26:55 +0000 (03:26 +0800)]
[TableGen] Add support for variable length instruction in decoder generator

To support variable length instructions, I think of them as fixed length instructions with the "maximum length". For example, if there're three instructions with 2, 6 and 9 bytes, we can fit them into the algorithm by treating them all as 9 bytes.

Also, since we can't know the length of the instruction in advance, there is a function object with type `void(APInt &, uint64_t)` added in the parameter list of `decodeInstruction` and `fieldFromInstruction`. We can use this to supply the additional bits the decoder needs after we know the opcode of the instruction.

Finally, `InstrLenTable` is added to let the decoder know the length of the instructions.

See D120960 for its usage.

Reviewed By: myhsu

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

2 years agoRevert "Fix a misuse of `cast`"
Sheng [Mon, 2 May 2022 19:32:02 +0000 (03:32 +0800)]
Revert "Fix a misuse of `cast`"

This reverts commit ba59ec2843f99f19d55d7cd9f9ac536fb038fdab.

2 years ago[memprof] Don't instrument PGO and other compiler inserted variables
Teresa Johnson [Fri, 29 Apr 2022 21:53:31 +0000 (14:53 -0700)]
[memprof] Don't instrument PGO and other compiler inserted variables

Suppress instrumentation of PGO counter accesses, which is unnecessary
and costly. Also suppress accesses to other compiler inserted variables
starting with "__llvm". This is a slightly expanded variant of what is
done for tsan in shouldInstrumentReadWriteFromAddress.

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

2 years ago[OpenMP] Fix -Wswitch (due to new OMPC_cancellation_construct_type) after D123828
Fangrui Song [Mon, 2 May 2022 19:10:09 +0000 (12:10 -0700)]
[OpenMP] Fix -Wswitch (due to new OMPC_cancellation_construct_type) after D123828

2 years ago[SLP]Improve reductions analysis and emission, part 1.
Alexey Bataev [Thu, 18 Nov 2021 16:08:01 +0000 (08:08 -0800)]
[SLP]Improve reductions analysis and emission, part 1.

Currently SLP vectorizer walks through the instructions and selects
3 main classes of values: 1) reduction operations - instructions with same
reduction opcode (add, mul, min/max, etc.), which build the reduction,
2) reduced values - instructions with the same opcodes, but different
from the reduction opcode, 3) extra arguments - all other values,
instructions from the different basic block rather than the root node,
instructions with to many/less uses.

This scheme is not very efficient. It excludes some instructions and all
non-instruction values from the reductions (constants, proficient
gathers), to many possibly reduced values are marked as extra arguments.
Patch improves this process by introducing a bit extended analysis
stage. During this stage, we still try to select 3 classes of the
values: 1) reduction operations - same as before, 2) possibly reduced
values - all instructions from the current block/non-instructions, which
may build a vectorization tree, 3) extra arguments - instructions from
the different basic blocks. Additionally, an extra sorting of the
possibly reduced values occurs to build the scalar sequences which
highly likely will bed vectorized, e.g. loads are grouped by the
distance between them, constants are grouped together, cmp instructions
are sorted by their compare types and predicates, extractelement
instructions are sorted by the vector operand, etc. Also, these groups
are reordered by their length so the longest group is the first in the
list of the possibly reduced values.

The vectorization process tries to emit the reductions for all these
groups. These reductions, remaining non-vectorized possible reduced
values and extra arguments are then combined into the final expression
just like it was before.

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

2 years ago[SystemZ] Accept (. - 0x100000000) PCRel32 constants
Ilya Leoshkevich [Mon, 2 May 2022 18:56:51 +0000 (20:56 +0200)]
[SystemZ] Accept (. - 0x100000000) PCRel32 constants

Clang does not accept instructions like brasl %r0,.-0x100000000,
because the second operand's right-hand-side (0x100000000) barely
misses the acceptable range. However, since it's being subtracted, it
makes sense to perform the range check on the negated value.

Reviewed By: uweigand

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

2 years ago[SDAG] fix miscompile when casting int->FP->int
Sanjay Patel [Mon, 2 May 2022 16:48:02 +0000 (12:48 -0400)]
[SDAG] fix miscompile when casting int->FP->int

This is the codegen equivalent of D124692.

As shown in https://github.com/llvm/llvm-project/issues/55150 -
the existing fold may be wrong when converting to a signed value.
This is a quick fix to avoid the miscompile.
https://alive2.llvm.org/ce/z/KtaDmd

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

2 years ago[Object][DX] Initial DXContainer parsing support
Chris Bieneman [Thu, 28 Apr 2022 23:03:25 +0000 (18:03 -0500)]
[Object][DX] Initial DXContainer parsing support

This patch begins adding DXContainer parsing support to libObject.
Following the pattern used by ELFFile my goal here is to write a
standalone DXContainer parser and later write an adapter interface to
support a subset of the ObjectFile interfaces so that we can add
limited objdump support. I will also be adding ObjectYAML support to
help drive testing of the object tools and MC-level object writers as
those come together.

DXContainer is a slightly odd format. It is arranged in "parts" that
are semantically similar to sections, but it doesn't support symbol
listing.

Reviewed By: MaskRay

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

2 years agoUpdate movmsk-cmp.ll to match improvements made to InstCombine
Amaury Séchet [Mon, 2 May 2022 10:12:27 +0000 (10:12 +0000)]
Update movmsk-cmp.ll to match improvements made to InstCombine

This reflects the changes in the IR generated by InstCombine as pointed out by @RKSimon in https://reviews.llvm.org/D124743#3485199

Reviewed By: RKSimon

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

2 years ago[VPlan] Do not create VPWidenCall recipes for scalar vector factors.
Florian Hahn [Mon, 2 May 2022 18:40:33 +0000 (19:40 +0100)]
[VPlan] Do not create VPWidenCall recipes for scalar vector factors.

'Widen' recipe are only used when actual vector values are generated.
Fix tryToWidenCall to do not create VPWidenCallRecipes for scalar vector
factors.

This was exposed by D123720, because the widened recipes are considered
vector users.

Reviewed By: Ayal

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

2 years ago[DeadArgElim] Set unused arguments for internal functions
Quentin Colombet [Fri, 29 Apr 2022 20:53:36 +0000 (13:53 -0700)]
[DeadArgElim] Set unused arguments for internal functions

Prior to this patch we would only set to undef the unused arguments of the
external functions. The rationale was that unused arguments of internal
functions wouldn't need to be turned into undef arguments because they
should have been simply eliminated by the time we reach that code.

This is actually not true because there are plenty of cases where we can't
remove unused arguments. For instance, if the internal function is used in
an indirect call, it may not be possible to change the function signature.
Yet, for statically known call-sites we would still like to mark the unused
arguments as undef.

This patch enables the "set undef arguments" optimization on internal
functions when we encounter cases where internal functions cannot be
optimized. I.e., whenever an internal function is marked "live".

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

2 years agoRevert "Re-apply 4b6c2cd642 "Deferred Concept Instantiation Implementation"""
Erich Keane [Mon, 2 May 2022 18:10:35 +0000 (11:10 -0700)]
Revert "Re-apply 4b6c2cd642 "Deferred Concept Instantiation Implementation"""

This reverts commit a97899108e495147985e5e9492e742d51d5cc97a.

The patch caused some problems with the libc++ `__range_adaptor_closure`
that I haven't been able to figure out the cause of, so I am reverting
while I figure out whether this is a solvable problem/issue with the
  CFE, or libc++ depending on an older 'incorrect' behavior.

2 years ago[PS5] Check for HasNativeLLVMSupport
Paul Robinson [Mon, 2 May 2022 18:03:08 +0000 (11:03 -0700)]
[PS5] Check for HasNativeLLVMSupport

2 years ago[NFC] Add test for HasNativeLLVMSupport
Paul Robinson [Mon, 2 May 2022 17:58:22 +0000 (10:58 -0700)]
[NFC] Add test for HasNativeLLVMSupport

It looks like there used to be a test for this, but the test evolved
in a way that caused the check for the diagnostic to be eliminated.
Add a test that is obviously and specifically for that diagnostic.

2 years ago[Driver][test] Remove clang{{.*}} when testing -cc1 command lines
Fangrui Song [Mon, 2 May 2022 18:02:19 +0000 (11:02 -0700)]
[Driver][test] Remove clang{{.*}} when testing -cc1 command lines

The majority of tests omit testing "clang" for -cc1 command lines. In addition,
some distributions symlink %clang to an executable with a content hash based
filename so clang{{.*}} check won't work.

With this change, we can remove many -no-canonical-prefixes whose purpose was to
make the tests pass on such distributions.

2 years ago[ifs] Fix bug where exclude only excluded when outputting ifs files
Alex Brachet [Mon, 2 May 2022 17:49:06 +0000 (17:49 +0000)]
[ifs] Fix bug where exclude only excluded when outputting ifs files

Now output elf files will also have excluded symbols removed.

Reviewed By: haowei

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

2 years agoReapply "[BuildLibCalls] Introduce getOrInsertLibFunc() for use when building
Jonas Paulsson [Wed, 20 Apr 2022 16:19:37 +0000 (18:19 +0200)]
Reapply "[BuildLibCalls] Introduce getOrInsertLibFunc() for use when building
libcalls." (was 0f8c626). This reverts commit 14d9390.

The patch previously failed to recognize cases where user had defined a
function alias with an identical name as that of the library
function. Module::getFunction() would then return nullptr which is what the
sanitizer discovered.

In this updated version a new function isLibFuncEmittable() has as well been
introduced which is now used instead of TLI->has() anytime a library function
is to be emitted . It additionally also makes sure there is e.g. no function
alias with the same name in the module.

Reviewed By: Eli Friedman

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

2 years ago[mlir][OpenMP] Add omp.cancel and omp.cancellationpoint.
Raghu Maddhipatla [Mon, 2 May 2022 17:23:11 +0000 (12:23 -0500)]
[mlir][OpenMP] Add omp.cancel and omp.cancellationpoint.

Reviewed By: kiranchandramohan, peixin, shraiysh

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

2 years ago[mlir] CRunnerUtils: qualify UnrankedMemRefType to avoid collisions with mlir::Unrank...
Eugene Zhulenev [Sun, 1 May 2022 20:28:51 +0000 (13:28 -0700)]
[mlir] CRunnerUtils: qualify UnrankedMemRefType to avoid collisions with mlir::UnrankedMemRefType

When CRunnerUtils included together with MLIR IR headers, it can lead to compilation errors.

Reviewed By: mehdi_amini

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

2 years agoMark identifier prefixes as substitutable
Harald van Dijk [Mon, 2 May 2022 17:07:47 +0000 (18:07 +0100)]
Mark identifier prefixes as substitutable

The Itanium C++ ABI says prefixes are substitutable. For most prefixes
we already handle this: the manglePrefix(const DeclContext *, bool) and
manglePrefix(QualType) overloads explicitly handles substitutions or
defer to functions that handle substitutions on their behalf. The
manglePrefix(NestedNameSpecifier *) overload, however, is different and
handles some cases implicitly, but not all. The Identifier case was not
handled; this change adds handling for it, as well as a test case.

Reviewed By: erichkeane

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

2 years ago[PowerPC] Enable CR bits support for Power8 and above.
Amy Kwan [Mon, 2 May 2022 06:30:10 +0000 (01:30 -0500)]
[PowerPC] Enable CR bits support for Power8 and above.

This patch turns on support for CR bit accesses for Power8 and above. The reason
why CR bits are turned on as the default for Power8 and above is that because
later architectures make use of builtins and instructions that require CR bit
accesses (such as the use of setbc in the vector string isolate predicate
and bcd builtins on Power10).

This patch also adds the clang portion to allow for turning on CR bits in the
front end if the user so desires to.

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

2 years ago[Driver][test] Avoiding producing object file in the current directory
Fangrui Song [Mon, 2 May 2022 17:00:57 +0000 (10:00 -0700)]
[Driver][test] Avoiding producing object file in the current directory

2 years ago[GlobalOpt] Iterate over replaced values deterministically to constprop
Arthur Eubanks [Mon, 2 May 2022 16:21:39 +0000 (09:21 -0700)]
[GlobalOpt] Iterate over replaced values deterministically to constprop

If there are pre-existing dead instructions, the order we visit replaced
values can cause us sometimes to not delete dead instructions.

The added test non-deterministically failed without the change.

2 years ago[Driver][test] Add back some -no-canonical-prefixes
Fangrui Song [Mon, 2 May 2022 16:35:58 +0000 (09:35 -0700)]
[Driver][test] Add back some -no-canonical-prefixes

To make them meaningful, it's useful to check "clang". Use
-no-canonical-prefixes to support distributions that symlink %clang to an
executable with a filename not ending in "clang".

2 years ago[InstCombine] Handle non-canonical GEP index in indexed compare fold (PR55228)
Nikita Popov [Mon, 2 May 2022 15:52:02 +0000 (17:52 +0200)]
[InstCombine] Handle non-canonical GEP index in indexed compare fold (PR55228)

Normally the index type will already be canonicalized here, but
this is not guaranteed depending on visitation order. The code
was already accounting for a potentially needed sext, but a trunc
may also be needed.

Add a ConstantExpr::getSExtOrTrunc() helper method to make this
simpler. This matches the corresponding IRBuilder method in behavior.

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

2 years ago[gn build] Port 5de0a3e9da72
LLVM GN Syncbot [Mon, 2 May 2022 15:51:27 +0000 (15:51 +0000)]
[gn build] Port 5de0a3e9da72

2 years ago[Analyzer] Minor cleanups in StreamChecker
Marco Antognini [Tue, 26 Apr 2022 09:16:36 +0000 (11:16 +0200)]
[Analyzer] Minor cleanups in StreamChecker

Remove unnecessary conversion to Optional<> and incorrect assumption
that BindExpr can return a null state.

Reviewed By: steakhal

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

2 years ago[trace][intelpt] Support system-wide tracing [1] - Add a method for accessing the...
Walter Erquinigo [Wed, 27 Apr 2022 19:13:40 +0000 (12:13 -0700)]
[trace][intelpt] Support system-wide tracing [1] - Add a method for accessing the list of logical core ids

In order to open perf events per core, we need to first get the list of
core ids available in the system. So I'm adding a function that does
that by parsing /proc/cpuinfo. That seems to be the simplest and most
portable way to do that.

Besides that, I made a few refactors and renames to reflect better that
the cpu info that we use in lldb-server comes from procfs.

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

2 years ago[X86] Reduce some superfluous diffs between znver1/znver2 models. NFC
Simon Pilgrim [Mon, 2 May 2022 15:45:39 +0000 (16:45 +0100)]
[X86] Reduce some superfluous diffs between znver1/znver2 models. NFC

znver2 is a mainly a search+replace of the znver1 model, but for no reason the HADD and DPPS have been moved around - try to keep these in sync (no actual changes in the models).

2 years ago[X86][AMX] combineLdSt - don't dereference dyn_cast. NFC
Simon Pilgrim [Mon, 2 May 2022 15:20:06 +0000 (16:20 +0100)]
[X86][AMX] combineLdSt - don't dereference dyn_cast. NFC

This leads to null pointer dereference warnings - use cast<> which will assert that the cast correct.

2 years ago[Analyzer] Fix clang::ento::taint::dumpTaint definition
Marco Antognini [Tue, 19 Apr 2022 11:18:02 +0000 (13:18 +0200)]
[Analyzer] Fix clang::ento::taint::dumpTaint definition

Ensure the definition is in the "taint" namespace, like its declaration.

Reviewed By: steakhal

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

2 years agoBuildLibCalls: add alloc-family attribute to many allocator functions
Augie Fackler [Thu, 17 Mar 2022 13:54:46 +0000 (09:54 -0400)]
BuildLibCalls: add alloc-family attribute to many allocator functions

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

2 years agoRe-apply 4b6c2cd642 "Deferred Concept Instantiation Implementation""
Erich Keane [Mon, 2 May 2022 13:29:25 +0000 (06:29 -0700)]
Re-apply 4b6c2cd642 "Deferred Concept Instantiation Implementation""

This reverts commit 0c31da48389754822dc3eecc4723160c295b9ab2.

I've solved the issue with the PointerUnion by making the
`FunctionTemplateDecl` pointer be a NamedDecl, that could be a
`FunctionDecl` or `FunctionTemplateDecl` depending.  This is enforced
with an assert.

2 years ago[LV][SLP] Add tests for vectorizing fptoi_sat intrinsics. NFC
David Green [Mon, 2 May 2022 14:11:44 +0000 (15:11 +0100)]
[LV][SLP] Add tests for vectorizing fptoi_sat intrinsics. NFC

2 years agoBuildLibCalls: infer allocptr attribute for free and realloc() family functions
Augie Fackler [Wed, 16 Mar 2022 17:53:18 +0000 (13:53 -0400)]
BuildLibCalls: infer allocptr attribute for free and realloc() family functions

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

2 years ago[X86] Replace avx512f integer add reduction builtins with generic builtin
Simon Pilgrim [Mon, 2 May 2022 13:39:10 +0000 (14:39 +0100)]
[X86] Replace avx512f integer add reduction builtins with generic builtin

D124741 added the generic "__builtin_reduce_add" which we can use to replace the x86 specific integer add reduction builtins - internally these were mapping to the same intrinsic already so there are no test changes required.

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

2 years agoRevert "Deferred Concept Instantiation Implementation"
Erich Keane [Mon, 2 May 2022 13:25:38 +0000 (06:25 -0700)]
Revert "Deferred Concept Instantiation Implementation"

This reverts commit 4b6c2cd647e9e5a147954886338f97ffb6a1bcfb.

The patch caused numerous ARM 32 bit build failures, since we added a
5th item to the PointerUnion, and went over the 2-bits available in the
32 bit pointers.

2 years ago[CodeGen] Add tests for X+(Y&~X) pattern (NFC)
Nikita Popov [Mon, 2 May 2022 13:23:13 +0000 (15:23 +0200)]
[CodeGen] Add tests for X+(Y&~X) pattern (NFC)

2 years ago[AArch64] add tests for int->FP->int casts; NFC
Sanjay Patel [Mon, 2 May 2022 13:18:12 +0000 (09:18 -0400)]
[AArch64] add tests for int->FP->int casts; NFC

Copied from x86 tests for multi-target coverage.
Also, provides coverage for target-specific asm
testing for Alive2 or its follow-ons.

See #55150 and D124692

2 years ago[x86] add tests for int->FP->int casts; NFC
Sanjay Patel [Mon, 2 May 2022 12:23:52 +0000 (08:23 -0400)]
[x86] add tests for int->FP->int casts; NFC

Adapted from tests for IR in D124692.
Also see #55150

2 years ago[x86] update test file with complete auto-generated check lines; NFC
Sanjay Patel [Mon, 2 May 2022 12:12:43 +0000 (08:12 -0400)]
[x86] update test file with complete auto-generated check lines; NFC

Also, improve test names.

2 years agoDeferred Concept Instantiation Implementation
Erich Keane [Thu, 3 Mar 2022 16:27:49 +0000 (08:27 -0800)]
Deferred Concept Instantiation Implementation

As reported here: https://github.com/llvm/llvm-project/issues/44178

Concepts are not supposed to be instantiated until they are checked, so
this patch implements that and goes through significant amounts of work
to make sure we properly re-instantiate the concepts correctly.

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

2 years ago[libunwind] Add SystemZ support
Ulrich Weigand [Mon, 2 May 2022 12:35:29 +0000 (14:35 +0200)]
[libunwind] Add SystemZ support

Add support for the SystemZ (s390x) architecture to libunwind.

Support should be feature-complete with the exception of
unwinding from signal handlers (to be added later).

Reviewed by: MaskRay

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