Commit Graph

367435 Commits

Author SHA1 Message Date
Simon Pilgrim 0c671bfe00 [InstCombine] Add tests for vector rotate by constants with undefs. 2020-09-28 09:55:43 +01:00
Georgii Rymar dab9917164 [yaml2obj][obj2yaml] - Add a support for SHT_ARM_EXIDX section.
This adds the support for SHT_ARM_EXIDX sections to obj2yaml/yaml2obj tools.

SHT_ARM_EXIDX is a ARM specific index table filled with entries.
Each entry consists of two 4-bytes values (words).
(https://developer.arm.com/documentation/ihi0038/c/?lang=en#index-table-entries)

Differential revision: https://reviews.llvm.org/D88228
2020-09-28 11:45:49 +03:00
Raphael Isemann cabee89bed [lldb] Reference STL types in import-std-module tests
With the recent patches to the ASTImporter that improve template type importing
(D87444), most of the import-std-module tests can now finally import the
type of the STL container they are testing. This patch removes most of the casts
that were added to simplify types to something the ASTImporter can import
(for example, std::vector<int>::size_type was casted to `size_t` until now).
Also adds the missing tests that require referencing the container type (for
example simply printing the whole container) as here we couldn't use a casting
workaround.

The only casts that remain are in the forward_list tests that reference
the iterator and the stack test. Both tests are still failing to import the
respective container type correctly (or crash while trying to import).
2020-09-28 10:37:03 +02:00
Georgii Rymar ea0f66e848 [obj2yaml][yaml2obj] - Stop recognizing SHT_MIPS_ABIFLAGS on non-MIPS targets.
Currently we are always recognizing the `SHT_MIPS_ABIFLAGS` section,
even on non-MIPS targets.

The problem of doing this is briefly discussed in D88228 which does the same for `SHT_ARM_EXIDX`:

"The problem is that `SHT_ARM_EXIDX` shares the value with `SHT_X86_64_UNWIND (0x70000001U)`.
We might have other machine specific conflicts, e.g.
`SHT_ARM_ATTRIBUTES` vs `SHT_MSP430_ATTRIBUTES` vs `SHT_RISCV_ATTRIBUTES (0x70000003U)`."

I think we should only recognize target specific sections when the machine type
matches. I.e. `SHT_MIPS_*` should be recognized only on `MIPS`, `SHT_ARM_*`
only on `ARM` etc.

This patch stops recognizing `SHT_MIPS_ABIFLAGS` on `non-MIPS` targets.

Note: I had to update `ScalarEnumerationTraits<ELFYAML::MIPS_ISA>::enumeration`, because
otherwise test crashes, calling `llvm_unreachable`.

Differential revision: https://reviews.llvm.org/D88294
2020-09-28 11:28:53 +03:00
Benjamin Kramer 7e5a356d2b [Coroutines] Remove unused includes. NFC. 2020-09-28 10:27:23 +02:00
Sjoerd Meijer f39f92c1f6 [ARM][MVE] tail-predication: overflow checks for elementcount, cont'd
This is a reimplementation of the overflow checks for the elementcount,
i.e. the 2nd argument of intrinsic get.active.lane.mask. The element
count is lowered in each iteration of the tail-predicated loop, and
we must prove that this expression doesn't overflow.

Many thanks to Eli Friedman and Sam Parker for all their help with
this work.

Differential Revision: https://reviews.llvm.org/D88086
2020-09-28 09:20:51 +01:00
David Green e4b9867cb6 [ARM] Expand cannotInsertWDLSTPBetween to the last instruction
9d9a11c7be added this check for predicatable instructions between the
D/WLSTP and the loop's start, but it was missing the last instruction in
the block. Change it to use some iterators instead.

Differential Revision: https://reviews.llvm.org/D88354
2020-09-28 09:14:40 +01:00
Raphael Isemann 070a1d562b [lldb] Remove nothreadallow from SWIG's __str__ wrappers to work around a Python>=3.7 crash
Usually when we enter a SWIG wrapper function from Python, SWIG automatically
adds a `Py_BEGIN_ALLOW_THREADS`/`Py_END_ALLOW_THREADS` around the call to the SB
API C++ function. This will ensure that Python's GIL is released when we enter
LLDB and locked again when we return to the wrapper code.

D51569 changed this behaviour but only for the generated `__str__` wrappers. The
added `nothreadallow` disables the injection of the GIL release/re-acquire code
and the GIL is now kept locked when entering LLDB and is expected to be still
locked when returning from the LLDB implementation. The main reason for that was
that back when D51569 landed the wrapper itself created a Python string. These
days it just creates a std::string and SWIG itself takes care of getting the GIL
and creating the Python string from the std::string, so that workaround isn't
necessary anymore.

This patch just removes `nothreadallow` so that our `__str__` functions now
behave like all other wrapper functions in that they release the GIL when
calling into the SB API implementation.

The motivation here is actually to work around another potential bug in LLDB.
When one calls into the LLDB SB API while holding the GIL and that call causes
LLDB to interpret some Python script via `ScriptInterpreterPython`, then the GIL
will be unlocked when the control flow returns from the SB API. In the case of
the `__str__` wrapper this would cause that the next call to a Python function
requiring the GIL would fail (as SWIG will not try to reacquire the GIL as it
isn't aware that LLDB removed it).

The reason for this unexpected GIL release seems to be a workaround for recent
Python versions:
```
    // The only case we should go further and acquire the GIL: it is unlocked.
    if (PyGILState_Check())
      return;
```

The early-exit here causes `InitializePythonRAII::m_was_already_initialized` to
be always false and that causes that `InitializePythonRAII`'s destructor always
directly unlocks the GIL via `PyEval_SaveThread`. I'm investigating how to
properly fix this bug in a follow up patch, but for now this straightforward
patch seems to be enough to unblock my other patches (and it also has the
benefit of removing this workaround).

The test for this is just a simple test for `std::deque` which has a synthetic
child provider implemented as a Python script. Inspecting the deque object will
cause `expect_expr` to create a string error message by calling
`str(deque_object)`. Printing the ValueObject causes the Python script for the
synthetic children to execute which then triggers the bug described above where
the GIL ends up being unlocked.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D88302
2020-09-28 10:10:34 +02:00
Chuanqi Xu b3a722e66b [Coroutines] Reuse storage for local variables with non-overlapping lifetimes
bug 45566 shows the process of building coroutine frame won't consider
that the lifetimes of different local variables are not overlapped,
which means the compiler could generates smaller frame.

This patch calculate the lifetime range of each alloca by StackLifetime
class. Then the patch build non-overlapped sets for allocas whose
lifetime ranges are not overlapped. We use the largest type in a
non-overlapped set as the field type in the frame. In insertSpills
process, if we find the type of field is not the same with the alloca,
we cast the pointer to the field type to the pointer to the alloca type.
Since the lifetime range of alloca in one non-overlapped set is not
overlapped with each other, it should be ok to reuse the storage space
in the frame.

Test plan: check-llvm, check-clang, cppcoro, folly

Reviewers: junparser, lxfind, modocache

Differential Revision: https://reviews.llvm.org/D87596
2020-09-28 15:48:00 +08:00
David Sherwood bafdd11326 [SVE] Replace / operator in TypeSize/ElementCount with divideCoefficientBy
After some recent upstream discussion we decided that it was best
to avoid having the / operator for both ElementCount and TypeSize,
since this could give the impression that these classes can be used
in the same way as basic integer integer types. However, division
for scalable types is a bit odd because we are only dividing the
minimum quantity by a value, as opposed to something like:

  (MinSize * Vscale) / SomeValue

This is why when performing division it's important the caller
first establishes whether the operation makes sense, perhaps by
calling isKnownMultipleOf() prior to division. The caller must now
explictly call divideCoefficientBy() on the class to perform the
operation.

Differential Revision: https://reviews.llvm.org/D87700
2020-09-28 08:03:00 +01:00
Kai Luo dd3ba72066 [PowerPC] Add tests for `select` patterns. NFC. 2020-09-28 06:11:40 +00:00
Arthur Eubanks a2578e92e2 Revert "Reland [CodeGen] emit CG profile for COFF object file"
This reverts commit 506b6170cb.

This still causes link errors, see https://crbug.com/1130780.
2020-09-27 22:43:14 -07:00
Max Kazantsev 15985952ac [Test] Add tests where we can replace condition with invariants 2020-09-28 12:04:20 +07:00
Richard Smith df2a1f2aab Add profiling support for APValues.
For C++20 P0732R2; unused so far. Will be used and tested by a follow-on
commit.
2020-09-27 20:05:39 -07:00
Richard Smith 9dcd96f728 Canonicalize declaration pointers when forming APValues.
References to different declarations of the same entity aren't different
values, so shouldn't have different representations.

Recommit of e6393ee813 with fixed handling
for weak declarations. We now look for attributes on the most recent
declaration when determining whether a declaration is weak. (Second
recommit with further fixes for mishandling of weak declarations. Our
behavior here is fundamentally unsound -- see PR47663 -- but this
approach attempts to not make things worse.)
2020-09-27 19:05:26 -07:00
Valentin Clement fa08afc320 [mlir][openacc] Add if, deviceptr operands and default attribute
Add operands to represent if and deviceptr. Default clause is represented with
an attribute.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D88331
2020-09-27 21:28:06 -04:00
Valentin Clement 12ab4f8aca [mlir][openacc] Switch to assembly format for acc.data
This patch remove the printer/parser for the acc.data operation since its syntax
fits nicely with the assembly format. It reduces the maintenance for this op.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D88330
2020-09-27 21:20:50 -04:00
Valentin Clement 3d2bab176f [mlir][openacc] Remove detach and delete operands from acc.data
This patch remove the detach and delete operands. Those operands represent the detach
and delete clauses that will appear in another operation acc.exit_data

Reviewed By: kiranktp, kiranchandramohan

Differential Revision: https://reviews.llvm.org/D88326
2020-09-27 20:28:12 -04:00
Dávid Bolvanský 155ac33394 [BuildLibCalls] Add noalias for strcat and stpcpy
strcat:
destination and source shall not overlap. (http://www.cplusplus.com/reference/cstring/strcat/)

stpcpy:
The strings may not overlap, and the destination string dest must be  large enough to receive the copy. (https://man7.org/linux/man-pages/man3/stpcpy.3.html)

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D88335
2020-09-27 21:37:09 +02:00
Joseph Huber 0103df7903 [OpenMP] Add Missing _static Director for OpenMP Documentation
Summary:
Adding a missing directory needed for generating Sphinx documentation without
errors. Directory current contains a placeholder image just to populate the
directory.
2020-09-27 15:35:47 -04:00
Nikita Popov 01bde7310b [CVP] Remove unnecessary block splits in tests (NFC)
These are no longer necessary since D69686.
2020-09-27 20:55:28 +02:00
Nikita Popov fe79061be2 [LVI][CVP] Use block value when simplifying icmps
Add a flag to getPredicateAt() that allows making use of the block
value. This allows us to take into account range information from
the current block, rather than only information that is threaded
over edges, making the icmp simplification in CVP a lot more
powerful.

I'm not changing getPredicateAt() to use the block value
unconditionally to avoid any impact on the JumpThreading pass,
which is somewhat picky about LVI query order.

Most test changes here are just icmps that now get dropped (while
previously only a result used in a return was replaced). The three
tests in icmp.ll show some representative improvements. Some of
the folds this enables have been covered by IPSCCP in the meantime,
but LVI can reason about some cases which are hard to support in
IPSCCP, such as in test_br_cmp_with_offset.

The compile-time time cost of doing this is fairly minimal, with
a ~0.05% CTMark regression for ReleaseThinLTO:
https://llvm-compile-time-tracker.com/compare.php?from=709d03f8af4da4204849a70f01798e7cebba2e32&to=6236fd503761f43c99f4537121e057a01056f185&stat=instructions

This is because the block values will typically already be queried
and cached by other CVP optimizations anyway.

Differential Revision: https://reviews.llvm.org/D69686
2020-09-27 20:25:16 +02:00
Fangrui Song 50bd71e1d7 [NewPM] Port ConstraintElimination to the new pass manager
If -enable-constraint-elimination is specified, add it to the -O2/-O3 pipeline.
(-O1 uses a separate function now.)

Reviewed By: fhahn, aeubanks

Differential Revision: https://reviews.llvm.org/D88365
2020-09-27 11:12:26 -07:00
Benjamin Kramer 7b782062b4 [InstCombine] Simplify code. NFCI. 2020-09-27 19:11:07 +02:00
Nikita Popov 4f6e11948c [CVP] Make srem test more robust (NFC)
D69686 will be able to determine that the icmp is always false.
As this is not the purpose of the test, use a different modulus
that doesn't trivialize the condition.
2020-09-27 18:57:07 +02:00
Nikita Popov 709d03f8af [LVI] Clarify getValueAt/getValueInBlock doc comments (NFC)
The lattice value returned by getValueInBlock() holds at the start
of the block, not at the end. Also make it clearer what the
difference between getValueInBlock() and getValueAt() is.
2020-09-27 18:21:19 +02:00
Nikita Popov 9b959b59df [LVI] Require context instruction in external API (NFCI)
Require CxtI in getConstant() and getConstantRange() APIs.
Accordingly drop the BB parameter, as it is implied by
CxtI->getParent().

This makes sure we don't forget to pass the context instruction,
and makes the API contract clearer (also clean up the comments to
that effect -- the value holds at the context instruction, not
the end of the block).
2020-09-27 18:07:24 +02:00
Nikita Popov c8abf1c12d [CVP] Pass context instruction when narrowing div/rem
This fold was the only place not passing the context instruction.
The tests worked around that fact by introducing a basic block split,
which is now no longer necessary.
2020-09-27 17:51:30 +02:00
Simon Pilgrim 2d7a12f4ec [X86] Add some basic i128 udiv test coverage 2020-09-27 16:00:15 +01:00
Simon Pilgrim d9499c88d1 [X86] Regenerate i128 sdiv tests and add i686 coverage.
To hopefully help improve the codegen delta in D87976
2020-09-27 16:00:15 +01:00
Sanjay Patel 816b0a9c9f [CostModel] add cl option to check size and latency costs; NFC
This is a setting used by SimplifyCFG, LoopUnroll, and InlineCost,
but there is apparently no direct test coverage for any of those
cost model values.
2020-09-27 09:52:56 -04:00
Sanjay Patel 645c53a9d9 [ValueTracking] enhance isKnownNeverInfinity to understand sitofp
As discussed in D87877, instcombine already has this fold,
but it was missing from the more general ValueTracking logic.

https://alive2.llvm.org/ce/z/PumYZP
2020-09-27 08:40:31 -04:00
Sanjay Patel 71f25ac8ca [InstSimplify] add tests for fcmp with casted op; NFC
This shows missing analysis in ValueTracking's isKnownNeverInfinity().
2020-09-27 08:36:57 -04:00
Aaron Ballman de55ebe3bb Typo fix; NFC 2020-09-27 08:30:41 -04:00
Alexey Lapshin ababcd2ab4 [llvm-objcopy][NFC] refactor error handling. part 2.
Remove usages of special error reporting functions(error(),
reportError()). This patch is extracted from D87987.
Errors are reported as Expected<>/Error returning values.
This part is for COFF subfolder of llvm-objcopy.

Testing: check-all.

Differential Revision: https://reviews.llvm.org/D88213
2020-09-27 14:21:45 +03:00
Tatsuo Nomura e779427757 Fix MIPS and MIPS64 ABI to use ConstString in their register info arrays.
RegInfoBasedABI::GetRegisterInfoByName was failing because mips/mips64 ABIs
don't use ConstString in their register info array.

Reviewed By: #lldb, teemperor

Differential Revision: https://reviews.llvm.org/D88375
2020-09-27 12:36:09 +02:00
Amara Emerson 5811d72399 [AArch64][GlobalISel] Promote scalar G_SHL constant shift amounts to s64.
This was supposed to be done in the first place as is currently the case for
G_ASHR and G_LSHR but was forgotten when the original shift legalization
overhaul was done last year.

This was exposed because we started falling back on s32 = s32, s64 SHLs
due to a recent combiner change.

Gives a very minor (0.1%) code size -O0 improvement on consumer-typeset.
2020-09-27 01:53:26 -07:00
Nikita Popov f229bf2e12 [Legalize][X86] Improve nnan fmin/fmax vector reduction
Use +/-Inf or +/-Largest as neutral element for nnan fmin/fmax
reductions. This avoids dropping any FMF flags. Preserving the
nnan flag in particular is important to get a good lowering on X86.

Differential Revision: https://reviews.llvm.org/D87586
2020-09-27 10:47:35 +02:00
Amara Emerson 7156938be2 [AArch64][GlobalISel] Use the look-through constant helper for the shift s32->s64 custom legalization.
Almost NFC, except it catches more cases and gives a 0.1% CTMark -O0 size win.
2020-09-27 01:25:03 -07:00
Fangrui Song 82420b4e49 [DivRemPairs] Use DenseMapBase::find instead of operator[]. NFC 2020-09-27 01:13:14 -07:00
Craig Topper d78c4d9d00 [X86] Add more test cases to inline-asm-flag-output.ll. NFC
These are tests to make sure we are able to use the flag directly
in a conditional branch after the inline asm.
2020-09-26 23:27:25 -07:00
sunshaoce ba950ad0a5 Update Kaleidoscope: Change headers
Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D88141
2020-09-27 05:40:50 +00:00
Chen Zheng c8f6c0f961 [Machinesink] add one more profitable loop related pattern
Reviewed By: qcolombet

Differential Revision: https://reviews.llvm.org/D86925
2020-09-26 21:02:21 -04:00
Robert Widmann 55f727306e [LLVM-C] Turn a ShuffleVector Constant Into a Getter.
It is not a good idea to expose raw constants in the LLVM C API. Replace this with an explicit getter.

Differential Revision: https://reviews.llvm.org/D88367
2020-09-26 17:32:57 -06:00
Fangrui Song 20e9c36c01 Internalize functions from various tools. NFC
And internalize some classes if I noticed them:)
2020-09-26 15:57:13 -07:00
Amy Kwan 6f24774fc4 [NFC][PowerPC] Change PPCSubTarget (introduced from D87671) to Subtarget
In D87671, it introduced PPCSubTarget in PPCISelDAGToDAG. This should have been
Subtarget instead. This patch changes PPCSubTarget into Subtarget.
2020-09-26 17:53:51 -05:00
Aaron Puchert 485501899d Fix sphinx warnings in AttributeReference, NFC
The previous attempt in d34c8c70 didn't help (the problem was missing
indentation), and another issue was introduced by a51d51a0.
2020-09-27 00:52:36 +02:00
Fangrui Song 400bdbc422 [ConstraintElimination] Internalize function/class and delete an implied condition. NFC
Delete an implied condition (E.NumIn <= CB.NumIn)
2020-09-26 15:04:39 -07:00
Simon Pilgrim 6d374cf78c [X86] Add 64-bit target tests 2020-09-26 22:07:51 +01:00
Russell Yanofsky f702a6fa7c Thread safety analysis: Improve documentation for ASSERT_CAPABILITY
Previous description didn't actually state the effect the attribute has on
thread safety analysis (causing analysis to assume the capability is held).

Previous description was also ambiguous about (or slightly overstated) the
noreturn assumption made by thread safety analysis, implying the assumption had
to be true about the function's behavior in general, and not just its behavior
in places where it's used. Stating the assumption specifically should avoid a
perceived need to disable thread safety analysis in places where only asserting
that a specific capability is held would be better.

Reviewed By: aaronpuchert, vasild

Differential Revision: https://reviews.llvm.org/D87629
2020-09-26 22:16:50 +02:00