platform/upstream/llvm.git
2 years ago[CostModel][X86] Convert AVX1/SSE41 SREM/SDIV by constants to cost tables
Simon Pilgrim [Fri, 26 Aug 2022 13:51:43 +0000 (14:51 +0100)]
[CostModel][X86] Convert AVX1/SSE41 SREM/SDIV by constants to cost tables

When adding cost kind support it will be easier to maintain these if we're not calculating on the fly

2 years ago[CostModel][SVE] Correct cost model of SK_Splice shuffles for <vscale x 1 x Ty> vecto...
Paul Walker [Fri, 26 Aug 2022 13:32:46 +0000 (14:32 +0100)]
[CostModel][SVE] Correct cost model of SK_Splice shuffles for <vscale x 1 x Ty> vector types.

AArch64TTIImpl::getSpliceCost() is now used more aggressively and
LNT (MultiSource/Benchmarks/mafft) exposed a failure case for
<vscale x 1 x i1>. I've tested other element types and whilst they
can be costed they cannot be code generated, so this patch returns
InstructionCost::getInvalid() for all cases.

2 years ago[LV] Convert runtime diff check test to use opaque pointers.
Florian Hahn [Fri, 26 Aug 2022 15:02:38 +0000 (16:02 +0100)]
[LV] Convert runtime diff check test to use opaque pointers.

Modernize the test to make it easier to extend with up-to-date IR.

2 years ago[mlir][tensor] Remove folding of tensor.extract_slice during tiling
Thomas Raoux [Thu, 25 Aug 2022 15:27:40 +0000 (15:27 +0000)]
[mlir][tensor] Remove folding of tensor.extract_slice during tiling

Blindly folding tensor.extract_slice makes the bufferization
transformation harder. This kind of transformation should happen
separatley if needed rather than doing it within makeShape that is
called during tiling.
Also removed makeComposedExtractSliceOp as it is not tested outside of
this code.

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

2 years ago[CSKY] Fix warnings on the use of deprecated methods. NFC.
Michael Liao [Fri, 26 Aug 2022 14:21:52 +0000 (10:21 -0400)]
[CSKY] Fix warnings on the use of deprecated methods. NFC.

2 years ago[flang] Adding a guideline for flang design documentation
Jean Perier [Fri, 26 Aug 2022 14:11:49 +0000 (16:11 +0200)]
[flang] Adding a guideline for flang design documentation

The goal of this document is to:
- Allow the community to contribute to flang design by defining the
  expectations.
- Ensure there is a minimum of consistency between future design docs.

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

2 years ago[LCSSA] Skip updating users in unreachable blocks.
Florian Hahn [Fri, 26 Aug 2022 14:09:46 +0000 (15:09 +0100)]
[LCSSA] Skip updating users in unreachable blocks.

Don't waste time trying to update users in unreachable blocks.

2 years agoFix the Sphinx build bot
Aaron Ballman [Fri, 26 Aug 2022 14:04:06 +0000 (10:04 -0400)]
Fix the Sphinx build bot

This addresses an accidental break from
41667a8b9b624e282e7c08fadf7091223728d1c1

2 years ago[Basic] Drop header-only dependency from Basic to Lex
Benjamin Kramer [Fri, 26 Aug 2022 14:02:34 +0000 (16:02 +0200)]
[Basic] Drop header-only dependency from Basic to Lex

It's still a bit weird for IdentifierTable to depend on Lex diagnostics,
but we can get away with including the enum info that's in Basic already.

2 years ago[TTI] NFC: Reduce InstructionCost::getValue() usage...
Daniil Fukalov [Wed, 17 Aug 2022 23:34:22 +0000 (02:34 +0300)]
[TTI] NFC: Reduce InstructionCost::getValue() usage...

in order to propagate `InstructionCost` value upper.

Reviewed By: fhahn

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

2 years ago[SLP][NFC]Add a test for incorrectly calculated cost for extracted
Alexey Bataev [Fri, 26 Aug 2022 13:28:38 +0000 (06:28 -0700)]
[SLP][NFC]Add a test for incorrectly calculated cost for extracted
buildvector sequence, NFC.

2 years ago[X86] Add SimplifyMultipleUseDemandedBitsForTargetNode X86ISD::ANDNP handling
Simon Pilgrim [Fri, 26 Aug 2022 13:23:31 +0000 (14:23 +0100)]
[X86] Add SimplifyMultipleUseDemandedBitsForTargetNode X86ISD::ANDNP handling

See if we can remove X86ISD::ANDNP nodes by checking the state of the knownbits of the demanded elements.

This is equivalent to the generic ISD::AND handling, but flips the bits of the LHS operand to account for ANDNP.

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

2 years ago[CostModel][X86] getArithmeticInstrCost - use cost kind specific look up tables
Simon Pilgrim [Fri, 26 Aug 2022 13:13:24 +0000 (14:13 +0100)]
[CostModel][X86] getArithmeticInstrCost - use cost kind specific look up tables

Building on D132216, use CostKindTblEntry cost tables to simplify the transition to supporting cost kinds other than recip-throughput

Adding full cost kinds support is going to take a while, but by converting to CostKindTblEntry first it will make it easier to support the costs on a per-ISD basis.

2 years ago[lldb] Make CommunicationTest compatible with windows
Pavel Labath [Wed, 24 Aug 2022 13:59:46 +0000 (15:59 +0200)]
[lldb] Make CommunicationTest compatible with windows

Our (TCP) socket support is in a much better state than pipes. Use that
for testing the Communication class.

Move the CreateTCPConnectedSockets function
(SocketTestUtilities.{h,cpp}) to a place where it can be used from
Communication tests.

2 years agoDiagnosing the Future Keywords
Muhammad Usman Shahid [Fri, 26 Aug 2022 13:17:14 +0000 (09:17 -0400)]
Diagnosing the Future Keywords

The patch diagnoses an identifier as a future keyword if it exists in a
future language mode, such as:

int restrict;

in C modes earlier than C99. We now give a warning to the user that
such an identifier is a future keyword. Handles keywords from C as well
as C++.

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

2 years ago[Coro][Debuginfo] Add debug info to `__NoopCoro_ResumeDestroy` function
Adrian Vogelsgesang [Wed, 24 Aug 2022 17:27:23 +0000 (10:27 -0700)]
[Coro][Debuginfo] Add debug info to `__NoopCoro_ResumeDestroy` function

With this commit, we now attach an `DISubprogram` to the LLVM-generated
`_NoopCoro_ResumeDestroy` function. Thereby, lldb can show a
`std::coroutine_handle` to a `std::noop_coroutine` as

```
continuation = coro frame = 0x555555560d98 {
  resume = 0x0000555555555c50 (a.out`__NoopCoro_ResumeDestroy)
  destroy = 0x0000555555555c50 (a.out`__NoopCoro_ResumeDestroy)
}
```

instead of

```
continuation = coro frame = 0x555555560d98 {
  resume = 0x0000555555555c50 (a.out`___lldb_unnamed_symbol211)
  destroy = 0x0000555555555c50 (a.out`___lldb_unnamed_symbol211)
}
```

I renamed the function from `NoopCoro.ResumeDestroy` to
`_NoopCoro_ResumeDestroy` because:
* the leading `_` makes sure this is a reserved name and should not
  clash with any user-provided names
* the `.` was replaced by a `_`, so the name is now a valid identifier
  in C, making it allows me to type its name in the debugger

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

2 years agoTypo fix in Release notes.
Utkarsh Saxena [Fri, 26 Aug 2022 12:34:55 +0000 (14:34 +0200)]
Typo fix in Release notes.

2 years ago[dsymutil][DWARFv5] fix DW_FORM_addrx attribute offset calculation.
Alexey Lapshin [Wed, 24 Aug 2022 21:36:13 +0000 (00:36 +0300)]
[dsymutil][DWARFv5] fix DW_FORM_addrx attribute offset calculation.

DWARFLinker::DIECloner::cloneAddressAttribute() contains call to
relocateIndexedAddr(StartOffset, EndOffset). StartOffset is
incorrectly calculated. Val.getRawUValue() is an index into the
.debug_addr table, so it should be multiplied
by Unit.getOrigUnit().getAddressByteSize().

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

2 years ago[ADT] GCC 7 doesn't have constexpr char_traits, add a workaround
Benjamin Kramer [Fri, 26 Aug 2022 12:11:21 +0000 (14:11 +0200)]
[ADT] GCC 7 doesn't have constexpr char_traits, add a workaround

LLVM still supports GCC 7. This workaround can be removed when GCC 8
becomes the oldest supported GCC version.

Fixes #57057

2 years ago[lldb] Skip TestCoroutineHandle.py on libstdc++<11
Pavel Labath [Fri, 26 Aug 2022 12:03:27 +0000 (14:03 +0200)]
[lldb] Skip TestCoroutineHandle.py on libstdc++<11

2 years ago[gn build] Port 56c54cf66bcd
LLVM GN Syncbot [Fri, 26 Aug 2022 11:23:06 +0000 (11:23 +0000)]
[gn build] Port 56c54cf66bcd

2 years ago[gn build] Port 3e39b2710168
LLVM GN Syncbot [Fri, 26 Aug 2022 11:23:05 +0000 (11:23 +0000)]
[gn build] Port 3e39b2710168

2 years ago[gn build] port bb26ebb4d18c
Nico Weber [Fri, 26 Aug 2022 11:22:35 +0000 (07:22 -0400)]
[gn build] port bb26ebb4d18c

2 years ago[pseudo] Placeholder disambiguation strategy: always choose second
Sam McCall [Tue, 23 Aug 2022 13:54:48 +0000 (15:54 +0200)]
[pseudo] Placeholder disambiguation strategy: always choose second

Mostly mechanics here. Interesting decisions:
 - apply disambiguation in-place instead of copying the forest
   debatable, but even the final tree size is significant
 - split decide/apply into different functions - this allows the hard part
   (decide) to be tested non-destructively and combined with HTML forest easily
 - add non-const accessors to forest to enable apply
 - unit tests but no lit tests: my plan is to test actual C++ disambiguation
   heuristics with lit, generic disambiguation mechanics without the C++ grammar

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

2 years agoRevert "Clang: fix AST representation of expanded template arguments."
Matheus Izvekov [Fri, 26 Aug 2022 11:09:55 +0000 (13:09 +0200)]
Revert "Clang: fix AST representation of expanded template arguments."

This reverts commit 1d1a56929b725f9a79d98877f12d0a14f8418b38.

2 years ago[llvm/CodeGen] Add ExpandLargeDivRem pass
Matthias Gehre [Wed, 25 May 2022 11:19:28 +0000 (12:19 +0100)]
[llvm/CodeGen] Add ExpandLargeDivRem pass

Adds a pass ExpandLargeDivRem to expand div/rem instructions
with more than 128 bits into a loop computing that value.

As discussed on https://reviews.llvm.org/D120327, this approach has the advantage
that it is independent of the runtime library. This also helps the clang driver,
which otherwise would need to understand enough about the runtime library
to know whether to allow _BitInts with more than 128 bits.

Targets are still free to disable this pass and instead provide a faster
implementation in a runtime library.

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

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

2 years ago[lldb] Fix dotest argument order
Felipe de Azevedo Piovezan [Tue, 23 Aug 2022 15:11:06 +0000 (11:11 -0400)]
[lldb] Fix dotest argument order

When running LLDB API tests, a user can override test arguments with
LLDB_TEST_USER_ARGS. However, these flags used to be concatenated with a
CMake-derived variable LLDB_TEST_COMMON_ARGS, as below:

```
set(LLDB_DOTEST_ARGS ${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS}
    CACHE INTERNAL STRING)
```

This is problematic, because LLDB_TEST_COMMON_ARGS must be processed
first, while LLDB_TEST_USER_ARGS args must be processed last, so that
user overrides are respected. Currently, if a user attempts to override
one of the "inferred" flags, the user's request is ignored. This is the
case, for example, with `--libcxx-include-dir` and
`--libcxx-library-dir`. Both flags are needed by the greendragon bots.

This commit removes the concatenation above, keeping the two original
variables throughout the entire flow, processing the user's flag last.

The variable LLDB_TEST_COMMON_ARGS needs to be a CACHE property, but it
is modified throughout the CMake file with `set` or `list` or `string`
commands, which don't work with properties. As such, a temporary
variable `LLDB_TEST_COMMON_ARGS_VAR` is created.

This was tested locally by invoking CMake with:
-DLLDB_TEST_USER_ARGS="--libcxx-include-dir=blah --libcxx-library-dir=blah2"
and checking that tests failed appropriately.

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

2 years ago[DAG] Strip poison generating flags in freeze(op()) -> op(freeze()) fold
Simon Pilgrim [Fri, 26 Aug 2022 10:47:44 +0000 (11:47 +0100)]
[DAG] Strip poison generating flags in freeze(op()) -> op(freeze()) fold

This patch follows the InstCombine approach of stripping poison generating flags (nsw/nuw from add/sub etc.) to allow us to push a freeze() through the op. Unlike InstCombine it doesn't retain any flags, but we have plenty of DAG folds that do the same thing already. We assert that the newly generated op isGuaranteedNotToBeUndefOrPoison.

Similar to the ValueTracking approach, isGuaranteedNotToBeUndefOrPoison has been updated to confirm that if an op can't create undef/poison and its operands are guaranteed not to be undef/poison - then its not undef/poison. This is just for the generic opcodes - target specific opcodes will need to do this manually just in case they have some special cases.

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

2 years agoRevert "[Pipelines] Introduce DAE after ArgumentPromotion"
Pavel Samolysov [Fri, 26 Aug 2022 10:21:29 +0000 (13:21 +0300)]
Revert "[Pipelines] Introduce DAE after ArgumentPromotion"

The commit breaks the compiler when a function is used as a function
parameter (hm... for a function from the standard C library?):

```
static float strtof(char *, char *) {}
void a() { strtof(a, 0); }
```

This reverts commit 879f5118fc74657e4a5c4eff6810098e1eed75ac.

2 years ago[mlir][Vector] Support 0-D vectors in TransposeOp
Nicolas Vasilache [Fri, 26 Aug 2022 10:34:39 +0000 (03:34 -0700)]
[mlir][Vector] Support 0-D vectors in TransposeOp

Co-authored-by: Michal Terepeta <michalt@google.com>
Reviewed-by: ftynse
Differential Revision: https://reviews.llvm.org/D115743

2 years ago[CostModel][X86] getTypeBasedIntrinsicInstrCost - adjustTableCost - split CostTblEntr...
Simon Pilgrim [Fri, 26 Aug 2022 10:16:57 +0000 (11:16 +0100)]
[CostModel][X86] getTypeBasedIntrinsicInstrCost - adjustTableCost - split CostTblEntry into ISD/Cost pair. NFC

This will be necessary to allow us to reuse this for other cost kind types

2 years ago[SVE] Lower fixed-length floating point loads and stores to integer variants.
Paul Walker [Fri, 19 Aug 2022 17:51:02 +0000 (18:51 +0100)]
[SVE] Lower fixed-length floating point loads and stores to integer variants.

There's no advatange to emitting floating point scalable accesses,
whereas by lowering them to integer variants we can benefit from
several combines that seek to replace explicit extends/truncates
with extending/truncating accesses.

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

2 years ago[flang] Remove obsolete TODO
Daniil Dudkin [Fri, 26 Aug 2022 10:00:06 +0000 (13:00 +0300)]
[flang] Remove obsolete TODO

As the comment tells, the TODO was added because
there was no conversion for abstract results in function types inside GlobalOps.
Since the conversion was added, this TODO is obsolete, so it is removed.

Reviewed By: jeanPerier

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

2 years ago[LAA] Rename printing pass to print<access-info>.
Florian Hahn [Fri, 26 Aug 2022 10:00:08 +0000 (11:00 +0100)]
[LAA] Rename printing pass to print<access-info>.

This updates the naming for the LAA printing pass to be in line with
most other analysis printing passes.

The old name has come up as confusing multiple times already, e.g. in
D131924.

2 years agoRevert "[SelectionDAG] Emit calls to __divei4 and friends for division/remainder...
Matthias Gehre [Wed, 25 May 2022 15:00:54 +0000 (16:00 +0100)]
Revert "[SelectionDAG] Emit calls to __divei4 and friends for division/remainder of large integers"

This reverts https://reviews.llvm.org/D120329.
I abandoned the PR [0] to add __divei4 functions to compiler-rt
in favor of adding a pass to transform div/rem [1].

This removes the backend code that was supposed to emit calls to the __divei4 functions.

[0] https://reviews.llvm.org/D120327
[1] https://reviews.llvm.org/D130076

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

2 years ago[LoongArch] Port over minimal applyFixup from RISCV
WANG Xuerui [Fri, 26 Aug 2022 04:12:26 +0000 (12:12 +0800)]
[LoongArch] Port over minimal applyFixup from RISCV

Many DebugInfo tests now pass with native builds.

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

2 years ago[ARM] Use getSymbolPreferLocal() in GetARMGVSymbol
Alex Richardson [Thu, 25 Aug 2022 12:34:12 +0000 (12:34 +0000)]
[ARM] Use getSymbolPreferLocal() in GetARMGVSymbol

This allows relaxing some relocations to symbol+offset instead of emitting
a relocation against a symbol.

Reviewed By: MaskRay

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

2 years agoMark the $local function begin symbol as a function
Alex Richardson [Thu, 25 Aug 2022 12:15:47 +0000 (12:15 +0000)]
Mark the $local function begin symbol as a function

While this does not matter for most targets, when building for Arm Morello,
we have to mark the symbol as a function and add size information, so that
LLD can correctly evaluate relocations against the local symbol.
Since Morello is an out-of-tree target, I tried to reproduce this with
in-tree backends and with the previous reviews applied this results in
a noticeable difference when targeting Thumb.

Background: Morello uses a method similar Thumb where the encoding mode is
specified in the LSB of the symbol. If we don't mark the target as a
function, the relocation will not have the LSB set and calls will end up
using the wrong encoding mode (which will almost certainly crash).

Reviewed By: MaskRay

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

2 years ago[lldb][Test] Add missing breakpoint in TestNamespaceLookup.py
Michael Buch [Fri, 26 Aug 2022 09:28:28 +0000 (10:28 +0100)]
[lldb][Test] Add missing breakpoint in TestNamespaceLookup.py

2 years ago[lldb][ClangExpression] Fix LLDB_LOG incorrect format specifier
Michael Buch [Thu, 25 Aug 2022 22:41:47 +0000 (23:41 +0100)]
[lldb][ClangExpression] Fix LLDB_LOG incorrect format specifier

Previously this would log:
```
 FindExternalLexicalDecls on (ASTContext*)0x00000005CE825200 'Expression
ASTContext for '<user expression 0>'' in 'weak_ptr'
(%sDecl*)ClassTemplateSpecialization
 FindExternalLexicalDecls on (ASTContext*)0x00000005CE825200 'Expression
ASTContext for '<user expression 0>'' in '__shared_count'
(%sDecl*)CXXRecord
```

Note that the `%s` isn't actually respected. This patch fixes this
by providing the format specifiers that `lldb::formatv` supports.

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

2 years agoRevert "ManagedStatic: remove from DebugCounter"
Nicolai Hähnle [Fri, 26 Aug 2022 09:02:00 +0000 (11:02 +0200)]
Revert "ManagedStatic: remove from DebugCounter"

This reverts commit b5b6ef1500af29b6aba71330d8aaf82ecccb1f37.

2 years agoPotentiallyEvaluatedContext in a ImmediateFunctionContext.
Utkarsh Saxena [Thu, 25 Aug 2022 14:05:50 +0000 (16:05 +0200)]
PotentiallyEvaluatedContext in a ImmediateFunctionContext.

Body of `consteval` should be in an `ImmediateFunctionContext` instead of `ConstantEvaluated`.
PotentiallyEvaluated expressions in Immediate functions are in a `ImmediateFunctionContext` as well.

Fixes https://github.com/llvm/llvm-project/issues/51182
Original divergence: https://godbolt.org/z/vadGT5j6f

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

2 years ago[SimplifyCFG] Don't widen cond br if false branch has successors
Dmitry Makogon [Mon, 22 Aug 2022 08:06:57 +0000 (15:06 +0700)]
[SimplifyCFG] Don't widen cond br if false branch has successors

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

This limits the tryWidenCondBranchToCondBranch transform making it
work only if the false block of widenable condition branch
has no successors.

If that block has successors, then SimplifyCondBranchToCondBranch
may undo the transform done by tryWidenCondBranchToCondBranch, which
would lead to infinite cycle of transformation and eventually
an assert failing.

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

2 years ago[compiler-rt][hwasan] Support for Intel LAM v6 API
Alexander Potapenko [Wed, 24 Aug 2022 09:58:59 +0000 (11:58 +0200)]
[compiler-rt][hwasan] Support for Intel LAM v6 API

Version 6 of Intel LAM kernel patches
(https://lore.kernel.org/all/20220815041803.17954-1-kirill.shutemov@linux.intel.com/)
introduces arch_prctl(ARCH_GET_MAX_TAG_BITS), which (unlike
ARCH_GET_UNTAG_MASK) can be used to determine if the kernel really
supports pointer tagging. arch_prctl(ARCH_GET_UNTAG_MASK) will be used to
verify that HWASan can place tags in the given bit range.

Depends on D132545

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

2 years ago[clang] NFC. Small tweak to release notes
Ilya Biryukov [Fri, 26 Aug 2022 08:17:44 +0000 (10:17 +0200)]
[clang] NFC. Small tweak to release notes

Forgotten in the last patch.

2 years ago[clang] Add cxx scope if needed for requires clause.
Luke Nihlen [Fri, 26 Aug 2022 07:52:06 +0000 (09:52 +0200)]
[clang] Add cxx scope if needed for requires clause.

Fixes issue #55216.

Patch by Luke Nihlen! (luken@google.com, luken-google@)

Reviewed By: #clang-language-wg, aaron.ballman

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

2 years agoManagedStatic: remove from DebugCounter
Nicolai Hähnle [Mon, 4 Jul 2022 10:52:08 +0000 (12:52 +0200)]
ManagedStatic: remove from DebugCounter

Follow the pattern used in MLIR for the cl::opt instances.

v2:
- make DebugCounter::isCountingEnabled public so that the
  DebugCounterOwner doesn't have to be a nested class. This simplifies
  later changes

v3:
- remove the indirection via DebugCounterOwner::instance()

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

2 years ago[mlir][Bazel] Fix wrong dependency to //llvm:Support
Adrian Kuegel [Fri, 26 Aug 2022 07:06:40 +0000 (09:06 +0200)]
[mlir][Bazel] Fix wrong dependency to //llvm:Support

2 years ago[mlir][Bazel] Fix bazel build.
Adrian Kuegel [Fri, 26 Aug 2022 07:04:50 +0000 (09:04 +0200)]
[mlir][Bazel] Fix bazel build.

2 years ago[NFC][M68k][test] Fix incorrect use of `getelementptr`
Sheng [Fri, 26 Aug 2022 06:42:15 +0000 (14:42 +0800)]
[NFC][M68k][test] Fix incorrect use of `getelementptr`

Reviewers: RKSimon

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

2 years ago[RISCV] Generate correct ELF abi flag when empty .ll file has target-abi attribute
Yunze Zhu [Fri, 26 Aug 2022 06:05:15 +0000 (14:05 +0800)]
[RISCV] Generate correct ELF abi flag when empty .ll file has target-abi attribute

In patch D121183, target abi is get from .ll file's target-abi
attribute and set in RISCVAsmPrinter::emitFunctionEntryLabel
function. In https://github.com/llvm/llvm-project/issues/57242,
an api mismatch error may be caused by failing to call function
RISCVAsmPrinter::emitFunctionEntryLabel to set target-abi to
correct one when the .ll is empty or a module has no function.

This patch move setting target-abi part to function
RISCVAsmPrinter::emitStartOfAsmFile, make sure all .ll file and
module in LTO read target-abi from module flag and set, with or
without function.

Signed-off-by: xiaojing.zhang <xiaojing.zhang@xcalibyte.com>
Signed-off-by: jianxin.lai <jianxin.lai@xcalibyte.com>
Reviewed By: luismarques

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

2 years ago[RISCV] : Add support for simm10_lsb0000nonzero operand.
LiaoChunyu [Fri, 26 Aug 2022 06:18:53 +0000 (14:18 +0800)]
[RISCV] : Add support for simm10_lsb0000nonzero operand.

Running on RISCV machine llvm-exegesis I faced with trouble: can't measure C_ADDI16SP, beacuse immediate has type simm10_lsb0000nonzero.

Patch adds support for processing this immediate operand type.

Reviewed By: craig.topper

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

2 years ago[Coroutines] Store the index for final suspend point if there is unwind coro end
Chuanqi Xu [Fri, 26 Aug 2022 05:49:00 +0000 (13:49 +0800)]
[Coroutines] Store the index for final suspend point if there is unwind coro end

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

The root cause for this issue is an pre-mature optimization to eliminate
the index for the final suspend point since we feel like we can judge
if a coroutine is suspended at the final suspend by if resume_fn_addr is
null. However this is not true if the coroutine exists via an exception
in promise.unhandled_exception(). According to
[dcl.fct.def.coroutine]p14:

> If the evaluation of the expression promise.unhandled_exception()
> exits via an exception, the coroutine is considered suspended at the
> final suspend point.

But from the perspective of the implementation, we can't set the coro
index to the final suspend point directly since it breaks the states.

To fix the issue, we block the optimization if we find there is any
unwind coro end, which indicates that it is possible that the coroutine
exists via an exception from promise.unhandled_exception().

Test Plan: folly

2 years ago[clang-format][NFC] Call eof() and isEOF() in UnwrappedLineParser
owenca [Fri, 26 Aug 2022 04:57:40 +0000 (21:57 -0700)]
[clang-format][NFC] Call eof() and isEOF() in UnwrappedLineParser

2 years ago[Object] Support LoongArch in RelocationResolver
WANG Xuerui [Fri, 26 Aug 2022 03:42:17 +0000 (11:42 +0800)]
[Object] Support LoongArch in RelocationResolver

Similar to the RISCV logic added in D62062.

With this patch applied, llvm-dwarfdump works on existing LoongArch
object files, but generation of debuginfo on LoongArch is still pending
on proper support for relocations, so no test cases this time. They will
come later.

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

2 years ago[LoongArch] Support register-register-addressed FPR load and store
gonglingqin [Fri, 26 Aug 2022 02:14:30 +0000 (10:14 +0800)]
[LoongArch] Support register-register-addressed FPR load and store

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

2 years ago[mlir][math] Added math::IPowI conversion to calls of outlined implementations.
Slava Zakharin [Tue, 12 Jul 2022 23:07:38 +0000 (16:07 -0700)]
[mlir][math] Added math::IPowI conversion to calls of outlined implementations.

Power functions are implemented as linkonce_odr scalar functions
for integer types used by IPowI operations met in a module.
Vector form of IPowI is linearized into a sequence of calls
of the scalar functions.

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

2 years ago[libc++][test] Use TEST_HAS_NO_CHAR8_T to simplify #ifdefs. NFCI.
Joe Loser [Thu, 25 Aug 2022 00:50:28 +0000 (18:50 -0600)]
[libc++][test] Use TEST_HAS_NO_CHAR8_T to simplify #ifdefs. NFCI.

Many tests in `libcxx/test/std/strings` use
`#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L`
which can be replaced with the more terse `#ifndef TEST_HAS_NO_CHAR8_T`.

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

2 years ago[ADT] Make `llvm::identity` a transparent function object
Joe Loser [Thu, 25 Aug 2022 01:31:15 +0000 (19:31 -0600)]
[ADT] Make `llvm::identity` a transparent function object

`llvm::identity` is similar to `std::identity` from C++20, but one surprising
thing is that `llvm::identity` is not a transparent function object. Add the
`is_transparent` type alias to denote it can be used as a transparent function
object.

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

2 years ago[RISCV][NFC] Use common prefix to simplify test.
jacquesguan [Thu, 25 Aug 2022 08:43:43 +0000 (16:43 +0800)]
[RISCV][NFC] Use common prefix to simplify test.

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

2 years ago[Driver][test] Replace legacy -target with --target=
Fangrui Song [Fri, 26 Aug 2022 02:30:21 +0000 (19:30 -0700)]
[Driver][test] Replace legacy -target with --target=

2 years ago[lldb][test] Fix nullptr test expctation for 32-bit system
Adrian Vogelsgesang [Thu, 25 Aug 2022 23:29:06 +0000 (16:29 -0700)]
[lldb][test] Fix nullptr test expctation for 32-bit system

Follow-up to https://reviews.llvm.org/D132415

Fixes https://lab.llvm.org/buildbot/#/builders/17/builds/26630

2 years ago[BOLT][DWARF] Fix updating CU that has no entry in .debug_addr
Alexander Yermolovich [Fri, 26 Aug 2022 00:01:41 +0000 (17:01 -0700)]
[BOLT][DWARF] Fix updating CU that has no entry in .debug_addr

We were trying to process .debug_addr for CU that doesn't have it. This resulted
in assert. Example came from GCC that also doesn't use DW_OP_addrx in
DW_FORM_exprloc.

Reviewed By: maksfb

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

2 years ago[HLSL] Add abs library function
Chris Bieneman [Thu, 25 Aug 2022 23:25:20 +0000 (18:25 -0500)]
[HLSL] Add abs library function

This change exposes the abs library function for HLSL scalar types. Abs
is supported for all scalar, vector and matrix types. This patch only
adds a subset of scalar type support.

Fixes #57100 (https://llvm.org/pr57100)

The full documentation of the HLSL abs function is available here:
https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-abs

Reviewed By: bogner

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

2 years ago[flang] Fold DOT_PRODUCT()
Peter Klausler [Thu, 28 Oct 2021 16:37:43 +0000 (09:37 -0700)]
[flang] Fold DOT_PRODUCT()

Implement constant folding of the intrinsic function DOT_PRODUCT().

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

2 years ago[lldb] Computer the slide when and apply it to each fileset's vm addr
Jonas Devlieghere [Thu, 25 Aug 2022 23:36:16 +0000 (16:36 -0700)]
[lldb] Computer the slide when and apply it to each fileset's vm addr

Computer the slide when and apply it to each entry's vm addr when
reading from memory.

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

2 years ago[AArch64] Filter out invalid code model in frontend.
Hsiangkai Wang [Wed, 24 Aug 2022 08:25:32 +0000 (08:25 +0000)]
[AArch64] Filter out invalid code model in frontend.

AArch64 only supports tiny, small, and large code model. Show error
messages when users specify other code model.

Fix https://github.com/llvm/llvm-project/issues/53402

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

2 years ago[flang] Allow NULL() actual argument for procedure pointer dummy argument with unspec...
Peter Klausler [Thu, 25 Aug 2022 17:27:32 +0000 (10:27 -0700)]
[flang] Allow NULL() actual argument for procedure pointer dummy argument with unspecified intent

A NULL() pointer is a valid actual argument for a procedure pointer dummy
argument whose intent is INTENT(IN); it should also be acceptable for a
procedure pointer dummy argument with unspecified intent.

Also make it possible to discern null object pointers from null procedure
pointers, so that an attempt to use one in place of the other in a context
where the distinction matters will still elicit an error.

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

2 years ago[SLP][NFC] Add a coverage test for horizontal reductions.
Valery N Dmitriev [Thu, 25 Aug 2022 23:02:22 +0000 (16:02 -0700)]
[SLP][NFC] Add a coverage test for horizontal reductions.

Reduction feeds single insertelement instruction.

2 years ago[flang] Fix module file issue with renamed shadowed specific procedures
Peter Klausler [Tue, 23 Aug 2022 21:31:18 +0000 (14:31 -0700)]
[flang] Fix module file issue with renamed shadowed specific procedures

A specific procedure in the list of specific procedures associated with
a generic interface needs to be a symbol that is not inadvertently
resolved to its ultimate symbol in another module when it is also
shadowed by a generic interface of the same name.

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

2 years ago[flang] Make C_F_POINTER a generic interface
Peter Klausler [Thu, 25 Aug 2022 17:24:53 +0000 (10:24 -0700)]
[flang] Make C_F_POINTER a generic interface

The intrinsic procedure C_F_POINTER needs to be a generic interface
in intrinsic module ISO_C_BINDING.  (It also needs to be implemented,
but that remains a TODO for either lowering or the runtime.)

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

2 years ago[gn build] Port 48506fbbbf27
LLVM GN Syncbot [Thu, 25 Aug 2022 22:25:21 +0000 (22:25 +0000)]
[gn build] Port 48506fbbbf27

2 years ago[lldb] Teach LLDB about Mach-O filesets
Jonas Devlieghere [Thu, 25 Aug 2022 22:11:32 +0000 (15:11 -0700)]
[lldb] Teach LLDB about Mach-O filesets

This patch teaches LLDB about Mach-O filesets. Filsets are Mach-O files
that contain a bunch of other Mach-O files. Unlike universal binaries,
which have a different header, Filesets use load commands to describe
the different entries it contains.

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

2 years ago[flang] Allow non-definable actual arguments to volatile/asynchronous dummy arguments
Peter Klausler [Thu, 25 Aug 2022 17:23:19 +0000 (10:23 -0700)]
[flang] Allow non-definable actual arguments to volatile/asynchronous dummy arguments

Semantic checking for calls was requiring an actual argument that corresponds
to an ASYNCHRONOUS or VOLATILE dummy argument to be definable, but this is not
a constraint or requirement in the standard and doesn't even make sense
as a warning; these two attributes are "scopable" in the context of BLOCK
constructs.   Remove the checks and adjust the tests.

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

2 years ago[flang] Emit missing IMPORTs in module file interfaces
Peter Klausler [Thu, 25 Aug 2022 17:22:10 +0000 (10:22 -0700)]
[flang] Emit missing IMPORTs in module file interfaces

When a symbol from the enclosing scope is necessary to declare
a procedure or procedure pointer dummy argument or function result
for a procedure interface, note it in the collection of symbols to
be imported when scanning that interface.

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

2 years ago[flang] Accept unambiguous USE name clashes
Peter Klausler [Thu, 25 Aug 2022 17:20:41 +0000 (10:20 -0700)]
[flang] Accept unambiguous USE name clashes

When, due to one or more USE associations, possibly with renaming,
a symbol conflicts with another of the same name in the same scope,
don't raise an error if both symbols resolve to the same intrinsic
procedure or to the same non-generic external procedure interface --
the usage is unambiguous and safe, and (14.2.2 p8) standard.

(Generic interfaces already work by way of combining their sets of
specific procedures.)

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

2 years ago[flang] Allow a construct entity as a concurrent-header index
Peter Klausler [Thu, 25 Aug 2022 17:19:20 +0000 (10:19 -0700)]
[flang] Allow a construct entity as a concurrent-header index

A construct entity of an ASSOCIATE or SELECT TYPE construct
should be acceptable as an index variable of a concurrent-header in
a FORALL or DO CONCURRENT, so long as it also satisfies other
requirements.

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

2 years ago[flang] Add nested scoping to label distinctness checking
Peter Klausler [Thu, 25 Aug 2022 17:17:25 +0000 (10:17 -0700)]
[flang] Add nested scoping to label distinctness checking

Fortran defines derived type definitions and explicit interface
blocks for subroutines and functions to be nestable scopes for
statement labels, even though such labels are useless for all
purposes.  Handle these scopes in label resolution so that bogus
errors about conflicting labels in "real" code don't come out.

Note that BLOCK constructs could have also been defined as scopes
for statement labeling, but were not.

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

2 years ago[Clang] Implement P0848 (Conditionally Trivial Special Member Functions)
Roy Jacobson [Thu, 25 Aug 2022 21:51:06 +0000 (00:51 +0300)]
[Clang] Implement P0848 (Conditionally Trivial Special Member Functions)

This patch implements P0848 in Clang.

During the instantiation of a C++ class, in `Sema::ActOnFields`, we evaluate constraints for all the SMFs and compare the constraints to compute the eligibility. We defer the computation of the type's [copy-]trivial bits from addedMember to the eligibility computation, like we did for destructors in D126194. `canPassInRegisters` is modified as well to better respect the ineligibility of functions.

Note: Because of the non-implementation of DR1734 and DR1496, I treat deleted member functions as 'eligible' for the purpose of [copy-]triviallity. This is unfortunate, but I couldn't think of a way to make this make sense otherwise.

Reviewed By: #clang-language-wg, cor3ntin, aaron.ballman

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

2 years agoDon't index the skeleton CU when we have a fission compile unit.
Greg Clayton [Mon, 8 Aug 2022 19:30:20 +0000 (12:30 -0700)]
Don't index the skeleton CU when we have a fission compile unit.

When fission is enabled, we were indexing the skeleton CU _and_ the .dwo CU. Issues arise when users enable compiler options that add extra data to the skeleton CU (like -fsplit-dwarf-inlining) and there can end up being types in the skeleton CU due to template parameters. We never want to index this information since the .dwo file has the real definition, and we really don't want function prototypes from this info since all parameters are removed. The index doesn't work correctly if it does index the skeleton CU as the DIE offset will assume it is from the .dwo file, so even if we do index the skeleton CU, the index entries will try and grab information from the .dwo file using the wrong DIE offset which can cause errors to be displayed or even worse, if the DIE offsets is valid in the .dwo CU, the wrong DIE will be used.

We also fix DWO ID detection to use llvm::Optional<uint64_t> to make sure we can load a .dwo file with a DWO ID of zero.

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

2 years ago[libc++] Allow specifying conditional compile flags dependent on basic Lit features
Louis Dionne [Wed, 24 Aug 2022 17:22:42 +0000 (13:22 -0400)]
[libc++] Allow specifying conditional compile flags dependent on basic Lit features

This patch adds support for passing basic Lit features to the
ADDITIONAL_COMPILE_FLAGS keyword by enclosing them in parentheses.
This is done to support https://llvm.org/D131836.

In the future, we should instead add proper support for conditional
keywords in Lit, so that we can evaluate arbitrary Lit boolean
expressions such as `ADDITIONAL_COMPILE_FLAGS(x && !y): -flag`.

Note that I can see this being exceptionally useful when combined
with RUN commands, which would allow using different commands on
different systems. For example:

     RUN(!buildhost=windows): something
     RUN(buildhost=windows): something-else

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

2 years ago[flang][runtime] Fix MINVAL([CHARACTER(2)::])
Peter Klausler [Fri, 19 Aug 2022 19:33:00 +0000 (12:33 -0700)]
[flang][runtime] Fix MINVAL([CHARACTER(2)::])

The result of MINVAL over an empty default character array should
(per the standard) have a 127 in every character position, not just
the first.

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

2 years ago[LAA] Prune dependencies with distance large than access implied by trip count
Philip Reames [Thu, 25 Aug 2022 21:16:34 +0000 (14:16 -0700)]
[LAA] Prune dependencies with distance large than access implied by trip count

When we have a dependency with a dependence distance which can only be hit on an iteration beyond the actual trip count of the loop, we can ignore that dependency when analyzing said loop. We already had this code, but had restricted it solely to unknown dependence distances. This change applies it to all dependence distances.

Without this code, we relied on the vectorizer reducing VF such that our infeasible dependence was respected. This usually worked out to about the same result, but not always. For fixed length vectorization, this could mean a smaller VF than optimal being chosen or additional runtime checks. For scalable vectorization - where the bounds on access implied by VF are broader - we could often not find a feasible VF at all.

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

2 years ago[MC][ELF] Mark GNU ABI if ifunc are used
Adhemerval Zanella [Thu, 25 Aug 2022 20:25:34 +0000 (17:25 -0300)]
[MC][ELF] Mark GNU ABI if ifunc are used

Similar to D107861.  Some tools required the GNU ABI mark to output
the symbol is a IFUNC type correctly (for instance binutils readelf).

Reviewed By: MaskRay

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

2 years ago[mlir][LLVMIR] Fix oneToOneRewrite for zero-result ops
Jeff Niu [Thu, 25 Aug 2022 20:36:37 +0000 (13:36 -0700)]
[mlir][LLVMIR] Fix oneToOneRewrite for zero-result ops

`oneToOneRewrite` segfaulted for zero result-ops because a null type was being
passed to the op builders.

Reviewed By: rriddle

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

2 years ago[mlir] Add convenience builder for arith.addui_carry
Jakub Kuderski [Thu, 25 Aug 2022 21:00:07 +0000 (17:00 -0400)]
[mlir] Add convenience builder for arith.addui_carry

This is so that future conversions do not have to figure out how to
create matching boolean types for the second result.

Reviewed By: Mogball

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

2 years ago[mlir][spirv] Add convenience builders for AddICarry and SubIBorrow
Jakub Kuderski [Thu, 25 Aug 2022 20:54:26 +0000 (16:54 -0400)]
[mlir][spirv] Add convenience builders for AddICarry and SubIBorrow

This is so that we do not have to spell out long structure types every
time we create these ops.

Reviewed By: antiagainst

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

2 years ago[ValueTracking][InstCombine] restrict FP min/max matching to avoid miscompile
Sanjay Patel [Thu, 25 Aug 2022 19:43:39 +0000 (15:43 -0400)]
[ValueTracking][InstCombine] restrict FP min/max matching to avoid miscompile

This is a long-standing FIXME with a non-FMF test that exposes
the bug as shown in issue #57357.

It's possible that there's still a way to miscompile by
mis-identifying/mis-folding FP min/max patterns, but
this patch only exposes a couple of seemingly minor
regressions while preventing the broken transform.

2 years agoRemove TODO related to adding assert from Sparse Tensor Pipeline code
Rajas Vanjape [Thu, 25 Aug 2022 19:05:58 +0000 (19:05 +0000)]
Remove TODO related to adding assert from Sparse Tensor Pipeline code

Removing the TODO related to asserting that original `pm` is for ModuleOp.
The TODO is removed for following reasons:
1. There is no easy way to do this. We currently don't have this information stored in OpPassManager object.
2. There are currently no consumers of this information and storing this information with OpPassManager for a
   simple assert will be an overkill.

Reviewed By: aartbik

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

2 years ago[libc++][NFC] Remove tab in filebuf/traits_mismatch.fail.cpp
Nikolas Klauser [Thu, 25 Aug 2022 20:45:47 +0000 (22:45 +0200)]
[libc++][NFC] Remove tab in filebuf/traits_mismatch.fail.cpp

2 years ago[LAA] Cache PSE.getSE() in variable (NFC).
Florian Hahn [Thu, 25 Aug 2022 20:40:21 +0000 (21:40 +0100)]
[LAA] Cache PSE.getSE() in variable (NFC).

Preparation for follow-up patches will introduce additional uses
of SE.

2 years ago[compiler-rt][builtins] Revert all the recent changes I made for adding
Akira Hatanaka [Thu, 25 Aug 2022 20:27:29 +0000 (13:27 -0700)]
[compiler-rt][builtins] Revert all the recent changes I made for adding
security-related compiler flags

The changes broke Fuchsia builders.

2 years ago[libc++][NFC] Remove mentions of warn_unused_result
Nikolas Klauser [Thu, 25 Aug 2022 20:24:21 +0000 (22:24 +0200)]
[libc++][NFC] Remove mentions of warn_unused_result

We don't use `clang::warn_unused_result` anymore, so let's remove the mentions of it from the tests

Reviewed By: Mordante, #libc

Spies: libcxx-commits

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

2 years ago[libc++] Consolidate the different [[nodiscard]] configuration options into a single one
Nikolas Klauser [Fri, 19 Aug 2022 13:41:56 +0000 (15:41 +0200)]
[libc++] Consolidate the different [[nodiscard]] configuration options into a single one

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

2 years ago[LV] Add additional test coverage for SCEVexp and LCSSA interaction.
Florian Hahn [Thu, 25 Aug 2022 19:57:45 +0000 (20:57 +0100)]
[LV] Add additional test coverage for SCEVexp and LCSSA interaction.

Also converts the test to use opaque pointers while I am here.

2 years ago[compiler-rt][builtins] Check whether the flags are usable before adding
Akira Hatanaka [Thu, 25 Aug 2022 19:51:09 +0000 (12:51 -0700)]
[compiler-rt][builtins] Check whether the flags are usable before adding
them to the compiler command line

This is another attempt to fix the broken window bot.

2 years ago[RISCV][M68k] Replace fixed size BitVector with std::bitset.
Craig Topper [Thu, 25 Aug 2022 19:38:42 +0000 (12:38 -0700)]
[RISCV][M68k] Replace fixed size BitVector with std::bitset.

Saves a heap allocation and avoids an explicit call to the BitVector constructor.

Reviewed By: reames, myhsu

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

2 years ago[InstCombine] add test for fcmp+select miscompile; NFC
Sanjay Patel [Thu, 25 Aug 2022 19:38:19 +0000 (15:38 -0400)]
[InstCombine] add test for fcmp+select miscompile; NFC

issue #57357

2 years ago[flang] Introduce `AbstractResultOnGlobalOpt` pass
Daniil Dudkin [Thu, 25 Aug 2022 18:57:45 +0000 (21:57 +0300)]
[flang] Introduce `AbstractResultOnGlobalOpt` pass

This pass allows to convert operations
which use functions with abstract results to ones that do not.

Depends on D130087

Reviewed By: jeanPerier

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

2 years ago[libc++][NFC] Enable modernize-use-override
Nikolas Klauser [Wed, 24 Aug 2022 00:14:29 +0000 (02:14 +0200)]
[libc++][NFC] Enable modernize-use-override

Reviewed By: Mordante, #libc

Spies: aheejin, libcxx-commits, smeenai

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