platform/upstream/llvm.git
3 years ago[docs][GlobalISel]Adding info for G_JUMP_TABLE generic opcode
pooja2299 [Thu, 5 Aug 2021 18:24:56 +0000 (23:54 +0530)]
[docs][GlobalISel]Adding info for G_JUMP_TABLE generic opcode

Added description of jump table and G_JUMP_TABLE opcode.

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

3 years ago[ARM] Workaround tailpredication min/max costmodel
David Green [Mon, 30 Aug 2021 18:19:51 +0000 (19:19 +0100)]
[ARM] Workaround tailpredication min/max costmodel

The min/max intrinsics are not yet canonical, but when they are the tail
predications analysis will change from treating them like icmp to
treating them like intrinsics. Unfortunately, they can currently produce
better code by not being tail predicated thanks to the vectorizer picking
higher VF's and the backend folding to better instructions (especially
for saturate patterns). In the long run we will need to improve the
vectorizers cost modelling, recognizing the instruction directly, but in
the meantime this treats min/max as before to prevent performance
regressions.

3 years ago[lld/mac] Tweak estimateStubsInRangeVA a bit
Nico Weber [Sat, 28 Aug 2021 03:27:03 +0000 (23:27 -0400)]
[lld/mac] Tweak estimateStubsInRangeVA a bit

- Move a few variables closer to their uses, remove some completely
  (no behavior change)
- Add some comments
- Make maxPotentialThunks include calls to stubs. It's possible that
  an earlier call to a stub late in the stub table will need a thunk,
  and that inserted thunk could push a stub earlier in the stub table
  out of range. This is unlikely to happen, but usually there are
  way fewer stub calls than non-stub calls, so if we're doing a
  conservative approximation here we might as well do it correctly.
  (For chromium's unit_tests target, 134421/242639 stub calls are
  direct calls without this change, compared to 134408/242639 with
  this change)

No real, meaningful behavior difference.

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

3 years ago[InstrInfo] Use 64-bit immediates for analyzeCompare() (NFCI)
Nikita Popov [Sat, 28 Aug 2021 19:29:31 +0000 (21:29 +0200)]
[InstrInfo] Use 64-bit immediates for analyzeCompare() (NFCI)

The backend generally uses 64-bit immediates (e.g. what
MachineOperand::getImm() returns), so use that for analyzeCompare()
and optimizeCompareInst() as well. This avoids truncation for
targets that support immediates larger 32-bit. In particular, we
can avoid the bugprone value normalization hack in the AArch64
target.

This is a followup to D108076.

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

3 years ago[libc++abi] Avoid the warning: "__EXCEPTIONS" is not defined, evaluates to 0 [-Werror...
Xiang Xiao [Mon, 30 Aug 2021 17:34:20 +0000 (13:34 -0400)]
[libc++abi] Avoid the warning: "__EXCEPTIONS" is not defined, evaluates to 0 [-Werror=undef]

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

3 years agoDebugInfo: Correct printing empty template parameter packs
David Blaikie [Mon, 30 Aug 2021 17:06:00 +0000 (10:06 -0700)]
DebugInfo: Correct printing empty template parameter packs

Empty packs in the non-final position would result in an extra ", ".
Empty packs in the final position would result in missing the space
between trailing >>.

3 years agoRevert "[SLP]Improve graph reordering."
Mikhail Goncharov [Mon, 30 Aug 2021 17:16:44 +0000 (19:16 +0200)]
Revert "[SLP]Improve graph reordering."

This reverts commit 84cbd71c95923f9912512f3051c6ab548a99e016.

This commit breaks one of the internal tests. As agreed with Alexey I
will provide the reproducer later.

3 years ago[CSSPGO] Avoid repeatedly computing md5 hash code for pseudo probe inline contexts.
Hongtao Yu [Wed, 25 Aug 2021 18:57:48 +0000 (11:57 -0700)]
[CSSPGO] Avoid repeatedly computing md5 hash code for pseudo probe inline contexts.

Md5 hashing is expansive. Using a hash map to look up already computed GUID for dwarf names. Saw a 2% build time improvement on an internal large application.

Reviewed By: wenlei

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

3 years ago[AsmParser] Support %ty* in force-opaque-pointers mode
Nikita Popov [Sat, 28 Aug 2021 20:26:45 +0000 (22:26 +0200)]
[AsmParser] Support %ty* in force-opaque-pointers mode

Only enforce that ptr* is illegal if the base type is a simple type,
not when it is something like %ty, where %ty may resolve to an
opaque pointer in force-opaque-pointers mode.

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

3 years ago[libcxx][docs] Mark LWG3348 as complete
Joe Loser [Mon, 30 Aug 2021 17:03:33 +0000 (13:03 -0400)]
[libcxx][docs] Mark LWG3348 as complete

Mark LWG3348 as complete. The `__cpp_lib_unwrap_ref` feature test macro
was placed in `<functional>` in 466df1718e41fe2fca6ce6bd98c01b18f42c05e4

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

3 years ago[SCEV] Clarify the overflow precondition of computeMaxBECountForLT [NFC]
Philip Reames [Mon, 30 Aug 2021 16:47:45 +0000 (09:47 -0700)]
[SCEV] Clarify the overflow precondition of computeMaxBECountForLT [NFC]

And add a test case to illustrate that we do in fact produce the right result for the multiple exit case.  I have gotten myself confused at least three times when reading this code, so clarify to prevent future confusion.

3 years ago[NFC][clang] Move IR-independent parts of target MV support to X86TargetParser.cpp
Andrei Elovikov [Mon, 30 Aug 2021 16:24:41 +0000 (09:24 -0700)]
[NFC][clang] Move IR-independent parts of target MV support to X86TargetParser.cpp

...that is located under llvm/lib/Support/.

Reviewed By: erichkeane

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

3 years ago[libc++] Various cleanups in the ranges tests
Louis Dionne [Fri, 27 Aug 2021 16:04:12 +0000 (12:04 -0400)]
[libc++] Various cleanups in the ranges tests

- Rename test files to follow conventions better
- Split constructor tests that were in a single file
- Add missing tests for take_view and transform_view's default constructors
- Add missing tests for transform_view's view/function constructor
- Fix include guards
- Mark some tests as being specific to libc++

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

3 years ago[lld/mac] Set branchRange a bit more carefully
Nico Weber [Sun, 29 Aug 2021 19:19:19 +0000 (15:19 -0400)]
[lld/mac] Set branchRange a bit more carefully

- Don't subtract thunkSize from branchRange. Most places care about
  the actual maximal branch range. Subtract thunkSize in the one place
  that wants to leave room for a thunk.
- Set it to 0x800_0000 instead of 0xFF_FFFF
- Subtract 4 for the positive branch direction since it's a
  two's complement 24bit number sign-extended mutiplied by 4,
  so its range is -0x800_0000..+0x7FF_FFFC
- Make boundary checks include the boundary values

This doesn't make a huge difference in practice. It's preparation
for a "real" fix for PR51578 -- but it also lets the repro in comment 0
in that bug place one more thunk before hitting the TODO.

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

3 years ago[IROutliner] Ensure instructions at end of candidate are excluded
Andrew Litteken [Fri, 11 Jun 2021 17:00:22 +0000 (12:00 -0500)]
[IROutliner] Ensure instructions at end of candidate are excluded

Occasionally instructions are between the last instruction in a region,
and the following instruction as identified by the Candidate.  This
adds an extra check right before splitting a candidate that excludes the region from being split/checked for outlining to remove errors.

Tests Added:
Tranforms/IROuutliner/outlining-extra-bitcasts.ll

Reviewer: paquette, jroelofs

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

3 years ago[AMDGPU][CostModel] Update shuffle instruction tests. NFC.
Daniil Fukalov [Mon, 30 Aug 2021 16:05:55 +0000 (19:05 +0300)]
[AMDGPU][CostModel] Update shuffle instruction tests. NFC.

New tests ported over from test/Analysis/CostModel/AArch64/shuffle-other.ll.

3 years ago[llvm] Remove redundant calls to str() and c_str() (NFC)
Kazu Hirata [Mon, 30 Aug 2021 16:05:05 +0000 (09:05 -0700)]
[llvm] Remove redundant calls to str() and c_str() (NFC)

Identified with readability-redundant-string-cstr.

3 years ago[RISCV] Enable CONCAT_VECTORS for fixed FP vectors.
Craig Topper [Mon, 30 Aug 2021 15:47:43 +0000 (08:47 -0700)]
[RISCV] Enable CONCAT_VECTORS for fixed FP vectors.

Reviewed By: frasercrmck

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

3 years ago[DAGCombiner][RISCV] Don't use vector types in DAGCombiner::tryStoreMergeOfLoads...
Craig Topper [Mon, 30 Aug 2021 15:40:00 +0000 (08:40 -0700)]
[DAGCombiner][RISCV] Don't use vector types in DAGCombiner::tryStoreMergeOfLoads if we need a rotate.

The check for whether a rotate is possible occurs before the
memory legality checks for the integer type. So it's possible we
decide we can use a rotate, but then fail the legality checks. If
that happens we should not fall back to a vector type. This triggers
an assertion in the rotate handling when it finds a vector type
instead of an integer type.

In theory we could use a shufflevector in place of the rotate, but
right now I'd just like to fix the crash.

Reviewed By: RKSimon

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

3 years ago[LSR][NFC] Add test case for pr42770
Danila Malyutin [Mon, 30 Aug 2021 15:45:25 +0000 (18:45 +0300)]
[LSR][NFC] Add test case for pr42770

3 years ago[IRSim] Adding missing comments canonical relation commit
Andrew Litteken [Mon, 30 Aug 2021 15:34:25 +0000 (08:34 -0700)]
[IRSim] Adding missing comments canonical relation commit

Adding missing comments to IRSimilarityIdentifier.cpp since
they were not properly added in commit 063af63b9664151b3a9206feefa9a6a36a471e80.

3 years ago[libomptarget][amdcgn] Only add opt/llvm-link dependency if TARGET is available
Joachim Protze [Mon, 30 Aug 2021 14:50:21 +0000 (16:50 +0200)]
[libomptarget][amdcgn] Only add opt/llvm-link dependency if TARGET is available

In some build configurations, the target we depend on is not available for declaring the build dependency.
We only need to declare the build dependency, if the build target is available in the same build.

Fixes the issue raised in https://reviews.llvm.org/D107156#2969862
This patch should go into release/13 together with D108404

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

3 years ago[mlir][python] Extend C/Python API to be usable for CFG construction.
Stella Laurenzo [Sun, 29 Aug 2021 03:15:51 +0000 (20:15 -0700)]
[mlir][python] Extend C/Python API to be usable for CFG construction.

* It is pretty clear that no one has tried this yet since it was both incomplete and broken.
* Fixes a symbol hiding issues keeping even the generic builder from constructing an operation with successors.
* Adds ODS support for successors.
* Adds CAPI `mlirBlockGetParentRegion`, `mlirRegionEqual` + tests (and missing test for `mlirBlockGetParentOperation`).
* Adds Python property: `Block.region`.
* Adds Python methods: `Block.create_before` and `Block.create_after`.
* Adds Python property: `InsertionPoint.block`.
* Adds new blocks.py test to verify a plausible CFG construction case.

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

3 years ago[AIX] Suppress -Waix-compat warning with SmallVector class
Jake Egan [Mon, 30 Aug 2021 14:42:59 +0000 (10:42 -0400)]
[AIX] Suppress -Waix-compat warning with SmallVector class

When building LLVM with Open XL and -Werror is specified, the -Waix-compat warning becomes an error. This patch updates the SmallVector class to suppress the -Waix-compat warning/error on AIX.

Reviewed By: daltenty

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

3 years ago[PowerPC][NFC] Rename P10 builtins vec_clrl, vec_clrr to vec_clr_first and vec_clr_last
Victor Huang [Mon, 30 Aug 2021 14:32:48 +0000 (09:32 -0500)]
[PowerPC][NFC] Rename P10 builtins vec_clrl, vec_clrr to vec_clr_first and vec_clr_last

This patch renames the vector clear left/right builtins vec_clrl, vec_clrr to
vec_clr_first and vec_clr_last to avoid the ambiguities when dealing with endianness.

Reviewed By: amyk, lei

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

3 years ago[lldb][NFC] Add size tests for empty records with alignment and with empty members
Raphael Isemann [Mon, 30 Aug 2021 13:16:18 +0000 (15:16 +0200)]
[lldb][NFC] Add size tests for empty records with alignment and with empty members

This came up during the Windows bot failure discussing after D105471 . See
also 3d9a9fa6911a5228ce799a7c639e94d322678934 .

3 years ago[LLDB] Fix 'std::out_of_range' crashing bug when file name completion using file...
Hiroki [Mon, 30 Aug 2021 12:12:29 +0000 (14:12 +0200)]
[LLDB] Fix 'std::out_of_range' crashing bug when file name completion using file path.

When I run a lldb command that uses filename completion, if I enter a string
that is not only a filename but also a string with a non-file name string added,
such as "./" that is relative path string , it will crash as soon as I press the
[Tab] key. For example, debugging an executable file named "hello" that is
compiled from a file named "hello.c" , and I’ll put a breakpoint on line 3 of
hello.c.

```
$ lldb ./hello
(lldb) breakpoint set --file hello.c --line 3
```

This is not a problem, but if I set "--file ./hello."  and then press [Tab] key
to complete file name, lldb crashes.

```
$ lldb ./hello
(lldb) breakpoint set --file ./hello.terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr: __pos (which is 8) > this->size() (which is 7)
```

The crash was caused because substr() (in lldb/source/Host/common/Editline.cpp)
cut out string which size is user's input string from the completion string.

I modified the code that erase the user's intput string from current line and
then add the completion string.

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

3 years agoSilence a signed/unsigned mismatch warning; NFC
Aaron Ballman [Mon, 30 Aug 2021 12:51:08 +0000 (08:51 -0400)]
Silence a signed/unsigned mismatch warning; NFC

3 years ago[lldb] Return all line entries matchign a line if no column is specified
Kim-Anh Tran [Mon, 30 Aug 2021 12:19:34 +0000 (14:19 +0200)]
[lldb] Return all line entries matchign a line if no column is specified

Previously, if no column was specified, ResolveSymbolContext would take
the first match returned by FindLineEntryIndexByFileIndex, and reuse it
to find subsequent exact matches. With the introduction of columns, columns
are now considered when matching the line entries.

This leads to a problem if one wants to get all existing line entries
that match that line, since now the column is also used for the exact match.
This way, all line entries are filtered out that have a different
column number, but the same line number.

This patch changes that by ignoring the column information of the first match
if the original request of ResolveSymbolContext was also ignoring it.

Reviewed By: mib

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

3 years ago[LiveDebugValues] Cleanup Transfers when removing Entry Value
Djordje Todorovic [Mon, 30 Aug 2021 12:00:36 +0000 (14:00 +0200)]
[LiveDebugValues] Cleanup Transfers when removing Entry Value

If we encounter a new debug value, describing the same parameter,
we should stop tracking the parameter's Entry Value. At that point,
in some cases, the Transfer which uses the parameter's Entry Value,
is already emitted. Thanks to the RemoveRedundantDebugValues pass,
many problems with incorrect instruction order and number of DBG_VALUEs
are fixed. However, we still cannot rely on the rule that each new
debug value is set by the previous non-debug instruction in Machine
Basic Block.

When new parameter debug value triggers removal of Backup Entry Value
for the same parameter, do the cleanup of Transfers emitted from Backup
Entry Values. Get the Transfer Instruction which created the new debug
value and search for debug values already emitted from the to-be-deleted
Backup Entry Value and attached to the Transfer Instruction. If found,
delete the Transfer and remove "primary" Entry Value Var Loc from
OpenRanges.

This patch fixes PR47628.

Patch by Nikola Tesic.

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

3 years ago[flang][mlir] Fix FIR after D108899
Jean Perier [Mon, 30 Aug 2021 11:46:04 +0000 (04:46 -0700)]
[flang][mlir] Fix FIR after D108899

After 41d4aa7de68ed551010f27ff04ffc54e7616292a, some builder.getStringAttr
calls in FIR were wrong.

3 years ago[clang] Add gcc-toolset-10 support (RHEL/CentOS 8)
Simon Moll [Mon, 30 Aug 2021 11:30:52 +0000 (13:30 +0200)]
[clang] Add gcc-toolset-10 support (RHEL/CentOS 8)

Clang only adds GCC paths for RHEL <= 7 'devtoolset-<N>' Software
Collections (SCL).  This generalizes this support to also include the
'gcc-toolset-10' SCL in RHEL/CentOS 8.

Reviewed By: stephan.dollberg

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

3 years ago[TTI][X86] getArithmeticInstrCost - move opcode canonicalization before all target...
Simon Pilgrim [Mon, 30 Aug 2021 11:24:59 +0000 (12:24 +0100)]
[TTI][X86] getArithmeticInstrCost - move opcode canonicalization before all target-specific costs. NFCI.

The GLM/SLM special cases still get tested first but after the the MUL/DIV/REM pattern detection - this will be necessary for when we make the SLM vXi32 MUL canonicalization generic to improve PMULLW/PMULHW/PMADDDW cost support etc.

3 years agoFix MSVC "signed/unsigned mismatch" comparison warning. NFCI.
Simon Pilgrim [Mon, 30 Aug 2021 11:10:58 +0000 (12:10 +0100)]
Fix MSVC "signed/unsigned mismatch" comparison warning. NFCI.

3 years ago[lldb][NFC] Remove TypeSystemClang::CreateFunctionType overload
Raphael Isemann [Thu, 26 Aug 2021 10:29:01 +0000 (12:29 +0200)]
[lldb][NFC] Remove TypeSystemClang::CreateFunctionType overload

This can just be a default argument.

3 years ago[CMake][NFC] Add comment about new `--gdb-index` option used with `-gsplit-dwarf`
Anton Afanasyev [Mon, 30 Aug 2021 09:32:20 +0000 (12:32 +0300)]
[CMake][NFC] Add comment about new `--gdb-index` option used with `-gsplit-dwarf`

Follow-up of https://reviews.llvm.org/D108776

3 years agotsan: add a comment to CallUserSignalHandler
Dmitry Vyukov [Mon, 30 Aug 2021 08:58:46 +0000 (10:58 +0200)]
tsan: add a comment to CallUserSignalHandler

Reviewed By: melver

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

3 years ago[NFCI][IndVars] rewriteLoopExitValues(): don't expand SCEV's until needed
Roman Lebedev [Mon, 30 Aug 2021 09:27:41 +0000 (12:27 +0300)]
[NFCI][IndVars] rewriteLoopExitValues(): don't expand SCEV's until needed

Previously, we'd expand *ALL* the SCEV's eagerly, because we needed to
check with `isValidRewrite()`, and discard bad rewrite candidates,
but now that we do not do that, we also don't need to always expand.

In particular, this avoids expanding potentially-huge SCEV's that we
would discard anyways because they are high-cost and we aren't
rewriting aggressively.

3 years ago[CMake] Add `--gdb-index` option to linker if split dwarf compiling
Anton Afanasyev [Wed, 25 Aug 2021 22:25:27 +0000 (01:25 +0300)]
[CMake] Add `--gdb-index` option to linker if split dwarf compiling

The option `--gdb-index` should be passed to linker if compiler is invoked
with `-gsplit-dwarf` option. This allows debugger to locate the appropriate
units quickly. See "Invocation" section here: https://gcc.gnu.org/wiki/DebugFission

Suggested by @dblaikie here: https://reviews.llvm.org/D68556#1698442

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

3 years agoFix interface trait declaration in SymbolInterfaces.td
Alex Zinenko [Mon, 30 Aug 2021 09:13:19 +0000 (11:13 +0200)]
Fix interface trait declaration in SymbolInterfaces.td

41d4aa7de68ed551010f27ff04ffc54e7616292a introduced incorrect code in
extraTraitClassDeclaration: `this` refers to the trait class and not the
operation class so `->getContext()` is not valid. Use `$_op` instead.

3 years ago[IndVars] Drop check for the validity of rewrite
Roman Lebedev [Mon, 30 Aug 2021 09:00:26 +0000 (12:00 +0300)]
[IndVars] Drop check for the validity of rewrite

`isValidRewrite()` checks that the both the original SCEV,
and the rewrite SCEV have the same base pointer.
I //believe//, after all the recent SCEV improvements,
this invariant is already enforced by SCEV itself.

I originally tried changing it into an assert in D108043,
but that showed that it triggers on e.g. https://reviews.llvm.org/D108043#2946621,
where SCEV manages to forward the store to load,
test added.

Reviewed By: nikic

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

3 years ago[NFC][IndVars] Add test that caused D108043 to be reverted
Roman Lebedev [Mon, 30 Aug 2021 09:00:08 +0000 (12:00 +0300)]
[NFC][IndVars] Add test that caused D108043 to be reverted

We currently don't simplify anything here, but we can.

3 years ago[lldb] [gdb-remote client] Support minimal fork/vfork handling
Michał Górny [Fri, 9 Apr 2021 14:18:50 +0000 (16:18 +0200)]
[lldb] [gdb-remote client] Support minimal fork/vfork handling

Add a support for handling fork/vfork stops in LLGS client.  At this
point, it only sends a detach packet for the newly forked child
(and implicitly resumes the parent).

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

3 years ago[DebugInfo] Emit DW_TAG_namelist and DW_TAG_namelist_item
“bhkumarn” [Mon, 23 Aug 2021 12:43:11 +0000 (18:13 +0530)]
[DebugInfo] Emit DW_TAG_namelist and DW_TAG_namelist_item

This patch emits DW_TAG_namelist and DW_TAG_namelist_item for fortran
namelist variables. DICompositeType is extended to support this fortran
feature.

Reviewed By: aprantl

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

3 years ago[flang] Add runtime interface for GET_COMMAND_ARGUMENT
Diana Picus [Wed, 25 Aug 2021 05:57:25 +0000 (05:57 +0000)]
[flang] Add runtime interface for GET_COMMAND_ARGUMENT

GET_COMMAND_ARGUMENT takes a lot of optional arguments: VALUE, LENGTH,
STATUS and ERRMSG. This patch breaks up the interface into 2 different
functions:

* One for getting the LENGTH of an argument.

* One for getting the VALUE and the ERRMSG of an argument. This returns
the STATUS, which can be easily ignored by lowering if it is missing in
the invocation.

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

3 years ago[flang] Add runtime interface for COMMAND_ARGUMENT_COUNT
Diana Picus [Wed, 25 Aug 2021 03:16:30 +0000 (03:16 +0000)]
[flang] Add runtime interface for COMMAND_ARGUMENT_COUNT

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

3 years ago[VPlan] Introduce code to limit querying VPValues using IR references.
Florian Hahn [Mon, 30 Aug 2021 06:50:17 +0000 (08:50 +0200)]
[VPlan] Introduce code to limit querying VPValues using IR references.

After applying VPlan-to-VPlan transformations, using IR references to
query VPlan values may be incorrect, as the IR is not in sync with the
VPlan any longer.

To better detect such mis-matches, this patch introduces a new flag to
VPlans to indicate whether it is safe to query VPValues using IR values.

getVPValue is updated to assert if it is called when the flag indicates
it is not safe any longer.

There is an escape hatch via an extra argument, because there are 3
places that need to be fixed first. Those are

1. truncateToMinimalBitwidths
2. clearReductionWrapFlags
3. fixLCSSAPHIs

As a first step, this flag will help preventing new code from violating
this property.

Any suggestions with respect to naming very welcome!

Reviewed By: Ayal

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

3 years ago[docs] Add a new tutorial that talk about how to make a change to llvm
Shivam Gupta [Mon, 30 Aug 2021 06:55:29 +0000 (06:55 +0000)]
[docs] Add a new tutorial that talk about how to make a change to llvm

This tutorial will guide you through the process of making a change to LLVM, and contributing it back to the LLVM project.
We'll be making a change to Clang, but the steps for other parts of LLVM are the same. Even though the change we'll be making is simple,
we're going to cover steps like building LLVM, running the tests, and code review. This is good practice, and you'll be prepared for making larger changes.

Authors: @meikeb , @gribozavr
Commit: Zhiqian Xia

PS - This is a duplicate revision of https://reviews.llvm.org/D100714 which was actually used for patch review.

Reviewed By: kuhnel

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

3 years ago[flang] Apply double precision KindCode in specific proc interface
Jean Perier [Mon, 30 Aug 2021 06:58:53 +0000 (08:58 +0200)]
[flang] Apply double precision KindCode in specific proc interface

The double precision KindCode was ignored when building the interface
of specific intrinsic procedures leading to bad semantics checks.

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

3 years ago[X86] AVX512FP16 instructions enabling 6/6
Wang, Pengfei [Mon, 30 Aug 2021 04:07:18 +0000 (12:07 +0800)]
[X86] AVX512FP16 instructions enabling 6/6

Enable FP16 complex FMA instructions.

Ref.: https://software.intel.com/content/www/us/en/develop/download/intel-avx512-fp16-architecture-specification.html

Reviewed By: LuoYuanke

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

3 years ago[SymbolRefAttr] Revise SymbolRefAttr to hold a StringAttr.
Chris Lattner [Sun, 29 Aug 2021 21:22:24 +0000 (14:22 -0700)]
[SymbolRefAttr] Revise SymbolRefAttr to hold a StringAttr.

SymbolRefAttr is fundamentally a base string plus a sequence
of nested references.  Instead of storing the string data as
a copies StringRef, store it as an already-uniqued StringAttr.

This makes a lot of things simpler and more efficient because:
1) references to the symbol are already stored as StringAttr's:
   there is no need to copy the string data into MLIRContext
   multiple times.
2) This allows pointer comparisons instead of string
   comparisons (or redundant uniquing) within SymbolTable.cpp.
3) This allows SymbolTable to hold a DenseMap instead of a
   StringMap (which again copies the string data and slows
   lookup).

This is a moderately invasive patch, so I kept a lot of
compatibility APIs around.  It would be nice to explore changing
getName() to return a StringAttr for example (right now you have
to use getNameAttr()), and eliminate things like the StringRef
version of getSymbol.

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

3 years ago[libc] Ensure the result of the clone syscall is not on stack in thrd_create.
Siva Chandra Reddy [Mon, 30 Aug 2021 04:31:30 +0000 (04:31 +0000)]
[libc] Ensure the result of the clone syscall is not on stack in thrd_create.

Also, added a call to munmap on error in thrd_create.

3 years ago[PowerPC] Set branch/call instructions as no hasSideEffects
Qiu Chaofan [Mon, 30 Aug 2021 04:18:57 +0000 (12:18 +0800)]
[PowerPC] Set branch/call instructions as no hasSideEffects

PowerPC can model these instructions, so we don't need this flag set.

Reviewed By: shchenz, jsji

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

3 years ago[libc][NFC] Add a check to catch mismatch in internal and public mutex types.
Siva Chandra Reddy [Mon, 30 Aug 2021 04:08:35 +0000 (04:08 +0000)]
[libc][NFC] Add a check to catch mismatch in internal and public mutex types.

3 years ago[X86] Support __SSC_MARK(const int id)
Xiang1 Zhang [Mon, 30 Aug 2021 01:55:19 +0000 (09:55 +0800)]
[X86] Support __SSC_MARK(const int id)

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

3 years agoRevert "[X86] Support __SSC_MARK(const int id)"
Xiang1 Zhang [Mon, 30 Aug 2021 01:50:00 +0000 (09:50 +0800)]
Revert "[X86] Support __SSC_MARK(const int id)"

This reverts commit 78fbde57794e50f5629979f5d69592caf64067e3.

3 years ago[mlir][SCF] Canonicalize dim(x) where x is an iter_arg
Matthias Springer [Mon, 30 Aug 2021 01:12:14 +0000 (01:12 +0000)]
[mlir][SCF] Canonicalize dim(x) where x is an iter_arg

* Add `DimOfIterArgFolder`.
* Move existing cross-dialect canonicalization patterns to `LoopCanonicalization.cpp`.
* Rename `SCFAffineOpCanonicalization` pass to `SCFForLoopCanonicalization`.
* Expand documentaton of scf.for: The type of loop-carried variables may not change with iterations. (Not even the dynamic type.)

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

3 years ago[AIX] "aligned" attribute does not decrease alignment
Steven Wan [Mon, 30 Aug 2021 01:32:54 +0000 (21:32 -0400)]
[AIX] "aligned" attribute does not decrease alignment

The "aligned" attribute can only increase the alignment of a struct, or struct member, unless it's used together with the "packed" attribute, or used as a part of a typedef, in which case, the "aligned" attribute can both increase and decrease alignment.

That said, we expect:
1. "aligned" attribute alone: does not interfere with the alignment upgrade instrumented by the AIX "power" alignment rule,
2. "aligned" attribute + typedef: overrides any computed alignment,
3. "aligned" attribute + "packed" attribute: overrides any computed alignment.
The old implementation achieved 2 and 3, but didn't get 1 right, in that any field marked attribute "aligned" would not go through the alignment upgrade.

Reviewed By: rjmccall

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

3 years ago[X86] Support __SSC_MARK(const int id)
Xiang1 Zhang [Mon, 30 Aug 2021 01:21:14 +0000 (09:21 +0800)]
[X86] Support __SSC_MARK(const int id)

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

3 years agoRevert "[X86] Support __SSC_MARK(const int id)"
Xiang1 Zhang [Mon, 30 Aug 2021 01:17:42 +0000 (09:17 +0800)]
Revert "[X86] Support __SSC_MARK(const int id)"

This reverts commit 83e82ff767530158fd5590ffea617f50a07534b5.

3 years ago[mlir][Analysis] Add batched version of FlatAffineConstraints::addId
Matthias Springer [Mon, 30 Aug 2021 00:31:07 +0000 (00:31 +0000)]
[mlir][Analysis] Add batched version of FlatAffineConstraints::addId

* Add batched version of all `addId` variants, so that multiple IDs can be added at a time.
* Rename `addId` and variants to `insertId` and `appendId`. Most external users call `appendId`. Splitting `addId` into two functions also makes it possible to provide batched version for both. (Otherwise, the overloads are ambigious when calling `addId`.)

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

3 years ago[X86] Support __SSC_MARK(const int id)
Xiang1 Zhang [Wed, 25 Aug 2021 01:55:54 +0000 (09:55 +0800)]
[X86] Support __SSC_MARK(const int id)

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

3 years ago[InstCombine] Remove invariant group intrinsincs when comparing against null
Arthur Eubanks [Wed, 25 Aug 2021 18:31:22 +0000 (11:31 -0700)]
[InstCombine] Remove invariant group intrinsincs when comparing against null

We cannot leak any equivalency information by comparing against null
since null never has virtual metadata associated with it (when null is
not a valid dereferenceable pointer).

Instcombine seems to make sure that a null will be on the RHS, so we
don't have to check both operands.

This fixes a missed optimization in llvm-test-suite's MultiSource lambda
benchmark under -fstrict-vtable-pointers.

Reviewed By: Prazek

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

3 years ago[clang-format] Add PackConstructorInitializers backward compat test
owenca [Sat, 28 Aug 2021 22:21:23 +0000 (15:21 -0700)]
[clang-format] Add PackConstructorInitializers backward compat test

Add backward compatibility tests for mapping the deprecated
ConstructorInitializerAllOnOneLineOrOnePerLine and
AllowAllConstructorInitializersOnNextLine to
PackConstructorInitializers.

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

3 years ago[ELF] Simplify addGotEntry. NFC
Fangrui Song [Sun, 29 Aug 2021 20:40:08 +0000 (13:40 -0700)]
[ELF] Simplify addGotEntry. NFC

3 years ago[ELF] Untangle TLS IE and regular GOT from addGotEntry for non-mips. NFC
Fangrui Song [Sun, 29 Aug 2021 20:21:06 +0000 (13:21 -0700)]
[ELF] Untangle TLS IE and regular GOT from addGotEntry for non-mips. NFC

3 years ago[ELF] Move handleTlsRelocations. NFC
Fangrui Song [Sun, 29 Aug 2021 20:11:35 +0000 (13:11 -0700)]
[ELF] Move handleTlsRelocations. NFC

Prepare for addGotEntry simplification.

3 years ago[SCEVExpander] Reuse removePointerBase() for canonical addrecs
Nikita Popov [Sun, 29 Aug 2021 19:07:13 +0000 (21:07 +0200)]
[SCEVExpander] Reuse removePointerBase() for canonical addrecs

ExposePointerBase() in SCEVExpander implements basically the same
functionality as removePointerBase() in SCEV, so reuse it.

The SCEVExpander code assumes that the pointer operand on adds is
the last one -- I'm not sure that always holds. As such this might
not be strictly NFC.

3 years ago[ELF] Remove unused processRelocAux argument. NFC
Fangrui Song [Sun, 29 Aug 2021 19:07:56 +0000 (12:07 -0700)]
[ELF] Remove unused processRelocAux argument. NFC

3 years ago[SCEVExpander] Remove unnecessary mul/udiv check (NFC)
Nikita Popov [Sun, 29 Aug 2021 18:46:24 +0000 (20:46 +0200)]
[SCEVExpander] Remove unnecessary mul/udiv check (NFC)

Pointer-typed SCEV expressions can no longer be mul or udiv, so
we do not need to specially handle them here.

3 years ago[SCEVExpander] Assert single pointer op in add (NFC)
Nikita Popov [Sun, 29 Aug 2021 18:29:04 +0000 (20:29 +0200)]
[SCEVExpander] Assert single pointer op in add (NFC)

There can only be one pointer operand in an add expression, and
we have sorted operands to guarantee that it is the first. As
such, the pointer check for other operands is dead code.

3 years ago[SCEV] Assert unique pointer base (NFC)
Nikita Popov [Sun, 29 Aug 2021 17:58:56 +0000 (19:58 +0200)]
[SCEV] Assert unique pointer base (NFC)

Add expressions can contain at most one pointer operand nowadays,
assert that in getPointerBase() and removePointerBase().

3 years ago[X86] Remove X86LowerAMXType::getRowFromCol from X86LowerAMXType.cpp
Vince Bridgers [Fri, 27 Aug 2021 22:57:44 +0000 (17:57 -0500)]
[X86] Remove X86LowerAMXType::getRowFromCol from X86LowerAMXType.cpp

Remove method X86LowerAMXType::getRowFromCol since it's not used, and
it's causing a warning.

Reviewed By: LuoYuanke

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

3 years ago[Support] Remove redundant calls to str() and c_str() (NFC)
Kazu Hirata [Sun, 29 Aug 2021 16:14:47 +0000 (09:14 -0700)]
[Support] Remove redundant calls to str() and c_str() (NFC)

Identified with readability-redundant-string-cstr.

3 years ago[mlir][spirv] Use type dyn_cast when scanning spv.GlobalVariable
Lei Zhang [Sun, 29 Aug 2021 16:01:19 +0000 (12:01 -0400)]
[mlir][spirv] Use type dyn_cast when scanning spv.GlobalVariable

This avoids crashes when there are spv.GlobalVariable without
pointer type.

3 years agotest-release.sh: remove an unused reference to the old svn repo
Sylvestre Ledru [Sun, 29 Aug 2021 15:44:58 +0000 (17:44 +0200)]
test-release.sh: remove an unused reference to the old svn repo

3 years ago[lldb] Allow to register frame recognizers applied beyond the first instruction
Roman Podoliaka [Sun, 29 Aug 2021 15:26:15 +0000 (17:26 +0200)]
[lldb] Allow to register frame recognizers applied beyond the first instruction

It is currently possible to register a frame recognizer, but it will be applied if and only if the frame's PC points to the very first instruction of the specified function, which limits usability of this feature.

The implementation already supports changing this behaviour by passing an additional flag, but it's not possible to set it via the command interface. Fix that.

Reviewed By: jingham

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

3 years ago[NewPM] Add missing LTO ArgPromotion pass
Nikita Popov [Sat, 28 Aug 2021 10:25:58 +0000 (12:25 +0200)]
[NewPM] Add missing LTO ArgPromotion pass

This is a followup to D96780 to add one more pass missing from the
NewPM LTO pipeline. The missing ArgPromotion run is inserted at
the same position as in the LegacyPM, resolving the already
present FIXME:
https://github.com/llvm/llvm-project/blob/16086d47c0d0cd08ffae8e69a69c88653e654d01/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp#L1096-L1098

The compile-time impact is minimal with ~0.1% geomean regression
on CTMark.

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

3 years ago[BPF] support btf_tag attribute in .BTF section
Yonghong Song [Tue, 20 Jul 2021 17:59:19 +0000 (10:59 -0700)]
[BPF] support btf_tag attribute in .BTF section

A new kind BTF_KIND_TAG is added to .BTF to encode
btf_tag attributes. The format looks like
   CommonType.name : attribute string
   CommonType.type : attached to a struct/union/func/var.
   CommonType.info : encoding BTF_KIND_TAG
                     kflag == 1 to indicate the attribute is
                     for CommonType.type, or kflag == 0
                     for struct/union member or func argument.
   one uint32_t    : to encode which member/argument starting from 0.

If one particular type or member/argument has more than one attribute,
multiple BTF_KIND_TAG will be generated.

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

3 years ago[Polly][test] Add dependency to count.
Michael Kruse [Sun, 29 Aug 2021 03:50:07 +0000 (22:50 -0500)]
[Polly][test] Add dependency to count.

Polly does not use the count program itself, but somewhere in lit it is
expected to exists. Otherwise, the following error occurs:

    llvm-lit: llvm-project/llvm/utils/lit/lit/llvm/subst.py:133: fatal: Did not find count in ./bin

3 years ago[Polly] Fix dumpfunction.ll test.
Michael Kruse [Sun, 29 Aug 2021 03:38:52 +0000 (22:38 -0500)]
[Polly] Fix dumpfunction.ll test.

3 years agoTypeInfo records more information about align requirement
Steven Wan [Sat, 28 Aug 2021 23:47:31 +0000 (19:47 -0400)]
TypeInfo records more information about align requirement

Extend the information preserved in `TypeInfo` by replacing the `AlignIsRequired` bool flag with a three-valued enum, the enum also indicates where the alignment attribute come from, which could be helpful in determining whether the attribute should overrule.

Reviewed By: rjmccall

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

3 years ago[OpenMP][NVPTX] Fixed missing variables for CUDA free compilation in NVPTX plugin
Shilei Tian [Sat, 28 Aug 2021 22:08:03 +0000 (18:08 -0400)]
[OpenMP][NVPTX] Fixed missing variables for CUDA free compilation in NVPTX plugin

`CU_EVENT_DEFAULT` is defined in CUDA header. It should be added to
`openmp/libomptarget/plugins/cuda/dynamic_cuda/cuda.h` for CUDA free build.

Reviewed By: ronlieb

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

3 years ago[Polly] Don't prune non-external function itself from dump.
Michael Kruse [Sat, 28 Aug 2021 21:48:28 +0000 (16:48 -0500)]
[Polly] Don't prune non-external function itself from dump.

3 years ago[Sanitizers] PGO implements enable/disable SIGKILL on callers on FreeBSD.
David Carlier [Sat, 28 Aug 2021 21:53:16 +0000 (22:53 +0100)]
[Sanitizers] PGO implements enable/disable SIGKILL on callers on FreeBSD.

Reviewed By: phosek

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

3 years ago[Linker] Replace comdat based bool LinkFromSrc with enum class LinkFrom and improve...
Fangrui Song [Sat, 28 Aug 2021 20:56:31 +0000 (13:56 -0700)]
[Linker] Replace comdat based bool LinkFromSrc with enum class LinkFrom and improve nodeduplicate tests. NFC

This is different from symbol resolution based LinkFromSrc.  Rename to be
clearer.

In the future we may support a new enum member 'Both' for nodeduplicate. This is
feasible (by renaming to a private linkage GlobalValue), but we need to be
careful not to break InstrProfiling.cpp's expectation of parallel profd/profc.

The challenge is that current LTO symbol resolution only allows to mark one
profc as prevailing: the other profc in another comdat nodeduplicate may be
discarded while its associated profd isn't.

3 years ago[llc] Initialize context for parsing options
Nikita Popov [Sat, 28 Aug 2021 20:36:37 +0000 (22:36 +0200)]
[llc] Initialize context for parsing options

This will allow using -force-opaque-pointers in codegen tests.

3 years ago[OpenMP][Offloading] Add support for event related interfaces
Shilei Tian [Sat, 28 Aug 2021 20:24:06 +0000 (16:24 -0400)]
[OpenMP][Offloading] Add support for event related interfaces

This patch adds the support form event related interfaces, which will be used
later to fix data race. See D104418 for more details.

Reviewed By: jdoerfert, ye-luo

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

3 years ago[test] Reorganize test/Linker/comdat*.ll
Fangrui Song [Sat, 28 Aug 2021 17:11:08 +0000 (10:11 -0700)]
[test] Reorganize test/Linker/comdat*.ll

3 years ago[mlir] add missing include, fix broken build
Aart Bik [Sat, 28 Aug 2021 16:22:15 +0000 (09:22 -0700)]
[mlir] add missing include, fix broken build

Reviewed By: mehdi_amini

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

3 years ago[libomptarget][NFC] Fixed tests which checked for obsolete string "getOrAllocTgtPtr"
George Rokos [Sat, 28 Aug 2021 14:35:42 +0000 (07:35 -0700)]
[libomptarget][NFC] Fixed tests which checked for obsolete string "getOrAllocTgtPtr"

3 years ago[mlir][NFC] Fully qualify default value of Attributes `getStorageType()` in files...
Markus Böck [Sat, 28 Aug 2021 13:34:34 +0000 (15:34 +0200)]
[mlir][NFC] Fully qualify default value of Attributes `getStorageType()` in files generated by mlir-tblgen

3 years ago[llvm] Fix typos in documentation (NFC)
Kazu Hirata [Sat, 28 Aug 2021 13:37:03 +0000 (06:37 -0700)]
[llvm] Fix typos in documentation (NFC)

3 years ago[Analysis] Fix a "set but not used" warning
Kazu Hirata [Sat, 28 Aug 2021 13:37:01 +0000 (06:37 -0700)]
[Analysis] Fix a "set but not used" warning

3 years ago[WebAssembly] Fix FastISel of condition in different block (PR51651)
Nikita Popov [Fri, 27 Aug 2021 20:18:07 +0000 (22:18 +0200)]
[WebAssembly] Fix FastISel of condition in different block (PR51651)

If the icmp is in a different block, then the register for the icmp
operand may not be initialized, as it nominally does not have
cross-block uses. Add a check that the icmp is in the same block
as the branch, which should be the common case.

This matches what X86 FastISel does:
https://github.com/llvm/llvm-project/blob/5b6b090cf2129228f05d7d0f504676b67f7524cf/llvm/lib/Target/X86/X86FastISel.cpp#L1648

The "not" transform that could have a similar issue is dropped
entirely, because it is currently dead: The incoming value is
a branch or select condition of type i1, but this code requires
an i32 to trigger.

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

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

3 years ago[MLIR][GPU] Drop mgpuMemHostRegisterMemRef's dependence on LLVM Support
Uday Bondhugula [Fri, 20 Aug 2021 11:46:25 +0000 (17:16 +0530)]
[MLIR][GPU] Drop mgpuMemHostRegisterMemRef's dependence on LLVM Support

Drop mgpuMemHostRegisterMemRef's dependence on LLVM Support. This
method is the only one in CUDA runtime wrappers library that creates
a dependence on libLLVMSupport due to its use of SmallVector and
ArrayRef. The code can be as easily/compactly written without those ADT.
The dependence on LLVMSupport adds a significant amount of additional
complexity for external things that want to link this library in (both
statically or as a shared object) since libLLVMSupport includes numerous
other objects that are sensitive to C++ compiler version and ABI.

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

3 years ago[JITLink][RISCV] Support GOT/PLT relocations
luxufan [Fri, 27 Aug 2021 14:17:06 +0000 (22:17 +0800)]
[JITLink][RISCV] Support GOT/PLT relocations

This patch add the R_RISCV_GOT_HI20 and R_RISCV_CALL_PLT relocation support. And the basic got/plt was implemented. Because of riscv32 and riscv64 has different pointer size, the got entry size and instructions of plt entry is different. This patch is the basic support, the optimization pass at preFixup stage has not been implemented.

Reviewed By: lhames

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

3 years ago[lld/mac] Don't assert on -dead_strip + arm64 range extension thunks
Nico Weber [Fri, 27 Aug 2021 23:20:29 +0000 (19:20 -0400)]
[lld/mac] Don't assert on -dead_strip + arm64 range extension thunks

The assert is harmless and thinks worked fine in builds with asserts enabled,
but it's still nice to fix the assert.

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

3 years ago[Modules] Change result of reading AST block to llvm::Error instead
Ben Barham [Sat, 28 Aug 2021 02:38:46 +0000 (19:38 -0700)]
[Modules] Change result of reading AST block to llvm::Error instead

Reading the AST block can never fail with a recoverable error as modules
cannot be removed during this phase. Change the return type of these
functions to return an llvm::Error instead, ie. either success or
failure.

NFC other than the wording of some of the errors.

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

3 years agoRemove `const` from `const T &&` in debugString() helper to make it a universal refer...
Mehdi Amini [Sat, 28 Aug 2021 01:09:00 +0000 (01:09 +0000)]
Remove `const` from `const T &&` in debugString() helper to make it a universal reference (NFC)

It broke lvalue arguments otherwise: