platform/upstream/llvm.git
2 years agoCleanup LLVMTextAPI headers
serge-sans-paille [Wed, 26 Jan 2022 13:02:49 +0000 (08:02 -0500)]
Cleanup LLVMTextAPI headers

Based on the output of iwyu. A full rebuild of llvm-project doesn't exhibit any
significant false dependencies.

The impact on preprocessed output is larger than expected, given the small
amount of changes

$ clang++ -E  -Iinclude -I../llvm/include ../llvm/lib/TextAPI/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l
before: 635319
After: 643716

Discourse thread on the topic: https://llvm.discourse.group/t/include-what-you-use-include-cleanup

2 years agoRewrite Doxygen comment to resolve -Wdocumentation warning (NFC)
Salman Javed [Wed, 26 Jan 2022 12:30:38 +0000 (01:30 +1300)]
Rewrite Doxygen comment to resolve -Wdocumentation warning (NFC)

Comment change only, no functional change intended.
Example of warning:
https://lab.llvm.org/buildbot/#/builders/188/builds/8696/steps/4/logs/warnings__2_

2 years ago[VE] Packed 32/64bit broadcast isel and tests
Simon Moll [Wed, 26 Jan 2022 09:32:26 +0000 (10:32 +0100)]
[VE] Packed 32/64bit broadcast isel and tests

Packed-mode broadcast of f32/i32 requires the subregister to be
replicated to the full I64 register prior. Add repl_i32 and repl_f32 to
faciliate this.

Reviewed By: kaz7

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

2 years agoFix conditional include in ThreadPool
serge-sans-paille [Wed, 26 Jan 2022 13:15:14 +0000 (14:15 +0100)]
Fix conditional include in ThreadPool

Should fix  https://lab.llvm.org/buildbot#builders/37/builds/10259

2 years ago[DSE] Use helper for unwind check (NFCI)
Nikita Popov [Wed, 26 Jan 2022 12:08:39 +0000 (13:08 +0100)]
[DSE] Use helper for unwind check (NFCI)

This should be no functional change, as the cases supported by the
helper and the cases supported by DSE are currently the same, the
code structure is just slightly different.

2 years ago[AArch64] Add NEON test cases for ISD::ABDS/U.
Paul Walker [Wed, 26 Jan 2022 12:55:15 +0000 (12:55 +0000)]
[AArch64] Add NEON test cases for ISD::ABDS/U.

2 years ago[flang][tco] Remove unneeded dependencies
Andrzej Warzynski [Tue, 25 Jan 2022 09:42:35 +0000 (09:42 +0000)]
[flang][tco] Remove unneeded dependencies

`tco` does not generate machine code, so it does not require (machine)
code-gen related dependencies.

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

2 years ago[demangler] refactor SpecialSubKind
Nathan Sidwell [Mon, 24 Jan 2022 15:59:57 +0000 (07:59 -0800)]
[demangler] refactor SpecialSubKind

Code generating the special substitutions in std is a switch statement
with each case block containing the same conststruction template.  It
is more efficient to commonize that after the switch, having
determined which SubKind to create.  Also, let's sort the cases.

Reviewed By: ChuanqiXu

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

2 years ago[demangler] improve test harness
Nathan Sidwell [Mon, 24 Jan 2022 19:07:29 +0000 (11:07 -0800)]
[demangler] improve test harness

The demangler test harness is a little unclear.  The failed demangling
message always causes me to think about 'reality', changing to a
simple 'Found' seems clearer.

The expected-to-fail tests abort as soon as one passes, rather than
continue, and then abort if any passed.  This changes that loop to
fail at the end, in a similar manner to the expected-to-work loop.

Reviewed By: ChuanqiXu

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

2 years agoCleanup headers for BinaryFormat
serge-sans-paille [Wed, 26 Jan 2022 11:22:41 +0000 (06:22 -0500)]
Cleanup headers for BinaryFormat

A few header removal, some forward declarations. As usual, this can
break your build due to false dependencies, the most notable change are:

- "llvm/BinaryFormat/AMDGPUMetadataVerifier.h" no longer includes "llvm/BinaryFormat/MsgPackDocument.h"

The impact on generated preprocessed lines for LLVMBinaryFormat is
pretty nice:

$ clang++ -E  -Iinclude -I../llvm/include ../llvm/lib/BinaryFormat/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l
before this patch: 705281
after this patch: 751456

Discourse thread on the topic: https://llvm.discourse.group/t/include-what-you-use-include-cleanup

2 years ago[mlir][LLVM] Add support for operand_attrs to InlineAsmOp
Nicolas Vasilache [Wed, 26 Jan 2022 10:57:09 +0000 (05:57 -0500)]
[mlir][LLVM] Add support for operand_attrs to InlineAsmOp

This revision adds enough support to allow InlineAsmOp to work properly with indirect memory constraints "*m".
These require an explicit "elementtype" TypeAttr on the operands to pass LLVM verification and need to be provided.

Reviewed By: bkramer

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

2 years ago[X86] Extend PR53419 test coverage
Simon Pilgrim [Wed, 26 Jan 2022 12:32:38 +0000 (12:32 +0000)]
[X86] Extend PR53419 test coverage

Test on SSE2/SSE41/AVX1 targets to compare PMOVMSK vs PTEST codegen paths

Add v8i8 reduction case and test on X64 and X86 targets to check 32-bit handling

2 years ago[AMDGPU] Enable divergence-driven XNOR selection
alex-t [Fri, 24 Dec 2021 14:40:49 +0000 (17:40 +0300)]
[AMDGPU] Enable divergence-driven XNOR selection

Currently not (xor_one_use) pattern is always selected to S_XNOR irrelative od the node divergence.
This relies on further custom selection pass which converts to VALU if necessary and replaces with V_NOT_B32 ( V_XOR_B32)
on those targets which have no V_XNOR.
Current change enables the patterns which explicitly select the not (xor_one_use) to appropriate form.
We assume that xor (not) is already turned into the not (xor) by the combiner.

Reviewed By: rampitec

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

2 years ago[gn build] Port 5da7c040030c
LLVM GN Syncbot [Wed, 26 Jan 2022 12:14:21 +0000 (12:14 +0000)]
[gn build] Port 5da7c040030c

2 years ago[lldb] Convert POSIXLog to use the new API
Pavel Labath [Wed, 26 Jan 2022 12:02:48 +0000 (13:02 +0100)]
[lldb] Convert POSIXLog to use the new API

2 years ago[SVE] Use DUPM to handling more splat immediate cases.
Paul Walker [Mon, 24 Jan 2022 12:35:18 +0000 (12:35 +0000)]
[SVE] Use DUPM to handling more splat immediate cases.

NOTE: Only considers i64 based vectors at this time because smaller
element types require extra isel operand parsing.

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

2 years agoRe-land "Cache the locations of NOLINTBEGIN/END blocks" with fix for build bot
Salman Javed [Wed, 26 Jan 2022 12:02:35 +0000 (01:02 +1300)]
Re-land "Cache the locations of NOLINTBEGIN/END blocks" with fix for build bot

2 years ago[gn build] Port 8e29d19b8d29
LLVM GN Syncbot [Wed, 26 Jan 2022 11:52:58 +0000 (11:52 +0000)]
[gn build] Port 8e29d19b8d29

2 years agoRevert "[clang-tidy] Cache the locations of NOLINTBEGIN/END blocks"
Salman Javed [Wed, 26 Jan 2022 11:52:25 +0000 (00:52 +1300)]
Revert "[clang-tidy] Cache the locations of NOLINTBEGIN/END blocks"

Build warning here:
https://lab.llvm.org/buildbot/#/builders/57/builds/14322

2 years ago[gn build] Port 19eaad94c47f
LLVM GN Syncbot [Wed, 26 Jan 2022 11:47:14 +0000 (11:47 +0000)]
[gn build] Port 19eaad94c47f

2 years ago[MemCpyOpt] Use helper for unwind check
Nikita Popov [Wed, 26 Jan 2022 10:27:44 +0000 (11:27 +0100)]
[MemCpyOpt] Use helper for unwind check

This extends support to byval arguments. It would be further
extended to handle the case of non-captured noalias returns.

2 years ago[clang][dataflow] Enable merging distinct values in Environment::join
Stanislav Gatev [Mon, 24 Jan 2022 13:29:06 +0000 (13:29 +0000)]
[clang][dataflow] Enable merging distinct values in Environment::join

Make specializations of `DataflowAnalysis` extendable with domain-specific
logic for merging distinct values when joining environments. This could be
a strict lattice join or a more general widening operation.

This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.

Reviewed-by: xazax.hun
Differential Revision: https://reviews.llvm.org/D118038

2 years ago[Dexter] Remove false requirement of lldb for dexter regression tests on Windows
OCHyams [Wed, 26 Jan 2022 11:09:21 +0000 (11:09 +0000)]
[Dexter] Remove false requirement of lldb for dexter regression tests on Windows

Not quite NFC because a little work was required to configure some tests to run
on Windows at all.

Before this patch on Windows:

    $ llvm-lit cross-project-tests\debuginfo-tests\dexter\feature-tests
       Unsupported: 49
       Passed     : 23

After this patch on Windows:

    $ llvm-lit cross-project-tests\debuginfo-tests\dexter\feature-tests
       Unsupported      : 27
       Passed           : 39
       Expectedly failed:  6

There are 3 main changes here. The first is to add a few more substitutions in
cross-project-tests/lit.cfg.py so that tests need to use specific flags can
still use the dexter regression test defaults for the native platform. These
are:

     %dexter_regression_test_debugger
     %dexter_regression_test_builder
     %dexter_regression_test_cflags
     %dexter_regression_test_ldflags

Tests that now use these options and therefore can be run on Windows too
(though the second is still failing for unknown reasons):

    cross-project-tests/debuginfo-tests/dexte/feature_tests
        /subtools/clang-opt-bisect/clang-opt-bisect.cpp
        /subtools/test/source-root-dir.cpp

The second change is to remove spurious `REQUIRES: system-linux, lldb` and
`UNSUPPORTED: system-windows` directives, and make changes to lit.local.cfg
files that have the same effect. I've also added comments to the genuine
REQUIRES, UNSUPPORTED, and XFAIL directives so it's easier to understand
requirements at a glance. The most common reason for a test to not be supported
on Windows is that it uses DexLimitSteps, DexDeclareAddress, or DexCommandLine,
none of which are supported in the dbgeng driver.

There are two failures on Windows that were previously hidden, which I've
XFAILed:

    cross-project-tests/debuginfo-tests/dexter/feature_tests
        /commands/perfect/dex_finish_test/default_conditional.cpp
        /commands/perfect/dex_finish_test/default_conditional_hit_count.cpp

And two that were easy to fix:

    cross-project-tests/debuginfo-tests/dexter/feature_tests
        /commands/perfect/dex_finish_test/default_simple.cpp
        /commands/perfect/dex_finish_test/default_hit_count.cpp

Lastly, I've set three directories as unsupported.

    cross-project-tests/debuginfo-tests/dexter/feature_tests
        /commands/perfect/limit_steps
        /commands/perfect/dex_declare_address
        /commands/perfect/dex_declare_file

The first two are unsupported on Windows because they contains tests for the
DexLimitSteps and DexDeclareAddress commands which aren't supported in the
dbgeng driver. The third is unsupported on all platforms as the tests involve
invoking clang directly, which isn't currently a supported way of building
tests for dexter in lit (it can cause problems for cross compilers that can
target the host, as the tests use the default triple and linker, which may
be aligned for the default target, not host).

Tested on Windows and Linux.

Reviewed By: jmorse

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

2 years agoFix MSVC 'not all control paths return a value' warning. NFC.
Simon Pilgrim [Wed, 26 Jan 2022 11:33:08 +0000 (11:33 +0000)]
Fix MSVC 'not all control paths return a value' warning. NFC.

2 years ago[AMDGPU][GlobalISel] Combine unmerge of undef
Sebastian Neubauer [Tue, 25 Jan 2022 14:20:42 +0000 (15:20 +0100)]
[AMDGPU][GlobalISel] Combine unmerge of undef

Fold (unmerge undef) -> undef, undef, ...

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

2 years ago[AMDGPU][NFC] Pre-commit regenerated test
Sebastian Neubauer [Tue, 25 Jan 2022 14:22:28 +0000 (15:22 +0100)]
[AMDGPU][NFC] Pre-commit regenerated test

2 years ago[lldb][AArch64] Add MakeTaggedRanges to MemoryTagManager
David Spickett [Fri, 29 Oct 2021 15:09:03 +0000 (16:09 +0100)]
[lldb][AArch64] Add MakeTaggedRanges to MemoryTagManager

This is to be used when you want to know what subranges
of a larger range have memory tagging. Like MakeTaggedRange
but memory without tags is skipped and you get a list of ranges back.

Will be used later by DumpDataExtractor to show memory tags.

MakeTaggedRanges assumes that the memory regions it is
given are sorted in ascending order and do not overlap.
For the current use case where you get regions from
GetMemoryRegions and are on some Linux like OS, this is
reasonable to assume.

I've used asserts to check those conditions. In future
any API binding will check them up front to prevent a crash.

Reviewed By: omjavaid

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

2 years ago[Test] Add test for PR53419
Max Kazantsev [Wed, 26 Jan 2022 10:48:32 +0000 (17:48 +0700)]
[Test] Add test for PR53419

These tests demonstrate how suboptimal is the lowering of
equality checks for short vectors.

2 years ago[clang-tidy] Cache the locations of NOLINTBEGIN/END blocks
Salman Javed [Wed, 26 Jan 2022 10:56:27 +0000 (23:56 +1300)]
[clang-tidy] Cache the locations of NOLINTBEGIN/END blocks

Support for NOLINT(BEGIN/END) blocks (implemented in D108560) is
currently costly. This patch aims to improve the performance with the
following changes:

- The use of tokenized NOLINTs instead of a series of repetitive ad-hoc
string operations (`find()`, `split()`, `slice()`, regex matching etc).
- The caching of NOLINT(BEGIN/END) block locations. Determining these
locations each time a new diagnostic is raised is wasteful as it
requires reading and parsing the entire source file.

Move NOLINT-specific code from `ClangTidyDiagnosticConsumer` to new
purpose-built class `NoLintDirectiveHandler`.

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

2 years ago[mlir][Linalg] Add GenericOp self-copy on buffers folding
Nicolas Vasilache [Wed, 26 Jan 2022 10:19:53 +0000 (05:19 -0500)]
[mlir][Linalg] Add GenericOp self-copy on buffers folding

Reviewed By: pifon2a

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

2 years ago[MemCpyOpt] Add additiona call slot unwind tests (NFC)
Nikita Popov [Wed, 26 Jan 2022 10:48:11 +0000 (11:48 +0100)]
[MemCpyOpt] Add additiona call slot unwind tests (NFC)

Test a possibly unwinding call with a byval and sret argument.

2 years agoremove spurious comma [NFC]
Nuno Lopes [Wed, 26 Jan 2022 10:48:43 +0000 (10:48 +0000)]
remove spurious comma [NFC]

2 years ago[LSV] Vectorize loads of vectors by turning it into a larger vector
Benjamin Kramer [Thu, 13 Jan 2022 12:12:50 +0000 (13:12 +0100)]
[LSV] Vectorize loads of vectors by turning it into a larger vector

Use shufflevector to do the subvector extracts. This allows a lot more
load merging on AMDGPU and also on NVPTX when <2 x half> is involved.

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

2 years ago[clang][dataflow] Assign aggregate storage locations to union stmts
Stanislav Gatev [Wed, 26 Jan 2022 09:15:07 +0000 (09:15 +0000)]
[clang][dataflow] Assign aggregate storage locations to union stmts

This patch ensures that the dataflow analysis framework does not crash
when it encounters access to members of union types.

This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.

Reviewed-by: xazax.hun
Differential Revision: https://reviews.llvm.org/D118226

2 years ago[mlir][openmp] Custom syntax for `omp.target` operation
Alexander Batashev [Wed, 26 Jan 2022 10:10:50 +0000 (10:10 +0000)]
[mlir][openmp] Custom syntax for `omp.target` operation

Add a custom parser and printer for `omp.target` operation.

Reviewed By: kiranchandramohan

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

2 years ago[clang] Fix serialized diagnostics edge-cases
Jan Svoboda [Wed, 26 Jan 2022 10:21:49 +0000 (11:21 +0100)]
[clang] Fix serialized diagnostics edge-cases

The Clang frontend sometimes fails on the following assertion when launched with `-serialize-diagnostic-file <x>`:

```
Assertion failed: (BlockScope.empty() && CurAbbrevs.empty() && "Block imbalance"), function ~BitstreamWriter, file BitstreamWriter.h, line 125.
```

This was first noticed when passing an unknown command-line argument to `-cc1`.

It turns out the `DiagnosticConsumer::finish()` function should be called as soon as processing of all source files ends, but there are some code paths where that doesn't happen:

1. when command line parsing fails in `cc1_main()`,
2. when `!Act.PrepareToExecute(*this)` or `!createTarget()` evaluate to `true` in `CompilerInstance::ExecuteAction` and the function returns early.

This patch ensures `finish()` is called in all those code paths.

Reviewed By: Bigcheese

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

2 years ago[clang][syntax] Replace `std::vector<bool>` use
Jan Svoboda [Wed, 26 Jan 2022 10:18:00 +0000 (11:18 +0100)]
[clang][syntax] Replace `std::vector<bool>` use

LLVM Programmer’s Manual strongly discourages the use of `std::vector<bool>` and suggests `llvm::BitVector` as a possible replacement.

This patch replaces `std::vector<bool>` with `llvm::BitVector` in the Syntax library and replaces range-based for loop with regular for loop. This is necessary due to `llvm::BitVector` not having `begin()` and `end()` (D117116).

Reviewed By: dexonsmith, dblaikie

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

2 years ago[llvm][support] Replace `std::vector<bool>` use in YAMLTraits
Jan Svoboda [Wed, 26 Jan 2022 10:16:11 +0000 (11:16 +0100)]
[llvm][support] Replace `std::vector<bool>` use in YAMLTraits

LLVM Programmer’s Manual strongly discourages the use of `std::vector<bool>` and suggests `llvm::BitVector` as a possible replacement.

This patch replaces the use of `std::vector` with `llvm::BitVector` in LLVM's YAML traits and replaces the call to `Vec.insert(Vec.begin(), N, false)` on empty `Vec` with `Vec.resize(N)`, which has the same semantics but avoids using `insert` and iterators, which `llvm::BitVector` doesn't possess.

Reviewed By: dexonsmith, dblaikie

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

2 years ago[NewGVN] FIx phi-of-ops in the presence of memory read operations
Nuno Lopes [Wed, 26 Jan 2022 10:10:22 +0000 (10:10 +0000)]
[NewGVN] FIx phi-of-ops in the presence of memory read operations

The phi-of-ops functionality has a function OpIsSafeForPHIOfOps
to determine when it's safe to create the new phi.
But this function only checks for the obvious dominator conditions
and ignores memory.
This patch takes the conservative approach and disables phi-of-ops
whenever there's a load that doesn't dominate the phi, as its
value may be affected by a store inside the loop.

This can be improved later to check aliasing between the
load/stores.

Fixes https://llvm.org/PR53277

Reviewed By: asbirlea

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

2 years ago[NFC] Additional header dependency cleanup LLVMSupport
serge-sans-paille [Wed, 26 Jan 2022 07:50:00 +0000 (02:50 -0500)]
[NFC] Additional header dependency cleanup LLVMSupport

A few more forward-declarations, a few less headers. the impact on number of
preprocessed lines for LLVMSupport is negligible (-3K lines) but it's always
good to remove dependencies.

Related discourse thread: https://llvm.discourse.group/t/include-what-you-use-include-cleanup

2 years ago[LICM] Generalize unwinding check during scalar promotion
Nikita Popov [Tue, 11 Jan 2022 10:02:26 +0000 (11:02 +0100)]
[LICM] Generalize unwinding check during scalar promotion

This extract a common isNotVisibleOnUnwind() helper into
AliasAnalysis, which handles allocas, byval arguments and noalias
calls. After D116998 this could also handle sret arguments. We
have similar logic in DSE and MemCpyOpt, which will be switched
to use this helper as well.

The noalias call case is a bit different from the others, because
it also requires that the object is not captured. The caller is
responsible for doing the appropriate check.

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

2 years agoFix edb02d8c5df36bb375df7171b4ba61635564dfb4
serge-sans-paille [Wed, 26 Jan 2022 10:06:12 +0000 (05:06 -0500)]
Fix edb02d8c5df36bb375df7171b4ba61635564dfb4

2 years ago[LICM] Add additional tests for promotion with unwinding (NFC)
Nikita Popov [Tue, 11 Jan 2022 09:57:56 +0000 (10:57 +0100)]
[LICM] Add additional tests for promotion with unwinding (NFC)

2 years ago[OpenMPIRBuilderTest] Avoid pointer element type access
Nikita Popov [Wed, 26 Jan 2022 10:02:03 +0000 (11:02 +0100)]
[OpenMPIRBuilderTest] Avoid pointer element type access

This was reintroduced by D110114.

2 years agoRestrict performPostLD1Combine to 64 and 128 bit vectors
Maciej Gabka [Wed, 26 Jan 2022 09:46:32 +0000 (09:46 +0000)]
Restrict performPostLD1Combine to 64 and 128 bit vectors

When wider vectors are used, for example fixed width SVE,
there is no patterns to select AArch64ISD::LD1LANEpost
nodes, so we should do an early exit.

Reviewed By: paulwalker-arm

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

2 years ago[mlir][Bazel] Remove unnecessary dependencies
Adrian Kuegel [Wed, 26 Jan 2022 09:15:44 +0000 (10:15 +0100)]
[mlir][Bazel] Remove unnecessary dependencies

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

2 years ago[libcxx] [test] Fix mismatches between _aligned_malloc and free() on Windows
Martin Storsjö [Sun, 9 Jan 2022 22:32:47 +0000 (22:32 +0000)]
[libcxx] [test] Fix mismatches between _aligned_malloc and free() on Windows

This allows getting rid of one case of LIBCXX-WINDOWS-FIXME. The fixme
comment was inaccurate; aligned allocation functions are provided these
days, but the test kept failing as it was using mismatched allocation
and free functions.

A similar issue was fixed earlier, in
6596778b46ba69517191e7397289228168064ff4. That test was fixed by
overriding the aligned `operator new` too, and returning a dummy fixed
allocation instead. As this test is libcxx specific, it can use the
internal `std::__libcpp_aligned_free()` instead, to match libcxx's
internal aligned `operator new`.

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

2 years ago[SCEVExpander] Remove pointer element type access in assertion
Nikita Popov [Wed, 26 Jan 2022 09:34:23 +0000 (10:34 +0100)]
[SCEVExpander] Remove pointer element type access in assertion

Assert directly on i8 rather than the element type of i8*.

2 years ago[OpenMPOpt] Add const qualifier (NFC)
Nikita Popov [Wed, 26 Jan 2022 09:20:39 +0000 (10:20 +0100)]
[OpenMPOpt] Add const qualifier (NFC)

Make it clear that this large lambda does not modify the vector.

2 years ago[NFC] Use an llvm::DenseMap instead of std::map in CategorizedHelpPrinter::printOptions
serge-sans-paille [Tue, 25 Jan 2022 20:48:51 +0000 (15:48 -0500)]
[NFC] Use an llvm::DenseMap instead of std::map in CategorizedHelpPrinter::printOptions

It's a recommit of 6427f4c52c31cc36004 (patch included)

2 years ago[AddressSanitizer] Avoid pointer element type accesses
Nikita Popov [Wed, 26 Jan 2022 09:10:13 +0000 (10:10 +0100)]
[AddressSanitizer] Avoid pointer element type accesses

Determine masked load/store type based on the value operand and
result types, rather than pointer element type.

2 years ago[flang] Get rid of code duplication in wrapper. Fix checking of undefined variables.
Yury Gribov [Wed, 19 Jan 2022 08:21:44 +0000 (17:21 +0900)]
[flang] Get rid of code duplication in wrapper. Fix checking of undefined variables.

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

2 years ago[DAG] Create fptoui.sat from clamped fptoui
David Green [Wed, 26 Jan 2022 08:37:44 +0000 (08:37 +0000)]
[DAG] Create fptoui.sat from clamped fptoui

This is the unsigned variant of D111976, where we convert a clamped
fptoui to a fptoui.sat. Because we are unsigned, the condition this time
is only UMIN of UINT_MAX. Similarly to D111976 it handles ISD::UMIN,
ISD::SETCC/ISD::SELECT, ISD::VSELECT or ISD::SELECT_CC nodes.

This especially helps on ARM/AArch64 where the vcvt instructions
naturally saturate the result.

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

2 years ago[flang] Add a custom target for the "flang" wrapper script.
Yury Gribov [Wed, 19 Jan 2022 10:48:54 +0000 (19:48 +0900)]
[flang] Add a custom target for the "flang" wrapper script.

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

2 years agoAdd ieee_is_normal/ieee_is_negative to ieee_arithmetic module.
Yury Gribov [Fri, 21 Jan 2022 08:24:32 +0000 (17:24 +0900)]
Add ieee_is_normal/ieee_is_negative to ieee_arithmetic module.

2 years ago[RISCV] Fix support of vlen = 64.
jacquesguan [Wed, 26 Jan 2022 07:48:51 +0000 (15:48 +0800)]
[RISCV] Fix support of vlen = 64.

In the Zve* extensions, the vlen could be 64. This patch change the vlen constraint of low bound to 64.

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

2 years ago[mlir] Fix merging of delayed registrations during DialectRegistry::appendTo
Matthias Springer [Tue, 25 Jan 2022 18:35:33 +0000 (03:35 +0900)]
[mlir] Fix merging of delayed registrations during DialectRegistry::appendTo

The existing implementation called DenseMap::insert, which is a no-op if the map already contains an entry with the same key.

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

2 years ago[clang-format] Fix regression in parsing pointers to arrays.
Marek Kurdej [Wed, 26 Jan 2022 08:11:21 +0000 (09:11 +0100)]
[clang-format] Fix regression in parsing pointers to arrays.

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

After commit 5c2e7c9, the code:
```
template <> struct S : Template<int (*)[]> {};
```
was misformatted as:
```
template <> struct S : Template<int (*)[]>{};
```

Reviewed By: MyDeveloperDay, HazardyKnusperkeks, owenpan

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

2 years agoAdd release note for aarch64-none-elf driver change.
Kristof Beyls [Wed, 26 Jan 2022 08:13:22 +0000 (09:13 +0100)]
Add release note for aarch64-none-elf driver change.

2 years ago[ELF] --gdb-index: replace vector<uint8_t> with unique_ptr<uint8_t[]>. NFC
Fangrui Song [Wed, 26 Jan 2022 07:53:23 +0000 (23:53 -0800)]
[ELF] --gdb-index: replace vector<uint8_t> with unique_ptr<uint8_t[]>. NFC

2 years ago[flang] Change getLoweredName to translateNameToFrontendMangledName()
Valentin Clement [Tue, 25 Jan 2022 21:53:20 +0000 (22:53 +0100)]
[flang] Change getLoweredName to translateNameToFrontendMangledName()

getLoweredName() is not a well suited name change it to
translateNameToFrontendMangledName()

Reviewed By: schweitz

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

2 years ago[ELF] Optimize .relr.dyn to not grow vector<uint64_t>. NFC
Fangrui Song [Wed, 26 Jan 2022 07:33:40 +0000 (23:33 -0800)]
[ELF] Optimize .relr.dyn to not grow vector<uint64_t>. NFC

2 years ago[NFC] Group PowerPC clang codegen tests into directory
Qiu Chaofan [Wed, 26 Jan 2022 07:19:22 +0000 (15:19 +0800)]
[NFC] Group PowerPC clang codegen tests into directory

2 years ago[NFC] Remove duplicate include
Jim Lin [Wed, 26 Jan 2022 01:50:00 +0000 (09:50 +0800)]
[NFC] Remove duplicate include

2 years ago[ELF] Simplify and optimize .relr.dyn NFC
Fangrui Song [Wed, 26 Jan 2022 06:50:03 +0000 (22:50 -0800)]
[ELF] Simplify and optimize .relr.dyn NFC

2 years ago[JumpThreading] Add a test for handling zero !prof branch_weights
Yevgeny Rouban [Wed, 26 Jan 2022 05:38:17 +0000 (12:38 +0700)]
[JumpThreading] Add a test for handling zero !prof branch_weights

The test was a part of the revision D81499 and should have been
added with commit 707836ed4ed.

Reviewed By: yamauchi, wenlei
Differential Revision: https://reviews.llvm.org/D81499

2 years ago[ELF] Clarify that Z_BEST_SPEED==1 in a comment. NFC
Fangrui Song [Wed, 26 Jan 2022 06:40:53 +0000 (22:40 -0800)]
[ELF] Clarify that Z_BEST_SPEED==1 in a comment. NFC

2 years ago[ELF] --build-id: replace vector<uint8_t> with unique_ptr<uint8_t[]>. NFC
Fangrui Song [Wed, 26 Jan 2022 06:39:43 +0000 (22:39 -0800)]
[ELF] --build-id: replace vector<uint8_t> with unique_ptr<uint8_t[]>. NFC

We can't use C++20 make_unique_for_overwrite yet.

2 years ago[ELF] Cast size to size_t. NFC
Fangrui Song [Wed, 26 Jan 2022 06:38:23 +0000 (22:38 -0800)]
[ELF] Cast size to size_t. NFC

To fix

../../chromeclang/bin/../include/c++/v1/__algorithm/min.h:39:1: note: candidate template ignored: deduced conflicting types for parameter '_Tp' ('unsigned long' vs. 'unsigned long long')

on macOS arm64.

2 years agoRefactor: Extract Class MessagePrefix (NFC)
Richard [Mon, 3 Jan 2022 23:03:06 +0000 (16:03 -0700)]
Refactor: Extract Class MessagePrefix (NFC)

The work is the same, the only difference is the prefix
of the strings we look for in the reference files.

2 years ago[mlir] Propagate arith.index_cast past tensor.extract
Rob Suderman [Wed, 26 Jan 2022 06:15:55 +0000 (22:15 -0800)]
[mlir] Propagate arith.index_cast past tensor.extract

If we are extracting it is more useful to push the index_cast past the
extraction. This increases the chance the tensor.extract can evaluated at
compile time.

Reviewed By: rriddle

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

2 years ago[ELF] maybeCompress: replace vector<uint8_t> with unique_ptr<uint8_t[]>. NFC
Fangrui Song [Wed, 26 Jan 2022 06:15:44 +0000 (22:15 -0800)]
[ELF] maybeCompress: replace vector<uint8_t> with unique_ptr<uint8_t[]>. NFC

And mention that it is zero-initialized. I do not notice a speed-up if
changed to be uninitialized by forcing the zero filler in writeTo.

2 years ago[regalloc] Fix assertion error when LiveInterval is empty
wangpc [Wed, 26 Jan 2022 06:04:53 +0000 (14:04 +0800)]
[regalloc] Fix assertion error when LiveInterval is empty

When evicting interference, it causes an asseertion error
since LiveIntervals::intervalIsInOneMBB assumes that input
is not empty.

This patch fixed bug mentioned in D118020.

Reviewed By: MatzeB

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

2 years ago[MC] Support constant offset for symbol PendingFixup
luxufan [Fri, 14 Jan 2022 15:02:27 +0000 (23:02 +0800)]
[MC] Support constant offset for symbol PendingFixup

This patch add support relocation offset of sym+constant(like `foo+4`) form for pending fixup.

In the past, llvm-mc ignored the constant in sym+constant form, for `foo+4`, `4` would be ignored. And test case
```
.text
  ret
  nop
  nop
  .reloc foo+4, R_RISCV_32, 6

.data
.globl foo
foo:
  .word 0
  .word 0
  .word 0
```
when run `llvm-mc -filetype=obj -triple=riscv64 %s | llvm-readobj -r`
The output is
```
Relocations [
  Section (3) .rela.text {
    0x0 R_RISCV_32 - 0x6
  }
]
```

After applying this patch, the output is
```
Relocations [
  Section (3) .rela.text {
    0x4 R_RISCV_32 - 0x6
  }
]
```

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

2 years ago[CSSPGO] Adjust SampleContextFrameVector to be a shorter SmallVector
Hongtao Yu [Wed, 26 Jan 2022 00:11:41 +0000 (16:11 -0800)]
[CSSPGO] Adjust SampleContextFrameVector to be a shorter SmallVector

It appears that some memory saving can be archived by tweaking the existing `SampleContextFrameVector` setup. Below are memory usage for two benchmarks before and after this change.

1. Medium benchmark:
   - Before:

```
    note: After computeSizeForProfiledFunctions
    note: VM: 12.50 GB   RSS: 11.02 GB
    note: After generateProbeBasedProfile
    note: **VM: 30.56 GB   RSS: 29.08 GB**
    note: After postProcessProfiles
    note: VM: 31.91 GB   RSS: 30.43 GB
```
   - After:

```
    note: After computeSizeForProfiledFunctions
    note: VM: 12.26 GB   RSS: 10.80 GB
    note: After generateProbeBasedProfile
    note: **VM: 28.76 GB   RSS: 27.29 GB**
    note: After postProcessProfiles
    note: VM: 30.12 GB   RSS: 28.66 GB
```

2. Large benchmark:
   - Before:

```
    note: After computeSizeForProfiledFunctions
    note: VM: 106.28 GB   RSS: 91.25 GB
    note: After generateProbeBasedProfile
    note: **VM: 245.19 GB   RSS: 224.30 GB**
    note: After postProcessProfiles
    note: VM: 254.96 GB   RSS: 221.58 GB
```

   - After:

```
    note: After computeSizeForProfiledFunctions
    note: VM: 105.95 GB   RSS: 91.04 GB
    note: After generateProbeBasedProfile
    note: VM: **234.29 GB   RSS: 215.39 GB**
    note: After postProcessProfiles
    note: VM: 244.03 GB   RSS: 213.45 GB
```

Reviewed By: wenlei

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

2 years ago[PowerPC] Emit gnu_attribute according to float-abi metadata
Qiu Chaofan [Wed, 26 Jan 2022 05:23:21 +0000 (13:23 +0800)]
[PowerPC] Emit gnu_attribute according to float-abi metadata

According to GNU as documentation, PowerPC supports some .gnu_attribute
tags to represent the vector and float ABI type in the object file.
Some linkers like GNU ld respects the attribute and will prevent objects
with conflicting ABIs being linked.

This patch emits gnu_attribute value in assembly printer according to
the float-abi metadata. More attributes for soft-fp, hard single/double
and even vector ABI need to be supported in the future.

Reviewed By: jsji

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

2 years ago[AArch64] Fixes ADD/SUB opt bug and abstracts shared behavior in MIPeepholeOpt for...
Micah Weston [Wed, 26 Jan 2022 04:21:48 +0000 (04:21 +0000)]
[AArch64] Fixes ADD/SUB opt bug and abstracts shared behavior in MIPeepholeOpt for ADD, SUB, and AND.

This fixes a bug where (SUBREG_TO_REG 0 (MOVi32imm <negative-number>) sub_32)
would generate invalid code since the top 32-bits were not zeroed when inspecting the
immediate value. A new test was added for this case.

Change to abstract shared behavior in MIPeepholeOpt. Both
visitAND and visitADDSUB attempt to split an RR instruction with an immediate
operand into two RI instructions with the immediate split.

The differing behavior lies in how the immediate is split into two pieces and
how the new instructions are built. The rest of the behavior (adding new VRegs,
checking for the MOVImm, constraining reg classes, removing old intructions)
are shared between the operations.

The new helper function splitTwoPartImm implements the shared behavior and
delegates differing behavior to two function objects passed by the caller.
One function object splits the immediate into two values and returns the
opcode to use if it is a valid split. The other function object builds
the new instructions.

I felt this abstraction would help since I believe it will help reduce the
code repetition when adding new instructions of the pattern, such as
SUBS for this conditional optimization.

Tested it locally by running check all with compiler-rt, mlir, clang-tools-extra,
flang, llvm, and clang enabled.

Reviewed By: dmgreen

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

2 years ago[NFC][llvm] Align the comment
ly [Wed, 26 Jan 2022 03:49:50 +0000 (11:49 +0800)]
[NFC][llvm] Align the comment

Reviewed By: luismarques

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

2 years ago[lld][macho][NFC] Make MachO/start-end.s test less britle by checking for _main:
Puyan Lotfi [Wed, 26 Jan 2022 03:15:00 +0000 (19:15 -0800)]
[lld][macho][NFC] Make MachO/start-end.s test less britle by checking for _main:

In start-end.s there is a lit check line `# SEG: _main` to begin the
check at the start of the function main where `_main` is the Darwin name
mangling for C main. Because the text file that FileCheck is getting as
input has the path of the compiler build in it from llvm-mc and
llvm-objdump, and because of the lack of a trailing colon in this check
line we end up inadvertently matching against the line of text with the
compiler path in it in the case where said path contains "_main" some
place. This can be very likely if the compiler branch has "main" or
"_main" in it.

To fix this I include the training : since that will match on the
function label and not the path line.

2 years ago[MC] Put the Pending Fixups into location symbol's fragment
luxufan [Fri, 14 Jan 2022 14:03:23 +0000 (22:03 +0800)]
[MC] Put the Pending Fixups into location symbol's fragment

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

2 years ago[C++20] [Modules] Only check decls under namespace scope in CheckRedeclarationExported
Chuanqi Xu [Wed, 26 Jan 2022 02:53:50 +0000 (10:53 +0800)]
[C++20] [Modules] Only check decls under namespace scope in CheckRedeclarationExported

Since only the decls inhabit in a namespace scope could be exported, it
is not meaningful to check it in CheckRedeclarationExported, which
implements [module.interface]/p6.

Reviewed By: urnathan

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

2 years ago[OMPIRBuilder] Generate aggregate argument for parallel region outlined functions
Giorgis Georgakoudis [Wed, 26 Jan 2022 01:31:35 +0000 (20:31 -0500)]
[OMPIRBuilder] Generate aggregate argument for parallel region outlined functions

Summary:
This patch modifies code generation in OpenMPIRBuilder to pass arguments
to the parallel region outlined function in an aggregate (struct),
besides the global_tid and bound_tid arguments. It depends on the
updated CodeExtractor (see D96854) for support. It mirrors functionality
of Clang codegen (see D102107).

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

2 years ago[CodeExtractor] Enable partial aggregate arguments
Giorgis Georgakoudis [Wed, 26 Jan 2022 01:08:19 +0000 (20:08 -0500)]
[CodeExtractor] Enable partial aggregate arguments

Summary:
Enable CodeExtractor to construct output functions that partially
aggregate inputs/outputs in their argument list. A use case is the
OMPIRBuilder to create outlined functions for parallel regions that
aggregate in a struct the payload variables for the region while passing
as scalars thread and bound identifiers.

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

2 years ago[RISCV][NFC] Add getVLOperand for RVV intrinsics.
Zakk Chen [Tue, 25 Jan 2022 15:54:39 +0000 (07:54 -0800)]
[RISCV][NFC] Add getVLOperand for RVV intrinsics.

Use the VLOperand information to get the VL.

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

2 years ago[RISCV] Add the passthru operand for RVV nomask load intrinsics.
Zakk Chen [Tue, 25 Jan 2022 08:08:21 +0000 (00:08 -0800)]
[RISCV] Add the passthru operand for RVV nomask load intrinsics.

The goal is support tail and mask policy in RVV builtins.
We focus on IR part first.
If the passthru operand is undef, we use tail agnostic, otherwise
use tail undisturbed.

Co-Authored-by: Hsiangkai Wang <Hsiangkai@gmail.com>
Reviewers: craig.topper, frasercrmck

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

2 years ago[ASan] Added a unit test for D118184.
Kirill Stoimenov [Wed, 26 Jan 2022 00:57:40 +0000 (00:57 +0000)]
[ASan] Added a unit test for D118184.

To make sure the the libraries are there for executable and not there for DSOs.

Reviewed By: kda

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

2 years ago[NFC][IROutliner] fix namespace and unused variable
Andrew Litteken [Wed, 26 Jan 2022 00:41:18 +0000 (18:41 -0600)]
[NFC][IROutliner] fix namespace and unused variable

2 years ago[libc++] [test] Fix LWG3146 "Excessive unwrapping in std::ref/cref"
Arthur O'Dwyer [Sat, 22 Jan 2022 17:18:51 +0000 (12:18 -0500)]
[libc++] [test] Fix LWG3146 "Excessive unwrapping in std::ref/cref"

Drive-by constexprify the existing tests, too.

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

2 years ago[IRSim][IROutliner] Add support for outlining PHINodes with the rest of the region.
Andrew Litteken [Sun, 2 Jan 2022 22:25:43 +0000 (16:25 -0600)]
[IRSim][IROutliner] Add support for outlining PHINodes with the rest of the region.

We use the same similarity scheme we used for branch instructions for phi nodes, and allow them to be outlined. There is not a lot of special handling needed for these phi nodes when outlining, as they simply act as outputs. The code extractor does not currently allow for non entry blocks within the extracted region to have predecessors, so there are not conflicts to handle with respect to predecessors no longer contained in the function.

Recommit of 515eec3553b02533e9a88ee84bc245d5415163da

Reviewers: paquette

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

2 years agoRevert "[IRSim][IROutliner] Add support for outlining PHINodes with the rest of the...
Andrew Litteken [Wed, 26 Jan 2022 00:23:38 +0000 (18:23 -0600)]
Revert "[IRSim][IROutliner] Add support for outlining PHINodes with the rest of the region."

This reverts commit 515eec3553b02533e9a88ee84bc245d5415163da.

By mistake, commit message was not complete.

2 years ago[IRSim][IROutliner] Add support for outlining PHINodes with the rest of the region.
Andrew Litteken [Sun, 2 Jan 2022 22:25:43 +0000 (16:25 -0600)]
[IRSim][IROutliner] Add support for outlining PHINodes with the rest of the region.

2 years agoRevert "[IRSim][IROutliner] Allowing Intrinsic Calls to be Used in Similarity Matchin...
Andrew Litteken [Wed, 26 Jan 2022 00:18:27 +0000 (18:18 -0600)]
Revert "[IRSim][IROutliner] Allowing Intrinsic Calls to be Used in Similarity Matching and Outlined Regions"

This reverts commit 8de76bd569732acae6a10fdcb0152a49f7d4cd39.

Reverting due to failure of different-intrinsics.ll on lld-x86_64-win buildbot.

2 years ago[ASan] Not linking asan_static library for DSO.
Kirill Stoimenov [Tue, 25 Jan 2022 21:33:55 +0000 (21:33 +0000)]
[ASan] Not linking asan_static library for DSO.

Without this change DSOs fail to link because of missing asan_report_(load|store)n functions.

Reviewed By: kda

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

2 years agoReland "[AlwaysInliner] Enable call site inlining to make flatten attribute working...
Dávid Bolvanský [Tue, 25 Jan 2022 22:21:15 +0000 (23:21 +0100)]
Reland "[AlwaysInliner] Enable call site inlining to make flatten attribute working again (#53360)"

2 years ago[mlir] Fold tensor.reshape operations into tensor.from_elements.
Rob Suderman [Tue, 25 Jan 2022 23:54:49 +0000 (15:54 -0800)]
[mlir] Fold tensor.reshape operations into tensor.from_elements.

There is not much of a benefit to reshape a from element vs reloading it.
Updated to progagate shape manipulations into the output type of
tensor.from_elements.

Reviewed By: NatashaKnk

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

2 years ago[clangd] Add designator inlay hints for initializer lists.
Sam McCall [Fri, 7 Jan 2022 03:15:07 +0000 (04:15 +0100)]
[clangd] Add designator inlay hints for initializer lists.

These make the init lists appear as if designated initialization was used.

Example:
  ExpectedHint{"param: ", "arg"}
becomes
  ExpectedHint{.Label="param: ", .RangeName="arg"}

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

2 years ago[IRSim][IROutliner] Allowing Intrinsic Calls to be Used in Similarity Matching and...
Andrew Litteken [Thu, 23 Dec 2021 00:07:43 +0000 (18:07 -0600)]
[IRSim][IROutliner] Allowing Intrinsic Calls to be Used in Similarity Matching and Outlined Regions

Due to some complications with lifetime, and assume-like intrinsics, intrinsics were not included as outlinable instructions. This patch opens up most intrinsics, excluding lifetime and assume-like intrinsics, to be outlined. For similarity, it is required that the intrinsic IDs, and the intrinsics names match exactly, as well as the function type. This puts intrinsics in a different class than normal call instructions (https://reviews.llvm.org/D109448), where the name will no longer have to match.

This also adds an additional command line flag debug option to disable outlining intrinsics.

Reviewers: paquette, jroelofs

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

2 years ago[NFC] DeclCXX: Fix -Wreorder-ctor
Jordan Rupprecht [Tue, 25 Jan 2022 22:27:25 +0000 (14:27 -0800)]
[NFC] DeclCXX: Fix -Wreorder-ctor

From 8ba9c794feb30cd969b9776c39873def10c51bff

2 years agoAdd support for sycl_special_class attribute.
Zahira Ammarguellat [Tue, 23 Nov 2021 22:58:03 +0000 (14:58 -0800)]
Add support for sycl_special_class attribute.

Special classes such as accessor, sampler, and stream need additional
implementation when they are passed from host to device.

This patch is adding a new attribute “sycl_special_class” used to mark
SYCL classes/struct that need the additional compiler handling.

2 years agoRevert "[AlwaysInliner] Enable call site inlining to make flatten attribute working...
Dávid Bolvanský [Tue, 25 Jan 2022 22:13:46 +0000 (23:13 +0100)]
Revert "[AlwaysInliner] Enable call site inlining to make flatten attribute working again (#53360)"

This reverts commit ceec4383681c42bfd3d06a6913ce7554bea160b0. Clang tests fail.