platform/upstream/llvm.git
22 months ago[mlir] Don't include StringSwitch.h (NFC)
Kazu Hirata [Mon, 19 Sep 2022 06:09:40 +0000 (23:09 -0700)]
[mlir] Don't include StringSwitch.h (NFC)

These files don't seem to use StringSwitch.

22 months ago[NFC][SimplifyCFG]Precommit test case to show inner-loop metadata may not be preserved
Mingming Liu [Fri, 16 Sep 2022 04:26:43 +0000 (21:26 -0700)]
[NFC][SimplifyCFG]Precommit test case to show inner-loop metadata may not be preserved

- There is an outer while-loop and an inner for-loop in the test case.
  Inner-loop has `llvm.loop.unroll.enable` metadata that is not
  preserved. This happens around [1], when the loop metadata of outer loop
  overrides the inner loop metadata directly, without looking at whether inner-loop
  itself has loop metadata.

 [1] https://github.com/llvm/llvm-project/blob/ab755e65629ea098cb6faa77b13ac087849ffc67/llvm/lib/Transforms/Utils/Local.cpp#L1146

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

22 months ago[MLIR] NFC: improve comment about MLIR_CMAKE_DIR.
Christian Sigg [Mon, 19 Sep 2022 05:46:21 +0000 (07:46 +0200)]
[MLIR] NFC: improve comment about MLIR_CMAKE_DIR.

22 months ago[clang] Don't include StringSwitch.h (NFC)
Kazu Hirata [Mon, 19 Sep 2022 05:21:32 +0000 (22:21 -0700)]
[clang] Don't include StringSwitch.h (NFC)

These files don't seem to use StringSwitch.

22 months ago[llvm] Deprecate llvm::empty (NFC)
Kazu Hirata [Mon, 19 Sep 2022 05:01:32 +0000 (22:01 -0700)]
[llvm] Deprecate llvm::empty (NFC)

This patch deprecates llvm::empty as I've migrated all known uses of
llvm::empty(x) to x.empty().

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

22 months ago[mlir][sparse] Add push_back op to support code generation.
bixia1 [Fri, 16 Sep 2022 18:30:53 +0000 (11:30 -0700)]
[mlir][sparse] Add push_back op to support code generation.

Reviewed By: aartbik

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

22 months ago[Clang][LoongArch] Implement ABI lowering
Weining Lu [Mon, 19 Sep 2022 02:23:21 +0000 (10:23 +0800)]
[Clang][LoongArch] Implement ABI lowering

Reuse most of RISCV's implementation with several exceptions:

1. Assign signext/zeroext attribute to args passed in stack.
On RISCV, integer scalars passed in registers have signext/zeroext
when promoted, but are anyext if passed on the stack. This is defined
in early RISCV ABI specification. But after this change [1], integers
should also be signext/zeroext if passed on the stack. So I think
RISCV's ABI lowering should be updated [2].

While in LoongArch ABI spec, we can see that integer scalars narrower
than GRLEN bits are zero/sign-extended no matter passed in registers
or on the stack.

2. Zero-width bit fields are ignored.
This matches GCC's behavior but it hasn't been documented in ABI sepc.
See https://gcc.gnu.org/r12-8294.

3. `char` is signed by default.
There is another difference worth mentioning is that `char` is signed
by default on LoongArch while it is unsigned on RISCV.

This patch also adds `_BitInt` type support to LoongArch and handle it
in LoongArchABIInfo::classifyArgumentType.

[1] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/cec39a064ee0e5b0129973fffab7e3ad1710498f
[2] https://github.com/llvm/llvm-project/issues/57261

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

22 months ago[C++] [Modules] Generate the initializer for modules if we compile a
Chuanqi Xu [Mon, 19 Sep 2022 03:03:46 +0000 (11:03 +0800)]
[C++] [Modules] Generate the initializer for modules if we compile a
module unit directly

Previously we lack a test which ensures that the module unit will
generate initializer if it is compiled directly (instead of from a pcm
file). Now we add the test back.

22 months ago[mlir][Math] Add constant folder for ErfOp.
jacquesguan [Fri, 16 Sep 2022 06:57:55 +0000 (14:57 +0800)]
[mlir][Math] Add constant folder for ErfOp.

This patch adds constant folder for ErfOp by using erf/erff of libm.

Reviewed By: ftynse, Mogball

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

22 months ago[llvm] Use has_value instead of hasValue (NFC)
Kazu Hirata [Mon, 19 Sep 2022 02:45:34 +0000 (19:45 -0700)]
[llvm] Use has_value instead of hasValue (NFC)

22 months ago[CUDA][NFC] Rename 'addDeviceDepences' to 'addDeviceDependences' in DeviceActionBuilder.
wanglian [Mon, 19 Sep 2022 02:28:30 +0000 (10:28 +0800)]
[CUDA][NFC] Rename 'addDeviceDepences' to 'addDeviceDependences' in DeviceActionBuilder.

Reviewed By: tra

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

22 months ago[NFC] Move the position of CodeGen/module-initializer*.cpp
Chuanqi Xu [Mon, 19 Sep 2022 02:35:00 +0000 (10:35 +0800)]
[NFC] Move the position of CodeGen/module-initializer*.cpp

Previsouly the module-initializer*.cpp lives in the CodeGen dir instead
of CodeGenCXX dir, which is not consistency with other tests since
modules are features for C++.

22 months ago[RISCV][NFC]Remove outdated comment from targetShrinkDemandedConstant
LiaoChunyu [Mon, 19 Sep 2022 02:22:31 +0000 (10:22 +0800)]
[RISCV][NFC]Remove outdated comment from targetShrinkDemandedConstant

Reviewed By: craig.topper

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

22 months agoUse std::make_unsigned_t (NFC)
Kazu Hirata [Mon, 19 Sep 2022 01:41:02 +0000 (18:41 -0700)]
Use std::make_unsigned_t (NFC)

22 months ago[clang-format] Disallow requires clauses to become function declarations
Emilia Dreamer [Sun, 18 Sep 2022 23:49:58 +0000 (02:49 +0300)]
[clang-format] Disallow requires clauses to become function declarations

There already exists logic to disallow requires *expressions* to be
treated as function declarations, but this expands it to include
requires *clauses*, when they happen to also be parenthesized.

Previously, in the following case:

```
template <typename T>
  requires(Foo<T>)
T foo();
```

The line with the requires clause was actually being considered as the
line with the function declaration due to the parentheses, and the
*real* function declaration on the next line became a trailing
annotation

(Together with https://reviews.llvm.org/D134049) Fixes https://github.com/llvm/llvm-project/issues/56213

Reviewed By: HazardyKnusperkeks, owenpan

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

22 months ago[clang-format] Disallow trailing return arrows to be operators
Emilia Dreamer [Sun, 18 Sep 2022 23:47:42 +0000 (02:47 +0300)]
[clang-format] Disallow trailing return arrows to be operators

In the following construction:
`template <typename T> requires Foo<T> || Bar<T> auto func() -> int;`

The `->` of the trailing return type was actually considered as an
operator as part of the binary operation in the requires clause, with
the precedence level of `PrecedenceArrowAndPeriod`, leading to fake
parens being inserted in strange locations, that would never be closed.

Fixes one part of https://github.com/llvm/llvm-project/issues/56213
(the rest will probably be in a separate patch)

Reviewed By: HazardyKnusperkeks, owenpan

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

22 months ago[ORC][ORC-RT] Make WrapperFunctionCall::Create support void functions.
Lang Hames [Mon, 19 Sep 2022 00:47:12 +0000 (17:47 -0700)]
[ORC][ORC-RT] Make WrapperFunctionCall::Create support void functions.

Serialized calls to void-wrapper-functions should have zero bytes of argument
data, but accessing ArgData[0] may (and will, in the case of SmallVector) fail
if the argument data buffer is empty.

This commit fixes the issue by adding a check for empty argument buffers.

22 months ago[X86] Fix the LEA optimization pass
Kazu Hirata [Mon, 19 Sep 2022 00:50:17 +0000 (17:50 -0700)]
[X86] Fix the LEA optimization pass

The LEA optimization pass visits each basic block of a given machine
function.  In each basic block, for each pair of LEAs that differ only
in their displacement fields, we replace all uses of the second LEA
with the first LEA while adjusting the displacement.

Now, without this patch, after all the replacements are made, the
following assert triggers:

        assert(MRI->use_empty(LastVReg) &&
               "The LEA's def register must have no uses");

The replacement loop uses:

  for (MachineOperand &MO :
       llvm::make_early_inc_range(MRI->use_operands(LastVReg))) {

which is equivalent to:

  for (auto UI = MRI->use_begin(LastVReg), UE = MRI->use_end();
       UI != UE;) {
    MachineOperand &MO = *UI++;  // <-- Look!

That is, immediately after the post increment, make_early_inc_range
already has the iterator for the next iteration in its mind.

The problem is that in one iteration of the loop, we could replace two
uses in a debug instruction like:

  DBG_VALUE_LIST !"r", !DIExpression(DW_OP_LLVM_arg, 0), %0:gr64, %0:gr64, ...

So, the iterator for the next iteration becomes invalid.  We end up
traversing a garbage use list from that point on.  In turn, we don't
get to visit remaining uses.

The patch fixes the problem by switching to a "draining" while loop:

  while (!MRI->use_empty(LastVReg)) {
    MachineOperand &MO = *MRI->use_begin(LastVReg);
    MachineInstr &MI = *MO.getParent();

The credit goes to Simon Pilgrim for reducing the test case.

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

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

22 months ago[mlir] Use empty (NFC)
Kazu Hirata [Mon, 19 Sep 2022 00:46:53 +0000 (17:46 -0700)]
[mlir] Use empty (NFC)

22 months ago[SimplifyCFG] accumulate bonus insts cost
Yaxun (Sam) Liu [Sat, 17 Sep 2022 21:57:35 +0000 (17:57 -0400)]
[SimplifyCFG] accumulate bonus insts cost

SimplifyCFG folds

bool foo() {
  if (cond1) return false;
  if (cond2) return false;
  return true;
}

as

bool foo() {
  if (cond1 | cond2) return false
  return true;
}

'cond2' is called 'bonus insts' in branch folding since they introduce overhead
since the original CFG could do early exit but the folded CFG always executes
them. SimplifyCFG calculates the costs of 'bonus insts' of a folding a BB into
its predecessor BB which shares the destination. If it is below bonus-inst-threshold,
SimplifyCFG will fold that BB into its predecessor and cond2 will always be executed.

When SimplifyCFG calculates the cost of 'bonus insts', it only consider 'bonus' insts
in the current BB to be considered for folding. This causes issue for unrolled loops
which share destinations, e.g.

bool foo(int *a) {
  for (int i = 0; i < 32; i++)
    if (a[i] > 0) return false;
  return true;
}

After unrolling, it becomes

bool foo(int *a) {
  if(a[0]>0) return false
  if(a[1]>0) return false;
  //...
  if(a[31]>0) return false;
  return true;
}

SimplifyCFG will merge each BB with its predecessor BB,
and ends up with 32 'bonus insts' which are always executed, which
is much slower than the original CFG.

The root cause is that SimplifyCFG does not consider the
accumulated cost of 'bonus insts' which are folded from
different BB's.

This patch fixes that by introducing a ValueMap to track
costs of 'bonus insts' coming from different BB's into
the same BB, and cuts off if the accumulated cost
exceeds a threshold.

Reviewed by: Artem Belevich, Florian Hahn, Nikita Popov, Matt Arsenault

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

22 months ago[AMDGPU] Fix isSGPRReg for special registers
Carl Ritson [Sun, 18 Sep 2022 23:23:43 +0000 (08:23 +0900)]
[AMDGPU] Fix isSGPRReg for special registers

Special registers, e.g. MODE, do not have register classes so
will cause null pointer exception if passed to isSGPRReg.

Reviewed By: arsenm

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

22 months ago[BOLT] Remove duplicate types (NFC)
Kazu Hirata [Sun, 18 Sep 2022 23:23:19 +0000 (16:23 -0700)]
[BOLT] Remove duplicate types (NFC)

This patch, a follow-up for 588628de3e954d8029b20841aceb612e328ae104,
removes duplicate types like T and PointerT in favor of reference and
pointer, respectively.

22 months ago[HLSL] [clang] Add vector version of abs for HLSL
Xiang Li [Mon, 12 Sep 2022 22:58:32 +0000 (15:58 -0700)]
[HLSL] [clang] Add vector version of abs for HLSL

Add vector version of abs as
```
__attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
int2 abs (int2 );
__attribute__((clang_builtin_alias(__builtin_elementwise_abs)))
int3 abs (int3 );
```
To make this work.
Allowed custom type checking builtins to be recelareable.

Reviewed By: RKSimon

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

22 months ago[ModuleInliner] Capitalize a variable name (NFC)
Kazu Hirata [Sun, 18 Sep 2022 21:35:09 +0000 (14:35 -0700)]
[ModuleInliner] Capitalize a variable name (NFC)

22 months ago[ModuleInliner] Remove unused using declarations (NFC)
Kazu Hirata [Sun, 18 Sep 2022 21:27:06 +0000 (14:27 -0700)]
[ModuleInliner] Remove unused using declarations (NFC)

22 months ago[ModuleInliner] Move getInlineCostWrapper to an anonymous namespace (NFC)
Kazu Hirata [Sun, 18 Sep 2022 21:09:21 +0000 (14:09 -0700)]
[ModuleInliner] Move getInlineCostWrapper to an anonymous namespace (NFC)

This patch moves getInlineCostWrapper to an anonymous namespace.
While I am at it, I'm moving the function closer to the beginning of
the file so that I can use it elsewhere in the file without a forward
declaration.

22 months ago[Clang] Fix compat diagnostic to detect a nontype template parameter has a placeholde...
Shafik Yaghmour [Sun, 18 Sep 2022 18:54:32 +0000 (11:54 -0700)]
[Clang] Fix compat diagnostic to detect a nontype template parameter has a placeholder type using getContainedAutoType()

Based on the changes introduced by 15361a21e01026e74cb17011b702c7d1c881ae94 it
looks like C++17 compatibility diagnostic should have been checking
getContainedAutoType().

This fixes: https://github.com/llvm/llvm-project/issues/57369
  https://github.com/llvm/llvm-project/issues/57643
  https://github.com/llvm/llvm-project/issues/57793

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

22 months ago[InstCombine] remove multi-use add demanded constant fold
Sanjay Patel [Sun, 18 Sep 2022 18:21:21 +0000 (14:21 -0400)]
[InstCombine] remove multi-use add demanded constant fold

This was originally part of D133788. There are no visible
regressions. All of the diffs show a large unsigned constant
becoming a small negative constant. This should be better
for analysis (and slightly less compile-time) and codegen.

22 months ago[llvm] Use x.empty() instead of llvm::empty(x) (NFC)
Kazu Hirata [Sun, 18 Sep 2022 18:21:16 +0000 (11:21 -0700)]
[llvm] Use x.empty() instead of llvm::empty(x) (NFC)

I'm planning to deprecate and eventually remove llvm::empty.

Note that no use of llvm::empty requires the ability of llvm::empty to
determine the emptiness from begin/end only.

22 months ago[clang-format] Skip token annotation in passes that don't need it
owenca [Sat, 17 Sep 2022 04:31:21 +0000 (21:31 -0700)]
[clang-format] Skip token annotation in passes that don't need it

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

22 months ago[flang] Use x.empty() instead of llvm::empty(x) (NFC)
Kazu Hirata [Sun, 18 Sep 2022 18:10:11 +0000 (11:10 -0700)]
[flang] Use x.empty() instead of llvm::empty(x) (NFC)

I'm planning to deprecate and eventually remove llvm::empty.

Note that no use of llvm::empty requires the ability of llvm::empty to
determine the emptiness from begin/end only.

22 months ago[clang] Use x.empty() instead of llvm::empty(x) (NFC)
Kazu Hirata [Sun, 18 Sep 2022 18:07:50 +0000 (11:07 -0700)]
[clang] Use x.empty() instead of llvm::empty(x) (NFC)

I'm planning to deprecate and eventually remove llvm::empty.

Note that no use of llvm::empty requires the ability of llvm::empty to
determine the emptiness from begin/end only.

22 months ago[BOLT] Use x.empty() instead of llvm::empty(x) (NFC)
Kazu Hirata [Sun, 18 Sep 2022 18:01:56 +0000 (11:01 -0700)]
[BOLT] Use x.empty() instead of llvm::empty(x) (NFC)

I'm planning to deprecate and eventually remove llvm::empty.

Note that no use of llvm::empty requires the ability of llvm::empty to
determine the emptiness from begin/end only.

22 months ago[mlir] Use x.empty() instead of llvm::empty(x) (NFC)
Kazu Hirata [Sun, 18 Sep 2022 17:53:49 +0000 (10:53 -0700)]
[mlir] Use x.empty() instead of llvm::empty(x) (NFC)

I'm planning to deprecate and eventually remove llvm::empty.

Note that no use of llvm::empty requires the ability of llvm::empty to
determine the emptiness from begin/end only.

22 months agoUse std::decay_t (NFC)
Kazu Hirata [Sun, 18 Sep 2022 17:25:08 +0000 (10:25 -0700)]
Use std::decay_t (NFC)

22 months agoUse std::conditional_t (NFC)
Kazu Hirata [Sun, 18 Sep 2022 17:25:06 +0000 (10:25 -0700)]
Use std::conditional_t (NFC)

22 months ago[ADT] Use std::common_type_t (NFC)
Kazu Hirata [Sun, 18 Sep 2022 17:25:04 +0000 (10:25 -0700)]
[ADT] Use std::common_type_t (NFC)

22 months ago[InstCombine] Fix bug when folding x + (x | -x) to x & (x - 1)
Marc Auberer [Sun, 18 Sep 2022 17:16:12 +0000 (13:16 -0400)]
[InstCombine] Fix bug when folding x + (x | -x) to x & (x - 1)

Addresses concern: https://reviews.llvm.org/rG09cdddea0c4d284c2c22f5dfade40a60850c5ea7

There was a copy/paste mistake in the code. Updated code and test ref.

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

22 months ago[InstCombine] fold full-shift of sdiv to icmp+extend
Sanjay Patel [Sun, 18 Sep 2022 16:40:53 +0000 (12:40 -0400)]
[InstCombine] fold full-shift of sdiv to icmp+extend

This is a disguised sign-bit test with offset:
(X / +DivC) >> (Width - 1) --> ext (X <= -DivC)
(X / -DivC) >> (Width - 1) --> ext (X >= +DivC)

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

We don't match/test poison in the sdiv constant because
that would be immediate undefined behavior.

22 months ago[InstCombine] add tests for full-right-shift of sdiv; NFC
Sanjay Patel [Fri, 16 Sep 2022 20:34:36 +0000 (16:34 -0400)]
[InstCombine] add tests for full-right-shift of sdiv; NFC

22 months agoMake sure libLLVM users link with libatomic if needed
Aaron Puchert [Sun, 18 Sep 2022 17:11:54 +0000 (19:11 +0200)]
Make sure libLLVM users link with libatomic if needed

64-bit atomics are used in llvm/ADT/Statistic.h, which means that users
of libLLVM.so might also have to link with libatomic. To avoid having
to special-case the library here, we simply add all `LLVM_SYSTEM_LIBS`
as public link dependencies to libLLVM.

This fixes a build failure on PowerPC 32-bit.

Reviewed By: beanz

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

22 months ago[ModuleInliner] Remove InlineOrder::front (NFC)
Kazu Hirata [Sun, 18 Sep 2022 15:49:44 +0000 (08:49 -0700)]
[ModuleInliner] Remove InlineOrder::front (NFC)

InlineOrder::front is a remnant from the era when we had a nested
"while" loops in the module inliner, with the inner one grouping the
call sites with the same caller.

Now that we have a simple "while" loop draining the priority queue, we
can just use InlineOrder::pop.

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

22 months ago[Clang][NFC] update predicate and reduce redundant check
Phoebe Wang [Sun, 18 Sep 2022 13:55:26 +0000 (21:55 +0800)]
[Clang][NFC] update predicate and reduce redundant check

22 months ago[DAG] MatchRotate - reuse existing LHSShiftArg/RHSShiftArg variables. NFC.
Simon Pilgrim [Sun, 18 Sep 2022 13:35:04 +0000 (14:35 +0100)]
[DAG] MatchRotate - reuse existing LHSShiftArg/RHSShiftArg variables. NFC.

22 months ago[Docs] Add a link that refers to C++ standard modules in Clang modules doc
Jun Zhang [Sat, 17 Sep 2022 09:41:46 +0000 (17:41 +0800)]
[Docs] Add a link that refers to C++ standard modules in Clang modules doc

Currently there're two pages that both talk about "Modules" in clang, but
they're different. The one that describes C++ standard modules explicitly
spells out the difference but the other one which targeting Clang modules
doesn't.

This patch adds a link that refers to the C++ standard modules
one in Clang modules doc, as you usually got the later page when
googling. I believe this will make newcomers less confused.

Signed-off-by: Jun Zhang <jun@junz.org>
Differential Revision: https://reviews.llvm.org/D134105

22 months ago[Clang][NFC] update obsolete check predicate
Phoebe Wang [Sun, 18 Sep 2022 10:00:36 +0000 (18:00 +0800)]
[Clang][NFC] update obsolete check predicate

22 months ago[libc++] Avoid including <tuple> in compressed_pair.h
Nikolas Klauser [Sat, 17 Sep 2022 12:30:29 +0000 (14:30 +0200)]
[libc++] Avoid including <tuple> in compressed_pair.h

compressed_pair is widely used in the library, but most of the uses don't use the tuple parts. To avoid including <tuple> everywhere, use the forward declaration instead in compressed_pair.h

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

22 months ago[Modules] Don't judge if we're compiling a module unit by LangOpts::CurrentModule...
Chuanqi Xu [Sun, 18 Sep 2022 08:43:27 +0000 (16:43 +0800)]
[Modules] Don't judge if we're compiling a module unit by LangOpts::CurrentModule.empty()

Closing https://github.com/llvm/llvm-project/issues/57778.

Previously it judge if we're compiling a module unit by
LangOpts::CurrentModule.empty(). But it is not true since we can specify
the module name by `-fmodule-name` option for arbitrary module unit.
Then this patch adjuest the judgement properly.

22 months agoSilence unused variable warning in release builds. NFC
Benjamin Kramer [Sun, 18 Sep 2022 07:15:32 +0000 (09:15 +0200)]
Silence unused variable warning in release builds. NFC

22 months ago[NFC] Typo fix in ARCMTActions.h
Shivam Gupta [Sun, 18 Sep 2022 06:59:40 +0000 (12:29 +0530)]
[NFC] Typo fix in ARCMTActions.h

22 months ago[Transforms] Merge function attributes within InlineFunction (NFC)
Kazu Hirata [Sun, 18 Sep 2022 06:10:23 +0000 (23:10 -0700)]
[Transforms] Merge function attributes within InlineFunction (NFC)

In the past, we've had a bug resulting in a compiler crash after
forgetting to merge function attributes (D105729).

This patch teaches InlineFunction to merge function attributes.  This
way, we minimize the "time" when the IR is valid, but the function
attributes are not.

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

22 months ago[Analysis] Introduce isSoleCallToLocalFunction (NFC)
Kazu Hirata [Sun, 18 Sep 2022 03:59:54 +0000 (20:59 -0700)]
[Analysis] Introduce isSoleCallToLocalFunction (NFC)

We check to see if a given CallBase is a sole call to a local function
at multiple places in InlineCost.cpp.  This patch factors out the
common code.

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

22 months ago[SimplifyCFG] add a test for branch folding multiple BB
Yaxun (Sam) Liu [Tue, 30 Aug 2022 03:03:29 +0000 (23:03 -0400)]
[SimplifyCFG] add a test for branch folding multiple BB

Reviewed by: Florian Hahn

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

22 months ago[GISel] Fix match tree emitter.
Kai Nacke [Sat, 3 Sep 2022 16:04:55 +0000 (16:04 +0000)]
[GISel] Fix match tree emitter.

The following changes are necessasy to get the generated tree
matcher to compile:

- In CodeExpansions::declare(), the assert() prevents connecting
  two instructions. E.g. the match code
    (match (MUL $t, $s1, $s2),
           (SUB $d, $t, $s3)),
  results in two declarations of $t, one for the def and one for
  the use. Removing the assertion allows this construct.
  If $t is later used, it is one of the operands, which should be
  perfectly fine.
- The code emitted in GIMatchTreeVRegDefPartitioner::generatePartitionSelectorCode()
  is not compilable:
  - The value of NewInstrID should be emitted, not the name
  - Both calls involving getOperand() end with one parenthesis too many
- Swaps generated condition for the partition code in the latter function

It also changes the rules i2p_to_p2i, fabs_fabs_fold, and fneg_fneg_fold
to use the tree matcher for a linear match. These rules are tested by:

CodeGen/AArch64/GlobalISel/combine-fabs.mir
CodeGen/AArch64/GlobalISel/combine-fneg.mir
CodeGen/AArch64/GlobalISel/combine-ptrtoint.mir
CodeGen/AMDGPU/GlobalISel/combine-add-nullptr.mir

Reviewed By: arsenm

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

22 months ago[ModuleInliner] Set Changed earlier (NFC)
Kazu Hirata [Sat, 17 Sep 2022 21:16:32 +0000 (14:16 -0700)]
[ModuleInliner] Set Changed earlier (NFC)

It makes more sense to set Changed to true immediately after a
successful inlining.

22 months ago[analyzer] Cleanup some artifacts from non-POD array evaluation
isuckatcs [Sat, 10 Sep 2022 17:04:28 +0000 (19:04 +0200)]
[analyzer] Cleanup some artifacts from non-POD array evaluation

Most of the state traits used for non-POD array evaluation were
only cleaned up if the ctors/dtors were inlined, since the cleanup
happened in ExprEngine::processCallExit(). This patch makes sure
they are removed even if said functions are not inlined.

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

22 months ago[mlir] Don't include SetVector.h (NFC)
Kazu Hirata [Sat, 17 Sep 2022 20:36:16 +0000 (13:36 -0700)]
[mlir] Don't include SetVector.h (NFC)

22 months ago[lld] Don't include SetVector.h (NFC)
Kazu Hirata [Sat, 17 Sep 2022 20:36:15 +0000 (13:36 -0700)]
[lld] Don't include SetVector.h (NFC)

22 months ago[clang] Don't include SetVector.h (NFC)
Kazu Hirata [Sat, 17 Sep 2022 20:36:13 +0000 (13:36 -0700)]
[clang] Don't include SetVector.h (NFC)

22 months ago[gn build] Port e5e3dccd0741
LLVM GN Syncbot [Sat, 17 Sep 2022 19:55:35 +0000 (19:55 +0000)]
[gn build] Port e5e3dccd0741

22 months ago[mlgo] Add in-development instruction based features for regalloc advisor
Aiden Grossman [Sat, 17 Sep 2022 19:27:18 +0000 (19:27 +0000)]
[mlgo] Add in-development instruction based features for regalloc advisor

This patch adds in instruction based features to the regalloc advisor
gated behind a flag so a user can decide at runtime whether or not they
want to enable the feature. The features are only enabled when LLVM is
compiled in MLGO develpment mode (LLVM_HAVE_TF_API) is set to true.

To extract the instruction features, I'm taking a list of segments from
each LiveInterval and noting the start and end SlotIndices. This list is then
sorted based on the start SlotIndex and I iterate through each SlotIndex
to grab instructions, making sure to check for overlaps. This results in
a vector of opcodes and binary mapping matrix that maps live ranges to the
opcodes of the instructions within that LR.

Reviewed By: mtrofin

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

22 months ago[llvm] Don't including SetVector.h (NFC)
Kazu Hirata [Sat, 17 Sep 2022 19:36:43 +0000 (12:36 -0700)]
[llvm] Don't including SetVector.h (NFC)

llvm/lib/ProfileData/RawMemProfReader.cpp uses SetVector without
including SetVector.h, so this patch adds an appropriate #include
there.

22 months ago[Support] Rename llvm::compression::{zlib,zstd}::uncompress to more appropriate decom...
Fangrui Song [Sat, 17 Sep 2022 19:35:17 +0000 (12:35 -0700)]
[Support] Rename llvm::compression::{zlib,zstd}::uncompress to more appropriate decompress

This improves consistency with other places (e.g. llvm::compression::decompress,
llvm::object::Decompressor::decompress, llvm-objcopy).
Note: when zstd::uncompress was added, we noticed that the API `ZSTD_decompress`
is fine while the zlib API `uncompress` is a misnomer.

22 months ago[ModuleInliner] Don't include SetVector.h (NFC)
Kazu Hirata [Sat, 17 Sep 2022 19:17:51 +0000 (12:17 -0700)]
[ModuleInliner] Don't include SetVector.h (NFC)

We don't use SetVector in the module inliner.

22 months ago[ModuleInliner] Remove unnecessary #includes (NFC)
Kazu Hirata [Sat, 17 Sep 2022 19:05:35 +0000 (12:05 -0700)]
[ModuleInliner] Remove unnecessary #includes (NFC)

While I am at it, this patch removes an unnecessary forward
declaration.

22 months ago[ModuleInliner] Move UseInlinePriority to InlineOrder.cpp (NFC)
Kazu Hirata [Sat, 17 Sep 2022 18:41:28 +0000 (11:41 -0700)]
[ModuleInliner] Move UseInlinePriority to InlineOrder.cpp (NFC)

UseInlinePriority specifies the priority function.  This patch
simplifies the code by moving UseInlinePriority closer to the actual
consumer -- the switch statement inside getInlineOrder.

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

22 months ago[AArch64][SME] Add intrinsics for enabling/disabling ZA.
Sander de Smalen [Sat, 17 Sep 2022 16:23:32 +0000 (16:23 +0000)]
[AArch64][SME] Add intrinsics for enabling/disabling ZA.

This adds the intrinsics:
* void @llvm.aarch64.sme.za.enable() -> smstart za
* void @llvm.aarch64.sme.za.disable()  -> smstop za

Reviewed By: aemerson

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

22 months ago[AArch64][SME] Disable tail-call optimization when streaming mode change or lazy...
Sander de Smalen [Sat, 17 Sep 2022 15:38:50 +0000 (15:38 +0000)]
[AArch64][SME] Disable tail-call optimization when streaming mode change or lazy-save may be required.

When a streaming mode change is (or may be) required for a call, it will
need to restore the original mode after the call, which prevents the use of
tail-call optimization. The same holds true for a call that requires the lazy-save
mechanism to be set up before the call, and possibly restored after.

More details about the SME attributes and design can be found
in D131562.

Reviewed By: aemerson

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

22 months ago[libc++][NFC] Inline the string constructors
Nikolas Klauser [Fri, 26 Aug 2022 16:35:25 +0000 (18:35 +0200)]
[libc++][NFC] Inline the string constructors

This removes a lot of boilerplate code.

Reviewed By: ldionne, #libc

Spies: EricWF, libcxx-commits

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

22 months ago[Clang] Support label at end of compound statement
Evgeny Shulgin [Wed, 14 Sep 2022 18:08:34 +0000 (18:08 +0000)]
[Clang] Support label at end of compound statement

Implements paper P2324R2
https://wg21.link/p2324r2
https://github.com/cplusplus/papers/issues/1006

Reviewed By: cor3ntin

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

22 months ago[clang][C++20] Fix clang/clangd assert/crash after compilation errors
Dmitry Polukhin [Thu, 15 Sep 2022 14:39:10 +0000 (07:39 -0700)]
[clang][C++20] Fix clang/clangd assert/crash after compilation errors

After compilation errors, expression a transformation result may not be usable.
It triggers an assert in RemoveNestedImmediateInvocation and SIGSEGV in case of
builds without asserts. This issue significantly affects clangd because source
may not be valid during typing. Tests cases that I attached was reduce from huge
C++ translation unit.

Test Plan: check-clang

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

22 months ago[ConstraintElimination] Fix crash when combining results.
Florian Hahn [Sat, 17 Sep 2022 13:47:38 +0000 (14:47 +0100)]
[ConstraintElimination] Fix crash when combining results.

f213128b292d didn't account for the possibility that the result of
decompose may be empty. Fix that by explicitly checking. Use a newly
introduced helper to also reduce some duplication.

Thanks @bjope for finding the issue!

22 months ago[NFC] Fix a comment in InitializePasses.h
Shivam Gupta [Sat, 17 Sep 2022 13:39:26 +0000 (19:09 +0530)]
[NFC] Fix a comment in InitializePasses.h

22 months agoAdd code examples to the potentially breaking changes
Aaron Ballman [Sat, 17 Sep 2022 12:43:17 +0000 (08:43 -0400)]
Add code examples to the potentially breaking changes

It may help users to better understand the change by showing them a
contrived code example which demonstrates the difference in behavior.

22 months ago[libc++] Add test to ensure that type trait aliases in dependent return types can...
Nikolas Klauser [Fri, 2 Sep 2022 11:38:01 +0000 (13:38 +0200)]
[libc++] Add test to ensure that type trait aliases in dependent return types can be mangled

Reviewed By: ldionne, #libc

Spies: libcxx-commits, jeroen.dobbelaere

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

22 months agoFix release note formatting and style; NFC
Aaron Ballman [Sat, 17 Sep 2022 12:21:33 +0000 (08:21 -0400)]
Fix release note formatting and style; NFC

Uses double backticks where appropriate, changes some instances of
GH12345 to be Issue 12345, etc.

22 months agoFix this test to be more robust
Aaron Ballman [Sat, 17 Sep 2022 12:06:16 +0000 (08:06 -0400)]
Fix this test to be more robust

The test is failing because it lacks a target triple, so the number of
diagnostics differs between Windows and Linux targets.

This should correct the issue found by:
https://lab.llvm.org/buildbot/#/builders/109/builds/46804

22 months agoCorrectly diagnose use of long long literals w/o a suffix
Aaron Ballman [Sat, 17 Sep 2022 11:55:10 +0000 (07:55 -0400)]
Correctly diagnose use of long long literals w/o a suffix

We would diagnose use of `long long` as an extension in C89 and C++98
modes when the user spelled the type `long long` or used the `LL`
literal suffix, but failed to diagnose when the literal had no suffix
but required a `long long` to represent the value.

22 months ago[Bazel] Allow lit_test() macro to be used from other repos.
Christian Sigg [Fri, 16 Sep 2022 20:27:04 +0000 (22:27 +0200)]
[Bazel] Allow lit_test() macro to be used from other repos.

Wrap implicit dependencies in Label() so that they refer to @llvm-project, see https://bazel.build/rules/lib/Label#Label.

This change allows lit_test() to be used from other bazel repositories.

22 months ago[ARM] Add more tests on instructions fusion with comparison with zero; NFC
Filipp Zhinkin [Fri, 16 Sep 2022 18:01:09 +0000 (21:01 +0300)]
[ARM] Add more tests on instructions fusion with comparison with zero; NFC

Baseline tests for D131786

22 months ago[lld-macho] Simplify base address calculation for init offsets (NFC)
Daniel Bertalan [Fri, 16 Sep 2022 16:11:55 +0000 (18:11 +0200)]
[lld-macho] Simplify base address calculation for init offsets (NFC)

22 months ago[NFC} update CodeGenHLSL tests to use cc1 instead of driver-mode
Xiang Li [Sat, 17 Sep 2022 07:11:44 +0000 (00:11 -0700)]
[NFC} update CodeGenHLSL tests to use cc1 instead of driver-mode

22 months ago[mlir] use strided layouts in vector transfer on memrefs
Alex Zinenko [Fri, 16 Sep 2022 14:16:27 +0000 (16:16 +0200)]
[mlir] use strided layouts in vector transfer on memrefs

One of the vector transformation patterns has been indiscriminately
converting layouts to affine maps. Leverage the strided form when
possible.

Reviewed By: nicolasvasilache, dcaballe

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

22 months ago[mlir] use strided layout in structured codegen-related tests
Alex Zinenko [Fri, 16 Sep 2022 13:36:40 +0000 (15:36 +0200)]
[mlir] use strided layout in structured codegen-related tests

All relevant operations have been switched to primarily use the strided
layout, but still support the affine map layout. Update the relevant
tests to use the strided format instead for compatibility with how ops
now print by default.

Reviewed By: nicolasvasilache

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

22 months ago[LLDB][RISCV] Add RVM and RVA instruction support for EmulateInstructionRISCV
Emmmer [Sun, 11 Sep 2022 08:36:12 +0000 (16:36 +0800)]
[LLDB][RISCV] Add RVM and RVA instruction support for EmulateInstructionRISCV

Add:
- RVM and RVA instructions sets.
- corresponding unittests.

Further work:
- implement RVC, RVF, RVD, and RVV extension.

Reviewed By: DavidSpickett

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

22 months agoRevert "[llvm] Remove llvm::is_trivially_{copy/move}_constructible (NFC)"
Kazu Hirata [Sat, 17 Sep 2022 01:26:19 +0000 (18:26 -0700)]
Revert "[llvm] Remove llvm::is_trivially_{copy/move}_constructible (NFC)"

This reverts commit 01ffe31cbb54bfd8e38e71b3cf804a1d67ebf9c1.

A build breakage with GCC 7.3 has been reported:

https://reviews.llvm.org/D132311#3797053

FWIW, GCC 7.5 is OK according to Pavel Chupin.  I also personally
tested GCC 8.4.0.

22 months ago[GlobalISel][DebugInfo] Salvage trivially dead instructions
Vladislav Dzhidzhoev [Fri, 9 Sep 2022 23:15:39 +0000 (02:15 +0300)]
[GlobalISel][DebugInfo] Salvage trivially dead instructions

Use salvageDebugInfo for instructions erased as trivially dead in
GlobalISel.

It would be helpful to implement support of G_PTR_ADD and G_FRAME_INDEX
in salvageDebugInfo in future in order to preserve more variable
location.

Reviewed by: arsenm

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

22 months ago[BOLT][NFC] Remove unreachable assertion
Maksim Panchenko [Fri, 16 Sep 2022 23:45:19 +0000 (16:45 -0700)]
[BOLT][NFC] Remove unreachable assertion

Reviewed By: ayermolo

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

22 months ago[mlir][sparse] add loop simplification to sparsification pass
Aart Bik [Fri, 16 Sep 2022 22:22:48 +0000 (15:22 -0700)]
[mlir][sparse] add loop simplification to sparsification pass

Reviewed By: bixia

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

22 months ago[clang] Fix AST representation of expanded template arguments.
Matheus Izvekov [Sat, 18 Jun 2022 02:21:59 +0000 (04:21 +0200)]
[clang] Fix AST representation of expanded template arguments.

Extend clang's SubstTemplateTypeParm to represent the pack substitution index.

Fixes PR56099.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D128113

22 months ago[mlir][sparse] Only try to compute a better iteraton graph when needed
Peiming Liu [Fri, 16 Sep 2022 18:21:59 +0000 (18:21 +0000)]
[mlir][sparse] Only try to compute a better iteraton graph when needed

Reviewed By: aartbik

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

22 months ago[libc][cmake] separate installing headers
Michael Jones [Thu, 15 Sep 2022 18:24:47 +0000 (11:24 -0700)]
[libc][cmake] separate installing headers

Now libc headers can be installed separately from installing the rest of
the libc.

Reviewed By: sivachandra

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

22 months ago[Inliner] Retire DefaultInlineOrder (NFC)
Kazu Hirata [Fri, 16 Sep 2022 22:36:40 +0000 (15:36 -0700)]
[Inliner] Retire DefaultInlineOrder (NFC)

DefaultInlineOrder was largely an exercise in generalizing the
traversal order of call sites within the inliner.

Now that the module inliner is starting to form its shape, there is no
point in sharing DefaultInlineOrder between the module inliner and the
CGSCC inliner.  DefaultInlineOrder and all the other inline orders are
mutually exclusive in the following sense:

- The use of DefaultInlineOrder doesn't make sense in the module
  inliner because there is no priority inherent in the order in which
  call sites are added to the list of call sites -- SmallVector.

- The use of any other inline order doesn't make sense in the CGSCC
  inliner because little prioritization can be done within one CGSCC.

This patch essentially reverts the addition of DefaultInlineOrder so
that the loop structure of Inliner.cpp looks like the state just
before we started working on the module inliner (circa June 2021).

At the same time, ww remove the choice of DefaultInlineOrder from
UseInlinePriority.

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

22 months ago[mlir][emacs] Enable loading bytecode files as text
Jacques Pienaar [Fri, 16 Sep 2022 22:08:55 +0000 (15:08 -0700)]
[mlir][emacs] Enable loading bytecode files as text

Use auto-compression-mode to read bytecode files in human readable
manner.

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

22 months ago[SLP]Improve isUndefVector function by adding insertelement analysis.
Alexey Bataev [Wed, 14 Sep 2022 19:28:31 +0000 (12:28 -0700)]
[SLP]Improve isUndefVector function by adding insertelement analysis.

Added the mask and the analysis of the buildvector sequence in the
isUndefVector function, improves codegen and cost estimation.

Metric: SLP.NumVectorInstructions

Program                                                                                       SLP.NumVectorInstructions
                                                                          results                   results0 diff
test-suite :: External/SPEC/CFP2017rate/526.blender_r/526.blender_r.test 27362.00                  27360.00 -0.0%

Metric: size..text

Program                                                                                                           size..text
                                                                   results     results0    diff
test-suite :: External/SPEC/CFP2017rate/508.namd_r/508.namd_r.test   805299.00   806035.00  0.1%

526.blender_r - some extra code is vectorized.
508.namd_r - some extra code is optimized out.

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

22 months ago[libc] Add implementation of POSIX "uname" function.
Siva Chandra Reddy [Fri, 16 Sep 2022 19:34:44 +0000 (19:34 +0000)]
[libc] Add implementation of POSIX "uname" function.

Reviewed By: lntue

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

22 months ago[libc][Obvious] Fix typo in struct rlimit name - remove the "_t" suffix.
Siva Chandra Reddy [Fri, 16 Sep 2022 20:54:57 +0000 (20:54 +0000)]
[libc][Obvious] Fix typo in struct rlimit name - remove the "_t" suffix.

22 months ago[HLSL] Enable availability attribute
Chris Bieneman [Fri, 16 Sep 2022 19:42:40 +0000 (14:42 -0500)]
[HLSL] Enable availability attribute

Some HLSL functionality is gated on the target shader model version.
Enabling the use of availability markup allows us to diagnose
availability issues easily in the frontend.

Reviewed By: erichkeane

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

22 months ago[SelectOpti] Restrict load sinking
Sotiris Apostolakis [Fri, 16 Sep 2022 20:34:37 +0000 (20:34 +0000)]
[SelectOpti] Restrict load sinking

This is a follow-up to D133777, which resolved a use-after-free case but
did not cover all possible memory bugs due to misplacement of loads.

In short, the overall problem was that sinked loads could be moved after
state-modifying instructions leading to memory bugs.

The solution is to restrict load sinking unless it is found to be sound.
i) Within a basic block (to-be-sinked load and select-user are in the same BB),
loads can be sinked only if there is no intervening state-modifying instruction.
This is a conservative approach to avoid resorting to alias analysis to detect
potential memory overlap.
ii) Across basic blocks, sinking of loads is avoided. This is because going over
multiple basic blocks looking for memory conflicts could be computationally
expensive and also unlikely to allow loads to sink. Further, experiments showed
that not sinking these loads has a slight positive performance effect.
Maybe for some of these loads, having some separation allows enough time
for the load to be executed in time for its user. This is not the case for
floating point operations that benefit more from sinking.

The solution in D133777 was essentially undone in this patch,
since the latter is a complete solution to the observed problem.

Overall, the performance impact of this patch is minimal.
Tested on two internal Google workloads with instrPGO.
Search application showed <0.05% perf difference,
while the database one showed a slight improvement,
but not statistically significant.

Reviewed By: davidxl

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

22 months ago[libc] Add implementation of POSIX setrlimit and getrlimit functions.
Siva Chandra Reddy [Thu, 15 Sep 2022 22:22:59 +0000 (22:22 +0000)]
[libc] Add implementation of POSIX setrlimit and getrlimit functions.

Reviewed By: lntue

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