Commit Graph

419942 Commits

Author SHA1 Message Date
Momchil Velikov 980c3e6dd2 [CodeGen] Async unwind - add a pass to fix CFI information
This pass inserts the necessary CFI instructions to compensate for the
inconsistency of the call-frame information caused by linear (non-CFG
aware) nature of the unwind tables.

Unlike the `CFIInstrInserer` pass, this one almost always emits only
`.cfi_remember_state`/`.cfi_restore_state`, which results in smaller
unwind tables and also transparently handles custom unwind info
extensions like CFA offset adjustement and save locations of SVE
registers.

This pass takes advantage of the constraints that LLVM imposes on the
placement of save/restore points (cf. `ShrinkWrap.cpp`):

  * there is a single basic block, containing the function prologue

  * possibly multiple epilogue blocks, where each epilogue block is
    complete and self-contained, i.e. CSR restore instructions (and the
    corresponding CFI instructions are not split across two or more
    blocks.

  * prologue and epilogue blocks are outside of any loops

Thus, during execution, at the beginning and at the end of each basic
block the function can be in one of two states:

  - "has a call frame", if the function has executed the prologue, or
     has not executed any epilogue

  - "does not have a call frame", if the function has not executed the
    prologue, or has executed an epilogue

These properties can be computed for each basic block by a single RPO
traversal.

In order to accommodate backends which do not generate unwind info in
epilogues we compute an additional property "strong no call frame on
entry" which is set for the entry point of the function and for every
block reachable from the entry along a path that does not execute the
prologue. If this property holds, it takes precedence over the "has a
call frame" property.

From the point of view of the unwind tables, the "has/does not have
call frame" state at beginning of each block is determined by the
state at the end of the previous block, in layout order.

Where these states differ, we insert compensating CFI instructions,
which come in two flavours:

- CFI instructions, which reset the unwind table state to the
    initial one.  This is done by a target specific hook and is
    expected to be trivial to implement, for example it could be:
```
     .cfi_def_cfa <sp>, 0
     .cfi_same_value <rN>
     .cfi_same_value <rN-1>
     ...
```
where `<rN>` are the callee-saved registers.

- CFI instructions, which reset the unwind table state to the one
    created by the function prologue. These are the sequence:
```
       .cfi_restore_state
       .cfi_remember_state
```
In this case we also insert a `.cfi_remember_state` after the
last CFI instruction in the function prologue.

Reviewed By: MaskRay, danielkiss, chill

Differential Revision: https://reviews.llvm.org/D114545
2022-04-04 14:38:22 +01:00
Nathan Sidwell ee6ec9e861 [demangler] Parenthesize >> inside template args
Both > and >> expressions need to be parenthesized inside template
argument lists.

Reviewed By: dblaikie, rjmccall

Differential Revision: https://reviews.llvm.org/D122474
2022-04-04 06:35:32 -07:00
Sam McCall 72ae6cc3a6 [pseudo] respect CLANG_INCLUDE_TESTS 2022-04-04 15:30:11 +02:00
Nico Weber b0abada8fe [gn build] llvm-lipo, llvm-libtool-darwin symlink targets now dep on binary
This fixes a regression from 69cde915e923d: If llvm_install_cctools_symlinks
is false, depending llvm-lipo:symlinks didn't actually depend on llvm-lipo
and the binary didn't get built as dependency of `check-lld` (because the
`symlinks` array ended up empty).
2022-04-04 09:20:49 -04:00
Louis Dionne a4f73b9b14 [libc++][NFC] Rename generate_assertion_tests.py to generate_header_tests.py 2022-04-04 09:10:52 -04:00
Louis Dionne be1294de9d [libc++] Implement all public header tests using the new generator
Note that `generate_assertion_tests.py` will be renamed to
`generate_header_tests.py` separately to facilitate change tracking.

Differential Revision: https://reviews.llvm.org/D123000
2022-04-04 09:09:37 -04:00
Nico Weber cd52b35ee4 fix comment typos to cycle bots 2022-04-04 08:56:18 -04:00
Simon Pilgrim 328754474a [DAG] SimplifySetCC - clang-format add/xor/sub with constant handling. NFC. 2022-04-04 13:30:17 +01:00
Yitzhak Mandelbaum 506ec85ba8 [clang][dataflow] Add support for clang's `__builtin_expect`.
This patch adds basic modeling of `__builtin_expect`, just to propagate the
(first) argument, making the call transparent.

Driveby: adds tests for proper handling of other builtins.

Differential Revision: https://reviews.llvm.org/D122908
2022-04-04 12:20:43 +00:00
Pavel Samolysov 87b28f5092 [clang][NFC] Extract the EmitAssemblyHelper::TargetTriple member
Few times in different methods of the EmitAssemblyHelper class the following
code snippet is used to get the TargetTriple and then use it's single method
to check some conditions:

TargetTriple(TheModule->getTargetTriple())

The parsing of a target triple string is not a trivial operation and it takes
time to repeat the parsing many times in different methods of the class and
even numerous times in one method just to call a getter
(llvm::Triple(TheModule->getTargetTriple()).getVendor()), for example.
The patch extracts the TargetTriple member of the EmitAssemblyHelper class to
parse the triple only once in the class' constructor.

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D122587
2022-04-04 12:16:39 +03:00
Simon Pilgrim 9db1eb13b6 [Thumb2] Regenerate thumb2-teq2 tests 2022-04-04 12:48:20 +01:00
PeixinQiao 706dec3e47 [mlir] Fix the build error in OpenMPToLLVMIRTranslation.cpp
Fix the build error with "-Werror,-Wcovered-switch-default".

Reviewed By: hpmorgan

Differential Revision: https://reviews.llvm.org/D123018
2022-04-04 19:46:16 +08:00
David Green 2abaa027d9 [AArch64] Teach the costmodel about widening muls
A vector mul(sext, sext) or mul(zext, zext) will be code generated as a
single smull or umull instruction. This most notably effects v2i64
multiplies, which are otherwise not legal and need to be expanded.

The oneuse check has also been slightly changed, as it is already
checked from the use of isWideningInstruction in getCastInstrCost.

Differential Revision: https://reviews.llvm.org/D123006
2022-04-04 12:45:04 +01:00
Simon Pilgrim ec93435ba0 [Thumb2] Regenerate thumb2-teq tests 2022-04-04 12:24:35 +01:00
David Spickett 434b545d4f [lldb][AArch64] Update disassembler feature list and add tests for all extensions
This updates the disassembler to enable every optional extension.
Previously we had added things that we added "support" for in lldb.
(where support means significant work like new registers, fault types, etc.)

Something like TME (transactional memory) wasn't added because
there are no new lldb features for it. However we should still be
disassembling the instructions.

So I went through the AArch64 extensions and added all the missing
ones. The new test won't prevent us missing a new extension but it
does at least document our current settings.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D121999
2022-04-04 11:21:01 +00:00
Simon Pilgrim d4cdaa24fd [MIPS] Regenerate countleading tests with common check prefixes 2022-04-04 12:19:57 +01:00
David Green 2e2f38a1ac [AArch64] Add widening arithmetic cost tests. NFC 2022-04-04 12:19:45 +01:00
Nikita Popov 3c9f3f76f1 [ConstantFold] Fold zero-index GEPs with opaque pointers
With opaque pointers, we can eliminate zero-index GEPs even if
they have multiple indices, as this no longer impacts the result
type of the GEP.

This optimization is already done for instructions in InstSimplify,
but we were missing the corresponding constant expression handling.

The constexpr transform is a bit more powerful, because it can
produce a vector splat constant and also handles undef values --
it is an extension of an existing single-index transform.
2022-04-04 13:04:27 +02:00
Nikita Popov d092df42f3 [InstSimplify] Add tests for zero-offset opaque ptr constexpr GEP (NFC) 2022-04-04 13:04:26 +02:00
Simon Pilgrim ad59bd0be9 [X86] Regenerate peep tests checks 2022-04-04 12:02:33 +01:00
Muhammad Omair Javaid a96638e50e Revert "[NFCI] Regenerate PhaseOrdering test checks"
This reverts commit e91fe08999.

Breaks following buildbots: https://lab.llvm.org/buildbot/#/builders/171
2022-04-04 15:30:57 +05:00
Andrzej Warzynski 03efa5a362 [flang] Update the conversion code for fir.coordinate_of
These are mostly small changes to make the code a bit clearer and more
consistent. Summary of changes:
  * add missing namespace qualifiers (that's the preference in Flang)
  * replace const member methods with static methods (to avoid passing
    the *this pointer unnecessarily)
  * rename `currentObjTy` (current object type) as `cpnTy` (component
    type) - the latter feels more fitting
  * remove redundant `return failure();` calls (` return
    mlir::emitError` gives the same result)
  * updated a few comments

Differential Revision: https://reviews.llvm.org/D122799
2022-04-04 10:15:14 +00:00
Jeremy Morse 059d1f84d2 [DebugInfo] Correctly recognize bitfields when emitting dwarf
Use the "isBitfield" flag for debug types to determine whether something is
a bitfield, rather than trying to guess from it's layout. Fixes
https://bugs.llvm.org/show_bug.cgi?id=44601

Patch by: mahkoh

Differential Revision: https://reviews.llvm.org/D96334
2022-04-04 11:14:13 +01:00
Simon Pilgrim 623d4b5787 [X86] Support optional NOT stages in the AND(SRL(X,Y),1) -> SETCC(BT(X,Y)) fold
Extension to D122891, peek through NOT() ops, adjusting the condcode as we go.
2022-04-04 10:51:26 +01:00
Simon Pilgrim 842175676c [X86] Add additional test cases for NOT(AND(SRL(X,Y),1))/AND(SRL(NOT(X(,Y),1) -> SETCC(BT(X,Y))
As suggested in post review on D122891
2022-04-04 10:29:33 +01:00
Florian Hahn 1817c526e1
[VPlan] Update VPInterleavedAccessInfo to use getVectorLoopRegion.
Update VPInterleavedAccessInfo  to use the generic getVectorLoopRegion
helper instead of relying on the entry block being the top-most vector
loop region.
2022-04-04 10:26:39 +01:00
Martin Sebor 5ccfd5f6d4 [SimplifyLibCalls] Optimize memchr() with known char+str and unknown length
If both the character and string are known, but the length
potentially isn't, we can optimize the memchr() call to a select
of either the known position of the character or null.

Split off from https://reviews.llvm.org/D122836.
2022-04-04 11:01:33 +02:00
Martin Sebor 5197d2791f [SimplifyLibCalls] Move handling of constant char earlier (NFC)
Handle the simple constant char case before the bitmask optimization.
This will allow extending the code to handle a non-constant size
argument in a followup change.

Split out from https://reviews.llvm.org/D122836.
2022-04-04 11:01:33 +02:00
Valentin Clement d333b38270
[flang][NFC] Add tests for array-value-copy pass with array with pointers
This patch adds tests for the array-value-copy pass with array assignment
involving Fortran pointers.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: schweitz

Differential Revision: https://reviews.llvm.org/D122878
2022-04-04 10:45:45 +02:00
Martin Sebor d18991debf [SimplifyLibCalls] Fold memchr() with size 1
If the memchr() size is 1, then we can convert the call into a
single-byte comparison. This works even if both the string and the
character are unknown.

Split off from https://reviews.llvm.org/D122836.
2022-04-04 10:41:20 +02:00
Martin Sebor 0f08875744 [InstCombine] Add additional memchr test (NFC)
And fix some test names / comments.
2022-04-04 10:41:20 +02:00
Florian Hahn 8cd1892725
[VPlan] Remember previous loop and reset vector loop.
At the moment this is NFC, but will be needed once nested loops are also
modeled as regions. Preparation for D123005.
2022-04-04 09:27:15 +01:00
Nikita Popov a5c3b5748c [MemCpyOpt] Work around PR54682
As discussed on https://github.com/llvm/llvm-project/issues/54682,
MemorySSA currently has a bug when computing the clobber of calls
that access loop-varying locations. I think a "proper" fix for this
on the MemorySSA side might be non-trivial, but we can easily work
around this in MemCpyOpt:

Currently, MemCpyOpt uses a location-less getClobberingMemoryAccess()
call to find a clobber on either the src or dest location, and then
refines it for the src and dest clobber. This was intended as an
optimization, as the location-less API is cached, while the
location-affected APIs are not.

However, I don't think this really makes a difference in practice,
because I don't think anything will use the cached clobbers on
those calls later anyway. On CTMark, this patch seems to be very
mildly positive actually.

So I think this is a reasonable way to avoid the problem for now,
though MemorySSA should also get a fix.

Differential Revision: https://reviews.llvm.org/D122911
2022-04-04 10:19:51 +02:00
Nikita Popov c0cc98251a [Float2Int] Make sure dependent ranges are calculated first (PR54669)
The range calculation in walkForwards() assumes that the ranges of
the operands have already been calculated. With the used visit
order, this is not necessarily the case when there are multiple
roots. (There is nothing guaranteeing that instructions are visited
in topological order.)

Fix this by queuing instructions for reprocessing if the operand
ranges haven't been calculated yet.

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

Differential Revision: https://reviews.llvm.org/D122817
2022-04-04 10:18:39 +02:00
Jean Perier b8e8f62d5e [flang] Fold instantiated PDT character component length when needed
In case a character component PDT length only depends on kind parameters,
fold it while instantiating the PDT. This is especially important if the
component has an initializer because later semantic phases (offset
computation or runtime type info generation) might get confused and
generate offset/type info that will lead to crashes in lowering.

Differential Revision: https://reviews.llvm.org/D122938
2022-04-04 09:47:15 +02:00
Valentin Clement 7dc492ed34
[flang][NFC] Add tests for fir.address_of
This patch adds FIR to LLVM test for fir.address_of.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: schweitz

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2022-04-04 09:28:44 +02:00
Fangrui Song 388584d382 [ELF][test] Fix RUN lines in lto/sample-profile.ll
Reported at https://github.com/llvm/llvm-project/issues/54679#issuecomment-1086862116
2022-04-03 23:57:31 -07:00
Min-Yih Hsu fccdc5618d [M68k] Adopt VarLenCodeEmitter for shift / rotate instructions
This patch is covered by existing MC tests.
2022-04-03 22:52:32 -07:00
Min-Yih Hsu 22201f499d [M68k][test] Remove redundant CHECK-LABEL directive
The associated test had a redundant CHECK-LABEL directive that might fail
the test since the inception, but this issue was "burried" by a missing
colon, which was addressed in fb65aaf0be.
Thus, the test finally failed after the said commit.

This patch remove that CHECK-LABEL directive.
2022-04-03 22:51:03 -07:00
Yuanfang Chen 948f3deca9 Reland "[lit] Use sharding for GoogleTest format"
This relands commit a87ba5c86d.

Adjust llvm/utils/lit/tests/googletest-timeout.py for new test output.
2022-04-03 22:35:45 -07:00
Argyrios Kyrtzidis 5877df735d [Support/BLAKE3] CMake: Remove the workaround that checks for "CC=ccache /path/to/clang"
The LLVM builders that were doing that have been updated to use "-DLLVM_CCACHE_BUILD=ON" instead.
2022-04-03 21:02:02 -07:00
Augie Fackler 603ae73146 AttributorAttributes: guard against TLI being nullptr
I didn't dig into this very much because it appears to be totally valid
(especially once these properties can come from attributes instead
of only from hard-coded library functions) for TLI to not be defined,
and nothing broke when I added this check, including with all my other
patches applied.

Differential Revision: https://reviews.llvm.org/D122917
2022-04-03 23:19:23 -04:00
Augie Fackler e90bce8f91 CallBase: fix getFnAttr so it also checks the function
Prior to this change, CallBase::hasFnAttr checked the called function to
see if it had an attribute if it wasn't set on the CallBase, but
getFnAttr didn't do the same delegation, which led to very confusing
behavior. This patch fixes the issue by making CallBase::getFnAttr also
check the function under the same circumstances.

Test changes look (to me) like they're cleaning up redundant attributes
which no longer get specified both on the callee and call. We also clean
up the one ad-hoc implementation of this getter over in InlineCost.cpp.

Differential Revision: https://reviews.llvm.org/D122821
2022-04-03 23:19:23 -04:00
Philip Reames 88de27e3fd [LV] Handle non-integral types when considering interleave widening legality
In general, anywhere we might need to insert a blind bitcast, we need to make sure the types are losslessly convertible.

This fixes pr54634.
2022-04-03 20:16:20 -07:00
Philip Reames 7c51669c21 [memcpyopt] Restructure store(load src, dest) form of callslotopt for compile time
The search for the clobbering call is fairly expensive if uses are not optimized at construction.  Defer the clobber walk to the point in the implementation we need it; there are a bunch of bailouts before that point.  (e.g. If the source pointer is not an alloca, we can't do callslotopt.)

On a test case which involves a bunch of copies from argument pointers, this switches memcpyopt from > 1/2 second to < 10ms.
2022-04-03 20:16:20 -07:00
Yuanfang Chen c0f90c84b1 Revert "[lit] Use sharding for GoogleTest format"
This reverts commit a87ba5c86d.

Breaks bots:
https://lab.llvm.org/buildbot/#/builders/196/builds/10454
2022-04-03 20:04:55 -07:00
Yuanfang Chen a87ba5c86d [lit] Use sharding for GoogleTest format
This helps lit unit test performance by a lot, especially on windows. The performance gain comes from launching one gtest executable for many subtests instead of one (this is the current situation).

The shards are executed by the test runner and the results are stored in the
json format supported by the GoogleTest. Later in the test reporting stage,
all test results in the json file are retrieved to continue the test results
summary etc.

On my Win10 desktop, before this patch: `check-clang-unit`: 177s, `check-llvm-unit`: 38s; after this patch: `check-clang-unit`: 37s, `check-llvm-unit`: 11s.
On my Linux machine, before this patch: `check-clang-unit`: 46s, `check-llvm-unit`: 8s; after this patch: `check-clang-unit`: 7s, `check-llvm-unit`: 4s.

Reviewed By: yln, rnk

Differential Revision: https://reviews.llvm.org/D122251
2022-04-03 19:47:02 -07:00
Xiang1 Zhang f830392be7 Correct spelling error in TLS-Load-Hoist 2022-04-04 08:27:54 +08:00
Dávid Bolvanský 872f7000fc Revert "[NFCI] Regenerate SROA/LoopVectorize test checks"
This reverts commit 14e3450fb5.
2022-04-04 01:15:30 +02:00
Dávid Bolvanský 14e3450fb5 [NFCI] Regenerate SROA test checks 2022-04-04 00:55:54 +02:00