platform/upstream/llvm.git
2 years ago[RISCV] Add test for vector extension
eopXD [Fri, 14 Jan 2022 21:00:07 +0000 (13:00 -0800)]
[RISCV] Add test for vector extension

It seems that D115709 have mis-deleted the whole testcase for vector
extension. This commit adds them back.

Reviewed By: craig.topper

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

2 years ago[NFC][msan] Track alignment in the test
Vitaly Buka [Sat, 15 Jan 2022 07:04:24 +0000 (23:04 -0800)]
[NFC][msan] Track alignment in the test

2 years agoRevert "[cmake] Use `GNUInstallDirs` to support custom installation dirs."
John Ericson [Sat, 15 Jan 2022 07:35:02 +0000 (07:35 +0000)]
Revert "[cmake] Use `GNUInstallDirs` to support custom installation dirs."

Sorry for the disruption, I will try again later.

This reverts commit efeb50197091b2ade24c00b9d55814bc433a7fd1.

2 years ago[RISCV] Add the zvl extension according to the v1.0 spec
eopXD [Sat, 23 Oct 2021 10:18:24 +0000 (03:18 -0700)]
[RISCV] Add the zvl extension according to the v1.0 spec

`zvl` is the new standard vector extension that specifies the minimum vector length of the vector extension.
The `zvl` extension is related to the `zve` extension and other updates that are added in v1.0.

According to https://github.com/riscv-non-isa/riscv-c-api-doc/pull/21,
Clang defines macro `__riscv_v_min_vlen` for `zvl` and it can be used for applications that uses the vector extension.
LLVM checks whether the option `riscv-v-vector-bits-min` (if specified) matches the `zvl*` extension specified.

Reviewed By: craig.topper

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

2 years ago[msan] Reset shadow of byval before call
Vitaly Buka [Fri, 14 Jan 2022 07:52:34 +0000 (23:52 -0800)]
[msan] Reset shadow of byval before call

If function is not sanitized we must reset shadow, not copy.

Depends on D117285

Reviewed By: kda, eugenis

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

2 years agoworkflows: Make issue-subscriber more robust for labels with special characters
Tom Stellard [Sat, 15 Jan 2022 01:08:01 +0000 (17:08 -0800)]
workflows: Make issue-subscriber more robust for labels with special characters

Also, replace the existing actionscript implementation with a python
script that can be run outside of GitHub Actions.  The intention is
that going forward, all github action functionality would be implemented
in this script.

Reviewed By: kwk

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

2 years ago[RISCV][NFC] Add IsRV64 predicate in xperm.w pattern
Lian Wang [Sat, 15 Jan 2022 04:04:56 +0000 (04:04 +0000)]
[RISCV][NFC] Add IsRV64 predicate in xperm.w pattern

Reviewed By: craig.topper

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

2 years agoRevert "[X86][MS] Change the alignment of f80 to 16 bytes on Windows 32bits to match...
Phoebe Wang [Sat, 15 Jan 2022 02:04:25 +0000 (10:04 +0800)]
Revert "[X86][MS] Change the alignment of f80 to 16 bytes on Windows 32bits to match with ICC"

This reverts commit 1bb0caf561688681be67cc91560348c9e43fcbf3.

2 years agoRevert "[X86][LLD] Update datelayout in LLD tests. NFCI"
Phoebe Wang [Sat, 15 Jan 2022 02:03:35 +0000 (10:03 +0800)]
Revert "[X86][LLD] Update datelayout in LLD tests. NFCI"

This reverts commit 9b43237128da0a7a3bc8a16f6f2c0897b9e842be.

2 years ago[NFCI][CMake] add space among flag sets in all_linker_flags_uppercase
Yuanfang Chen [Sat, 15 Jan 2022 02:42:03 +0000 (18:42 -0800)]
[NFCI][CMake] add space among flag sets in all_linker_flags_uppercase

Follow-up on 74bb4ad5d4eb0. It should not change behaviors but a good thing to
do.

2 years ago[LSR] Fix crash in Phi node with EHPad block
Quentin Colombet [Sat, 15 Jan 2022 02:49:50 +0000 (18:49 -0800)]
[LSR] Fix crash in Phi node with EHPad block

This fixes a crash I observed in issue #48708 where the LSR
pass tries to insert an instruction in a basic block with only a
catchswitch statement in there. This happens because the Phi node
being evaluated assumes the same value for different basic blocks.

If the basic block associated with the incoming value of the operand
being evaluated has an EHPad terminator LSR skips optimizing it.
But if that incoming value can come from multiple different blocks
there can be some incoming basic blocks which are terminated in
an EHPad. If these are then rewritten in RewriteForPhi the ones
containing an EHPad terminator will hit the "Insertion point must
be a normal instruction" assert in AdjustInsertPositionForExpand.

This fix makes CollectLoopInvariantFixupsAndFormulae also ignore
cases where the same value has another incoming basic block with an
EHPad, same as it already does in case the primary value has one.

Patch by Lorenz Brun <lorenz@brun.one>

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

2 years ago[RISCV] Add patterns for vector widening integer add/subtract
jacquesguan [Thu, 13 Jan 2022 07:41:21 +0000 (15:41 +0800)]
[RISCV] Add patterns for vector widening integer add/subtract

Add patterns for vector widening integer add/subtract instructions

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

2 years ago[BOLT][DWARF] Reduce overhead for sized dealloc
Alexander Yermolovich [Sat, 15 Jan 2022 01:25:30 +0000 (17:25 -0800)]
[BOLT][DWARF] Reduce overhead for sized dealloc

This is a follow up to Fix size mismatch error with jemalloc.
4243b6582cf3bb5fbcde908913d4779ded731321
Although that fix works it increased memory footprint.
With this patch we go back to original memory footprint.

Reviewed By: maksfb

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

2 years ago[msan] Clear byval shadow in ignored functions
Vitaly Buka [Fri, 14 Jan 2022 04:22:56 +0000 (20:22 -0800)]
[msan] Clear byval shadow in ignored functions

If function has no sanitize_memory we still reset shadow for nested calls.
The first return from getShadow() correctly returned shadow for argument,
but it didn't reset shadow of byval pointee.

Depends on D117277

Reviewed By: eugenis

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

2 years ago[RISCV] update zfh and zfhmin extention to v1.0
Shao-Ce SUN [Sat, 15 Jan 2022 01:11:58 +0000 (09:11 +0800)]
[RISCV] update zfh and zfhmin extention to v1.0

`zfh` and `zfhmin` have been ratified, with version 1.0.

Reviewed By: craig.topper

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

2 years agoenable noundef analysis with -fsanitize-memory-param-retval
Kevin Athey [Fri, 14 Jan 2022 10:12:57 +0000 (02:12 -0800)]
enable noundef analysis with -fsanitize-memory-param-retval

Enable noundef analysis (-enable-noundef-analysis) via the -fsanitize-memory-param-retval clang flag.
This completes the work found in:
  - https://reviews.llvm.org/D116855
  - https://reviews.llvm.org/D116633

Depends on D116633

Reviewed By: vitalybuka

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

2 years ago[cmake] Use `GNUInstallDirs` to support custom installation dirs.
John Ericson [Tue, 11 Jan 2022 05:35:14 +0000 (05:35 +0000)]
[cmake] Use `GNUInstallDirs` to support custom installation dirs.

This is the original patch in my GNUInstallDirs series, now last to merge as the final piece!

It arose as a new draft of D28234. I initially did the unorthodox thing of pushing to that when I wasn't the original author, but since I ended up

 - Using `GNUInstallDirs`, rather than mimicking it, as the original author was hesitant to do but others requested.

 - Converting all the packages, not just LLVM, effecting many more projects than LLVM itself.

I figured it was time to make a new revision.

I have used this patch series (and many back-ports) as the basis of https://github.com/NixOS/nixpkgs/pull/111487 for my distro (NixOS), which was merged last spring (2021). It looked like people were generally on board in D28234, but I make note of this here in case extra motivation is useful.

---

As pointed out in the original issue, a central tension is that LLVM already has some partial support for these sorts of things. Variables like `COMPILER_RT_INSTALL_PATH` have already been dealt with. Variables like `LLVM_LIBDIR_SUFFIX` however, will require further work, so that we may use `CMAKE_INSTALL_LIBDIR`.

These remaining items will be addressed in further patches. What is here is now rote and so we should get it out of the way before dealing more intricately with the remainder.

Reviewed By: #libunwind, #libc, #libc_abi, compnerd

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

2 years ago[NFC][msan] Consolidate clean shadow handling
Vitaly Buka [Fri, 14 Jan 2022 02:16:42 +0000 (18:16 -0800)]
[NFC][msan] Consolidate clean shadow handling

Depends on D117276

Reviewed By: kda, eugenis

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

2 years ago[NFC][msan] Don't setOrigin for byval pointer
Vitaly Buka [Fri, 14 Jan 2022 01:23:51 +0000 (17:23 -0800)]
[NFC][msan] Don't setOrigin for byval pointer

It's NFC because shadow of pointer is clean so origins will not be
propagated anyway.

Depends on D117275

Reviewed By: kda, eugenis

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

2 years agoTeach llvm-jitlink to support archives in inputs files and -load_hidden
Ben Langmuir [Fri, 14 Jan 2022 20:07:25 +0000 (12:07 -0800)]
Teach llvm-jitlink to support archives in inputs files and -load_hidden

Similar to the ld64 command-line options. These use the same underlying
mechanisms as -l and -hidden-l, but allow specifying an absolute path to
the archive. This is often more convenient for a one-off, or when adding
a new search path could change how existing -l options are resolved.

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

2 years ago[lldb/doc] Rephrase tutorial paragraph (NFC)
Med Ismail Bennani [Sat, 15 Jan 2022 00:21:10 +0000 (16:21 -0800)]
[lldb/doc] Rephrase tutorial paragraph (NFC)

Fixes #52694

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2 years ago[mlir][sparse] parameterize MTTKRP kernel
Aart Bik [Fri, 14 Jan 2022 19:08:57 +0000 (11:08 -0800)]
[mlir][sparse] parameterize MTTKRP kernel

Rather than hardcoding all constants, we now use the input tensor to drive the
code setup. Of course, we still need to hardcode dim-2 of A and the final
verification in CHECK is input dependent, but overall this sets a slightly
better example of tensor setup in general.

Reviewed By: bixia

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

2 years ago[lldb] Only promote -Wignored-attributes to an error
Jonas Devlieghere [Sat, 15 Jan 2022 00:15:43 +0000 (16:15 -0800)]
[lldb] Only promote -Wignored-attributes to an error

Avoid other warnings from failing the test, such as
-Wunused-command-line-argument in the downstream Swift fork.

2 years ago[flasg] Debug folding of substring references
Peter Klausler [Thu, 6 Jan 2022 21:31:37 +0000 (13:31 -0800)]
[flasg] Debug folding of substring references

Character substrings weren't being folded correctly;
add tests and rework the implementation so that substrings
of literals and named constant character scalars & arrays
are properly folded for use in constant expressions.

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

2 years ago[lldb] Fix platform selection on Apple Silicon
Jonas Devlieghere [Fri, 14 Jan 2022 07:10:22 +0000 (23:10 -0800)]
[lldb] Fix platform selection on Apple Silicon

Currently, when connecting to a remote iOS device from the command line
on Apple Silicon, we end up using the host platform (PlatfromMacOSX)
instead of remote-ios (PlatformRemoteiOS). This happens because
PlatfromMacOSX includes arm64-apple-ios and arm64e-apple-ios as
compatible architectures, presumably to support debugging iOS Apps on
Apple Silicon [1].

This is a problem for debugging remote ios devices, because the host
platform doesn't look for an expanded shared cache on disk and as a
result we end up reading everything from memory, incurring a significant
performance hit.

The crux of this patch is to make PlatfromMacOSX *not* compatible with
arm64(e)-apple-ios. This also means that we now use remote-ios
(PlatformRemoteiOS) as the platform for debugging iOS apps on Apple
Silicon. This has the (unintended) side effect that unlike we do for the
host platform, we no longer check our local shared cache, and incur a
performance hit on debugging these apps.

To avoid that, PlatformRemoteiOS now also check the local cache to
support this use case, which is cheap enough to do unconditionally for
PlatformRemoteiOS.

[1] https://support.apple.com/guide/app-store/iphone-ipad-apps-mac-apple-silicon-fird2c7092da/mac

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

2 years agoRevert "Skip exception cleanups when the innermost scope is EHTerminateScope."
James Y Knight [Fri, 14 Jan 2022 23:59:02 +0000 (18:59 -0500)]
Revert "Skip exception cleanups when the innermost scope is EHTerminateScope."

Breaks tests on some platforms. Reverting while investigating.

This reverts commit a4e255f9c6d4458fa6e70394af626f3b65e0a26d.

2 years ago[BOLT][NFC] Remove redundant dependent template type
Amir Ayupov [Fri, 14 Jan 2022 20:57:37 +0000 (12:57 -0800)]
[BOLT][NFC] Remove redundant dependent template type

Summary:
Reduce code size by removing redundant dependent template type
from RewriteInstance methods.

Code size savings (via bloaty on llvm-bolt Debug build):
```
symbol,vmsize,filesize -> vmsize,filesize (delta vmsize,filesize)
updateELFSymbolTable         57096,59600 -> 56656,59048 (440,552)
updateELFSymbolTable::lambda 35957,55277 -> 35949,54485   (8,792)
getOutputSections            20592,21440 -> 20372,21156 (220,284)
getOutputSections::lambda      1792,5300 ->   1792,5372   (0,-72)

total delta (668,1556)
```

Reviewed By: maksfb

FBD33589393

2 years ago[BOLT][CMAKE] Use IN_LIST check
Amir Ayupov [Fri, 14 Jan 2022 22:26:37 +0000 (14:26 -0800)]
[BOLT][CMAKE] Use IN_LIST check

Summary:
Address @smeenai feedback https://reviews.llvm.org/D117061#inline-1122106:
>CMake has if(IN_LIST) now, which you can use instead of the string(FIND)

IN_LIST is available since CMake 3.3 released in 2015.

Reviewed By: smeenai

FBD33590959

2 years ago[Hexagon] Fix optimize address mode pass only handle BaseImmOffset mode
Pranav Bhandarkar [Fri, 14 Jan 2022 23:42:10 +0000 (15:42 -0800)]
[Hexagon] Fix optimize address mode pass only handle BaseImmOffset mode

This is a fix for a crash in the HexagonOptAddrMode pass that was looking
for the third operand (offset) in the following instruction that does not,
in fact, have a third operand:

  $r1 = L2_loadw_locked $r1

Additionally, this patch also adds an addrMode value to vgather pseudos
in the Hexagon backend.

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

2 years agoclang/AMDGPU: Don't set implicit arg attribute to default size
Matt Arsenault [Sat, 4 Dec 2021 15:52:07 +0000 (10:52 -0500)]
clang/AMDGPU: Don't set implicit arg attribute to default size

Since 2959e082e1427647e107af0b82770682eaa58fe1, we conservatively
assume all inputs are enabled by default. This isn't the best
interface for controlling these anyway, since it's not granular and
only allows trimming the last fields.

2 years ago[flang] Accept ENTRY names in generic interfaces
Peter Klausler [Mon, 10 Jan 2022 18:16:19 +0000 (10:16 -0800)]
[flang] Accept ENTRY names in generic interfaces

ENTRY statement names in module subprograms were not acceptable for
use as a "module procedure" in a generic interface, but should be.
ENTRY statements need to have symbols with place-holding
SubprogramNameDetails created for them in order to be visible in
generic interfaces.  Those symbols are created from the "program
tree" data structure.  This patch adds ENTRY statement names to the
program tree data structure and uses them to generate SubprogramNameDetails
symbols.

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

2 years ago[NFC] Add additional tests for icmp predicate.
Nadav Rotem [Fri, 14 Jan 2022 23:22:10 +0000 (15:22 -0800)]
[NFC] Add additional tests for icmp predicate.

This commit adds small tests for the combination of:
{exact, no_exact} x { EQ, NE, UGT, UGE, ULT, ULE, SGT, SGE, SLT, SLE}

This is related to the changes in D117338.

2 years ago[flang] Don't blank-fill remaining lines in internal output
Peter Klausler [Wed, 5 Jan 2022 19:42:18 +0000 (11:42 -0800)]
[flang] Don't blank-fill remaining lines in internal output

Internal writes to character arrays should not blank-fill
records (elements) past the last one that was written to.

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

2 years ago[clang-format] Add experimental option to remove LLVM braces
Owen Pan [Mon, 13 Dec 2021 02:25:33 +0000 (18:25 -0800)]
[clang-format] Add experimental option to remove LLVM braces

See the style examples at:
https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements

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

2 years agoSkip exception cleanups when the innermost scope is EHTerminateScope.
James Y Knight [Wed, 10 Nov 2021 17:45:02 +0000 (12:45 -0500)]
Skip exception cleanups when the innermost scope is EHTerminateScope.

EHTerminateScope is used to implement C++ noexcept semantics. Per C++
[except.terminate], it is implemented-defined whether no, some, or all
cleanups are run prior to terminatation.

Therefore, the code to run cleanups on the way towards termination is
unnecessary, and may be omitted.

After this change, we will still run some cleanups: any cleanups in a
function called from the noexcept function will continue to run, while
those in the noexcept function itself will not.

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

2 years agoRegenerate some autogenerated test files ahead of modifying them.
James Y Knight [Sun, 14 Nov 2021 00:00:54 +0000 (19:00 -0500)]
Regenerate some autogenerated test files ahead of modifying them.

2 years ago[SROA] Bail out on PHIs in catchswitch BBs
Heejin Ahn [Wed, 12 Jan 2022 23:07:45 +0000 (15:07 -0800)]
[SROA] Bail out on PHIs in catchswitch BBs

In the process of rewriting `alloca`s and `phi`s that use them, the SROA
pass can try to insert a non-PHI instruction by calling
`getFirstInsertionPt()`, which is not possible in a catchswitch BB. This
CL makes we bail out on these cases.

Reviewed By: dschuff

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

2 years ago[scudo] Make Scudo compile for C++20
Kostya Kortchinsky [Fri, 14 Jan 2022 21:50:37 +0000 (13:50 -0800)]
[scudo] Make Scudo compile for C++20

In C++20 compound assignment to volatile (here `LocalData[I]++`) is
deprecated, so `mutex_test.cpp` fails to compile.

Simply changing it to `LocalData[I] = LocalData[I] + 1` fixes it.

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

2 years ago[flang] Signal runtime error on WRITE after ENDFILE
Peter Klausler [Fri, 7 Jan 2022 18:29:23 +0000 (10:29 -0800)]
[flang] Signal runtime error on WRITE after ENDFILE

After an ENDFILE statement, a WRITE is an error without
a prior BACKSPACE.  Also fix the return value for the case
of formatted integer input with no input digits to be false
(exposed by new test).

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

2 years agoRevert "[BasicAliasAnalysis] Remove isMallocOrCallocLikeFn"
Bryce Wilson [Fri, 14 Jan 2022 22:42:53 +0000 (14:42 -0800)]
Revert "[BasicAliasAnalysis] Remove isMallocOrCallocLikeFn"

This reverts commit 1f2cfc4fdc1eefb2c5f562c77a5fe7e916bbf670.

2 years ago[NFC][msan] Add byvals tests with known issues
Vitaly Buka [Fri, 14 Jan 2022 01:11:23 +0000 (17:11 -0800)]
[NFC][msan] Add byvals tests with known issues

Depends on D117274

Reviewed By: eugenis

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

2 years ago[LLDB] Skip TestIOHandlerPythonREPLSigint.py on AArch64/Linux
Muhammad Omair Javaid [Fri, 14 Jan 2022 22:23:20 +0000 (03:23 +0500)]
[LLDB] Skip TestIOHandlerPythonREPLSigint.py on AArch64/Linux

TestIOHandlerPythonREPLSigint.py is running falky on AArch64/Linux
buildbot failing randomly. Skipping it for AArch64/Linux as well.

2 years ago[flang] Legacy extension: non-character formats
Peter Klausler [Fri, 7 Jan 2022 01:03:40 +0000 (17:03 -0800)]
[flang] Legacy extension: non-character formats

Very old (pre-'77 standard) codes would use arrays initialized
with Hollerith literals, typically in DATA, as modifiable
formats.

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

2 years ago[BOLT][DWARF] Fix high pc patching
Vladislav Khmelevsky [Fri, 14 Jan 2022 22:03:42 +0000 (01:03 +0300)]
[BOLT][DWARF] Fix high pc patching

The DW_FORM_addr form of highPC address is written in absolute addres,
the data form is written in offset-from-low pc format.

Due to the large test binary the test is prepared separately in
https://github.com/rafaelauler/bolt-tests/pull/8

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

Reviewed By: ayermolo

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

2 years ago[NFC][SCEV] Introduce `getCastExpr()` QoL helper
Roman Lebedev [Fri, 14 Jan 2022 21:33:43 +0000 (00:33 +0300)]
[NFC][SCEV] Introduce `getCastExpr()` QoL helper

2 years agoComment parsing: Don't recognize commands in single-line double quotation
Aaron Puchert [Fri, 14 Jan 2022 21:45:59 +0000 (22:45 +0100)]
Comment parsing: Don't recognize commands in single-line double quotation

This is consistent with the behavior of Doxygen, and allows users to
write strings with C escapes or document input/output formats containing
special characters (@ or \) without escaping them, which might be
confusing. For example, if a function wants to document its expected
input format as "user@host" it doesn't have to write user\@host instead,
which would look right in the documentation but confusing in the code.
Now users can just use double quotes (which they might do anyway).

This fixes a lot of false positives of -Wdocumentation-unknown-command,
but it could also fix issues with -Wdocumentation if the text triggers
an actual command.

Reviewed By: gribozavr2

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

2 years agoComment parsing: Simplify Lexer::skipLineStartingDecorations (NFC)
Aaron Puchert [Fri, 14 Jan 2022 21:44:58 +0000 (22:44 +0100)]
Comment parsing: Simplify Lexer::skipLineStartingDecorations (NFC)

Inspection of the first character can just be handled by the loop as
well, it does exactly the same thing. Dereferencing the pointer a second
time shouldn't be an issue: the middle end can eliminate that second
read as it's separated from the first only by a pure function call.

Reviewed By: gribozavr2

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

2 years ago[libc] move strdup out of requiring SCUDO
Michael Jones [Wed, 12 Jan 2022 19:51:53 +0000 (11:51 -0800)]
[libc] move strdup out of requiring SCUDO

strdup needs either scudo enabled or fullbuild disabled, this properly
adds the second condition

Reviewed By: sivachandra, lntue

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

2 years ago[LoopInterchange] Enable interchange with multiple inner loop indvars
Congzhe Cao [Fri, 14 Jan 2022 20:42:00 +0000 (15:42 -0500)]
[LoopInterchange] Enable interchange with multiple inner loop indvars

Currently loop interchange only supports loops with one inner loop
induction variable. This patch adds support for transformation with
more than one inner loop induction variables. The induction PHIs and
induction increment instructions are moved/duplicated properly to the
new outer header and the new outer latch, respectively.

Reviewed By: bmahjour

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

2 years ago[NFC][msan] Reorder branches in complex if
Vitaly Buka [Fri, 14 Jan 2022 00:13:37 +0000 (16:13 -0800)]
[NFC][msan] Reorder branches in complex if

Reviewed By: eugenis

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

2 years agoFix NDEBUG unused-variable warning after 05f6e93938b73d8335f72e852f5686521cca2390.
James Y Knight [Fri, 14 Jan 2022 21:08:56 +0000 (21:08 +0000)]
Fix NDEBUG unused-variable warning after 05f6e93938b73d8335f72e852f5686521cca2390.

2 years ago[mlir] Remove getNumberOfExecutions from RegionBranchOpInterface
Eugene Zhulenev [Fri, 14 Jan 2022 19:08:23 +0000 (11:08 -0800)]
[mlir] Remove getNumberOfExecutions from RegionBranchOpInterface

`getNumRegionInvocations` was originally added for the async reference counting, but turned out to be not useful, and currently is not used anywhere (couldn't find any uses in public github repos). Removing dead code.

Reviewed By: Mogball, mehdi_amini

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

2 years ago[lld-macho] Simplify DeduplicatedCStringSection::finalizeContents. NFC
Fangrui Song [Fri, 14 Jan 2022 21:12:57 +0000 (13:12 -0800)]
[lld-macho] Simplify DeduplicatedCStringSection::finalizeContents. NFC

Tail merge is slow and of low value. With regular string deduplication, we can
just use the return value of StringTableBuilder::add.

There is no noticeable performance increase because without deduplication
`__cstring` is quite small (7.6MiB for chromium_framework).

Reviewed By: #lld-macho, Jez Ng

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

2 years agoDocument several clang-supported builtins
serge-sans-paille [Fri, 14 Jan 2022 10:28:29 +0000 (11:28 +0100)]
Document several clang-supported builtins

Namely
__builtin_alloca
__builtin_alloca_with_align
__builtin_call_with_static_chain
__builtin_expect
__builtin_expect_with_probablity
__builtin_prefetch

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

2 years agoFold ashr-exact into a icmp-ugt.
Nadav Rotem [Fri, 14 Jan 2022 16:55:10 +0000 (08:55 -0800)]
Fold ashr-exact into a icmp-ugt.

This commit optimizes the code sequence:
  icmp-XXX (ashr-exact (X, C_1), C_2).

Instcombine already implements this optimization for sgt, and this
patch adds support to additional predicates. The transformation is legal
for all predicates if the 'exact' flag is set, and to SGE, UGE, SLT, ULT
when the exact flag is not present.

This pattern is found in the std::vector bounds checks code of the at()
method.

Alive2 proof:
https://alive2.llvm.org/ce/z/JT_WL8

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

2 years ago[clang-format] Fix short functions being considered as inline inside an indented...
Marek Kurdej [Fri, 14 Jan 2022 20:51:06 +0000 (21:51 +0100)]
[clang-format] Fix short functions being considered as inline inside an indented namespace.

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

With config:
```
AllowShortFunctionsOnASingleLine: Inline
NamespaceIndentation: All
```

The code:
```
namespace Test
{
    void f()
    {
        return;
    }
}
```
was incorrectly formatted to:
```
namespace Test
{
    void f() { return; }
}
```

since the function `f` was considered being inside a class/struct/record.
That's because the check was simplistic and only checked for a non-zero indentation level of the line starting `f`.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks

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

2 years ago[SelectionDAGBuilder] Remove unneeded vector bitcast from visitTargetIntrinsic.
Craig Topper [Fri, 14 Jan 2022 20:03:16 +0000 (12:03 -0800)]
[SelectionDAGBuilder] Remove unneeded vector bitcast from visitTargetIntrinsic.

This seems to be a leftover from a long time ago when there was
an ISD::VBIT_CONVERT and a MVT::Vector. It looks like in those days
the vector type was carried in a VTSDNode.

As far as I know, these days ComputeValueTypes would have already
assigned "Result" the same type we're getting from TLI.getValueType
here. Thus the BITCAST is always a NOP. Verified by adding an assert
and running check-llvm.

Reviewed By: efriedma

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

2 years ago[libc++] [test] Add a test for proper _Uglification of template parameter names.
Arthur O'Dwyer [Mon, 10 Jan 2022 16:44:30 +0000 (11:44 -0500)]
[libc++] [test] Add a test for proper _Uglification of template parameter names.

Merge nasty_macros.h into the new test.

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

2 years ago[clang-format] Fix CompactNamespaces corner case when AllowShortLambdasOnASingleLine...
Marek Kurdej [Fri, 14 Jan 2022 20:42:09 +0000 (21:42 +0100)]
[clang-format] Fix CompactNamespaces corner case when AllowShortLambdasOnASingleLine/BraceWrapping.BeforeLambdaBody are set

In clang-format 12, `CompactNamespaces` misformatted the code when `AllowShortLambdasOnASingleLine` is set to false and `BraceWrapping.BeforeLambdaBody` is true.

Input:
```
namespace out {
namespace in {
}
} // namespace out::in
```

Expected output:
```
namespace out { namespace in {
}} // namespace out::in
```

Output from v12:
```
namespace out {
namespace in {
}
} // namespace out::in
```

Config triggering the issue:
```
---
AllowShortLambdasOnASingleLine: None
BraceWrapping:
  BeforeLambdaBody :    true
BreakBeforeBraces: Custom
CompactNamespaces: true
...
```

Seems there's a corner case when `AllowShortLambdasOnASingleLine` is false, and `BraceWrapping.BeforeLambdaBody` is true, that causes CompactNamespaces to stop working.
The cause was a misannotation of `{` opening brace after `namespace` as a lambda opening brace.
The regression was probably introduced with [this commit](https://github.com/llvm/llvm-project/commit/fa0118e6e588fe303b08e7e06ba28ac1f8d50c68).

Originally contributed by Ahmed Mahdy (@aybassiouny). Thank you!

Reviewed By: Wawha, HazardyKnusperkeks

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

2 years ago[libc++] Further small cleanups of move_iterator.h. NFC.
Arthur O'Dwyer [Fri, 14 Jan 2022 16:16:02 +0000 (11:16 -0500)]
[libc++] Further small cleanups of move_iterator.h. NFC.

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

2 years ago[libc++] s/_LIBCPP_INLINE_VISIBILITY/_LIBCPP_HIDE_FROM_ABI/g in move_iterator.h....
Arthur O'Dwyer [Fri, 14 Jan 2022 16:15:01 +0000 (11:15 -0500)]
[libc++] s/_LIBCPP_INLINE_VISIBILITY/_LIBCPP_HIDE_FROM_ABI/g in move_iterator.h. NFC.

2 years ago[libc++] Rename __i to __current_ in move_iterator. NFC.
Arthur O'Dwyer [Thu, 13 Jan 2022 21:11:12 +0000 (16:11 -0500)]
[libc++] Rename __i to __current_ in move_iterator. NFC.

2 years ago[BasicAliasAnalysis] Remove isMallocOrCallocLikeFn
Bryce Wilson [Thu, 13 Jan 2022 03:25:19 +0000 (19:25 -0800)]
[BasicAliasAnalysis] Remove isMallocOrCallocLikeFn

Allocation functions should be marked with onlyAccessesInaccessibleMemory (when that is correct for the given function) which is checked elsewhere so this check is no longer needed.

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

2 years ago[libc++] Add missing `<cstddef>` include in span test
Louis Dionne [Fri, 14 Jan 2022 20:05:25 +0000 (15:05 -0500)]
[libc++] Add missing `<cstddef>` include in span test

2 years ago[libcxx][test] Properly qualify uses of std::size_t
Casey Carter [Fri, 14 Jan 2022 19:41:18 +0000 (11:41 -0800)]
[libcxx][test] Properly qualify uses of std::size_t

To silence modular build error https://reviews.llvm.org/harbormaster/unit/view/1854595/

2 years ago[jitlink] add R_RISCV_BRANCH to jitlink
fourdim [Fri, 14 Jan 2022 19:35:50 +0000 (03:35 +0800)]
[jitlink] add R_RISCV_BRANCH to jitlink

This patch supported the R_RISCV_BRANCH relocation.

Reviewed By: lhames

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

2 years ago[InstrProf][NFC] Do not assume size of counter type
Ellis Hoag [Wed, 29 Dec 2021 21:36:28 +0000 (13:36 -0800)]
[InstrProf][NFC] Do not assume size of counter type

Existing code tended to assume that counters had type `uint64_t` and
computed size from the number of counters. Fix this code to directly
compute the counters size in number of bytes where possible. When the
number of counters is needed, use `__llvm_profile_counter_entry_size()`
or `getCounterTypeSize()`. In a later diff these functions will depend
on the profile mode.

Change the meaning of `DataSize` and `CountersSize` to make them more clear.
* `DataSize` (`CountersSize`) - the size of the data (counter) section in bytes.
* `NumData` (`NumCounters`) - the number of data (counter) entries.

Reviewed By: kyulee

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

2 years ago[JumpThreading] Change asserts for WantInteger into actual checks
Jessica Paquette [Fri, 2 Apr 2021 20:16:13 +0000 (13:16 -0700)]
[JumpThreading] Change asserts for WantInteger into actual checks

After e734e8286b4b521d829aaddb6d1cbbd264953625, it is possible to end up in
a situation where an `indirectbr` is fed by a cast, which is in turn fed by
an operation which only produces integers.

`indirectbr` expects a block address, however these operations can't produce
that.

There were several asserts in `computeValueKnownInPredecessorsImpl` which check
that we're not looking for a block address if we're walking through something
which can never produce one.

Since it's now possible to hit these asserts, this changes them into actual
checks which return false if `Preference` is not `WantInteger`.

This adds a testcase which verifies that we don't crash anymore in these
situations.

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

2 years ago[OpenMP] Fix problems with the declare variant append_args clause
Mike Rice [Wed, 12 Jan 2022 23:34:37 +0000 (15:34 -0800)]
[OpenMP] Fix problems with the declare variant append_args clause

Use ASTContext::getTypeDeclType() to get type of omp_interop_t since
TypeDecl::getTypeForDecl() may return null if TypeForDecl is not
setup yet.

Handle functions where the function type is under an AttributedType.

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

2 years ago[flang] "CFI" types for Fortran REAL and COMPLEX kinds 2, 3, 10, 16
V Donaldson [Fri, 14 Jan 2022 18:06:56 +0000 (10:06 -0800)]
[flang] "CFI" types for Fortran REAL and COMPLEX kinds 2, 3, 10, 16

Add additional "CFI" types for Fortran REAL and COMPLEX kinds 2, 3, 10, 16 to allow their use in Fortran descriptors.

2 years agoRecommit "[LV] Inline CreateSplatIV call for scalar VFs."
Florian Hahn [Fri, 14 Jan 2022 19:03:49 +0000 (19:03 +0000)]
Recommit "[LV] Inline CreateSplatIV call for scalar VFs."

This reverts the revert commit 073c27b5e5851f13d99d383e047309299b68827d.

A reduced test case has been added in 5e4966cbae7ba5 and the code has
been updated to handle the case where getInductionOpcode returns
BinaryOpsEnd. In this case, the original code was always using
Instruction::Add. Do the same in the patch.

Note this commit may slightly change the value naming, because it now
also assigns the 'induction' name in the floating point case.

2 years agoAdd new tests that check the icmp-ashr baseline.
Nadav Rotem [Fri, 14 Jan 2022 18:25:26 +0000 (10:25 -0800)]
Add new tests that check the icmp-ashr baseline.

This commit adds new tests that check the patterns that D117252 will
fix. As requested by @spatel.

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

2 years ago[flang] Allow pointers to non-sequence types in sequence types
Peter Klausler [Wed, 5 Jan 2022 01:09:33 +0000 (17:09 -0800)]
[flang] Allow pointers to non-sequence types in sequence types

Derived types with SEQUENCE must have data components of sequence
types; but this rule is relaxed as common an extension in the case of
pointer components, whose targets' types are not really relevant
to the implementation requirements of sequence types.

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

2 years ago[CPU-Dispatch] Make sure Dispatch names get updated if previously mangled
Erich Keane [Fri, 14 Jan 2022 18:22:06 +0000 (10:22 -0800)]
[CPU-Dispatch] Make sure Dispatch names get updated if previously mangled

Cases where there is a mangling of a cpu-dispatch/cpu-specific function
before the function becomes 'multiversion' (such as a member function)
causes the wrong name to be emitted for one of the variants/resolver,
since the name is cached.  Make sure we invalidate the cache in
cpu-dispatch/cpu-specific modes, like we previously did for just target
multiversioning.

2 years ago[libc++][NFC] Remove clang-diagnostic-c++98-compat-extra-semi warnings in experimenta...
Nikolas Klauser [Wed, 12 Jan 2022 23:07:01 +0000 (00:07 +0100)]
[libc++][NFC] Remove clang-diagnostic-c++98-compat-extra-semi warnings in experimental/simd

Force semicolons or remove them in `experimental/simd`

Reviewed By: Quuxplusone, ldionne, Mordante, #libc

Spies: libcxx-commits, miyuki

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

2 years agoApply clang-tidy fixes for readability-container-size-empty in SCF.cpp (NFC)
Mehdi Amini [Fri, 14 Jan 2022 07:34:55 +0000 (07:34 +0000)]
Apply clang-tidy fixes for readability-container-size-empty in SCF.cpp (NFC)

2 years agoApply clang-tidy fixes for readability-identifier-naming in MathOps.cpp (NFC)
Mehdi Amini [Fri, 14 Jan 2022 07:29:19 +0000 (07:29 +0000)]
Apply clang-tidy fixes for readability-identifier-naming in MathOps.cpp (NFC)

2 years agoApply clang-tidy fixes for performance-for-range-copy in PadOpInterchange.cpp (NFC)
Mehdi Amini [Fri, 14 Jan 2022 07:22:30 +0000 (07:22 +0000)]
Apply clang-tidy fixes for performance-for-range-copy in PadOpInterchange.cpp (NFC)

2 years agoApply clang-tidy fixes for performance-unnecessary-value-param in MLIRGen.cpp (NFC)
Mehdi Amini [Fri, 14 Jan 2022 06:09:14 +0000 (06:09 +0000)]
Apply clang-tidy fixes for performance-unnecessary-value-param in MLIRGen.cpp (NFC)

2 years ago[X86] Fix -Wunused-lambda-capture
Fangrui Song [Fri, 14 Jan 2022 18:07:20 +0000 (10:07 -0800)]
[X86] Fix -Wunused-lambda-capture

2 years ago[libc++] Fix __simple_view concept in std::ranges
Hui Xie [Fri, 14 Jan 2022 17:54:02 +0000 (12:54 -0500)]
[libc++] Fix __simple_view concept in std::ranges

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

2 years ago[InstCombine] remove unnecessary use check on X >>exact == 0 fold
Sanjay Patel [Fri, 14 Jan 2022 17:42:42 +0000 (12:42 -0500)]
[InstCombine] remove unnecessary use check on X >>exact == 0 fold

The transform replaces one icmp with another, so we should
not care if the shift has another use.

2 years ago[InstCombine] add tests for icmp with exact shift; NFC
Sanjay Patel [Fri, 14 Jan 2022 17:23:11 +0000 (12:23 -0500)]
[InstCombine] add tests for icmp with exact shift; NFC

2 years ago[libc++] [test] ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS is not supported on AIX.
Arthur O'Dwyer [Sat, 8 Jan 2022 20:20:37 +0000 (15:20 -0500)]
[libc++] [test] ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS is not supported on AIX.

I believe all four of these failures are directly due to the pattern where
allocations in the dylib are unobserved by the client program. If AIX32 and AIX64
don't support that, we should just disable the ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS
macro on AIX, and then we don't need to XFAIL these tests.

This also means I won't need to XFAIL a dozen other tests in D89057,
which rely heavily on ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS and
also currently fail on AIX.
See https://buildkite.com/llvm-project/libcxx-ci/builds/7669

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

2 years ago[libc] Implement correctly rounded log2f based on RLIBM library.
Tue Ly [Wed, 15 Dec 2021 21:32:40 +0000 (16:32 -0500)]
[libc] Implement correctly rounded log2f based on RLIBM library.

Implement log2f based on RLIBM library correctly rounded for all rounding modes.

Reviewed By: sivachandra, michaelrj, santoshn, jpl169, zimmermann6

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

2 years ago[libc++] [NFC] Remove a hard tab from __config.
Arthur O'Dwyer [Fri, 14 Jan 2022 17:18:44 +0000 (12:18 -0500)]
[libc++] [NFC] Remove a hard tab from __config.

2 years ago[MLIR] Introduce generic visitors.
Rahul Joshi [Thu, 13 Jan 2022 21:32:14 +0000 (13:32 -0800)]
[MLIR] Introduce generic visitors.

- Generic visitors invoke operation callbacks before/in-between/after visiting the regions
  attached to an operation and use a `WalkStage` to indicate which regions have been
  visited.
- This can be useful for cases where we need to visit the operation in between visiting
  regions attached to the operation.

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

2 years ago[X86][AVX] lowerShuffleAsLanePermuteAndShuffle - don't split repeated mask patterns
Simon Pilgrim [Fri, 14 Jan 2022 17:10:26 +0000 (17:10 +0000)]
[X86][AVX] lowerShuffleAsLanePermuteAndShuffle - don't split repeated mask patterns

Generalize 57a551a8dfa7 - if the inlane mask is a repeated mask, we're better off performing the lane permute instead of splitting

2 years ago[RISCV] Add basic support for matching shuffles to vslidedown.vi.
Craig Topper [Fri, 14 Jan 2022 17:04:53 +0000 (09:04 -0800)]
[RISCV] Add basic support for matching shuffles to vslidedown.vi.

Specifically the unary shuffle case where the elements being
shifted in are undef. This handles the shuffles produce by expanding
llvm.reduce.mul.

I did not reduce the VL which would increase the number of vsetvlis,
but may improve the execution speed. We'd also want to narrow the
multiplies so we could share vsetvlis between the vslidedown.vi and
the next multiply.

Reviewed By: frasercrmck

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

2 years ago[RISCV] Honor the VT when converting float point register names to register class...
Craig Topper [Fri, 14 Jan 2022 16:57:09 +0000 (08:57 -0800)]
[RISCV] Honor the VT when converting float point register names to register class for inline assembly.

It appears the code here was written for the inline asm clobbering
a specific register, but it also gets used for named input and
output registers.

For the input and output case, we should honor the VT so we
don't insert conversion instructions around the inline assembly.

For the clobber, case we need to pick the largest register class.

Reviewed By: asb, jrtc27

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

2 years ago[Docs] Use anonymous reference (NFC)
Nikita Popov [Fri, 14 Jan 2022 17:00:22 +0000 (18:00 +0100)]
[Docs] Use anonymous reference (NFC)

Hopefully fixes the build failure. Also fix a typo.

2 years ago[AMDGPU] Correct the known bits calculation for MUL_I24.
Craig Topper [Fri, 14 Jan 2022 16:47:40 +0000 (08:47 -0800)]
[AMDGPU] Correct the known bits calculation for MUL_I24.

I'm not entirely sure, but based on how ComputeNumSignBits handles
ISD::MUL, I believe this code was miscounting the number of sign
bits.

As an example of an incorrect result let's say that countMinSignBits
returned 1 for the left hand side and 24 for the right hand side.
LHSValBits would be 23 and RHSValBits would be 0 and the sum would
be 23. This would cause the code to set 9 high bits as zero/one. Now
suppose the real values for the left side is 0x800000 and the right
hand side is 0xffffff. The product is 0x00800000 which has 8 sign bits
not 9.

The number of valid bits for the left and right operands is now
the number of non-sign bits + 1. If the sum of the valid bits of
the left and right sides exceeds 32, then the result may overflow and we
can't say anything about the sign of the result. If the sum is 32
or less then it won't overflow and we know the result has at least
1 sign bit.

For the previous example, the code will now calculate the left
side valid bits as 24 and the right side as 1. The sum will be 25
and the sign bits will be 32 - 25 + 1 which is 8, the correct value.

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

2 years ago[AMDGPU] Pre-commit test for D116469. NFC
Craig Topper [Fri, 14 Jan 2022 16:47:05 +0000 (08:47 -0800)]
[AMDGPU] Pre-commit test for D116469. NFC

The multiply in this test is miscompiled to 0.

Reviewed By: foad

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

2 years ago[InstCombine] add more tests for binop with phi operands; NFC
Sanjay Patel [Fri, 14 Jan 2022 15:13:11 +0000 (10:13 -0500)]
[InstCombine] add more tests for binop with phi operands; NFC

Goes with D117110.

2 years ago[InstCombine] add test for limitation of knownbits with overshift; NFC
Sanjay Patel [Fri, 14 Jan 2022 15:01:11 +0000 (10:01 -0500)]
[InstCombine] add test for limitation of knownbits with overshift; NFC

The tests above this were added for D30781 and used to provide
coverage for a limit of knownbits, but improvements in other
transforms killed that intended purpose. This was noted because
another proposed improvement in D117110 will further reduce
those tests.

2 years ago[Docs] Update opaque pointer docs (NFC)
Nikita Popov [Fri, 14 Jan 2022 16:41:42 +0000 (17:41 +0100)]
[Docs] Update opaque pointer docs (NFC)

Mention -opaque-pointers, write a bit more about migration pitfalls
and update the open issues.

2 years ago[SystemZ][z/OS] ASCII/EBCDIC support with no coexistence
Muiez Ahmed [Fri, 14 Jan 2022 16:35:53 +0000 (11:35 -0500)]
[SystemZ][z/OS] ASCII/EBCDIC support with no coexistence

The aim of this patch is to break up the larger patch (https://reviews.llvm.org/D111323) to be more upstream friendly. In particular, this patch adds the char encoding sensitive changes but does not use inline namespaces as before. The use of namespaces to build both versions of the library, and localization of error messages will follow in a subsequent patch.

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

2 years agoRevert "[MemoryBuiltins] [NFC] Add missing section comments"
Philip Reames [Fri, 14 Jan 2022 16:01:56 +0000 (08:01 -0800)]
Revert "[MemoryBuiltins] [NFC] Add missing section comments"

This reverts commit 83338d5032424741accb1e851408021b47b84c08.  Comments in source are non-idiomatic and naming choice in head is unclear.

2 years ago[LTO] runNewPMPasses - remove check for TM != nullptr as we already dereference the...
Simon Pilgrim [Fri, 14 Jan 2022 16:31:14 +0000 (16:31 +0000)]
[LTO] runNewPMPasses - remove check for TM != nullptr as we already dereference the pointer directly later on in the same code

2 years ago[libc] Update exhaustive testing documentations.
Tue Ly [Fri, 14 Jan 2022 16:08:52 +0000 (11:08 -0500)]
[libc] Update exhaustive testing documentations.