platform/upstream/llvm.git
2 years ago[LV] Consistently use vputils::isUniformAfterVectorization [mostly nfc]
Philip Reames [Fri, 26 Aug 2022 17:59:17 +0000 (10:59 -0700)]
[LV] Consistently use vputils::isUniformAfterVectorization [mostly nfc]

I'd extracted isUniform, and Florian moved isUniformAfterVectorization out of VPlan at basically the same time. Let's go ahead and merge them.

For the VPTransformState::get path, a VPValue without a def (which corresponds to an external IR value outside of VPLan) is explicitly handled above the uniform check.  On the scalarizeInstruction path, I'm less sure why the change isn't visible, but test cases which would seem likely to hit it were already being handled as uniform through some other mechanism.  It would be correct to consider values defined outside of vplan uniform here.

2 years ago[InstCombine] Canonicalize "and, add", "or, add", "xor, add"
Eric Gullufsen [Wed, 24 Aug 2022 15:58:47 +0000 (11:58 -0400)]
[InstCombine] Canonicalize "and, add", "or, add", "xor, add"

Canonicalize
```
((x + C1) & C2) --> ((x & C2) + C1)
((x + C1) ^ C2) --> ((x ^ C2) + C1)
((x + C1) | C2) --> ((x | C2) + C1)
```
for suitable constants `C1` and `C2`.

Alive2 proofs: [[ https://alive2.llvm.org/ce/z/BqMDVZ | add, or --> or, add ]]
[[ https://alive2.llvm.org/ce/z/BhAeCl | add, xor --> xor, add ]]
[[ https://alive2.llvm.org/ce/z/jYRHEt | add, and --> and, add ]]

Reviewed By: spatel

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

2 years ago[NFC][InstCombine] Add baseline tests for canonicalizing "and, add", "or, add", ...
Eric Gullufsen [Wed, 24 Aug 2022 14:44:04 +0000 (10:44 -0400)]
[NFC][InstCombine] Add baseline tests for canonicalizing "and, add", "or, add", "xor, add"

Baseline tests for canonicalizing "logic op, add"
```
((x + C1) & C2) --> ((x & C2) + C1)
((x + C1) ^ C2) --> ((x ^ C2) + C1)
((x + C1) | C2) --> ((x | C2) + C1)
```
for suitable constants `C1` and `C2`.

Reviewed By: spatel

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

2 years ago[InstCombine] fold test of equality to 0.0 with bitcast operand
Sanjay Patel [Fri, 26 Aug 2022 15:15:09 +0000 (11:15 -0400)]
[InstCombine] fold test of equality to 0.0 with bitcast operand

fcmp oeq/une (bitcast X), 0.0 --> (and X, SignMaskC) ==/!= 0
https://alive2.llvm.org/ce/z/ZKATGN

2 years ago[InstCombine] add tests for fcmp with bitcast operand; NFC
Sanjay Patel [Fri, 26 Aug 2022 14:20:37 +0000 (10:20 -0400)]
[InstCombine] add tests for fcmp with bitcast operand; NFC

2 years ago[CostModel][X86] Add CodeSize handling for and/or/xor ops
Simon Pilgrim [Fri, 26 Aug 2022 17:42:42 +0000 (18:42 +0100)]
[CostModel][X86] Add CodeSize handling for and/or/xor ops

Eventually this will be part of the cost table lookup

2 years ago[VPlan] Move isUniformAfterVectorization from VPlan to vputils (NFC).
Florian Hahn [Fri, 26 Aug 2022 17:26:32 +0000 (18:26 +0100)]
[VPlan] Move isUniformAfterVectorization from VPlan to vputils (NFC).

This allows re-using the utility without a VPlan object. The helper also
doesn't access any data from VPlan.

2 years ago[SLP][NFC]Add a test for vectorization of stores with float constants,
Alexey Bataev [Fri, 26 Aug 2022 17:21:35 +0000 (10:21 -0700)]
[SLP][NFC]Add a test for vectorization of stores with float constants,
NFC.

2 years ago[bazel] Port a235562c0a051d0786cdb7da8e2af93e56e849c3
Benjamin Kramer [Fri, 26 Aug 2022 17:17:05 +0000 (19:17 +0200)]
[bazel] Port a235562c0a051d0786cdb7da8e2af93e56e849c3

2 years ago[LV] Extract utility for checking if VPValue is uniform [nfc]
Philip Reames [Fri, 26 Aug 2022 16:37:45 +0000 (09:37 -0700)]
[LV] Extract utility for checking if VPValue is uniform [nfc]

2 years ago[mlgo] Don't set the source permissions when copying over tf files
Mircea Trofin [Fri, 26 Aug 2022 16:49:53 +0000 (09:49 -0700)]
[mlgo] Don't set the source permissions when copying over tf files

This is akin to the `install` behavior. It should make build directory
deletable on certain build bots.

2 years ago[Clang] Fix assert in Sema::LookupTemplateName so that it does not attempt an uncondi...
Shafik Yaghmour [Fri, 26 Aug 2022 16:12:29 +0000 (09:12 -0700)]
[Clang] Fix assert in Sema::LookupTemplateName so that it does not attempt an unconditional cast to TagType

In Sema::LookupTemplateName(...) seeks to assert that the ObjectType is complete
or being defined. If the type is incomplete it will attempt to unconditionally
cast it to a TagType and not all incomplete types are a TagType. For example the
type could be void or it could be an IncompleteArray.

This change adds an additional check to confirm it is a TagType before attempting
to check if it is incomplete or being defined

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

2 years ago[CostModel][X86] Add CodeSize handling for fneg ops
Simon Pilgrim [Fri, 26 Aug 2022 16:34:43 +0000 (17:34 +0100)]
[CostModel][X86] Add CodeSize handling for fneg ops

Eventually this will be part of the cost table lookup

2 years ago[CostModel][X86] getArithmeticInstrCost - use the cost tables for all cost kinds
Simon Pilgrim [Fri, 26 Aug 2022 15:24:35 +0000 (16:24 +0100)]
[CostModel][X86] getArithmeticInstrCost - use the cost tables for all cost kinds

The tables currently only have TCK_RecipThroughput costs, but we should now be able to add individual entries without any further refactoring

2 years ago[mlir][TilingInterface] Enabling tiling `tensor.pad` using `TilingInterface`.
Mahesh Ravishankar [Fri, 26 Aug 2022 16:29:02 +0000 (16:29 +0000)]
[mlir][TilingInterface] Enabling tiling `tensor.pad` using `TilingInterface`.

Update the implementation of `TilingInterface` for `tensor.pad`
operations to allow tiling the op using the existing patterns for the
interface. Verify that tests that pass with existing pad tiling
patterns producer the same results through TilingInterface patterns.

Reviewed By: antiagainst

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

2 years ago[LV] Add another test for incorrect runtime check generation.
Florian Hahn [Fri, 26 Aug 2022 16:28:41 +0000 (17:28 +0100)]
[LV]  Add another test for incorrect runtime check generation.

Add a variation of @nested_loop_outer_iv_addrec_invariant_in_inner with
the dependence sink and source swapped to extend test coverage.

Also simplifies the test by removing an unneeded reduction.

2 years ago[HLSL] Move DXIL validation version out of ModuleFlags
Xiang Li [Wed, 20 Jul 2022 22:27:41 +0000 (15:27 -0700)]
[HLSL] Move DXIL validation version out of ModuleFlags

Put DXIL validation version into separate NamedMetadata to avoid update ModuleFlags.

Currently DXIL validation version is saved in ModuleFlags in clang codeGen.
Then in DirectX backend, the data will be extracted from ModuleFlags and cause rebuild of ModuleFlags.
This patch will build NamedMetadata for DXIL validation version and remove the code to rebuild ModuleFlags.

Reviewed By: beanz

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

2 years ago[mlir][Linalg] Drop check for output indexing maps.
Mahesh Ravishankar [Fri, 26 Aug 2022 16:15:08 +0000 (16:15 +0000)]
[mlir][Linalg] Drop check for output indexing maps.

The current check for form of the output indexing maps disallows
generic ops that return both a reduced and unreduced value. Such an op
seems like it could fall within the scope of a Strucutred op. Drop the
check. The only load-bearing place this was found to cause isseus was
during vectorization, but the fix for that seems to be simple.

Reviewed By: ThomasRaoux

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

2 years ago[mlir][MemRef] Introduce a memref.extract_metadata op.
Nicolas Vasilache [Fri, 19 Aug 2022 15:33:09 +0000 (08:33 -0700)]
[mlir][MemRef] Introduce a memref.extract_metadata op.

This is the counterpart of `memref.reinterpret_cast` and is useful to lift
strided memref manipulation out of the LLVM dialect.

Discussion: https://discourse.llvm.org/t/extracting-dynamic-offsets-strides-from-memref/64170

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

2 years ago[Clang] Fix crash in coverage of if consteval.
Corentin Jabot [Fri, 26 Aug 2022 08:20:12 +0000 (10:20 +0200)]
[Clang] Fix crash in coverage of if consteval.

Clang crashes when encountering an `if consteval` statement.
This is the minimum fix not to crash.
The fix is consistent with the current behavior of if constexpr,
which does generate coverage data for the discarded branches.
This is of course not correct and a better solution is
needed for both if constexpr and if consteval.
See https://github.com/llvm/llvm-project/issues/54419.

Fixes #57377

Reviewed By: aaron.ballman

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

2 years ago[libc++] Enable hash only for the correct types
Nikolas Klauser [Mon, 22 Aug 2022 00:59:09 +0000 (02:59 +0200)]
[libc++] Enable hash only for the correct types

Also implement LWG3705.
Fixes https://github.com/llvm/llvm-project/issues/55823

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

2 years ago[libc++][NFC] Remove reserved names from support/constexpr_char_traits.h
Nikolas Klauser [Fri, 26 Aug 2022 15:36:25 +0000 (17:36 +0200)]
[libc++][NFC] Remove reserved names from support/constexpr_char_traits.h

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

2 years ago[compiler-rt][builtins] Add compiler flags to catch potential errors
Akira Hatanaka [Fri, 26 Aug 2022 04:34:09 +0000 (21:34 -0700)]
[compiler-rt][builtins] Add compiler flags to catch potential errors
that can lead to security vulnerabilities

Also, fix a few places that were causing -Wshadow and
-Wformat-nonliteral warnings to be emitted.

This reapplies the patch that was reverted in caaafe4ae250 because it
broke Fuchsia builders.

I reverted the changes I made to InstrProfData.inc and instead renamed
the variables in InstrProfilingWriter.c. Also fixed a bug in function
add_security_warnings that was causing it to pass -Wformat-nonliteral
when the compiler doesn't support it.

2 years ago[LV] Add test for incorrect runtime check generation #57315.
Florian Hahn [Fri, 26 Aug 2022 15:29:20 +0000 (16:29 +0100)]
[LV] Add test for incorrect runtime check generation #57315.

Test for PR57315 based on a test provided by @kpdev42.

2 years ago[mlir][tensor] Remove incorrect parallel_insert_slice folder
Thomas Raoux [Thu, 25 Aug 2022 19:35:26 +0000 (19:35 +0000)]
[mlir][tensor] Remove incorrect parallel_insert_slice folder

parallel_insert_slice doesn't return a value therefore we shouldn't try
to fold the result. The insert folding don't apply to this op.
The current folding would cause pattern rewrite to not be able to
converge.

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

2 years agoFix the lldb test bots
Aaron Ballman [Fri, 26 Aug 2022 15:17:43 +0000 (11:17 -0400)]
Fix the lldb test bots

This addresses an accidental change in behavior from
41667a8b9b624e282e7c08fadf7091223728d1c1 to get the bots back to green.
However, I think there's an issue with LLDB assuming it's valid to
enable support for keywords in language modes that don't support the
keyword (as other parts of Clang are not expecting to be able to do
that).

This should fix (and others):
https://lab.llvm.org/buildbot/#/builders/68/builds/38374

2 years ago[CostModel][X86] Convert AVX2 SRA by uniform constant to cost table
Simon Pilgrim [Fri, 26 Aug 2022 15:09:02 +0000 (16:09 +0100)]
[CostModel][X86] Convert AVX2 SRA by uniform constant to cost table

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

2 years ago[CostModel][X86] getArithmeticInstrCost - move SLM reduceVMULWidth cost handling...
Simon Pilgrim [Fri, 26 Aug 2022 14:09:50 +0000 (15:09 +0100)]
[CostModel][X86] getArithmeticInstrCost - move SLM reduceVMULWidth cost handling into the generic MUL handling

This is still SLM specific atm, but converting this to more closely match the codegen from reduceVMULWidth should be straightforward

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