platform/upstream/llvm.git
3 years ago[clang] Visit enum base specifiers in libIndex
Kadir Cetinkaya [Wed, 6 Oct 2021 19:59:04 +0000 (21:59 +0200)]
[clang] Visit enum base specifiers in libIndex

Fixes https://github.com/clangd/clangd/issues/878.

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

3 years ago[clang] Traverse enum base specifier in RAV
Kadir Cetinkaya [Wed, 6 Oct 2021 19:48:14 +0000 (21:48 +0200)]
[clang] Traverse enum base specifier in RAV

3 years ago[clang] Fix range for forward-declared enums
Kadir Cetinkaya [Wed, 6 Oct 2021 18:25:26 +0000 (20:25 +0200)]
[clang] Fix range for forward-declared enums

This used to span just the `[[enum foo]] : bar;` in the absence of a
body. This patch expands the range to cover the base specifier, so that the
various consumers can detect the full range of the decl.

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

3 years ago[lldb] Modernize TestBitfields
Raphael Isemann [Mon, 25 Oct 2021 10:51:31 +0000 (12:51 +0200)]
[lldb] Modernize TestBitfields

This just does the usual modernizations such as using new test functions where
possible, clang-formatting the source, avoiding manual process setup,
assert improvements (` assertTrue(a == b) -> assertEqual(a, b)`).

This doesn't add any new test cases but removes some dependence on unrelated
features where possible (e.g., structs declared in functions, using the standard
library to printf stuff or initialize objects).

3 years ago[AArch64][Driver][SVE] Allow -msve-vector-bits=<n>+ syntax to mean no maximum vscale
Bradley Smith [Thu, 14 Oct 2021 11:04:33 +0000 (11:04 +0000)]
[AArch64][Driver][SVE] Allow -msve-vector-bits=<n>+ syntax to mean no maximum vscale

This patch splits the existing SveVectorBits LangOpt into VScaleMin and
VScaleMax LangOpts such that we can represent such an option. The cc1
option has also been split into -mvscale-{min,max}=<n> options so that the
cc1 arguments better reflect the vscale_range IR attribute.

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

3 years ago[lldb] Also print index of child when ValueCheck fails
Raphael Isemann [Mon, 25 Oct 2021 10:51:19 +0000 (12:51 +0200)]
[lldb] Also print index of child when ValueCheck fails

Makes the test failure reason more obvious in cases where we have unnamed fields
or large records.

3 years ago[mlir][python] Infer result types in generated constructors whenever possible
Alex Zinenko [Thu, 14 Oct 2021 15:19:06 +0000 (17:19 +0200)]
[mlir][python] Infer result types in generated constructors whenever possible

In several cases, operation result types can be unambiguously inferred from
operands and attributes at operation construction time. Stop requiring the user
to provide these types as arguments in the ODS-generated constructors in Python
bindings. In particular, handle the SameOperandAndResultTypes and
FirstAttrDerivedResultType traits as well as InferTypeOpInterface using the
recently added interface support. This is a significant usability improvement
for IR construction, similar to what C++ ODS provides.

Depends On D111656

Reviewed By: gysit

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

3 years ago[mlir] support interfaces in Python bindings
Alex Zinenko [Thu, 14 Oct 2021 15:18:28 +0000 (17:18 +0200)]
[mlir] support interfaces in Python bindings

Introduce the initial support for operation interfaces in C API and Python
bindings. Interfaces are a key component of MLIR's extensibility and should be
available in bindings to make use of full potential of MLIR.

This initial implementation exposes InferTypeOpInterface all the way to the
Python bindings since it can be later used to simplify the operation
construction methods by inferring their return types instead of requiring the
user to do so. The general infrastructure for binding interfaces is defined and
InferTypeOpInterface can be used as an example for binding other interfaces.

Reviewed By: gysit

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

3 years ago[SVE][CodeGen] Enable reciprocal estimates for scalable fdiv/fsqrt
Kerry McLaughlin [Mon, 25 Oct 2021 08:59:24 +0000 (09:59 +0100)]
[SVE][CodeGen] Enable reciprocal estimates for scalable fdiv/fsqrt

This patch enables the use of reciprocal estimates for SVE
when both the -Ofast and -mrecip flags are used.

Reviewed By: david-arm, paulwalker-arm

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

3 years ago[InstCombine] Make TTI comment more forceful (NFC)
Nikita Popov [Mon, 25 Oct 2021 10:10:31 +0000 (12:10 +0200)]
[InstCombine] Make TTI comment more forceful (NFC)

To save people not familiar with InstCombine from creating patches
that are immediately rejected by policy.

3 years ago[SimplifyCFG] Sanity assert in iterativelySimplifyCFG
Max Kazantsev [Mon, 25 Oct 2021 09:43:11 +0000 (16:43 +0700)]
[SimplifyCFG] Sanity assert in iterativelySimplifyCFG

We observe a hang within iterativelySimplifyCFG due to infinite
loop execution. Currently, there is no limit to this loop, so
in case of bug it just works forever. This patch adds an assert
that will break it after 1000 iterations if it didn't converge.

3 years ago[ARM] Add a complex dotprod test case.
David Green [Mon, 25 Oct 2021 09:52:12 +0000 (10:52 +0100)]
[ARM] Add a complex dotprod test case.

3 years ago[lldb][NFC] Use llvm::Optional to refer to Optional
Raphael Isemann [Mon, 25 Oct 2021 09:35:15 +0000 (11:35 +0200)]
[lldb][NFC] Use llvm::Optional to refer to Optional

clang::Optional is just an alias used within Clang.

3 years ago[gn build] Port e1fdec875ff1
LLVM GN Syncbot [Mon, 25 Oct 2021 09:16:00 +0000 (09:16 +0000)]
[gn build] Port e1fdec875ff1

3 years ago[analyzer] Allow cmake options to be passed to satest container
Manas [Mon, 25 Oct 2021 09:15:40 +0000 (11:15 +0200)]
[analyzer] Allow cmake options to be passed to satest container

This patch selects all cmake options and passes them to global cmake
command while building LLVM inside satest docker container.

Prior to this, the cmake command was hard-coded and this would consume
a huge amount of memory while building. There was no support to pass
extra cmake options for the build, except for changing the command
manually. This patch allows testers to pass all "-D*" cmake options to
the build.

Reviewed By: vsavchenko

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

Patch by: @manas (Manas Gupta)

3 years ago[analyzer] Add std::string checker
Balazs Benics [Mon, 25 Oct 2021 09:15:40 +0000 (11:15 +0200)]
[analyzer] Add std::string checker

This patch adds a checker checking `std::string` operations.
At first, it only checks the `std::string` single `const char *`
constructor for nullness.
If It might be `null`, it will constrain it to non-null and place a note
tag there.

Reviewed By: martong

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

3 years agoFix windows build for 6fa1b4ff4
Pavel Labath [Mon, 25 Oct 2021 09:12:39 +0000 (11:12 +0200)]
Fix windows build for 6fa1b4ff4

3 years ago[lldb] [Utility/UriParser] Return results as 'struct URI'
Michał Górny [Fri, 22 Oct 2021 13:34:54 +0000 (15:34 +0200)]
[lldb] [Utility/UriParser] Return results as 'struct URI'

Return results of URI parsing as 'struct URI' instead of assigning them
via output parameters.

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

3 years ago[InstSimplify] Refactor invariant.group load folding
Nikita Popov [Sat, 23 Oct 2021 16:12:54 +0000 (18:12 +0200)]
[InstSimplify] Refactor invariant.group load folding

Currently strip.invariant/launder.invariant are handled by
constructing constant expressions with the intrinsics skipped.
This takes an alternative approach of accumulating the offset
using stripAndAccumulateConstantOffsets(), with a flag to look
through invariant.group intrinsics.

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

3 years ago[VPlan] Do not create dummy entry block (NFC).
Florian Hahn [Mon, 25 Oct 2021 08:40:11 +0000 (09:40 +0100)]
[VPlan] Do not create dummy entry block (NFC).

At the moment a dummy entry block is created at the beginning of VPlan
construction. This dummy block is later removed again.

This means it is not easy to identify the VPlan header block in a
general fashion, because during recipe creation it is the single
successor of the entry block, while later it is the entry block.

To make getting the header easier, just skip creating the dummy block.

Reviewed By: Ayal

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

3 years ago[lldb] Support serial port parity checking
Michał Górny [Sat, 23 Oct 2021 15:49:58 +0000 (17:49 +0200)]
[lldb] Support serial port parity checking

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

3 years ago[AArch64] Remove redundant ORRWrs which is generated by zero-extend
Jingu Kang [Thu, 30 Sep 2021 14:39:10 +0000 (15:39 +0100)]
[AArch64] Remove redundant ORRWrs which is generated by zero-extend

%3:gpr32 = ORRWrs $wzr, %2, 0
%4:gpr64 = SUBREG_TO_REG 0, %3, %subreg.sub_32

If AArch64's 32-bit form of instruction defines the source operand of ORRWrs,
we can remove the ORRWrs because the upper 32 bits of the source operand are
set to zero.

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

3 years agoRemove ConstString from DynamicLoader, JITLoader and Instruction plugin names
Pavel Labath [Thu, 21 Oct 2021 11:32:42 +0000 (13:32 +0200)]
Remove ConstString from DynamicLoader, JITLoader and Instruction plugin names

3 years ago[lldb/DWARF] Don't create lldb_private::Functions for gc'ed DW_TAG_subprograms
Pavel Labath [Fri, 22 Oct 2021 12:19:27 +0000 (14:19 +0200)]
[lldb/DWARF] Don't create lldb_private::Functions for gc'ed DW_TAG_subprograms

Front-load the first_valid_code_address check, so that we avoid creating
the function object (instead of simply refusing to use it in queries).

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

3 years ago[SCEVExpander] Minor cleanup in value reuse (NFC)
Nikita Popov [Mon, 25 Oct 2021 08:27:08 +0000 (10:27 +0200)]
[SCEVExpander] Minor cleanup in value reuse (NFC)

Use dyn_cast_or_null and convert one of the checks into an
assertion. SCEV is a per-function analysis.

3 years ago[NFC][MLIR][OpenMP] Splitting the WsLoop tests.
Shraiysh Vaishay [Mon, 25 Oct 2021 07:07:46 +0000 (12:37 +0530)]
[NFC][MLIR][OpenMP] Splitting the WsLoop tests.

Splitting the WsLoop tests they were getting harder to debug with the offsets over 100 for some of them.

Reviewed By: clementval

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

3 years ago[SCEV] Fix a warning on an unused lambda capture
Kazu Hirata [Mon, 25 Oct 2021 07:45:18 +0000 (00:45 -0700)]
[SCEV] Fix a warning on an unused lambda capture

This patch fixes:

  llvm/lib/Analysis/ScalarEvolution.cpp:12770:37: error: lambda
  capture 'this' is not used [-Werror,-Wunused-lambda-capture]

3 years ago[SCEV][NFC] Win some compile time from mass forgetMemoizedResults
Max Kazantsev [Mon, 25 Oct 2021 07:09:41 +0000 (14:09 +0700)]
[SCEV][NFC] Win some compile time from mass forgetMemoizedResults

Mass forgetMemoizedResults can be done more efficiently than bunch
of individual invocations of helper because we can traverse maps being
updated just once, rather than doing this for each invidivual SCEV.

Should be NFC and supposedly improves compile time.

Differential Revision: https://reviews.llvm.org/D112294
Reviewed By: reames

3 years ago[SCEV][NFC] Apply mass forgetMemoizedResults queries where possible
Max Kazantsev [Mon, 25 Oct 2021 06:50:49 +0000 (13:50 +0700)]
[SCEV][NFC] Apply mass forgetMemoizedResults queries where possible

When forgetting multiple SCEVs, rather than doing this one by one, we can
instead use mass updates. We plan to make them more efficient than they
are now, potentially improving compile time.

Differential Revision: https://reviews.llvm.org/D111602
Reviewed By: reames

3 years ago[SCEV][NFC] Introduce API for mass forgetMemoizedResults query
Max Kazantsev [Mon, 25 Oct 2021 06:32:53 +0000 (13:32 +0700)]
[SCEV][NFC] Introduce API for mass forgetMemoizedResults query

This patch changes signature of forgetMemoizedResults to be able to work with
multiple SCEVs. Usage will come in follow-ups. We also plan to optimize it in the
future to work faster than individual invalidation updates. Should not change
behavior in any sense.

Split-off from D111602.

Differential Revision: https://reviews.llvm.org/D112293
Reviewed By: reames

3 years ago[NFC] Update test/CodeGen/RISCV/select-constant-xor.ll to use RV --check-prefix
Shivam Gupta [Mon, 25 Oct 2021 06:28:58 +0000 (11:58 +0530)]
[NFC] Update test/CodeGen/RISCV/select-constant-xor.ll to use RV --check-prefix

This is only for consistency with test cases.

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

3 years ago[mlir][Linalg] NFC - Reorganize options nesting.
Nicolas Vasilache [Sun, 24 Oct 2021 22:34:38 +0000 (22:34 +0000)]
[mlir][Linalg] NFC - Reorganize options nesting.

This removes duplication and makes nesting more clear.
It also reduces the amount of changes necessary for exposing future options.

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

3 years ago[NFC][SCEV] Do not track users of SCEVConstants
Max Kazantsev [Mon, 25 Oct 2021 05:30:46 +0000 (12:30 +0700)]
[NFC][SCEV] Do not track users of SCEVConstants

Follow-up from D112295, suggested by Nikita: we can avoid tracking
users of SCEVConstants because dropping their cached info is unlikely
to give any new prospects for fact inference, and it should not introduce
any correctness problems.

3 years ago[SCEV][NFC] API for tracking of SCEV users
Max Kazantsev [Mon, 25 Oct 2021 04:36:25 +0000 (11:36 +0700)]
[SCEV][NFC] API for tracking of SCEV users

This patch introduces API that keeps track of SCEVs users of
another SCEVs, required to handle invalidations of users along
with operands that comes in follow-up patches.

Differential Revision: https://reviews.llvm.org/D112295
Reviewed By: reames

3 years agoAdd a clear() method on the PassManager (NFC)
Mehdi Amini [Mon, 25 Oct 2021 02:49:46 +0000 (02:49 +0000)]
Add a clear() method on the PassManager (NFC)

This allows to clear an OpPassManager and populated it again with a new
pipeline, while preserving all the other options (including instrumentations).

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

3 years ago[PowerPC] common chains to reuse offsets to reduce register pressure.
Chen Zheng [Mon, 25 Oct 2021 03:27:16 +0000 (03:27 +0000)]
[PowerPC] common chains to reuse offsets to reduce register pressure.

Add a new preparation pattern in PPCLoopInstFormPrep pass to reduce register
pressure.

Reviewed By: jsji

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

3 years ago[mlir] Give GenericAtomicRMW region a name
Jacques Pienaar [Mon, 25 Oct 2021 02:50:15 +0000 (19:50 -0700)]
[mlir] Give GenericAtomicRMW region a name

Some tools assume all regions have names, provide one to avoid breakage.

3 years ago[AIX] Add i128 arg split tests
Jinsong Ji [Mon, 25 Oct 2021 01:52:03 +0000 (01:52 +0000)]
[AIX] Add i128 arg split tests

Address comments in D111078.

Reviewed By: hubert.reinterpretcast, lkail

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

3 years agoRevert "[NFC][sanitizer] constexpr a few functions"
Vitaly Buka [Mon, 25 Oct 2021 02:13:43 +0000 (19:13 -0700)]
Revert "[NFC][sanitizer] constexpr a few functions"

This reverts a part of commit 8cd51a69e5b4cf9513eb4f416f113058ebd8f257
and 5bf24f0581ee7ab9971b4050497375464b894c59 to fix Windows.

3 years ago[RISCV] Rename vmulh-sdnode-rv32.ll and add rv64 command line. NFC
Craig Topper [Mon, 25 Oct 2021 01:41:32 +0000 (18:41 -0700)]
[RISCV] Rename vmulh-sdnode-rv32.ll and add rv64 command line. NFC

3 years ago[NFC][sanitizer] Use power of two in TwoLevelMap
Vitaly Buka [Mon, 25 Oct 2021 00:34:13 +0000 (17:34 -0700)]
[NFC][sanitizer] Use power of two in TwoLevelMap

Using divisions by non power of two makes
a difference on x86_64 and aarch64 benchmarks.

3 years ago[NFC][sanitizer] DCHECKs in hot code
Vitaly Buka [Mon, 25 Oct 2021 00:05:50 +0000 (17:05 -0700)]
[NFC][sanitizer] DCHECKs in hot code

3 years ago[NFC][sanitizer] constexpr a few functions
Vitaly Buka [Sun, 24 Oct 2021 23:21:28 +0000 (16:21 -0700)]
[NFC][sanitizer] constexpr a few functions

3 years ago[mlir] Switch arith, llvm, std & shape dialects to accessors prefixed both form.
Jacques Pienaar [Mon, 25 Oct 2021 01:36:33 +0000 (18:36 -0700)]
[mlir] Switch arith, llvm, std & shape dialects to accessors prefixed both form.

Following
https://llvm.discourse.group/t/psa-ods-generated-accessors-will-change-to-have-a-get-prefix-update-you-apis/4476,
this follows flipping these dialects to _Both prefixed form. This
changes the accessors to have a prefix. This was possibly mostly without
breaking breaking changes if the existing convenience methods were used.

(https://github.com/jpienaar/llvm-project/blob/main/clang-tools-extra/clang-tidy/misc/AddGetterCheck.cpp
was used to migrate the callers post flipping, using the output from
Operator.cpp)

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

3 years ago[ELF] Remove ignored options that likely nobody uses
Fangrui Song [Mon, 25 Oct 2021 01:29:45 +0000 (18:29 -0700)]
[ELF] Remove ignored options that likely nobody uses

GNU ld doesn't support `--no-pic-executable`.

`-p` has been removed from likely the only use case (Linux kernel) for over 2.5 years: https://git.kernel.org/linus/091bb549f7722723b284f63ac665e2aedcf9dec9

`--no-add-needed` was the pre-binutils-2.23 spelling for `--no-copy-dt-needed-entries`.
The legacy alias is irrelevant in 2021.

3 years ago[mlir] Rename to avoid overlap in accessor prefixing
Jacques Pienaar [Mon, 25 Oct 2021 01:17:09 +0000 (18:17 -0700)]
[mlir] Rename to avoid overlap in accessor prefixing

Split out renaming from D112383 into standalone change.

3 years ago[Target, Transforms] Use predecessors instead of pred_begin and pred_end (NFC)
Kazu Hirata [Mon, 25 Oct 2021 00:35:35 +0000 (17:35 -0700)]
[Target, Transforms] Use predecessors instead of pred_begin and pred_end (NFC)

3 years agoUse llvm::any_of and llvm::none_of (NFC)
Kazu Hirata [Mon, 25 Oct 2021 00:35:33 +0000 (17:35 -0700)]
Use llvm::any_of and llvm::none_of (NFC)

3 years agopre-comitting tests for D110865
Matthias Braun [Sun, 24 Oct 2021 23:39:14 +0000 (16:39 -0700)]
pre-comitting tests for D110865

3 years agoX86InstrInfo: Look across basic blocks in optimizeCompareInstr
Matthias Braun [Fri, 24 Sep 2021 20:41:54 +0000 (13:41 -0700)]
X86InstrInfo: Look across basic blocks in optimizeCompareInstr

This extends `optimizeCompareInstr` to continue the backwards search
when it reached the beginning of a basic block. If there is a single
predecessor block then we can just continue the search in that block and
mark the EFLAGS register as live-in.

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

3 years agoX86InstrInfo: Refactor and cleanup optimizeCompareInstr
Matthias Braun [Fri, 24 Sep 2021 18:43:43 +0000 (11:43 -0700)]
X86InstrInfo: Refactor and cleanup optimizeCompareInstr

This changes the first part of `optimizeCompareInstr` being split into a
loop with a forward scan for cases that re-use zero flags from a
producer in case of compare with zero and a backward scan for finding an
instruction equivalent to a compare.

The code now uses a single backward scan searching for the next
instructions that reads or writes EFLAGS.

Also:
- Add comments giving examples for the 3 cases handled.
- Check `MI` which contains the result of the zero-compare cases,
  instead of re-checking `IsCmpZero`.
- Tweak coding style in some loops.
- Add new MIR based tests that test the optimization in isolation.

This also removes a check for flag readers in situations like this:
```
= SUB32rr %0, %1, implicit-def $eflags
...  we no longer stop when there are $eflag users here
CMP32rr %0, %1   ; will be removed
...
```

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

3 years agoTreat branch on poison as immediate UB (under an off by default flag)
Philip Reames [Sun, 24 Oct 2021 19:39:26 +0000 (12:39 -0700)]
Treat branch on poison as immediate UB (under an off by default flag)

The LangRef clearly states that branching on a undef or poison value is immediate undefined behavior, but historically, we have not been consistent about implementing that interpretation in the optimizer. Historically, we used (in some cases) a more relaxed model which essentially looked for provable UB along both paths which was control dependent on the condition. However, we've never been 100% consistent here. For instance SCEV uses the strong model for increments which form AddRecs (and only addrecs).

At the moment, the last big blocker for finally making this switch is enabling the fix landed in D106041. Loop unswitching (in it's classic form) is incorrect as it creates many "branch on poisons" when unswitching conditions originally unreachable within the loop.

This change adds a flag to value tracking which allows to easily test the optimization potential of treating branch on poison as immediate UB. It's intended to help ease work on getting us finally through this transition and avoid multiple independent rediscovers of the same issues.

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

3 years ago[instcombine] Fix oss-fuzz 39934 (mul matcher can match non-instruction)
Philip Reames [Sun, 24 Oct 2021 01:07:21 +0000 (18:07 -0700)]
[instcombine] Fix oss-fuzz 39934 (mul matcher can match non-instruction)

Fixes a crash observed by oss-fuzz in 39934.  Issue at hand is that code expects a pattern match on m_Mul to imply the operand is a mul instruction, however mul constexprs are also valid here.

3 years ago[sanitizer] Remove tag from StackDepotNode
Vitaly Buka [Tue, 12 Oct 2021 06:58:04 +0000 (23:58 -0700)]
[sanitizer] Remove tag from StackDepotNode

And share storage with size.

Depends on D111615.

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

3 years ago[sanitizer] Remove use_count from StackDepotNode
Vitaly Buka [Sat, 16 Oct 2021 20:31:59 +0000 (13:31 -0700)]
[sanitizer] Remove use_count from StackDepotNode

This is msan/dfsan data which does not need waste cache
of other sanitizers.

Depends on D111614.

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

3 years ago[ARC] Fix -Wunused-variable. NFC
Fangrui Song [Sun, 24 Oct 2021 17:31:44 +0000 (10:31 -0700)]
[ARC] Fix -Wunused-variable. NFC

3 years ago[llvm] Call *(Set|Map)::erase directly (NFC)
Kazu Hirata [Sun, 24 Oct 2021 16:32:59 +0000 (09:32 -0700)]
[llvm] Call *(Set|Map)::erase directly (NFC)

We can erase an item in a set or map without checking its membership
first.

3 years agoUse llvm::is_contained (NFC)
Kazu Hirata [Sun, 24 Oct 2021 16:32:57 +0000 (09:32 -0700)]
Use llvm::is_contained (NFC)

3 years ago[MLIR] FlatAffineValueConstraints: Fix bug in mergeSymbolIds
Groverkss [Sun, 24 Oct 2021 14:36:03 +0000 (20:06 +0530)]
[MLIR] FlatAffineValueConstraints: Fix bug in mergeSymbolIds

This patch fixes a bug in implementation `mergeSymbolIds` where symbol
identifiers were not unique after merging them. Asserts for checking uniqueness
before and after the merge are also added. The asserts checking uniqueness
after the merge fail without the fix on existing test cases.

Reviewed By: arjunp

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

3 years ago[BasicAA] Add range test with multiple indices (NFC)
Nikita Popov [Sun, 24 Oct 2021 14:10:16 +0000 (16:10 +0200)]
[BasicAA] Add range test with multiple indices (NFC)

3 years ago[x86] add tests for variants of usubsat; NFC
Sanjay Patel [Sun, 24 Oct 2021 12:08:30 +0000 (08:08 -0400)]
[x86] add tests for variants of usubsat; NFC

3 years ago[AMDGPU] add tests for alternate form of usubsat; NFC
Sanjay Patel [Fri, 22 Oct 2021 20:16:53 +0000 (16:16 -0400)]
[AMDGPU] add tests for alternate form of usubsat; NFC

3 years ago[TableGen] Use llvm::erase_value (NFC)
Kazu Hirata [Sun, 24 Oct 2021 03:41:48 +0000 (20:41 -0700)]
[TableGen] Use llvm::erase_value (NFC)

3 years agoUse StringRef::contains (NFC)
Kazu Hirata [Sun, 24 Oct 2021 03:41:46 +0000 (20:41 -0700)]
Use StringRef::contains (NFC)

3 years agoAdd support of the next Ubuntu (Ubuntu 22.04 - Jammy Jellyfish)
Sylvestre Ledru [Sat, 23 Oct 2021 21:55:50 +0000 (23:55 +0200)]
Add support of the next Ubuntu (Ubuntu 22.04 - Jammy Jellyfish)

It is going to be a LTS release

3 years ago[X86] findEltLoadSrc - fix shift amount variable name. NFCI.
Simon Pilgrim [Sat, 23 Oct 2021 20:06:03 +0000 (21:06 +0100)]
[X86] findEltLoadSrc - fix shift amount variable name. NFCI.

Fix the copy + paste, renaming shift amt from Idx to Amt

3 years ago[InstSimplify] Simplify fetching of index size (NFC)
Nikita Popov [Sat, 23 Oct 2021 20:07:31 +0000 (22:07 +0200)]
[InstSimplify] Simplify fetching of index size (NFC)

Directly fetch the size instead of going through the index type
first.

3 years agoRevert "[analyzer][solver] Introduce reasoning for not equal to operator"
Balazs Benics [Sat, 23 Oct 2021 19:01:59 +0000 (21:01 +0200)]
Revert "[analyzer][solver] Introduce reasoning for not equal to operator"

This reverts commit cac8808f154cef6446e507d55aba5721c3bd5352.

 #5 0x00007f28ec629859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x25859)
 #6 0x00007f28ec629729 (/lib/x86_64-linux-gnu/libc.so.6+0x25729)
 #7 0x00007f28ec63af36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
 #8 0x00007f28ecc2cc46 llvm::APInt::compareSigned(llvm::APInt const&) const (libLLVMSupport.so.14git+0xeac46)
 #9 0x00007f28e7bbf957 (anonymous namespace)::SymbolicRangeInferrer::VisitBinaryOperator(clang::ento::RangeSet, clang::BinaryOperatorKind, clang::ento::RangeSet, clang::QualType) (libclangStaticAnalyzerCore.so.14git+0x1df957)
 #10 0x00007f28e7bbf2db (anonymous namespace)::SymbolicRangeInferrer::infer(clang::ento::SymExpr const*) (libclangStaticAnalyzerCore.so.14git+0x1df2db)
 #11 0x00007f28e7bb2b5e (anonymous namespace)::RangeConstraintManager::assumeSymNE(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>, clang::ento::SymExpr const*, llvm::APSInt const&, llvm::APSInt const&) (libclangStaticAnalyzerCore.so.14git+0x1d2b5e)
 #12 0x00007f28e7bc67af clang::ento::RangedConstraintManager::assumeSymUnsupported(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>, clang::ento::SymExpr const*, bool) (libclangStaticAnalyzerCore.so.14git+0x1e67af)
 #13 0x00007f28e7be3578 clang::ento::SimpleConstraintManager::assumeAux(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>, clang::ento::NonLoc, bool) (libclangStaticAnalyzerCore.so.14git+0x203578)
 #14 0x00007f28e7be33d8 clang::ento::SimpleConstraintManager::assume(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>, clang::ento::NonLoc, bool) (libclangStaticAnalyzerCore.so.14git+0x2033d8)
 #15 0x00007f28e7be32fb clang::ento::SimpleConstraintManager::assume(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>, clang::ento::DefinedSVal, bool) (libclangStaticAnalyzerCore.so.14git+0x2032fb)
 #16 0x00007f28e7b15dbc clang::ento::ConstraintManager::assumeDual(llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>, clang::ento::DefinedSVal) (libclangStaticAnalyzerCore.so.14git+0x135dbc)
 #17 0x00007f28e7b4780f clang::ento::ExprEngine::evalEagerlyAssumeBinOpBifurcation(clang::ento::ExplodedNodeSet&, clang::ento::ExplodedNodeSet&, clang::Expr const*) (libclangStaticAnalyzerCore.so.14git+0x16780f)

This is known to be triggered on curl, tinyxml2, tmux, twin and on xerces.
But @bjope also reported similar crashes.
So, I'm reverting it to make our internal bots happy again.

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

3 years ago[ConstantFolding] Accept offset in ConstantFoldLoadFromConstPtr (NFCI)
Nikita Popov [Sat, 23 Oct 2021 15:58:07 +0000 (17:58 +0200)]
[ConstantFolding] Accept offset in ConstantFoldLoadFromConstPtr (NFCI)

As this API is now internally offset-based, we can accept a starting
offset and remove the need to create a temporary bitcast+gep
sequence to perform an offset load. The API now mirrors the
ConstantFoldLoadFromConst() API.

3 years agoEnsure newlines at the end of files (NFC)
Kazu Hirata [Sat, 23 Oct 2021 15:45:29 +0000 (08:45 -0700)]
Ensure newlines at the end of files (NFC)

3 years ago[llvm] Use StringRef::contains (NFC)
Kazu Hirata [Sat, 23 Oct 2021 15:45:27 +0000 (08:45 -0700)]
[llvm] Use StringRef::contains (NFC)

3 years ago[Orc][examples] Re-enable test for LLJITWithRemoteDebugging
Stefan Gränitz [Sat, 23 Oct 2021 13:54:38 +0000 (15:54 +0200)]
[Orc][examples] Re-enable test for LLJITWithRemoteDebugging

The test was removed temporarily in a539a847c9428e36722dcb43a1c953c9d66b7f0b to aid switching the RPC API in use in the LLJITWithRemoteDebugging example.

Reviewed By: lhames

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

3 years ago[ConstantFolding] Remove ConstantFoldLoadThroughGEPIndices() API (NFC)
Nikita Popov [Sat, 23 Oct 2021 14:58:09 +0000 (16:58 +0200)]
[ConstantFolding] Remove ConstantFoldLoadThroughGEPIndices() API (NFC)

The last user of this API went away in
4f5e9a2bb28e1cf4a12c9330f52e664542400ec7.

3 years agoRevert "[mlir][Linalg] NFC - Reorganize options nesting."
Nicolas Vasilache [Sat, 23 Oct 2021 13:46:22 +0000 (13:46 +0000)]
Revert "[mlir][Linalg] NFC - Reorganize options nesting."

This reverts commit 4703a07e6cc170666abb62d91307978ab4992d9c.

Didnt' mean to push this yet, sorry about the noise.

3 years ago[SCEV] Remove computeLoadConstantCompareExitLimit() (NFCI)
Nikita Popov [Fri, 22 Oct 2021 19:35:08 +0000 (21:35 +0200)]
[SCEV] Remove computeLoadConstantCompareExitLimit() (NFCI)

The functionality of this method is already covered by
computeExitCountExhaustively() in a more general fashion. It was
added at a time when exhaustive exit count calculation did not
support constant folding loads yet. I double checked that dropping
this code causes no binary changes in test-suite.

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

3 years ago[mlir][Linalg] NFC - Reorganize options nesting.
Nicolas Vasilache [Sat, 23 Oct 2021 13:01:40 +0000 (13:01 +0000)]
[mlir][Linalg] NFC - Reorganize options nesting.

This removes duplication and makes nesting more clear.
It also reduces the amount of changes necessary for exposing future options.

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

3 years ago[mlir] Add polynomial approximation for vectorized math::Rsqrt
Emilio Cota [Sat, 23 Oct 2021 11:48:24 +0000 (04:48 -0700)]
[mlir] Add polynomial approximation for vectorized math::Rsqrt

This patch adds a polynomial approximation that matches the
approximation in Eigen.

Note that the approximation only applies to vectorized inputs;
the scalar rsqrt is left unmodified.

The approximation is protected with a flag since it emits an AVX2
intrinsic (generated via the X86Vector). This is the only reasonably
clean way that I could find to generate the exact approximation that
I wanted (i.e. an identical one to Eigen's).

I considered two alternatives:

1. Introduce a Rsqrt intrinsic in LLVM, which doesn't exist yet.
   I believe this is because there is no definition of Rsqrt that
   all backends could agree on, since hardware instructions that
   implement it have widely varying degrees of precision.
   This is something that the standard could mandate, but Rsqrt is
   not part of IEEE754, so I don't think this option is feasible.

2. Emit fdiv(1.0, sqrt) with fast math flags to allow reciprocal
   transformations. Although portable, this doesn't allow us
   to generate exactly the code we want; it is the LLVM backend,
   and not MLIR, who controls what code is generated based on the
   target CPU.

Reviewed By: ezhulenev

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

3 years ago[www] Fix Ninja build instructions on Windows
Frederik Seiffert [Sat, 23 Oct 2021 10:37:36 +0000 (16:07 +0530)]
[www] Fix Ninja build instructions on Windows

The `clang` target used in the line below is only generated with `LLVM_ENABLE_PROJECTS=clang`.

Without this change, running `ninja clang` will fail with:
```
ninja: error: unknown target 'clang', did you mean 'clean'?
```

Reviewed By: xgupta

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

3 years ago[lldb] [Host/SerialPort] Fix build with GCC 7
Martin Storsjö [Sat, 23 Oct 2021 09:52:55 +0000 (12:52 +0300)]
[lldb] [Host/SerialPort] Fix build with GCC 7

3 years ago[lldb] [Host/FreeBSD] Remove unused variable (NFC)
Michał Górny [Sat, 23 Oct 2021 09:38:11 +0000 (11:38 +0200)]
[lldb] [Host/FreeBSD] Remove unused variable (NFC)

3 years ago[clang-tidy] Tidy up spelling, grammar, and inconsistencies in documentation (NFC)
Salman Javed [Sat, 23 Oct 2021 07:07:36 +0000 (00:07 -0700)]
[clang-tidy] Tidy up spelling, grammar, and inconsistencies in documentation (NFC)

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

3 years ago[NFC] Correct arc draft option
Shivam Gupta [Sat, 23 Oct 2021 06:51:31 +0000 (12:21 +0530)]
[NFC] Correct arc draft option

3 years ago[X86] Don't add implicit REP prefix to VIA PadLock xstore
Jessica Clarke [Sat, 23 Oct 2021 00:56:05 +0000 (01:56 +0100)]
[X86] Don't add implicit REP prefix to VIA PadLock xstore

Commit 8fa3e8fa1492 added an implicit REP prefix to all VIA PadLock
instructions, but GNU as doesn't add one to xstore, only all the others.
This resulted in a kernel panic regression in FreeBSD upon updating to
LLVM 11 (https://bugs.freebsd.org/259218) which includes the commit in
question. This partially reverts that commit.

Reviewed By: craig.topper

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

3 years ago[NFC][X86] Add MC tests for all untested VIA PadLock instructions
Jessica Clarke [Sat, 23 Oct 2021 00:55:56 +0000 (01:55 +0100)]
[NFC][X86] Add MC tests for all untested VIA PadLock instructions

We currently only test the encoding of xstore but none of the other
instructions, which should all have their implicit REP prefix be
verified as working.

Reviewed By: craig.topper

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

3 years ago[flang] Fix buildbot (new warnings on old code)
peter klausler [Fri, 22 Oct 2021 23:39:16 +0000 (16:39 -0700)]
[flang] Fix buildbot (new warnings on old code)

The clang-aarch64-full-2stage buildbot is complaining about a
warning with three instances in f18 code (none modified recently).
The warning is for using the | bitwise OR operator on bool operands.

In one instance, the bitwise operator was being used instead of the
logical || operator in order to avoid short-circuting.  The fix
requires using some temporary variables.  In the other two instances,
the bitwise operator seemed more idiomatic in context, but can be
replaced without harm with the logical operator.

Pushing without review as confidence is high and nobody wants
a buildbot to stay sad for long.

3 years ago[tools, utils] Use StringRef::contains (NFC)
Kazu Hirata [Sat, 23 Oct 2021 00:22:13 +0000 (17:22 -0700)]
[tools, utils] Use StringRef::contains (NFC)

3 years ago[gn build] Port e18ea6f2946a
LLVM GN Syncbot [Fri, 22 Oct 2021 23:26:01 +0000 (23:26 +0000)]
[gn build] Port e18ea6f2946a

3 years agoSupport: Skip buffering buffer_unique_ostream's owned stream
Duncan P. N. Exon Smith [Thu, 23 Sep 2021 03:31:43 +0000 (23:31 -0400)]
Support: Skip buffering buffer_unique_ostream's owned stream

Change buffer_unique_ostream's constructor to call
raw_ostream::SetUnbuffered() on its owned stream. Otherwise,
buffer_unique_ostream's destructor could cause the owned stream to
temporarily allocate a buffer only to be immediately flushed.

Also add some tests for buffer_ostream and buffer_unique_ostream. Use
the same naming scheme as other raw_ostream-related tests (e.g.,
`raw_ostreamTest` for the fixture, `raw_ostream_test.cpp` for the
filename).

(I considered changing buffer_ostream in the same way (calling
SetUnbuffered on the referenced stream), but that seemed like overreach
since the client may have more things to write.)

(I considered merging buffer_ostream and buffer_unique_ostream into a
single class (with a `raw_ostream&` and a `std::unique_ptr` that is only
sometimes used), but that makes the class bigger and the small amount of
code deduplication seems uncompelling.)

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

3 years ago[flang] Support legacy usage of 'A' edit descriptors for integer & real
peter klausler [Thu, 21 Oct 2021 20:33:07 +0000 (13:33 -0700)]
[flang] Support legacy usage of 'A' edit descriptors for integer & real

The 'A' edit descriptor once served as a form of raw I/O of bytes
to/from variables that weren't of type CHARACTER (which itself
didn't exist until F'77).  This usage was especially common for
output of numeric variables that had been initialized with Hollerith.

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

3 years ago[flang] Fix NAMELIST input bug with multiple subscript triplets
peter klausler [Thu, 21 Oct 2021 21:13:21 +0000 (14:13 -0700)]
[flang] Fix NAMELIST input bug with multiple subscript triplets

NAMELIST input can contain array subscripts with triplet notation.
The calculation of the default effective stride for the constructed
array descriptor was simply incorrect after the first dimension.

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

3 years ago[flang] Fix DOT_PRODUCT for logical
peter klausler [Thu, 21 Oct 2021 19:47:46 +0000 (12:47 -0700)]
[flang] Fix DOT_PRODUCT for logical

A build-time check in a template class instantiation was applying
a test that's meaningful only for numeric types.

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

3 years ago[flang] Extension: allow tabs in output format strings
peter klausler [Thu, 21 Oct 2021 21:47:55 +0000 (14:47 -0700)]
[flang] Extension: allow tabs in output format strings

A CHARACTER variable used as an output format may contain
unquoted tab characters, which are treated as if they had
been quoted.  This is an extension supported by all other
Fortran compilers to which I have access.

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

3 years ago[flang] Fix crash on empty formatted external READs
peter klausler [Fri, 22 Oct 2021 19:22:42 +0000 (12:22 -0700)]
[flang] Fix crash on empty formatted external READs

ExternalFileUnit::BeginReadingRecord() must be called at least once
during an external formatted READ statement before FinishReadingRecord().
In the case of a formatted external READ with no data items, the call
to finish processing of the format (which might have lingering control
items that need doing) was taking place before the call to BeginReadingRecord
from ExternalIoStatementState::EndIoStatement.  Add a call to
BeginReadingRecord on this path.

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

3 years ago[libomptarget] Run GPU offloading tests on both new and old runtime
Jon Chesterfield [Fri, 22 Oct 2021 22:28:42 +0000 (23:28 +0100)]
[libomptarget] Run GPU offloading tests on both new and old runtime

Implemented by patching python config instead of modifying all
the tests so that -generic and XFAIL work as usual. Expectation is for
this to be reverted once the old runtime is deleted.

Reviewed By: Meinersbur

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

3 years ago[BasicAA] Model implicit trunc of GEP indices
Nikita Popov [Wed, 29 Sep 2021 20:18:54 +0000 (22:18 +0200)]
[BasicAA] Model implicit trunc of GEP indices

GEP indices larger than the GEP index size are implicitly truncated
to the index size. BasicAA currently doesn't model this, resulting
in incorrect alias analysis results.

Fix this by explicitly modelling truncation in CastedValue in the
same way we do zext and sext. Additionally we need to disable a
number of optimizations for truncated values, in particular
"non-zero" and "non-equal" may no longer hold after truncation.
I believe the constant offset heuristic is also not necessarily
correct for truncated values, but wasn't able to come up with a
test for that one.

A possible followup here would be to use the new mechanism to
model explicit trunc as well (which should be much more common,
as it is the canonical form). This is straightforward, but omitted
here to separate the correctness fix from the analysis improvement.

(Side note: While I say "index size" above, BasicAA currently uses
the pointer size instead. Something for another day...)

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

3 years ago[flang] Speed common runtime cases of DOT_PRODUCT & MATMUL
Peter Klausler [Tue, 19 Oct 2021 18:30:45 +0000 (11:30 -0700)]
[flang] Speed common runtime cases of DOT_PRODUCT & MATMUL

Look for contiguous numeric argument arrays at runtime and
use specialized code for them.

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

3 years ago[flang] Fix generic resolution case
peter klausler [Tue, 19 Oct 2021 18:34:57 +0000 (11:34 -0700)]
[flang] Fix generic resolution case

Don't try to convert INTEGER argument expressions to the kind of
the dummy argument when performing generic resolution; specific
procedures may be distinguished only by their kinds.

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

3 years ago[flang] Support NAMELIST input of short arrays
peter klausler [Wed, 20 Oct 2021 20:56:47 +0000 (13:56 -0700)]
[flang] Support NAMELIST input of short arrays

NAMELIST array input does not need to fully define an array.
If another input item begins after at least one element,
it ends input into the array and the remaining items are
not modified.

The tricky part of supporting this feature is that it's not
always easy to determine whether the next non-blank thing in
the input is a value or the next item's name, esp. in the case
of logical data where T and F can be names.  E.g.,

  &group logicalArray = t f f t
      = 1 /

should read three elements into "logicalArray" and then read
an integer or real variable named "t".

So the I/O runtime has to do some look-ahead to determine whether
the next thing in the input is a name followed by '=', '(', or '%'.
Since the '=' may be on a later record, possibly with intervening
NAMELIST comments, the runtime has to support a general form of
saving and restoring its current position.  The infrastructure
in the I/O runtime already has to support repositioning for
list-directed repetition, even on non-positionable input sources
like terminals and sockets; this patch adds an internal RAII API
to make it easier to save a position and then do arbitrary
look-ahead.

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

3 years ago[lld-macho] Implement -oso_prefix
Vy Nguyen [Fri, 22 Oct 2021 02:38:12 +0000 (22:38 -0400)]
[lld-macho] Implement -oso_prefix

https://bugs.llvm.org/show_bug.cgi?id=50229

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

3 years ago[mlir][Linalg] Retire CodegenStrategy::transform
Nicolas Vasilache [Fri, 22 Oct 2021 12:04:32 +0000 (12:04 +0000)]
[mlir][Linalg] Retire CodegenStrategy::transform

Instead each pass should constructed a nested OpPassManager and runPipeline on that.

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