platform/upstream/llvm.git
17 months ago[X86] `X86TargetLowering`: override `allowsMemoryAccess()`
Roman Lebedev [Sat, 21 Jan 2023 21:12:27 +0000 (00:12 +0300)]
[X86] `X86TargetLowering`: override `allowsMemoryAccess()`

The baseline `allowsMemoryAccess()` is wrong for X86.
It assumes that aligned memory operations are always allowed,
but that is not true.

For example, We can not perform a 32-byte aligned non-temporal load
of a 32-byte vector, without AVX2 that is, yet `allowsMemoryAccess()`
will say it is allowed, so we may end up merging non-temporal loads,
only to split them up to legalize them, and here we go again.

NOTE: the test changes here are superfluous. The main effect is that without this change,
in D141777, we'd get stuck endlessly merging and splitting non-temporal stores.

Reviewed By: RKSimon

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

17 months ago[NFC][SCEV] `computeSCEVAtScope()`: reserve vector size upfront
Roman Lebedev [Sat, 21 Jan 2023 20:42:11 +0000 (23:42 +0300)]
[NFC][SCEV] `computeSCEVAtScope()`: reserve vector size upfront

17 months ago[NFC][SCEV] `computeSCEVAtScope()`: `scUnknown`: use early-returns
Roman Lebedev [Sat, 21 Jan 2023 20:27:51 +0000 (23:27 +0300)]
[NFC][SCEV] `computeSCEVAtScope()`: `scUnknown`: use early-returns

17 months ago[NFC][SCEV] Reflow `computeSCEVAtScope()` into an exhaustive switch
Roman Lebedev [Sat, 21 Jan 2023 20:23:59 +0000 (23:23 +0300)]
[NFC][SCEV] Reflow `computeSCEVAtScope()` into an exhaustive switch

Otherwise instead of a compile-time error that you forgot to modify it,
you'd get a run-time error, which happened every time i've added new expr.

This is completely NFC, there are no other changes here.

17 months ago[NFC][SCEV] `computeSCEVAtScope()`: clang-format
Roman Lebedev [Sat, 21 Jan 2023 20:23:20 +0000 (23:23 +0300)]
[NFC][SCEV] `computeSCEVAtScope()`: clang-format

17 months ago[clang/driver] Make sure that `-gno-modules` by itself doesn't enable debug info
Argyrios Kyrtzidis [Sat, 21 Jan 2023 19:31:21 +0000 (11:31 -0800)]
[clang/driver] Make sure that `-gno-modules` by itself doesn't enable debug info

17 months ago[OpenMP] Modernize the kernel launching interface and APIs
Johannes Doerfert [Thu, 19 Jan 2023 21:40:58 +0000 (13:40 -0800)]
[OpenMP] Modernize the kernel launching interface and APIs

We already created a versioned `__tgt_kernel_arguments` struct but it
was only briefly used and its content was passed in isolation anyway.
This makes it hard to add more information in the future. With this
patch we fully embrace the struct as means to pass information from the
compiler to the plugin as part of a kernel launch.

The patch also extends and renames the struct, bumping the version
number to 2. Version 1 entries are auto-upgraded. This is in preparation
for "bare" kernel launches, per kernel dynamic shared memory, CUDA/HIP
lowering, etc.

The `__tgt_target_kernel_nowait` interface was deprecated as it was
unused. Once we actually implement support for something like that, we
can add an appropriate API.

Note: Only plugins with the `launch_kernel` interface are now supported.
      That means that a new clang won't be able to use an old runtime.
      An old clang can still use the new runtime since the libomptarget
      interface did not change.

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

17 months ago[RISCV] Use llvm::bit_width (NFC)
Kazu Hirata [Sat, 21 Jan 2023 18:54:09 +0000 (10:54 -0800)]
[RISCV] Use llvm::bit_width (NFC)

I've verified that the arguments to llvm::bit_width are all of
uint64_t with:

  static_assert(std::is_same_v<uint64_t, decltype(Mask)>)

18 months ago[DAG] Convert static combineABSToABD to DAGCombiner::foldABSToABD. NFCI.
Simon Pilgrim [Sat, 21 Jan 2023 18:23:36 +0000 (18:23 +0000)]
[DAG] Convert static combineABSToABD to DAGCombiner::foldABSToABD. NFCI.

This will make some future legality checks easier.

18 months ago[ARM] Cortex-M55 Scheduling Model
David Green [Sat, 21 Jan 2023 18:03:24 +0000 (18:03 +0000)]
[ARM] Cortex-M55 Scheduling Model

This adds an Arm Cortex-M55 scheduling model, using the information from
https://developer.arm.com/documentation/102692/latest/

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

18 months ago[AArch64] Simplify isSeveralBitsExtractOpFromShr (NFC)
Kazu Hirata [Sat, 21 Jan 2023 17:23:39 +0000 (09:23 -0800)]
[AArch64] Simplify isSeveralBitsExtractOpFromShr (NFC)

This patch simplifies isSeveralBitsExtractOpFromShr.

The following statements are equivalent:

  unsigned BitWide = 64 - countLeadingOnes(~(AndMask >> SrlImm));
  unsigned BitWide = 64 - countLeadingZeros(AndMask >> SrlImm);

Now, consider:

  if (BitWide && isMask_64(AndMask >> SrlImm)) {

When isMask_64 returns true, AndMask >> SrlImm and BitWide must be
nonzero.  Since BitWide does not contribute to narrowing the
condition, we can simplify the condition as:

  if (isMask_64(AndMask >> SrlImm)) {

We can negate the condition for an early exit as recommended by the
LLVM Coding Standards.

Now, all of the following are equivalent if AndMask >> SrlImm is
nonzero:

  MSB = BitWide + SrlImm - 1
  MSB = (64 - countLeadingZero(AndMask >> SrlImm)) + SrlImm - 1
  MSB = (63 - countLeadingZero(AndMask >> SrlImm)) + SrlImm
  MSB = 63 - countLeadingZero(AndMask)
  MSB = 63 ^ countLeadingZero(AndMask)
  MSB = findLastSet(AndMask, ZB_Undefined)

18 months ago[VPlan] Consider all recipes in replicate blocks as sink candidates.
Florian Hahn [Sat, 21 Jan 2023 17:14:13 +0000 (17:14 +0000)]
[VPlan] Consider all recipes in replicate blocks as sink candidates.

Update sinkScalarOperands to consider all operands of recipes in
replicate blocks as sink candidates This enables additional sinking
opportunities and is another step towards retiring LLVM IR-based
sinkScalarOperands.

This enables iterative sinking of operands for successive calls of
sinkScalarOperands.

Depends on D139788.

Reviewed By: Ayal

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

18 months ago[X86] Add DAG tests showing the failure to reassociate IMINMAX nodes to fold constant...
Simon Pilgrim [Sat, 21 Jan 2023 15:24:49 +0000 (15:24 +0000)]
[X86] Add DAG tests showing the failure to reassociate IMINMAX nodes to fold constant operands

Test coverage for Issue #58110

18 months ago[X86] v8i1-masks.ll - add avx512 test coverage and use X86 check prefix instead of X32
Simon Pilgrim [Sat, 21 Jan 2023 14:14:24 +0000 (14:14 +0000)]
[X86] v8i1-masks.ll - add avx512 test coverage and use X86 check prefix instead of X32

We try to use X32 for tests on gnux32 triples

18 months ago[libc++] Granularize <type_traits> includes in <bit>, <numbers> and <coroutine>
Nikolas Klauser [Thu, 22 Dec 2022 23:23:30 +0000 (00:23 +0100)]
[libc++] Granularize <type_traits> includes in <bit>, <numbers> and <coroutine>

`<coroutine>` seems to be new enough to not be a huge problem.

Reviewed By: Mordante, #libc

Spies: libcxx-commits, ChuanqiXu

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

18 months ago[libc++] Implement P1413R3 (Deprecate std::aligned_storage and std::aligned_union)
Nikolas Klauser [Sun, 11 Dec 2022 01:10:31 +0000 (02:10 +0100)]
[libc++] Implement P1413R3 (Deprecate std::aligned_storage and std::aligned_union)

There are no tests for the aliases because clang doesn't diagnose deprecated template aliases currently.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

18 months ago[Cost] Add CostKind to getVectorInstrCost and its related users
ShihPo Hung [Sat, 21 Jan 2023 13:29:05 +0000 (05:29 -0800)]
[Cost] Add CostKind to getVectorInstrCost and its related users

LoopUnroll estimates the loop size via getInstructionCost(),
but getInstructionCost() cannot pass CostKind to getVectorInstrCost().
And so does getShuffleCost() to getBroadcastShuffleOverhead(),
getPermuteShuffleOverhead(), getExtractSubvectorOverhead(),
and getInsertSubvectorOverhead().

To address this, this patch adds an argument CostKind to these
functions.

Reviewed By: RKSimon

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

18 months ago[M68k] Fix M68k pipeline order test after 4ece50737d5385fb80cfa23f5297d1111f8eed39
Simon Pilgrim [Sat, 21 Jan 2023 13:00:46 +0000 (13:00 +0000)]
[M68k] Fix M68k pipeline order test after 4ece50737d5385fb80cfa23f5297d1111f8eed39

18 months ago[C++20][Modules] Handle defaulted and deleted functions in header units.
Iain Sandoe [Tue, 17 Jan 2023 10:17:08 +0000 (10:17 +0000)]
[C++20][Modules] Handle defaulted and deleted functions in header units.

Address part of https://github.com/llvm/llvm-project/issues/60079.

Deleted and Defaulted functions are implicitly inline, but that state
is not set at the point that we perform the diagnostic checks for externally-
visible non-inline functions; check the function body type explicitly in the
diagnostic.

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

18 months ago[openmp] Workaround for HSA in issue 60119
Jon Chesterfield [Sat, 21 Jan 2023 12:01:13 +0000 (12:01 +0000)]
[openmp] Workaround for HSA in issue 60119

Move plugin initialization to libomptarget initialization.

Removes the call_once control, probably fractionally faster overall.
Fixes issue 60119 because the plugin initialization, which might
try to dlopen unrelated shared libraries, is no longer nested within
a call from application code.

Fixes #60119

Reviewed By: Maetveis, jhuber6

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

18 months ago[X86] avx2-vperm.ll - use X86 check prefix instead of X32
Simon Pilgrim [Sat, 21 Jan 2023 11:43:42 +0000 (11:43 +0000)]
[X86] avx2-vperm.ll - use X86 check prefix instead of X32

We try to use X32 for tests on gnux32 triples

18 months ago[DAG] getNode - add type assertion checks for ISD::ABDS/ABDU
Simon Pilgrim [Sat, 21 Jan 2023 11:31:47 +0000 (11:31 +0000)]
[DAG] getNode - add type assertion checks for ISD::ABDS/ABDU

18 months ago[cmake] Fix some indentation in HandleLLVMOptions.cmake
Jay Foad [Sat, 21 Jan 2023 09:26:36 +0000 (09:26 +0000)]
[cmake] Fix some indentation in HandleLLVMOptions.cmake

18 months ago[ORC] Add lazy jit support for LoongArch64
wanglei [Sat, 21 Jan 2023 05:31:33 +0000 (13:31 +0800)]
[ORC] Add lazy jit support for LoongArch64

This patch adds resolver, indirection and trampoline stubs for
loongarch64, allowing lazy compilation to work.

It assumes hard float feature exists.

Depends on D141036

Reviewed By: lhames

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

18 months agoRe-commit "[clang][Interp] Unify visiting variable declarations"
Timm Bäder [Fri, 20 Jan 2023 14:07:25 +0000 (15:07 +0100)]
Re-commit "[clang][Interp] Unify visiting variable declarations"

We often visit the same variable multiple times, e.g. once when checking
its initializer and later when compiling the function. Unify both of
those in visitVarDecl() and do the returning of the value in
visitDecl().

This time, use a VariableScope instead of a DeclScope for local
variables. This way, we don't emit Destroy ops for the local variables
immediately after creating them.

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

18 months agoGlobalISel: Fix the broken release build after c1fc5219cb23d1e14c0115381321f6d8d6a4fc17
Haojian Wu [Sat, 21 Jan 2023 09:09:17 +0000 (10:09 +0100)]
GlobalISel: Fix the broken release build after c1fc5219cb23d1e14c0115381321f6d8d6a4fc17

18 months agoMake `shouldExpandLogicAtomicRMWInIR` able to match both operands.
Noah Goldstein [Sat, 21 Jan 2023 08:53:14 +0000 (00:53 -0800)]
Make `shouldExpandLogicAtomicRMWInIR` able to match both operands.

Previous logic was buggy and erroneously asserted that I->operand(0) must
be the RMW instruction. This change fixes that and makes it so that the
RMW instruction can be used in operand 0 or 1.

Also update the tests to explicitly test RMW as operand 0/1 (no change
to codegen).

Reviewed By: pengfei

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

18 months agosanmd: refine selection of functions for UAR checking
Dmitry Vyukov [Fri, 20 Jan 2023 09:26:20 +0000 (10:26 +0100)]
sanmd: refine selection of functions for UAR checking

There are no intrinsic functions that leak arguments.
If the called function does not return, the current function
does not return as well, so no possibility of use-after-return.
Sanitizer function also don't leak or don't return.
It's safe to both pass pointers to local variables to them
and to tail-call them.

Reviewed By: melver

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

18 months ago[Clang][test] Avoid FileCheck error when matching `-cc1`
hezuoqiang [Sat, 21 Jan 2023 04:28:01 +0000 (23:28 -0500)]
[Clang][test] Avoid FileCheck error when matching `-cc1`

FileCheck patterns consisting of only `-cc1` on a line by itself often
cause mismatches, e.g. with version strings formed from commit hashes
such as "clang-cc1514432c58". They should be changed to contain more
context and match more precisely.

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

18 months ago[ADT] Add [[nodiscard]] to the functions in bit.h (NFC)
Kazu Hirata [Sat, 21 Jan 2023 04:27:08 +0000 (20:27 -0800)]
[ADT] Add [[nodiscard]] to the functions in bit.h (NFC)

18 months ago[BOLT][NFC] Move getLTOCommonName to Utils
Amir Ayupov [Sat, 21 Jan 2023 03:27:38 +0000 (19:27 -0800)]
[BOLT][NFC] Move getLTOCommonName to Utils

Reuse getLTOCommonName in components other than Profile (to be used in Core)

Reviewed By: #bolt, maksfb

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

18 months ago[mlir][sparse] factoring out getRankedTensorType helper function
wren romano [Thu, 19 Jan 2023 03:11:48 +0000 (19:11 -0800)]
[mlir][sparse] factoring out getRankedTensorType helper function

Reviewed By: Peiming

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

18 months ago[ADT] Add bit_floor, bit_ceil, and bit_width to bit.h
Kazu Hirata [Sat, 21 Jan 2023 03:34:42 +0000 (19:34 -0800)]
[ADT] Add bit_floor, bit_ceil, and bit_width to bit.h

This patch adds C++20-style bit_floor, bit_ceil, and bit_width.

In a subsequent patch, I'm going to define PowerOf2Floor in
MathExtras.h in terms of bit_floor.

Unfortunately, PowerOf2Ceil isn't quite the same as bit_ceil because
PowerOf2Ceil(0) == 0, whereas bit_ceil(0) == 1.

MathExtras.h does not have a function directly corresponding to
bit_width, but Log2_32(X) + 1, which occurs in a few places, can be
replaced with bit_width(X).

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

18 months ago[bazel][libc] fixes
David Blaikie [Sat, 21 Jan 2023 01:52:20 +0000 (01:52 +0000)]
[bazel][libc] fixes

(Phab review only sent in draft to use bazel presubmit testing -
precommit human review was not required)

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

18 months ago[BOLT] Handle __uniq suffix added by -funique-internal-linkage-names
Amir Ayupov [Fri, 20 Jan 2023 23:50:59 +0000 (15:50 -0800)]
[BOLT] Handle __uniq suffix added by -funique-internal-linkage-names

In profile matching, if `.__uniq` suffix added for internal linkage
symbols with `-funique-internal-linkage-names` prevents BOLT from
matching to a binary function, try to strip the suffix and perform
fuzzy name matching.

Follow-up to D124117.

Reviewed By: #bolt, maksfb

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

18 months agoGlobalISel: Split main function of RegBankSelect up
Matt Arsenault [Wed, 18 Jan 2023 10:53:18 +0000 (05:53 -0500)]
GlobalISel: Split main function of RegBankSelect up

This will allow for easier overriding of the pass.

18 months agollvm-reduce: Fix default handling of intermediate format
Matt Arsenault [Fri, 20 Jan 2023 00:47:18 +0000 (20:47 -0400)]
llvm-reduce: Fix default handling of intermediate format

Bitcode inputs should produce bitcode intermediates by
default.

18 months agollvm-reduce: Reorganize some function locations
Matt Arsenault [Tue, 17 Jan 2023 18:35:43 +0000 (13:35 -0500)]
llvm-reduce: Reorganize some function locations

Move things that are naturally methods of ReducerWorkItem to
be methods of ReducerWorkItem in the same source file.

18 months agoReland: Drop the ZeroBehavior parameter from countLeadingZeros and the like (NFC)
Kazu Hirata [Sat, 21 Jan 2023 02:42:03 +0000 (18:42 -0800)]
Reland: Drop the ZeroBehavior parameter from countLeadingZeros and the like (NFC)

This patch drops the ZeroBehavior parameter from bit counting
functions like countLeadingZeros.  ZeroBehavior specifies the behavior
when the input to count{Leading,Trailing}Zeros is zero and when the
input to count{Leading,Trailing}Ones is all ones.

ZeroBehavior was first introduced on May 24, 2013 in commit
eb91eac9fb866ab1243366d2e238b9961895612d.  While that patch did not
state the intention, I would guess ZeroBehavior was for performance
reasons.  The x86 machines around that time required a conditional
branch to implement countLeadingZero<uint32_t> that returns the 32 on
zero:

        test    edi, edi
        je      .LBB0_2
        bsr     eax, edi
        xor     eax, 31
.LBB1_2:
        mov     eax, 32

That is, we can remove the conditional branch if we don't care about
the behavior on zero.

IIUC, Intel's Haswell architecture, launched on June 4, 2013,
introduced several bit manipulation instructions, including lzcnt and
tzcnt, which eliminated the need for the conditional branch.

I think it's time to retire ZeroBehavior as its utility is very
limited.  If you care about compilation speed, you should build LLVM
with an appropriate -march= to take advantage of lzcnt and tzcnt.
Even if not, modern host compilers should be able to optimize away
quite a few conditional branches because the input is often known to
be nonzero from dominating conditional branches.

In this iteration, I've moved the forward declarations of
_BitScanForward outside the llvm space to fix builds on Windows.

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

18 months ago[bazel][libc] fixes
David Blaikie [Sat, 21 Jan 2023 01:26:52 +0000 (01:26 +0000)]
[bazel][libc] fixes

& some aarch64 fixes?

18 months ago[libc][Obvious] Restore static keyword of a few static methods.
Siva Chandra [Sat, 21 Jan 2023 00:56:07 +0000 (16:56 -0800)]
[libc][Obvious] Restore static keyword of a few static methods.

The static keyword of the concerned methods was accidentally lost in a
previous commit.

18 months ago[clang][dataflow] Allow analyzing multiple functions in unit tests
Dmitri Gribenko [Sat, 21 Jan 2023 00:22:22 +0000 (01:22 +0100)]
[clang][dataflow] Allow analyzing multiple functions in unit tests

In unit tests for concrete dataflow analyses we typically use the
testonly `checkDataflow()` helper to analyse a free function called
"target". This pattern allows our tests to be uniform and focused on
specific statement- or expression-level C++ features.

As we expand our feature coverage, we want to analyze functions whose
names we don't fully control, like constructors, destructors, operators
etc. In such tests it is often convenient to analyze all functions
defined in the input code, to avoid having to carefully craft an AST
matcher that finds the exact function we're interested in. That can be
easily done by providing `checkDataflow()` with a catch-all matcher like
`functionDecl()`.

It is also often convenient to define multiple special member functions
in a single unit test, for example, multiple constructors, and share the
rest of the class definition code between constructors. As a result, it
makes sense to analyze multiple functions in one unit test.

This change allows `checkDataflow()` to correctly handle AST matchers
that match more than one function. Previously, it would only ever
analyze the first matched function, and silently ignore the rest. Now it
runs dataflow analysis in a loop, and calls `VerifyResults` for each
function that was found in the input and analyzed.

Reviewed By: ymandel, sgatev

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

18 months agobazel: libc: Add missing dependency
David Blaikie [Sat, 21 Jan 2023 00:18:19 +0000 (00:18 +0000)]
bazel: libc: Add missing dependency

18 months agoRevert "WIP listeners", totally pushed by mistake!
Mehdi Amini [Sat, 21 Jan 2023 00:16:06 +0000 (01:16 +0100)]
Revert "WIP listeners", totally pushed by mistake!

This reverts commit 2e312a7baec5e8d8f841ee819966ff3f53f274c6.
Should never have been pushed here...

18 months agoWIP listeners
Mehdi Amini [Fri, 20 Jan 2023 23:43:52 +0000 (00:43 +0100)]
WIP listeners

18 months ago[clang] Add ElaboratedType sugaring for types on implicit special members
Brad King [Fri, 20 Jan 2023 23:29:11 +0000 (15:29 -0800)]
[clang] Add ElaboratedType sugaring for types on implicit special members

Extend the change from commit 15f3cd6bfc67 ([clang] Implement
ElaboratedType sugaring for types written bare, 2021-10-11, D112374)
to cover types in the signatures of implicit copy-constructor,
copy-assignment, move-constructor, and move-assignment members in
C++ record types.

With this fix, diagnostic messages print types of special members
consistently whether they are explicitly or implicitly defined.

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

Reviewed By: rsmith

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

18 months ago[BOLT][NFC] Move out ReorderFunctions::printStats
Amir Ayupov [Fri, 20 Jan 2023 23:41:37 +0000 (15:41 -0800)]
[BOLT][NFC] Move out ReorderFunctions::printStats

Break out stats-printing code from ReorderFunctions::reorder for brevity.

Reviewed By: #bolt, maksfb

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

18 months agoRemove the LINK_COMPONENTS entry from lldb-instr CMakery
Jim Ingham [Fri, 20 Jan 2023 23:40:55 +0000 (15:40 -0800)]
Remove the LINK_COMPONENTS entry from lldb-instr CMakery

The presence of this entry causes the Xcode generator to produce
two references to libLLVMSupport.a, one at the end of the list, and
that causes the build to fail with a link error.  The first version
was pulled in when processing the CLANG_LIBS entries in the
lldb/tools/lldb-instr/CMakeLists.txt.

I looked around and the only places where we use LINK_COMPONENTS and
CLANG_LIBS together are various lldb subdirectories that produce .a
files but don't actually link anything.

Anyway, this line doesn't seem to be needed for either the regular
Ninja or the Xcode generator, and removing it makes the xcode build
work again.

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

18 months ago[OpenMP] Remove unfinished and unused 'Analyzer' tool
Joseph Huber [Fri, 20 Jan 2023 23:34:26 +0000 (17:34 -0600)]
[OpenMP] Remove unfinished and unused 'Analyzer' tool

Summary:
This patch removes a tool that was never finished and has no plans of
being picked up again. It does not need to live in LLVM source in an
unusable state.

18 months ago[OpenMP] Clean up AMD handling for `-fopenmp-targets=amdgcn` arch inference
Joseph Huber [Thu, 19 Jan 2023 17:49:15 +0000 (11:49 -0600)]
[OpenMP] Clean up AMD handling for `-fopenmp-targets=amdgcn` arch inference

Previously we had some special handling here that errored out if
multiple architectures were detected. This isn't a problem anymore as
the runtime can handle multi-archicture binaries automatically. So it's
safe to simply take the first architecture that we know works. If users
use `--offload-arch=native` instead it will build for all the
architectures at the same time rather than just picking one. This patch
makes it consisten with the NVPTX version.

Reviewed By: jdoerfert

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

18 months ago[BPF][clang] Ignore stack protector options for BPF target
Eduard Zingerman [Fri, 20 Jan 2023 23:11:00 +0000 (15:11 -0800)]
[BPF][clang] Ignore stack protector options for BPF target

Stack protector builtin functions are not implemented for BPF target,
thus compiling programs with one of the following options would result
in an error:
  -fstack-protector
  -fstack-protector-all
  -fstack-protector-strong

This commit adds logic to ignore these options for BPF target.
Searching through DiagnosticDriverKinds.td shows that all messages for
such kind of behavior are implemented as warnings, this commit follows
the suit.

Here is an example of the diagnostic message:
  clang-16: warning: ignoring '-fstack-protector' option as it is not currently supported for target 'bpf' [-Woption-ignored]

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

18 months ago[LegacyDivergenceAnalysis] Add NewPM support
Anshil Gandhi [Fri, 20 Jan 2023 22:20:39 +0000 (15:20 -0700)]
[LegacyDivergenceAnalysis] Add NewPM support

Reviewed By: arsenm

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

18 months agoFix a -Wunused-variable warning in release build.
Haojian Wu [Fri, 20 Jan 2023 22:39:04 +0000 (23:39 +0100)]
Fix a -Wunused-variable warning in release build.

18 months agoAMDGPU: Put un-initiaized enumerators together in an enum definition.
Changpeng Fang [Fri, 20 Jan 2023 22:39:40 +0000 (14:39 -0800)]
AMDGPU: Put un-initiaized enumerators together in an enum definition.

Summary:
  For any enumerator whose definition does not have an initializer,
the associated value is the value of the previous enumerator plus one.
In order to avoid the possibility that two unrelated enumerators to
have the same value, we should try to cluster the uninitialized enumerators
together.

Reviewers: arsenm

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

18 months ago[InstSimplify] with poison-safe logical ops: (X && Y) || X --> X
Sanjay Patel [Fri, 20 Jan 2023 21:06:33 +0000 (16:06 -0500)]
[InstSimplify] with poison-safe logical ops: (X && Y) || X --> X

https://alive2.llvm.org/ce/z/ptZcJH

issue #60167

18 months ago[InstSimplify] add tests for logical-and/or reduction; NFC
Sanjay Patel [Fri, 20 Jan 2023 20:42:08 +0000 (15:42 -0500)]
[InstSimplify] add tests for logical-and/or reduction; NFC

issue #60167

18 months ago[mlir] Fix a warning
Kazu Hirata [Fri, 20 Jan 2023 22:33:57 +0000 (14:33 -0800)]
[mlir] Fix a warning

This patch fixes:

  mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp:528:22:
  error: comparison of integers of different signs: 'uint64_t' (aka
  'unsigned long') and 'int64_t' (aka 'long') [-Werror,-Wsign-compare]

18 months ago[libc][NFC] Replace static inline and inline annotations with LIBC_INLINE.
Siva Chandra Reddy [Thu, 19 Jan 2023 08:32:50 +0000 (08:32 +0000)]
[libc][NFC] Replace static inline and inline annotations with LIBC_INLINE.

This is first of a few patches which will do similar mechanical changes.

LIBC_INLINE is a simple macro which is default defined as just `inline`.
The idea is that, different downstream contexts can define the macro as
suitable to their use case and context. For example, one can choose to
define LIBC_INLINE as `[[clang::internal_linkage]] inline`.

Reviewed By: lntue

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

18 months ago[libc++] Add FreeBSD XFAILs in preparation for CI
Ed Maste [Thu, 15 Dec 2022 14:34:29 +0000 (09:34 -0500)]
[libc++] Add FreeBSD XFAILs in preparation for CI

This at least allows us to stand up libc++ FreeBSD CI and avoid future
regressions.  The failures do need to be addressed, and can be done
iteratively.

Reviewed By: philnik, Mordante

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

18 months agoRevert "Add support for clang-cl's option `-fexcess-precision`."
Zahira Ammarguellat [Fri, 20 Jan 2023 21:42:56 +0000 (16:42 -0500)]
Revert "Add support for clang-cl's option `-fexcess-precision`."

This reverts commit 47074683c906f920cb7bba462beeb57ca4b84ab0.

Had to revert it that since it's breaking tests on MacOS. See
https://reviews.llvm.org/D141929 comments from @thakis.

18 months ago[Clang] Fix test case `clang/test/OpenMP/bug59944.c`
Shilei Tian [Fri, 20 Jan 2023 21:40:38 +0000 (16:40 -0500)]
[Clang] Fix test case `clang/test/OpenMP/bug59944.c`

18 months agoRevert "sanmd: refine selection of functions for UAR checking"
Arthur Eubanks [Fri, 20 Jan 2023 21:40:36 +0000 (13:40 -0800)]
Revert "sanmd: refine selection of functions for UAR checking"

This reverts commit 9d4f1a9eff27716069dc6a2d991baa228c197b85.

Breaks under -DCOMPILER_RT_BUILD_SANITIZERS=OFF

18 months ago[libc++] add FreeBSD atomic wait support
Konstantin Belousov [Wed, 18 Jan 2023 01:18:24 +0000 (20:18 -0500)]
[libc++] add FreeBSD atomic wait support

Reviewed By: philnik

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

18 months ago[clang][modules] Disallow importing private framework in the implementation
Jan Svoboda [Fri, 20 Jan 2023 01:02:42 +0000 (17:02 -0800)]
[clang][modules] Disallow importing private framework in the implementation

Whenever we are compiling implementation of a framework (with the `-fmodule-name=FW` option), we never translate `#import <FW/Header.h>` to an import, regardless of whether "Header.h" belongs to "FW" or "FW_Private". For the same reasons, we also disallow `@import FW`. However, we still allow `@import FW_Private`. This patch disallows that a well, to be consistent with the rest of the rules.

Reviewed By: benlangmuir

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

18 months ago[mlir][sparse] IR/SparseTensorDialect.cpp: misc code cleanup
wren romano [Thu, 19 Jan 2023 02:22:48 +0000 (18:22 -0800)]
[mlir][sparse] IR/SparseTensorDialect.cpp: misc code cleanup

Reviewed By: Peiming

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

18 months ago[Clang] [Sema] Removed a fix-it for system headers
Fahad Nayyar [Mon, 16 Jan 2023 19:42:10 +0000 (19:42 +0000)]
[Clang] [Sema] Removed a fix-it for system headers

Disabled an invalid fix-it which suggested fixes to be applied in system headers for some programs in IDEs like Xcode.

rdar://100890960

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

18 months ago[APSInt] Fix bug in APSInt mentioned in https://github.com/llvm/llvm-project/issues...
Peter Rong [Tue, 27 Dec 2022 02:05:11 +0000 (18:05 -0800)]
[APSInt] Fix bug in APSInt mentioned in https://github.com/llvm/llvm-project/issues/59515

Also provide a `tryExtValue()` API like APInt did in D139683

Reviewed By: RKSimon, efriedma

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

18 months ago[clang/CodeGenActionTest] Use the platform's path separator for the `DebugInfoCWDCode...
Argyrios Kyrtzidis [Fri, 20 Jan 2023 18:14:11 +0000 (10:14 -0800)]
[clang/CodeGenActionTest] Use the platform's path separator for the `DebugInfoCWDCodeGen` test

Fixes a failure in some Windows configuration.

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

18 months ago[AMDGPU][NFC] Clarify heterogeneous DWARF address/memory spaces
Tony Tye [Fri, 20 Jan 2023 18:08:19 +0000 (18:08 +0000)]
[AMDGPU][NFC] Clarify heterogeneous DWARF address/memory spaces

Reviewed By: scott.linder

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

18 months ago[OMPIRBuilder] Pass dependencies to createTask by value
Prabhdeep Singh Soni [Fri, 13 Jan 2023 03:58:21 +0000 (22:58 -0500)]
[OMPIRBuilder] Pass dependencies to createTask by value

This patch modifies OpenMPIRBuilder::createTask to accept its
Dependencies vector by value instead of by reference. This is
necessary because the PostOutlineCB lambda that uses this Dependencies
vector may outlive the original Dependencies vector.

Reviewed By: kiranchandramohan

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

18 months ago[lldb] Implement SymbolFile::CopyType
Augusto Noronha [Wed, 18 Jan 2023 20:22:43 +0000 (12:22 -0800)]
[lldb] Implement SymbolFile::CopyType

SymbolFiles should be the only point of creation of Types to ensure
that they aren't destroyed prematurely by keeping them in the
SymbolFile's TypeList. This patch hides the copy constructor of Types,
and adds a new CopyType function to SymbolFile, so Types can still be
copied safely.

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

18 months ago[lldb] Remove timer from SBModule copy ctor
Dave Lee [Tue, 29 Nov 2022 00:21:16 +0000 (16:21 -0800)]
[lldb] Remove timer from SBModule copy ctor

The SBModule copy constructor has fast execution, and is high firing. Fast and
frequent functions are not good candidates for timers.

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

18 months ago[bazel] Fix up dependency
Benjamin Kramer [Fri, 20 Jan 2023 20:58:56 +0000 (21:58 +0100)]
[bazel] Fix up dependency

18 months agoRevert "Revert "[MLIR] Update bazel build file after 455305624884cf9237143e2ba0635fcc...
Benjamin Kramer [Fri, 20 Jan 2023 20:56:25 +0000 (21:56 +0100)]
Revert "Revert "[MLIR] Update bazel build file after 455305624884cf9237143e2ba0635fcc5ba5206""

This reverts commit 9ef7ae507387f133cf34ca0bc0edd3f009a3ff71.

18 months ago[LSR] Style cleanup for code recently added in D132443
Philip Reames [Fri, 20 Jan 2023 20:44:47 +0000 (12:44 -0800)]
[LSR] Style cleanup for code recently added in D132443

Also add FIXMEs which highlight correctness bugs in this recently added off by default option.  These have also been raised on the original review.

18 months ago[clang/driver] Add `-gno-modules` as the negative version of `-gmodules`
Argyrios Kyrtzidis [Fri, 20 Jan 2023 18:04:59 +0000 (10:04 -0800)]
[clang/driver] Add `-gno-modules` as the negative version of `-gmodules`

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

18 months agoCorrect documentation for the refersToType AST matcher
Aaron Ballman [Fri, 20 Jan 2023 20:35:54 +0000 (15:35 -0500)]
Correct documentation for the refersToType AST matcher

The docs used a nonexisting matcher that caused some confusion. It has
now been replaced with the correct syntax.

Fixes #58044

18 months ago[mlir][Index] Implement InferIntRangeInterface, re-land
Krzysztof Drewniak [Mon, 9 Jan 2023 17:09:17 +0000 (17:09 +0000)]
[mlir][Index] Implement InferIntRangeInterface, re-land

Re-land D140899 to fix a missing dependency in the index dialect's
CMakeLists.txt.

Reviewed By: Mogball

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

18 months ago[PowerPC] Remove the lax warning for explicit casts
Maryam Moghadas [Fri, 20 Jan 2023 15:55:20 +0000 (09:55 -0600)]
[PowerPC] Remove the lax warning for explicit casts

This patch is to remove the erroneous lax vector conversion warning for CStyle; explicit; casts
that was added as part of D126540.

Reviewed By: nemanjai

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

18 months agoRecommit "[RISCV][TableGen] Move XLen detection into getMArch in RISCVTargetDefEmitte...
Craig Topper [Fri, 20 Jan 2023 20:20:58 +0000 (12:20 -0800)]
Recommit "[RISCV][TableGen] Move XLen detection into getMArch in RISCVTargetDefEmitter. NFC"

Using the correct feature name to detect 64bit this time. Previously,
I mistakenly compared the expected record name against a string inside
the record.

18 months ago[LSR] Generalize one aspect of terminator folding (recently introduced in D132443)
Philip Reames [Fri, 20 Jan 2023 20:15:44 +0000 (12:15 -0800)]
[LSR] Generalize one aspect of terminator folding (recently introduced in D132443)

There's no need to require the start value to come directly from the loop predecessor.  This was sometimes covering up a latent miscompile in this off-by-default option, but the miscompile needs fixed anyways and the issue has been raised on the original review.

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

18 months agoAllow a target loop to be used inside a parallel.
Doru Bercea [Wed, 11 Jan 2023 16:17:02 +0000 (10:17 -0600)]
Allow a target loop to be used inside a parallel.

18 months ago[OpenMP] Fix for distributed barrier.
Terry Wilmarth [Thu, 12 Jan 2023 16:29:20 +0000 (10:29 -0600)]
[OpenMP] Fix for distributed barrier.

Distributed barrier was found to cause hangs in some test cases. Found
that a section updating the barrier size was improperly shifted to a
different code section during patching.  Restored to original
location, all tests run to completion.

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

18 months agoUpdate the status of some C11 and C99 features we support
Aaron Ballman [Fri, 20 Jan 2023 19:49:25 +0000 (14:49 -0500)]
Update the status of some C11 and C99 features we support

This updates the status of:

N505 Make qualifiers idempotent
N725 Integer promotion rules
N1311 Initializing static of external variables

18 months ago[bazel] Remove some unused dependencies
Benjamin Kramer [Fri, 20 Jan 2023 19:43:57 +0000 (20:43 +0100)]
[bazel] Remove some unused dependencies

18 months ago[bazel] Add missing dependency after 16f8d17f7b
Benjamin Kramer [Fri, 20 Jan 2023 19:40:06 +0000 (20:40 +0100)]
[bazel] Add missing dependency after 16f8d17f7b

18 months ago[Clang][OpenMP] Bail out early if `Scope` is nullptr in case of any crash
Shilei Tian [Fri, 20 Jan 2023 19:40:16 +0000 (14:40 -0500)]
[Clang][OpenMP] Bail out early if `Scope` is nullptr in case of any crash

When there is any compile error, clang still tries to compile as many code as
possible, therefore `Scope` can be `nullptr` here. However, we didn't check it
beforehand, causing compiler crash.

Fix #59944.

Reviewed By: ABataev

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

18 months ago[RS4GC] Add a GCStrategy option to enable RS4GC
Campbell Suter [Fri, 20 Jan 2023 15:00:01 +0000 (18:00 +0300)]
[RS4GC] Add a GCStrategy option to enable RS4GC

Currently, the RewriteStatepointsForGC pass has a hardcoded list of GC
strategies that it operates on, forcing downstream projects to patch
LLVM to enable it for their own strategies. The diff D141110 changes
that to each GCStrategy having a flag to enable or disable RS4GC.

This patch adds that flag. It currently doesn't do anything, but is
provided so downstream projects can enable it to smooth the transition.

Reviewed By: dantrushin

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

18 months ago[BOLT][DWARF] Change loclist encoding to use base_addrx
Alexander Yermolovich [Fri, 20 Jan 2023 19:30:04 +0000 (11:30 -0800)]
[BOLT][DWARF] Change loclist encoding to use base_addrx

Doing the same thing as for rangelists. Changing loclists to use base_addrx, it
slightly increases .debug_loclists, but reduces .debug_addr section.

| section             | clang-16.bolt.base | clang-16.bolt | raw       |  % |
| debug_loclists |  198208                  |  203398          | 5190     | 102%  |
| .debug_addr    | 14415808              | 14351448        | -64360 |99.5% |

Reviewed By: maksfb

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

18 months ago[InstCombine] adjust tests for fptoui + trunc; NFC
Sanjay Patel [Fri, 20 Jan 2023 19:10:23 +0000 (14:10 -0500)]
[InstCombine] adjust tests for fptoui + trunc; NFC

Tests were duplicated for undef-ness, but that's not necessary.
There were no tests for bfloat/double.

I deleted the fptosi tests for now because those will just
be a bitwidth adjustment to the fptoui tests once we settle
on the right set of tests.

I think it should just be 2 tests on either side of the
bitwidth boundary to allow a fold with a couple of extra
tests thrown in to show other type constraints are not
a factor.

Goes with:
D142093

18 months ago[mlir] Add "memref::MemRefDialect" as dependentDialects for GpuToLLVMConversionPass
Xiang Li [Wed, 18 Jan 2023 04:20:11 +0000 (23:20 -0500)]
[mlir] Add "memref::MemRefDialect" as dependentDialects for GpuToLLVMConversionPass

For https://github.com/llvm/llvm-project/issues/60070.
The issue is caused by memref.store is not registed.
Registe it by add "memref::MemRefDialect" as dependetDialects for GpuToLLVMConsersionPass.

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

18 months agoAdd Parse/Sema for iterator for map clause.
Doru Bercea [Fri, 6 Jan 2023 17:17:57 +0000 (11:17 -0600)]
Add Parse/Sema for iterator for map clause.

18 months ago[CVP] Expand bound `udiv`'s, symmetrically with `urem`'s
Roman Lebedev [Fri, 20 Jan 2023 17:56:40 +0000 (20:56 +0300)]
[CVP] Expand bound `udiv`'s, symmetrically with `urem`'s

Symmetrical with the `urem` case, added in 66efb986322b206834e7c9e1eb777fa053912c39.

Simple case: https://alive2.llvm.org/ce/z/gRumLd / https://alive2.llvm.org/ce/z/rxEeC5
Second variant of precondition: https://alive2.llvm.org/ce/z/cAm9TD

18 months ago[NFC][CVP] Add tests for udiv expansion
Roman Lebedev [Fri, 20 Jan 2023 17:45:24 +0000 (20:45 +0300)]
[NFC][CVP] Add tests for udiv expansion

18 months agoRevert "[llvm] Move bit counting functions to bit.h (NFC)"
Nico Weber [Fri, 20 Jan 2023 18:51:29 +0000 (13:51 -0500)]
Revert "[llvm] Move bit counting functions to bit.h (NFC)"

This reverts commit f37614b25ccaa9c0710cc8a4fc2ba2fb0fcb9159.
Doesn't build on Windows: https://reviews.llvm.org/D142078#4068417

18 months agoRevert "[RISCV][TableGen] Move XLen detection into getMArch in RISCVTargetDefEmitter...
Craig Topper [Fri, 20 Jan 2023 18:44:49 +0000 (10:44 -0800)]
Revert "[RISCV][TableGen] Move XLen detection into getMArch in RISCVTargetDefEmitter. NFC"

This reverts commit e58010f712ccac83194852fa95ed70ef76ba6a33.

Seems this is failing on the build bots.

18 months ago[PGO] incorrect classof in InstrProfIncrementInst
Ellis Hoag [Fri, 20 Jan 2023 18:00:21 +0000 (10:00 -0800)]
[PGO] incorrect classof in InstrProfIncrementInst

Class InstrProfIncrementInstStep inherits from InstrProfIncrementInst but cannot cast to InstrProfIncrementInst, because InstrProfIncrementInst::classof does not cover such circumstance。

Function InstrProfiling::run traverse all instruction in a module and try to cast them to InstrProfIncrementInst using dyn_cast, but it will return nullptr if the instruction is InstrProfIncrementInstStep(subclass of InstrProfIncrementInst).

Reviewed By: tejohnson, ellis

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

18 months ago[RISCV][TableGen] Move XLen detection into getMArch in RISCVTargetDefEmitter. NFC
Craig Topper [Fri, 20 Jan 2023 18:15:27 +0000 (10:15 -0800)]
[RISCV][TableGen] Move XLen detection into getMArch in RISCVTargetDefEmitter. NFC

We no longer need the XLen in two places. Fold it into the code
that determines the default march.

18 months ago[InstCombine] regenerate test checks; NFC
Sanjay Patel [Fri, 20 Jan 2023 18:10:56 +0000 (13:10 -0500)]
[InstCombine] regenerate test checks; NFC

We have better value name propagation now. Eliminates some noise
in case something in this set of tests has a real change.

18 months ago[RISCV] Remove Features from CPUInfo in RISCVTargetParser.
Craig Topper [Fri, 20 Jan 2023 18:03:37 +0000 (10:03 -0800)]
[RISCV] Remove Features from CPUInfo in RISCVTargetParser.

Instead of having separate feature bits, get information from march.
Invalid is now implied by empty march.
64-bit is now implied by march starting with "rv64".

Reviewed By: fpetrogalli

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