platform/upstream/llvm.git
2 years ago[SelectionDAG] Widen scalable-vector loads/stores via VP_LOAD/VP_STORE
Fraser Cormack [Wed, 6 Oct 2021 17:14:06 +0000 (18:14 +0100)]
[SelectionDAG] Widen scalable-vector loads/stores via VP_LOAD/VP_STORE

This patch fixes a compiler crash when widening scalable-vector loads
and stores which end up breaking down to element-wise store operations.
It does so by providing a way for targets with support for
vector-predicated loads and stores to use those instead. By widening the
operation but maintaining the original effective operation length via
the EVL, only the intended vector elements are loaded or stored.

This method should in theory be possible and even preferred for
fixed-length vector types, but all fixed-length types can be broken down
into their elements, and regardless I have observed regressions in the
generated code when doing so. I believe this is simply due to
VP_LOAD/VP_STORE not being up to par with LOAD/STORE in terms of
optimization. It does improve performance on smaller self-contained
examples, however, so the potential is there.

While the only target that benefits from this is RISCV, the legalization
is generic and so was placed centrally.

Reviewed By: craig.topper

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

2 years agoRevert "[DebugInfo] Only create concrete DIEs of concrete functions"
Adrian Kuegel [Wed, 10 Nov 2021 09:51:16 +0000 (10:51 +0100)]
Revert "[DebugInfo] Only create concrete DIEs of concrete functions"

This reverts commit f19471a24985a0cbc32b6548c8fce1d2514e8243.
This leads to a crash. Still working on a reproducer to share.

2 years ago[mlir][linalg][bufferize] Bufferize ops via PreOrder traversal
Matthias Springer [Wed, 10 Nov 2021 09:47:28 +0000 (18:47 +0900)]
[mlir][linalg][bufferize] Bufferize ops via PreOrder traversal

The existing PostOrder traversal with special rules for certain ops was complicated and had a bug. Switch to PreOrder traversal.

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

2 years agoRevert "[DebugInfo] Fix broken MachO test"
Adrian Kuegel [Wed, 10 Nov 2021 08:46:35 +0000 (09:46 +0100)]
Revert "[DebugInfo] Fix broken MachO test"

This reverts commit 06736dab9bb5f8e170038e49b3a65e7a7e6e0f02.
This depends on another patch that will be reverted.

2 years ago[IR] In ConstantFoldShuffleVectorInstruction use zeroinitializer for splats of 0
David Sherwood [Mon, 8 Nov 2021 12:02:21 +0000 (12:02 +0000)]
[IR] In ConstantFoldShuffleVectorInstruction use zeroinitializer for splats of 0

When creating a splat of 0 for scalable vectors we tend to create them
with using a combination of shufflevector and insertelement, i.e.

shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> poison, i32 0, i32 0),
               <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer)

However, for the case of a zero splat we can actually just replace the
above with zeroinitializer instead. This makes the IR a lot simpler and
easier to read. I have changed ConstantFoldShuffleVectorInstruction to
use zeroinitializer when creating a splat of integer 0 or FP +0.0 values.

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

2 years ago[mlir][linalg][bufferize] Remove special scf::IfOp rules
Matthias Springer [Wed, 10 Nov 2021 09:39:16 +0000 (18:39 +0900)]
[mlir][linalg][bufferize] Remove special scf::IfOp rules

Remove some of the special rules for scf::IfOp (not all of them) and encode them in the op interface. This is in preparation of decoupling analysis, bufferization and dialects.

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

2 years ago[mlir][linalg][bufferize] Add helper method isMemoryWrite to op interface
Matthias Springer [Wed, 10 Nov 2021 09:34:26 +0000 (18:34 +0900)]
[mlir][linalg][bufferize] Add helper method isMemoryWrite to op interface

This is in preparating for decoupling the SCF dialect from the analysis.

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

2 years ago[mlir][linalg][bufferize] Fix buffer equivalence around scf.if ops
Matthias Springer [Wed, 10 Nov 2021 09:28:41 +0000 (18:28 +0900)]
[mlir][linalg][bufferize] Fix buffer equivalence around scf.if ops

Also extend the comments for aliasInfo and equivalenceInfo.

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

2 years ago[gn build] Port a35efc4dcb70
LLVM GN Syncbot [Wed, 10 Nov 2021 09:27:55 +0000 (09:27 +0000)]
[gn build] Port a35efc4dcb70

2 years ago[NFC][clang-tidy] Fixup documentation file names for 'readability-container-data...
Whisperity [Wed, 10 Nov 2021 09:16:06 +0000 (10:16 +0100)]
[NFC][clang-tidy] Fixup documentation file names for 'readability-container-data-pointer'

2 years ago[mlir][linalg][bufferize] Relax tensor.insert_slice conflict rules
Matthias Springer [Wed, 10 Nov 2021 09:15:19 +0000 (18:15 +0900)]
[mlir][linalg][bufferize] Relax tensor.insert_slice conflict rules

A tensor.insert_slice write does not conflict with a subsequent read of the source if the source is originating from a matching tensor.extract_slice.

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

2 years agoMisleading unicode identifier detection pass
serge-sans-paille [Fri, 15 Oct 2021 13:18:52 +0000 (15:18 +0200)]
Misleading unicode identifier detection pass

Detect when an identifier contains some Right-To-Left characters.
This pass relates to https://trojansource.codes/

Example of misleading source:

    short int א = (short int)0;
    short int ג = (short int)12345;

    int main() {
      int א = ג; // a local variable, set to zero?
      printf("ג is %d\n", ג);
      printf("א is %d\n", א);
    }

This is a recommit of 299aa4dfa1d8c120648b1404b481d858b76c8173 with missing
option registration fixed.

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

2 years ago[Test] Remove separated test in IndVars
Dmitry Makogon [Wed, 10 Nov 2021 09:17:58 +0000 (16:17 +0700)]
[Test] Remove separated test in IndVars

This patch removes a test file, which was forgotten to be removed in
97cb13615d6d9df254e3c0f3deef9eaedfe189b6. The deleted test
is separated into 2 parts by that patch.

2 years ago[ELF] Enforce double-dash form for --ignore-{data,function}-pointer-equality --reprod...
Fangrui Song [Wed, 10 Nov 2021 09:17:08 +0000 (01:17 -0800)]
[ELF] Enforce double-dash form for --ignore-{data,function}-pointer-equality --reproduce --thread

They are LLD-specific options. We have enforced double-dash forms for
other options (reduce collision with short options) but missed them.

2 years ago[Test] Separate IndVars test into AArch64 and X86 parts
Dmitry Makogon [Wed, 10 Nov 2021 08:48:56 +0000 (15:48 +0700)]
[Test] Separate IndVars test into AArch64 and X86 parts

The widen-loop-comp.ll in indvars has a target triple with
specified aarch64 architecture. This caused test failures with
db28934 "[IndVars] Pass TTI to replaceCongruentIVs" applied, because
with the patch indvars performed some target-specific
transforms, and for example if a build supported only X86,
then indvars would not have applied those transforms.
However, the checks in the test were generated as for aarch64.
Thus the test failures on such builds.

This patch separates widen-loop-comp.ll into two parts.
The first one is intended to be run only if a build supports aarch64.
This is now in AArch64 directory with a lit config.

The second one was added recently to show db28934 improvements.
This one is now in X86 directory.

This patch should resolve build issues caused by
5ec23863320ca12bfabb6dcff1d0425cb614b7a5.

2 years ago[mlir][linalg] Enable insertion of dealloc for end2end tests
Stephan Herhut [Mon, 4 Oct 2021 14:51:25 +0000 (16:51 +0200)]
[mlir][linalg] Enable insertion of dealloc for end2end tests

This uses the buffer-deallocation pass or, in case the test case does not use bufferization, has added explicit deallocs.

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

2 years ago[InstCombine] Extend stacksave/restore elimination
Itay Bookstein [Wed, 3 Nov 2021 13:08:06 +0000 (15:08 +0200)]
[InstCombine] Extend stacksave/restore elimination

Previously, InstCombine detected a pair of llvm.stacksave/stackrestore
instructions that are adjacent modulo debug instructions in order to
eliminate the llvm.stackrestore. This precludes situations where
intervening instructions (e.g. loads) preclude the llvm.stacksave and
llvm.stackrestore from becoming adjacent. This commit extends the logic
and allows for eliminating the llvm.stackrestore when the range of
instructions between them does not include any alloca or side-effect
causing instructions.

Signed-off-by: Itay Bookstein <itay.bookstein@nextsilicon.com>
Reviewed By: lebedev.ri

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

2 years ago[InstCombine][NFC] Refactor llvm.stackrestore handling
Itay Bookstein [Tue, 9 Nov 2021 07:06:30 +0000 (09:06 +0200)]
[InstCombine][NFC] Refactor llvm.stackrestore handling

Hoist the instruction classification logic outside the loop
in preparation for reuse in a future commit.

Signed-off-by: Itay Bookstein <itay.bookstein@nextsilicon.com>
Reviewed By: lebedev.ri

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

2 years ago[lldb] [gdb-server] Fix fill_clamp to handle signed src types
Michał Górny [Tue, 9 Nov 2021 22:55:52 +0000 (23:55 +0100)]
[lldb] [gdb-server] Fix fill_clamp to handle signed src types

Fix the fill_clamp() function to handle signed source types.  Make sure
that the source value is always non-negative, and cast it to unsigned
when verifying the upper bound.  This fixes compiler warnings about
comparing unsigned and signed types.

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

2 years ago[lldb] Support gdbserver signals
Michał Górny [Sat, 14 Aug 2021 21:22:29 +0000 (23:22 +0200)]
[lldb] Support gdbserver signals

GDB and LLDB use different signal models.  GDB uses a predefined set
of signal codes, and maps platform's signos to them.  On the other hand,
LLDB has historically simply passed native signos.

In order to improve compatibility between LLDB and gdbserver, the GDB
signal model should be used.  However, GDB does not provide a mapping
for all existing signals on Linux and unsupported signals are passed
as 'unknown'.  Limiting LLDB to this behavior could be considered
a regression.

To get the best of both worlds, use the LLDB signal model when talking
to lldb-server, and the GDB signal model otherwise.  For this purpose,
new versions of lldb-server indicate "native-signals+" via qSupported.
At the same time, we also detect older versions of lldb-server
via QThreadSuffixSupported for backwards compatibility.  If neither test
succeeds, we assume gdbserver or another implementation using GDB model.

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

2 years ago[Test] Remove incorrect test in GVN
Dmitry Makogon [Wed, 10 Nov 2021 08:15:04 +0000 (15:15 +0700)]
[Test] Remove incorrect test in GVN

Removed it because it runs indvars after GVN and
it's obvious it's an indvars test, not GVN.

Also the removed test file includes a 'target triple' with aarch64 specified,
which is needed for indvars to eliminate the Phis produced by GVN,
and the test directory doesn't have a lit config to exclude lit from
running the test if aarch64 is not supported by a build.

2 years ago[llvm-objdump] Remove a trailing semicolon, fixing GCC warnings. NFC.
Martin Storsjö [Wed, 10 Nov 2021 07:39:47 +0000 (09:39 +0200)]
[llvm-objdump] Remove a trailing semicolon, fixing GCC warnings. NFC.

2 years agoReland [XCOFF][yaml2obj] support for the auxiliary file header.
Esme-Yi [Wed, 10 Nov 2021 07:23:56 +0000 (07:23 +0000)]
Reland [XCOFF][yaml2obj] support for the auxiliary file header.

Summary: Fix the build failure on MSVC by making the `T` and `U` of the function
'T llvm::Optional<T>::getValueOr<llvm::yaml::Hex32>(U &&) const &' the same.

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

2 years ago[clangd] Trace per-token time in clangd --check
Sam McCall [Wed, 10 Nov 2021 07:22:28 +0000 (08:22 +0100)]
[clangd] Trace per-token time in clangd --check

2 years ago[CodeCompletion] Generally consider header files without extension
Christian Kandeler [Tue, 9 Nov 2021 17:12:01 +0000 (18:12 +0100)]
[CodeCompletion] Generally consider header files without extension

Real-world use case: The Qt framework's headers have the same name
as the respective class defined in them, and Qt's traditional qmake
build tool uses -I (rather than -isystem) to pull them in.

Reviewed By: sammccall

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

2 years ago[llvm] Use MachineBasicBlock::{successors,predecessors} (NFC)
Kazu Hirata [Wed, 10 Nov 2021 07:05:15 +0000 (23:05 -0800)]
[llvm] Use MachineBasicBlock::{successors,predecessors} (NFC)

2 years ago[clang-tidy] Fix llvm-header-guard so that it works with Windows paths
Salman Javed [Wed, 10 Nov 2021 05:34:41 +0000 (18:34 +1300)]
[clang-tidy] Fix llvm-header-guard so that it works with Windows paths

Fixes pr40372 (https://bugs.llvm.org/show_bug.cgi?id=40372).

The llvm-header-guard check does not take into account that the path
separator on Windows is `\`, not `/`.

This means that instead of suggesting a header guard in the form of:
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FOO_H

it incorrectly suggests:
C:\LLVM_PROJECT\CLANG_TOOLS_EXTRA\CLANG_TIDY\FOO_H

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

2 years ago[formatters] Add a libstdcpp formatter for forward_list and refactor list formatter
Danil Stefaniuc [Wed, 10 Nov 2021 05:22:14 +0000 (21:22 -0800)]
[formatters] Add a libstdcpp formatter for forward_list and refactor list formatter

This diff adds a data formatter for libstdcpp's forward_list. Besides, it refactors the existing code by extracting the common functionality between libstdcpp forward_list and list formatters into the AbstractListSynthProvider class.

Reviewed By: wallace

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

2 years ago[AArch64][GlobalISel] Fix atomic truncating stores from generating invalid copies.
Amara Emerson [Wed, 10 Nov 2021 04:41:26 +0000 (20:41 -0800)]
[AArch64][GlobalISel] Fix atomic truncating stores from generating invalid copies.

If the source reg is a 64b vreg, then we need to emit a subreg copy to a 32b
gpr before we select sub-64b variants like STLRW.

2 years ago[ELF] Inline isPPC64SmallCodeModelTocReloc which is only called once. NFC
Fangrui Song [Wed, 10 Nov 2021 04:41:05 +0000 (20:41 -0800)]
[ELF] Inline isPPC64SmallCodeModelTocReloc which is only called once. NFC

2 years ago[ELF] Move isStaticLinkTimeConstant closer to the only caller processRelocAux. NFC
Fangrui Song [Wed, 10 Nov 2021 04:24:40 +0000 (20:24 -0800)]
[ELF] Move isStaticLinkTimeConstant closer to the only caller processRelocAux. NFC

2 years agoFix unused variable warning in release build
Jorge Gorbe Moya [Wed, 10 Nov 2021 03:48:42 +0000 (19:48 -0800)]
Fix unused variable warning in release build

2 years ago[CFE][Codegen] Make sure to maintain the contiguity of all the static allocas
hsmahesha [Wed, 10 Nov 2021 03:14:58 +0000 (08:44 +0530)]
[CFE][Codegen] Make sure to maintain the contiguity of all the static allocas

at the start of the entry block, which in turn would aid better code transformation/optimization.

Reviewed By: rnk

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

2 years ago[clang-tblgen] Fix non-determinism in generating AttributeReference.rst
Igor Kudrin [Wed, 10 Nov 2021 03:07:20 +0000 (10:07 +0700)]
[clang-tblgen] Fix non-determinism in generating AttributeReference.rst

As for now, the categories are printed in an arbitrary order which
depends on the addresses of dynamically allocated objects. The patch
sorts them in an alphabetical order thus making the output stable.

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

2 years ago[clang-tblgen] Fix non-determinism in generating AttrSubMatchRulesParserStringSwitche...
Igor Kudrin [Wed, 10 Nov 2021 03:06:30 +0000 (10:06 +0700)]
[clang-tblgen] Fix non-determinism in generating AttrSubMatchRulesParserStringSwitches.inc

llvm::MapVector, compared to std::map, guarantees the same iteration
order in different runs.

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

2 years ago[dfsan] Dfsan version of D113328
Vitaly Buka [Tue, 9 Nov 2021 03:22:24 +0000 (19:22 -0800)]
[dfsan] Dfsan version of D113328

Depends on D113328.

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

2 years ago[msan] Block signals in MsanThread::Init
Vitaly Buka [Sat, 6 Nov 2021 02:57:19 +0000 (19:57 -0700)]
[msan] Block signals in MsanThread::Init

If async signal handler called when we MsanThread::Init
signal handler may trigger false reports.
I failed to reproduce this locally for a test.

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

2 years ago[NFC][sanitizer] Extract ScopedBlockSignals
Vitaly Buka [Tue, 9 Nov 2021 02:45:22 +0000 (18:45 -0800)]
[NFC][sanitizer] Extract ScopedBlockSignals

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

2 years ago[mlir-c] Add Region iterators matching Block & Operation ones
Jacques Pienaar [Wed, 10 Nov 2021 01:52:56 +0000 (17:52 -0800)]
[mlir-c] Add Region iterators matching Block & Operation ones

Enables using the same iterator interface to these even though underlying storage is different.

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

2 years agoFix flang following MLIR API change in f30a8a6f674
Mehdi Amini [Wed, 10 Nov 2021 01:25:36 +0000 (01:25 +0000)]
Fix flang following MLIR API change in f30a8a6f674

The printer for Attribute/Type does not need to include the mnemonic
anymore.

2 years agoFix ODS Attribute/Type declarative assembly generator after API change for Attribute...
Mehdi Amini [Wed, 10 Nov 2021 01:05:34 +0000 (01:05 +0000)]
Fix ODS Attribute/Type declarative assembly generator after API change for Attribute/Type print

The change in f30a8a6f674 conflicted with the recently landed feature on
ODS assembly format for Attribute/Type.

2 years agollvm-dwarfdump: Lookup type units when prettyprinting types
David Blaikie [Wed, 10 Nov 2021 00:47:30 +0000 (16:47 -0800)]
llvm-dwarfdump: Lookup type units when prettyprinting types

This handles DWARFv4 and DWARFv5 type units, but not Split DWARF type
units. That'll come in a follow-up patch.

2 years agoChange the contract with the type/attribute parsing to let the dispatch handle the...
Mehdi Amini [Wed, 10 Nov 2021 00:38:01 +0000 (00:38 +0000)]
Change the contract with the type/attribute parsing to let the dispatch handle the mnemonic

This breaking change requires to remove printing the mnemonic in the print()
method on Type/Attribute classes.
This makes it consistent with the parsing code which alread handles the
mnemonic outside of the parsing method.

This likely won't break the build for anyone, but tests will start
failing for dialects downstream. The fix is trivial and look like
going from:

void emitc::OpaqueType::print(DialectAsmPrinter &printer) const {
  printer << "opaque<\"";

to:

void emitc::OpaqueAttr::print(DialectAsmPrinter &printer) const {
  printer << "<\"";

Reviewed By: rriddle, aartbik

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

2 years agoEmit the boilerplate for Type printer/parser dialect dispatching from ODS
Mehdi Amini [Sat, 6 Nov 2021 07:14:32 +0000 (07:14 +0000)]
Emit the boilerplate for Type printer/parser dialect dispatching from ODS

Add a new `useDefaultTypePrinterParser` boolean settings on the dialect
(default to false for now) that emits the boilerplate to dispatch type
parsing/printing to the auto-generated method.
We will likely turn this on by default in the future.

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

2 years agoEmit the boilerplate for Attribute printer/parser dialect dispatching from ODS
Mehdi Amini [Sat, 6 Nov 2021 07:14:17 +0000 (07:14 +0000)]
Emit the boilerplate for Attribute printer/parser dialect dispatching from ODS

Add a new `useDefaultAttributePrinterParser` boolean settings on the dialect
(default to false for now) that emits the boilerplate to dispatch attribute
parsing/printing to the auto-generated method.
We will likely turn this on by default in the future.

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

2 years agoRestructure the Test dialect ODS to include the AttrDef in TestOps.td (NFC)
Mehdi Amini [Sat, 6 Nov 2021 07:14:02 +0000 (07:14 +0000)]
Restructure the Test dialect ODS to include the AttrDef in TestOps.td (NFC)

This structure is necessary to be able to use AttrDef as arguments on operations.

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

2 years ago[GlobalISel] Ensure that translateInvoke adds all successors for inlineasm
Jessica Paquette [Mon, 8 Nov 2021 22:43:12 +0000 (14:43 -0800)]
[GlobalISel] Ensure that translateInvoke adds all successors for inlineasm

The existing code didn't add all necessary successors, which resulted in
disjoint basic blocks. These would end up not being legalized which, in the
best case, caused a fallback only in assert builds.

Here's an example:

https://godbolt.org/z/ndx15Enfj

We also end up getting weird codegen here as well.

Refactoring the code here allows us to correctly attach all successors. With
this patch, the above example gives correct codegen at -O0 with and without
asserts.

Also autogen the testcase to show that we add all the successors now.

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

2 years agoFix memory leak in D demangler
David Blaikie [Wed, 10 Nov 2021 00:08:14 +0000 (16:08 -0800)]
Fix memory leak in D demangler

2 years ago[clang] Fix restructured markup
Nathan Sidwell [Tue, 9 Nov 2021 23:41:22 +0000 (18:41 -0500)]
[clang] Fix restructured markup

2 years ago[InstCombine] Precommit updated and-xor-or.ll tests. NFC.
Stanislav Mekhanoshin [Tue, 9 Nov 2021 23:38:24 +0000 (15:38 -0800)]
[InstCombine] Precommit updated and-xor-or.ll tests. NFC.

Tests for:
```
(c | ~(a & b)) & (b | ~(a & c)) --> ~(a & (b ^ c))
(b | ~(a & c)) & ~(a & b) --> ~((b | c) & a)
(b & ~(a | c)) | ~(a | b) --> ~((b & c) | a) (2 uses test)
```

2 years ago[llvm-reduce] Print extra newline when encountering unknown pass
Arthur Eubanks [Tue, 9 Nov 2021 23:19:43 +0000 (15:19 -0800)]
[llvm-reduce] Print extra newline when encountering unknown pass

2 years ago[RISCV] Add test cases for roundeven intrinsics. NFC
Craig Topper [Tue, 9 Nov 2021 22:47:44 +0000 (14:47 -0800)]
[RISCV] Add test cases for roundeven intrinsics. NFC

These just fall back to libcalls.

2 years ago[NFC][SROA] Precommit tests for promotion-with-spilling
Roman Lebedev [Tue, 9 Nov 2021 22:51:07 +0000 (01:51 +0300)]
[NFC][SROA] Precommit tests for promotion-with-spilling

Tests mainly stolen from https://reviews.llvm.org/D109749

2 years agoAMDGPU: Account for implicit argument alignment for kernarg segment
Matt Arsenault [Thu, 28 Oct 2021 00:59:46 +0000 (20:59 -0400)]
AMDGPU: Account for implicit argument alignment for kernarg segment

If a kernel had no formal arguments but did have the implicit
arguments, we were reporting a required kernarg alignment of 4. For
some reason we require an 8-byte alignment for this, even though
there's no real advantage and I don't see where this is documented in
the ABI.

The code object header code also claims the minimum alignment is 16,
which is what I thought you always got at runtime anyway so I don't
know why this matters.

2 years ago[OpenMP] Remove doing assumption propagation in the front end.
Joseph Huber [Fri, 8 Oct 2021 20:29:57 +0000 (16:29 -0400)]
[OpenMP] Remove doing assumption propagation in the front end.

This patch removes the assumption propagation that was added in D110655
primarily to get assumption informatino on opaque call sites for
optimizations. The analysis done in D111445 allows us to do this more
intelligently in the back-end.

Depends on D111445

Reviewed By: jdoerfert

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

2 years ago[OpenMP] Use AAAssumptionInfo to get assumptions in OpenMPOpt
Joseph Huber [Mon, 4 Oct 2021 21:42:46 +0000 (17:42 -0400)]
[OpenMP] Use AAAssumptionInfo to get assumptions in OpenMPOpt

This patch uses the abstract attributor introduced in D111054 to get the
assumption values instead of the `hasAssumption` function. This also
calls it so assumption information should propagate throug the device
where applicabile.

Reviewed By: jdoerfert

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

2 years ago[Attributor] Introduce AAAssumptionInfo to propagate assumptions
Joseph Huber [Mon, 4 Oct 2021 13:01:41 +0000 (09:01 -0400)]
[Attributor] Introduce AAAssumptionInfo to propagate assumptions

This patch introduces a new abstract attributor instance that propagates
assumption information from functions. Conceptually, if a function is
only called by functions that have certain assumptions, then we can
apply the same assumptions to that function. This problem is similar to
calculating the dominator set, but the assumptions are merged instead of
nodes.

Reviewed By: jdoerfert

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

2 years ago[sancov] add tracing for loads and store
Kostya Serebryany [Tue, 9 Nov 2021 01:52:36 +0000 (17:52 -0800)]
[sancov] add tracing for loads and store

add tracing for loads and stores.

The primary goal is to have more options for data-flow-guided fuzzing,
i.e. use data flow insights to perform better mutations or more agressive corpus expansion.
But the feature is general puspose, could be used for other things too.

Pipe the flag though clang and clang driver, same as for the other SanitizerCoverage flags.
While at it, change some plain arrays into std::array.

Tests: clang flags test, LLVM IR test, compiler-rt executable test.

Reviewed By: morehouse

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

2 years agoheaders: optionalise some generated resource headers
Saleem Abdulrasool [Tue, 9 Nov 2021 22:28:12 +0000 (22:28 +0000)]
headers: optionalise some generated resource headers

This splits out the generated headers and conditonalises them upon the
target being enabled.

The motivation here is that the RISCV header alone added 10MB to the
resource directory, which was previously at 10MB, increasing the build
size and time. This header is contributing ~50% of the size of the
resource headers (~10MB).

The ARM generated headers are contributing about ~10% or 1MB.

This could be extended further adding only the static resource headers
for the targets that the LLVM build supports.

The changes to the tests for ARM mirror what the RISCV target already
did and rnk identified as a possible issue.

Testing:
  cmake -G Ninja -D LLVM_TARGETS_TO_BUILD=X86 -D LLVM_ENABLE_PROJECTS="clang;lld" ../clang
  ninja check-clang

Differential Revision: https://reviews.llvm.org/D112890
Reviewed By: craig.topper

2 years agoRevert "[DebugInfo] Enforce implicit constraints on `distinct` MDNodes"
Arthur Eubanks [Tue, 9 Nov 2021 22:23:04 +0000 (14:23 -0800)]
Revert "[DebugInfo] Enforce implicit constraints on `distinct` MDNodes"

This reverts commit ee7652569854af567ba83e5255d70e80cc8619a1.

Causes crashes, see comments in D104827.

2 years agoFix test after aee49255074fd4ef38d97e6e70cbfbf2f9fd0fa7.
James Y Knight [Tue, 9 Nov 2021 16:18:36 +0000 (11:18 -0500)]
Fix test after aee49255074fd4ef38d97e6e70cbfbf2f9fd0fa7.

(Apparently no buildbots enable both examples and plugins!)

2 years ago[clang] Run LLVM Verifier in modes without CodeGen too
Itay Bookstein [Sat, 6 Nov 2021 22:06:28 +0000 (00:06 +0200)]
[clang] Run LLVM Verifier in modes without CodeGen too

Previously, the Backend_Emit{Nothing,BC,LL} modes did
not run the LLVM verifier since it is usually added via
the TargetMachine::addPassesToEmitFile method according
to the DisableVerify parameter. This is called from
EmitAssemblyHelper::AddEmitPasses, which is only relevant
for BackendAction-s that require CodeGen.

Note:
* In these particular situations the verifier is added
  to the optimization pipeline rather than the codegen
  pipeline so that it runs prior to the BC/LL emission
  pass.
* This change applies to both the old and the new PMs.
* Because the clang tests use -emit-llvm ubiquitously,
  this change will enable the verifier for them.
* A small bug is fixed in emitIFuncDefinition so that
  the clang/test/CodeGen/ifunc.c test would pass:
  the emitIFuncDefinition incorrectly passed the
  GlobalDecl of the IFunc itself to the call to
  GetOrCreateLLVMFunction for creating the resolver.

Signed-off-by: Itay Bookstein <ibookstein@gmail.com>
Reviewed By: rjmccall

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

2 years ago[CodeGen] Diagnose and reject non-function ifunc resolvers
Itay Bookstein [Sat, 30 Oct 2021 11:27:38 +0000 (14:27 +0300)]
[CodeGen] Diagnose and reject non-function ifunc resolvers

Signed-off-by: Itay Bookstein <ibookstein@gmail.com>
Reviewed By: MaskRay, erichkeane

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

2 years ago[clang][test][NFC] Move attr-ifunc.c test from Sema to CodeGen
Itay Bookstein [Tue, 9 Nov 2021 20:01:56 +0000 (22:01 +0200)]
[clang][test][NFC] Move attr-ifunc.c test from Sema to CodeGen

Signed-off-by: Itay Bookstein <ibookstein@gmail.com>
Reviewed By: erichkeane

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

2 years ago[clang][test][NFC] clang-format attr-ifunc.c test
Itay Bookstein [Tue, 9 Nov 2021 20:01:14 +0000 (22:01 +0200)]
[clang][test][NFC] clang-format attr-ifunc.c test

Signed-off-by: Itay Bookstein <ibookstein@gmail.com>
Reviewed By: erichkeane

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

2 years agoRevert "Misleading unicode identifier detection pass"
serge-sans-paille [Tue, 9 Nov 2021 21:38:56 +0000 (22:38 +0100)]
Revert "Misleading unicode identifier detection pass"

This reverts commit 7f92a1a84b96ff0b7568a35704c9483e9f24f057.

It triggers an assert, see http://45.33.8.238/linux/60293/step_9.txt

"AST/Decl.h:277: llvm::StringRef clang::NamedDecl::getName() const: Assertion `Name.isIdentifier() && "Name is not a simple identifier"' failed."

2 years ago[CodeGen][Outliner] Clean up dead code
Alexander Shaposhnikov [Tue, 9 Nov 2021 21:27:16 +0000 (21:27 +0000)]
[CodeGen][Outliner] Clean up dead code

Clean up dead code in X86InstrInfo.cpp and AArch64InstrInfo.cpp

Test plan: make check-all

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

2 years agoComment AST: Add support for variable templates
Aaron Puchert [Tue, 9 Nov 2021 21:24:44 +0000 (22:24 +0100)]
Comment AST: Add support for variable templates

We treat them as variables of course, though if they have function
pointer type we treat them as functions, i.e. allow parameter and return
value specifications. Just like VarDecls.

Reviewed By: gribozavr2

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

2 years agoComment AST: Declare function pointer variables as functions
Aaron Puchert [Tue, 9 Nov 2021 20:51:38 +0000 (21:51 +0100)]
Comment AST: Declare function pointer variables as functions

We were doing this already for type aliases, and it deduplicates the
code looking through aliases and pointers to find a function type. As
a side effect, this finds two warnings that we apparently missed before.

Reviewed By: gribozavr2

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

2 years agoComment AST: Factor out function type extraction in DeclInfo::fill (NFC)
Aaron Puchert [Tue, 9 Nov 2021 20:46:56 +0000 (21:46 +0100)]
Comment AST: Factor out function type extraction in DeclInfo::fill (NFC)

Reviewed By: gribozavr2

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

2 years agoDebugInfoDWARF: Refactor/simplify a couple of minor things
David Blaikie [Tue, 9 Nov 2021 20:51:05 +0000 (12:51 -0800)]
DebugInfoDWARF: Refactor/simplify a couple of minor things

2 years ago[clang] Don't crash on an incomplete-type base specifier in template context.
Haojian Wu [Tue, 9 Nov 2021 10:10:11 +0000 (11:10 +0100)]
[clang] Don't crash on an incomplete-type base specifier in template context.

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

2 years ago[InstCombine] Add tests for and/or of range checks (NFC)
Nikita Popov [Tue, 9 Nov 2021 20:59:40 +0000 (21:59 +0100)]
[InstCombine] Add tests for and/or of range checks (NFC)

2 years ago[libcxx][CI][AIX] Switch to LLVM_ENABLE_RUNTIMES
David Tenty [Tue, 9 Nov 2021 17:44:44 +0000 (12:44 -0500)]
[libcxx][CI][AIX] Switch to LLVM_ENABLE_RUNTIMES

and to the new `runtimes` top level CMakeLists.txt since the old path is now deprecated. This requires a slight adjustment of the libcxxabi CMake, since there are required macro definitions we previously got via the `llvm/CMakeList.txt` path.

Reviewed By: ldionne, #libc, #libc_abi

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

2 years ago[clang-format] Refactor SpaceBeforeParens to add options
C. Rayroud [Sun, 7 Nov 2021 19:56:35 +0000 (20:56 +0100)]
[clang-format] Refactor SpaceBeforeParens to add options

The coding style of some projects requires to have more control on space
before opening parentheses.
The goal is to add the support of clang-format to more projects.
For example adding a space only for function definitions or
declarations.
This revision adds SpaceBeforeParensOptions to configure each option
independently from one another.

Differentiel Revision: https://reviews.llvm.org/D110833

2 years ago[clang-format] Address fixme
Björn Schäpers [Fri, 5 Nov 2021 21:20:52 +0000 (22:20 +0100)]
[clang-format] Address fixme

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

2 years agoMisleading unicode identifier detection pass
serge-sans-paille [Fri, 15 Oct 2021 13:18:52 +0000 (15:18 +0200)]
Misleading unicode identifier detection pass

Detect when an identifier contains some Right-To-Left characters.
This pass relates to https://trojansource.codes/

This is a recommit of 299aa4dfa1d8c120648b1404b481d858b76c8173 with missing
option registration fixed.

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

2 years ago[DebugInfo] Fix broken MachO test
Ellis Hoag [Tue, 9 Nov 2021 20:45:54 +0000 (12:45 -0800)]
[DebugInfo] Fix broken MachO test

This test was introduced in https://reviews.llvm.org/D112337 and breaks on mac.

Reviewed By: dblaikie

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

2 years ago[Tools] Add a fuzzing tool to help fuzzing D demangler
Luís Ferreira [Tue, 9 Nov 2021 20:40:45 +0000 (12:40 -0800)]
[Tools] Add a fuzzing tool to help fuzzing D demangler

This patch adds a fuzzing helper tool for D demangler by feeding the demangler API with
pseudo-random null terminated strings with the help of libfuzzer heuristics.

Reviewed By: dblaikie

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

2 years ago[RegAllocFast] Fix nondeterminism in debuginfo generation
Ilya Yanok [Tue, 9 Nov 2021 20:35:43 +0000 (21:35 +0100)]
[RegAllocFast] Fix nondeterminism in debuginfo generation

Changes from commit 1db137b1859692ae33228c530d4df9f2431b2151
added iteration over hash map that can result in non-deterministic
order. Fix that by using a SmallMapVector to preserve the order.

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

2 years ago[compiler-rt] Fix diagnostic in InstrProfError
Gulfem Savrun Yeniceri [Tue, 9 Nov 2021 20:21:49 +0000 (20:21 +0000)]
[compiler-rt] Fix diagnostic in InstrProfError

This patch fixes some issues introduced in
https://reviews.llvm.org/D108942:

1) Remove the default label to fix the bots that use
-Werror,-Wcovered-switch-default
2) Modify the malformed test to fix the bots that are
built without zlib support
3) Modify some error messages in malformed profiles

2 years ago[AArch64] Extend and regenerate fcvt_combine.ll. NFC
David Green [Tue, 9 Nov 2021 20:29:42 +0000 (20:29 +0000)]
[AArch64] Extend and regenerate fcvt_combine.ll. NFC

This adds half and fptoi.sat variants of the tests in fcvt_combine.ll,
and regenerates the resulting check lines.

2 years agoAMDGPU: Regenerate test checks
Matt Arsenault [Thu, 4 Nov 2021 23:31:56 +0000 (19:31 -0400)]
AMDGPU: Regenerate test checks

Update these to include -NEXT to avoid spurious changes in a future
commit.

2 years ago[flang][CodeGen] Transform `fir.{store|load}` to `llvm.{store|load}`
Andrzej Warzynski [Wed, 3 Nov 2021 07:57:13 +0000 (07:57 +0000)]
[flang][CodeGen] Transform `fir.{store|load}` to `llvm.{store|load}`

This patch extends the `FIRToLLVMLowering` pass in Flang by adding a
hook to transform `fir.store`/`fir.load` to `llvm.store`/`fir.load`,
respectively.

This is part of the upstreaming effort from the `fir-dev` branch in [1].

[1] https://github.com/flang-compiler/f18-llvm-project

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

Patch originally written by:
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[InstCombine] Combine code for and/or of icmps (NFC)
Nikita Popov [Tue, 9 Nov 2021 20:17:09 +0000 (21:17 +0100)]
[InstCombine] Combine code for and/or of icmps (NFC)

The implementation for and/or is the same, apart from the choice
of exactIntersectWith() vs exactUnionWith(). Extract a common
function to make future extension easier.

2 years ago[gn build] Port 737c4a2673da
LLVM GN Syncbot [Tue, 9 Nov 2021 20:11:28 +0000 (20:11 +0000)]
[gn build] Port 737c4a2673da

2 years ago[clang][openmp][NFC] Remove arch-specific CGOpenMPRuntimeGPU files
Atmn Patel [Tue, 9 Nov 2021 04:16:54 +0000 (23:16 -0500)]
[clang][openmp][NFC] Remove arch-specific CGOpenMPRuntimeGPU files

The existing CGOpenMPRuntimeAMDGCN and CGOpenMPRuntimeNVPTX classes are
just code bloat. By removing them, the codebase gets a bit cleaner.

Reviewed By: jdoerfert, JonChesterfield, tianshilei1992

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

2 years ago[mlir][ods] Cleanup of handling Op vs OpAdaptor
Mogball [Tue, 9 Nov 2021 18:59:06 +0000 (18:59 +0000)]
[mlir][ods] Cleanup of handling Op vs OpAdaptor

In preparation for implementation subrange lookup on attributes.

Depends on D113039

Reviewed By: jpienaar, Chia-hungDuan

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

2 years ago[InstCombine] Refactor and/or of icmp with constant (NFCI)
Nikita Popov [Sat, 6 Nov 2021 21:15:26 +0000 (22:15 +0100)]
[InstCombine] Refactor and/or of icmp with constant (NFCI)

Rather than testing for many specific combinations of predicates
and values, compute the exact icmp regions for both comparisons
and check whether they union/intersect exactly. If they do,
construct the equivalent icmp for the new range. Assuming that the
existing code handled all possible cases, this should be NFC.

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

2 years agoBPF: change btf_type_tag BTF output format
Yonghong Song [Mon, 8 Nov 2021 04:36:52 +0000 (20:36 -0800)]
BPF: change btf_type_tag BTF output format

For the declaration like below:
  int __tag1 * __tag1 __tag2 *g
Commit 41860e602aaa ("BPF: Support btf_type_tag attribute")
implemented the following encoding:
  VAR(g) -> __tag1 --> __tag2 -> pointer -> __tag1 -> pointer -> int

Some further experiments with linux btf_type_tag support, esp.
with generating attributes in vmlinux.h, and also some internal
discussion showed the following format is more desirable:
  VAR(g) -> pointer -> __tag2 -> __tag1 -> pointer -> __tag1 -> int

The format makes it similar to other modifier like 'const', e.g.,
  const int *g
which has encoding VAR(g) -> PTR -> CONST -> int

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

2 years ago[InstCombine] Fuse checks for LHS (~(A | B) & C) | ... NFC.
Stanislav Mekhanoshin [Wed, 3 Nov 2021 18:10:26 +0000 (11:10 -0700)]
[InstCombine] Fuse checks for LHS (~(A | B) & C) | ... NFC.

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

2 years agoRevert "[clang-tidy] Fix lint warning in ClangTidyDiagnosticConsumer.cpp (NFC)"
Jorge Gorbe Moya [Tue, 9 Nov 2021 19:24:05 +0000 (11:24 -0800)]
Revert "[clang-tidy] Fix lint warning in ClangTidyDiagnosticConsumer.cpp (NFC)"

The change causes multiple clang-tidy tests to fail under ASan.

This reverts commit 00769572025f9b0d36dc832d3c1bc61500091ed5.

2 years ago[InstCombine] fix code comment to match code; NFC
Sanjay Patel [Tue, 9 Nov 2021 18:26:04 +0000 (13:26 -0500)]
[InstCombine] fix code comment to match code; NFC

2 years ago[libc++] Adds missing forward_list merge tests.
Mark de Wever [Sat, 6 Nov 2021 19:30:08 +0000 (20:30 +0100)]
[libc++] Adds missing forward_list merge tests.

During the review of D112660 it turned out the tests for
`std::forward_list::merge` are incomplete.

Adds tests for the rvalue reference overloads. The tests are extended to
better test the Effects [forward.list.ops]/25 and Remarks
[forward.list.ops]/27 of the function:
- x is empty after the merge.
- Pointers and references to the moved elements of x now refer to those
  same elements but as members of *this.
- Iterators referring to the moved elements will continue to refer to
  their elements, but they now behave as iterators into *this, not into x.
- The algorithm is stable.

Reviewed By: Quuxplusone, #libc, ldionne

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

2 years ago[Sema] Mark virtual method declaration in union as invalid
Yuanfang Chen [Tue, 9 Nov 2021 18:33:33 +0000 (10:33 -0800)]
[Sema] Mark virtual method declaration in union as invalid

Currently, this is only diagnosed but the decl is not marked invalid. This may hit assertions down the path.

This also reverts the fix for PR49534 since it is not needed anymore.

Reviewed By: hubert.reinterpretcast

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

2 years ago[DebugInfo] Only create concrete DIEs of concrete functions
Ellis Hoag [Tue, 9 Nov 2021 18:52:10 +0000 (10:52 -0800)]
[DebugInfo] Only create concrete DIEs of concrete functions

At the begining of the module we can iterate through the functions to
see which SPs should have concrete DIEs. Then when we need to reference
a DIE for a SP we can decide if it's ok to create a concrete DIE or not.

Fixes
 * https://bugs.llvm.org/show_bug.cgi?id=52159
 * https://bugs.llvm.org/show_bug.cgi?id=30637

Reviewed By: dblaikie

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

2 years ago[lldb] XFAIL TestPlatformKill on windows
Pavel Labath [Tue, 9 Nov 2021 18:39:17 +0000 (19:39 +0100)]
[lldb] XFAIL TestPlatformKill on windows

-> PR52451

2 years agoUse yaml2obj instead of relying on invoking the Darwin system assembler.
Adrian Prantl [Tue, 9 Nov 2021 18:46:09 +0000 (10:46 -0800)]
Use yaml2obj instead of relying on invoking the Darwin system assembler.

2 years ago[llvm-reduce] Fix invalid reduction in basic-blocks delta pass
Dwight Guth [Tue, 9 Nov 2021 18:42:52 +0000 (10:42 -0800)]
[llvm-reduce] Fix invalid reduction in basic-blocks delta pass

Previously, if the basic-blocks delta pass tried to remove a basic block
that was the last basic block in a function that did not have external
or weak linkage, the resulting IR would become invalid. Since removing
the last basic block in a function is effectively identical to removing
the function body itself, we check explicitly for this case and if we
detect it, we run the same logic as in ReduceFunctionBodies.cpp

Reviewed By: aeubanks

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

2 years ago[gn build] Port 533862933398
LLVM GN Syncbot [Tue, 9 Nov 2021 18:38:40 +0000 (18:38 +0000)]
[gn build] Port 533862933398