platform/upstream/llvm.git
3 years ago[NFC][CostModel] Fixed comment that comparisons work regardless of the state.
Daniil Fukalov [Tue, 8 Jun 2021 16:53:28 +0000 (19:53 +0300)]
[NFC][CostModel] Fixed comment that comparisons work regardless of the state.

Reviewed By: sdesmalen

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

3 years agoRevert "[IRSim] Adding basic implementation of llvm-sim."
Andrew Litteken [Fri, 11 Jun 2021 20:44:08 +0000 (15:44 -0500)]
Revert "[IRSim] Adding basic implementation of llvm-sim."

This reverts commit f47d00c54b52bd8adf9b8725912ea1cd0f1873d5.

3 years agoAllow ptrtoint/inttoptr of non-integral pointer types in IR
Philip Reames [Fri, 11 Jun 2021 20:30:10 +0000 (13:30 -0700)]
Allow ptrtoint/inttoptr of non-integral pointer types in IR

I don't like landing this change, but it's an acknowledgement of a practical reality.  Despite not having well specified semantics for inttoptr and ptrtoint involving non-integral pointer types, they are used in practice.  Here's a quick summary of the current pragmatic reality:
* I happen to know that the main external user of non-integral pointers has effectively disabled the verifier rules.
* RS4GC (the lowering pass for abstract GC machine model which is the key motivation for non-integral pointers), even supports them.  We just have all the tests using an integral pointer space to let the verifier run.
* Certain idioms (such as alignment checks for alignment N, where any relocation is guaranteed to be N byte aligned) are fine in practice.
* As implemented, inttoptr/ptrtoint are CSEd and are not control dependent.  This means that any code which is intending to check a particular bit pattern at site of use must be wrapped in an intrinsic or external function call.

This change allows them in the Verifier, and updates the LangRef to specific them as implementation dependent.  This allows us to acknowledge current reality while still leaving ourselves room to punt on figuring out "good" semantics until the future.

3 years ago[clang][ObjC] allow the use of NSAttributedString * argument type with format attribute
Alex Lorenz [Fri, 11 Jun 2021 20:23:44 +0000 (13:23 -0700)]
[clang][ObjC] allow the use of NSAttributedString * argument type with format attribute

This is useful for APIs that want to accept an attributed NSString as their format string

rdar://79163229

3 years ago[IRSim] Adding basic implementation of llvm-sim.
Andrew Litteken [Mon, 7 Jun 2021 15:57:39 +0000 (10:57 -0500)]
[IRSim] Adding basic implementation of llvm-sim.

This is a similarity visualization tool that accepts a Module and
passes it to the IRSimilarityIdentifier.  The resulting SimilarityGroups
are output in a JSON file.

Tests are found in test/tools/llvm-sim and check for the file not found,
a bad module, and that the JSON is created correctly.

Reviewers: paquette, jroelofs, MaskRay

Recommit of: 15645d044bcfe2a0f63156048b302f997a717688 to fix linking
errors.

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

3 years ago[docs][OpaquePtr] Add some specific examples of what needs to be done
Arthur Eubanks [Fri, 11 Jun 2021 19:51:25 +0000 (12:51 -0700)]
[docs][OpaquePtr] Add some specific examples of what needs to be done

3 years ago[mlir][docs] Reorder PassWrapper arguments
Marius Brehler [Fri, 11 Jun 2021 17:28:30 +0000 (19:28 +0200)]
[mlir][docs] Reorder PassWrapper arguments

Fixes the order of template arguments passed to the `PassWrapper`.

Reviewed By: mehdi_amini

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

3 years ago[flang] Handle multiple USE statements for the same module
Peter Steinfeld [Fri, 11 Jun 2021 16:28:26 +0000 (09:28 -0700)]
[flang] Handle multiple USE statements for the same module

It's possible to have several USE statements for the same module that
have different mixes of rename clauses and ONLY clauses.  The presence
of a rename cause has the effect of hiding a previously associated name,
and the presence of an ONLY clause forces the name to be visible even in
the presence of a rename.

I fixed this by keeping track of the names that appear on rename and ONLY
clauses.  Then, when processing the USE association of a name, I check to see
if it previously appeared in a rename clause and not in a USE clause.  If so, I
remove its USE associated symbol.  Also, when USE associating all of the names
in a module, I do not USE associate names that have appeared in rename clauses.

I also added a test.

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

3 years ago[clang-cl][sanitizer] Add -fsanitize-address-use-after-return to clang.
Kevin Athey [Fri, 11 Jun 2021 17:13:10 +0000 (10:13 -0700)]
[clang-cl][sanitizer] Add -fsanitize-address-use-after-return to clang.

Also:
  - add driver test (fsanitize-use-after-return.c)
  - add basic IR test (asan-use-after-return.cpp)
  - (NFC) cleaned up logic for generating table of __asan_stack_malloc
    depending on flag.

for issue: https://github.com/google/sanitizers/issues/1394

Reviewed By: vitalybuka

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

3 years ago[NFC][OpaquePtr] Explicitly pass GEP source type in optimizeGatherScatterInst()
Arthur Eubanks [Tue, 18 May 2021 22:09:06 +0000 (15:09 -0700)]
[NFC][OpaquePtr] Explicitly pass GEP source type in optimizeGatherScatterInst()

Reviewed By: craig.topper

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

3 years ago[compiler-rt] Add platform detection support for x32
John Paul Adrian Glaubitz [Fri, 11 Jun 2021 18:44:04 +0000 (19:44 +0100)]
[compiler-rt] Add platform detection support for x32

Currently, the compiler-rt build system checks only whether __X86_64
is defined to determine whether the default compiler-rt target arch
is x86_64. Since x32 defines __X86_64 as well, we must also check that
the default pointer size is eight bytes and not four bytes to properly
detect a 64-bit x86_64 compiler-rt default target arch.

Reviewed By: hvdijk, vitalybuka

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

3 years ago[gn build] Port 7eba4856c702
LLVM GN Syncbot [Fri, 11 Jun 2021 18:04:01 +0000 (18:04 +0000)]
[gn build] Port 7eba4856c702

3 years ago[libcxx][ranges] Add class ref_view.
zoecarver [Thu, 6 May 2021 20:19:13 +0000 (13:19 -0700)]
[libcxx][ranges] Add class ref_view.

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

3 years agoAMDGPU/GlobalISel: Remove leftover hack for argument memory sizes
Matt Arsenault [Thu, 10 Jun 2021 21:39:51 +0000 (17:39 -0400)]
AMDGPU/GlobalISel: Remove leftover hack for argument memory sizes

Since the call lowering code now tries to respect the tablegen
reported argument types, this is no longer necessary.

3 years agoAMDGPU/GlobalISel: Fix indentation
Matt Arsenault [Thu, 10 Jun 2021 16:00:36 +0000 (12:00 -0400)]
AMDGPU/GlobalISel: Fix indentation

3 years agoGlobalISel: Reduce indentation and remove dead path
Matt Arsenault [Thu, 10 Jun 2021 01:22:00 +0000 (21:22 -0400)]
GlobalISel: Reduce indentation and remove dead path

3 years agoCodeGen: Fix missing const
Matt Arsenault [Tue, 8 Jun 2021 21:10:51 +0000 (17:10 -0400)]
CodeGen: Fix missing const

3 years ago[Sema] Address-space sensitive check for unbounded arrays (v2)
eahcmrh [Tue, 8 Jun 2021 17:00:42 +0000 (19:00 +0200)]
[Sema] Address-space sensitive check for unbounded arrays (v2)

Check applied to unbounded (incomplete) arrays and pointers to spot
cases where the computed address is beyond the largest possible
addressable extent of the array, based on the address space in which the
array is delcared, or which the pointer refers to.

Check helps to avoid cases of nonsense pointer math and array indexing
which could lead to linker failures or runtime exceptions.  Of
particular interest when building for embedded systems with small
address spaces.

This is version 2 of this patch -- version 1 had some testing issues
due to a sign error in existing code.  That error is corrected and
lit test for this chagne is extended to verify the fix.

Originally reviewed/accepted by: aaron.ballman
Original revision: https://reviews.llvm.org/D86796

Reviewed By: aaron.ballman, ebevhan

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

3 years agoIntroduce alloca_scope op
Denys Shabalin [Fri, 11 Jun 2021 15:53:45 +0000 (17:53 +0200)]
Introduce alloca_scope op

## Introduction

This proposal describes the new op to be added to the `std` (and later moved `memref`)
dialect called `alloca_scope`.

## Motivation

Alloca operations are easy to misuse, especially if one relies on it while doing
rewriting/conversion passes. For example let's consider a simple example of two
independent dialects, one defines an op that wants to allocate on-stack and
another defines a construct that corresponds to some form of looping:

```
dialect1.looping_op {
  %x = dialect2.stack_allocating_op
}
```

Since the dialects might not know about each other they are going to define a
lowering to std/scf/etc independently:

```
scf.for … {
   %x_temp = std.alloca …
   … // do some domain-specific work using %x_temp buffer
   … // and store the result into %result
   %x = %result
}
```

Later on the scf and `std.alloca` is going to be lowered to llvm using a
combination of `llvm.alloca` and unstructured control flow.

At this point the use of `%x_temp` is bound to either be either optimized by
llvm (for example using mem2reg) or in the worst case: perform an independent
stack allocation on each iteration of the loop. While the llvm optimizations are
likely to succeed they are not guaranteed to do so, and they provide
opportunities for surprising issues with unexpected use of stack size.

## Proposal

We propose a new operation that defines a finer-grain allocation scope for the
alloca-allocated memory called `alloca_scope`:

```
alloca_scope {
   %x_temp = alloca …
   ...
}
```

Here the lifetime of `%x_temp` is going to be bound to the narrow annotated
region within `alloca_scope`. Moreover, one can also return values out of the
alloca_scope with an accompanying `alloca_scope.return` op (that behaves
similarly to `scf.yield`):

```
%result = alloca_scope {
   %x_temp = alloca …
   …
   alloca_scope.return %myvalue
}
```

Under the hood the `alloca_scope` is going to lowered to a combination of
`llvm.intr.stacksave` and `llvm.intr.strackrestore` that are going to be invoked
automatically as control-flow enters and leaves the body of the `alloca_scope`.

The key value of the new op is to allow deterministic guaranteed stack use
through an explicit annotation in the code which is finer-grain than the
function-level scope of `AutomaticAllocationScope` interface. `alloca_scope`
can be inserted at arbitrary locations and doesn’t require non-trivial
transformations such as outlining.

## Which dialect

Before memref dialect is split, `alloca_scope` can temporarily reside in `std`
dialect, and later on be moved to `memref` together with the rest of
memory-related operations.

## Implementation

An implementation of the op is available [here](https://reviews.llvm.org/D97768).

Original commits:

* Add initial scaffolding for alloca_scope op
* Add alloca_scope.return op
* Add no region arguments and variadic results
* Add op descriptions
* Add failing test case
* Add another failing test
* Initial implementation of lowering for std.alloca_scope
* Fix backticks
* Fix getSuccessorRegions implementation

Reviewed By: ftynse

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

3 years ago[lldb] Support new objective-c hash table layout
Jonas Devlieghere [Wed, 10 Feb 2021 03:52:11 +0000 (19:52 -0800)]
[lldb] Support new objective-c hash table layout

Update LLDB for thew new Objective-C hash table layout in the dyld
shared cache found in macOS Monterey.

rdar://72863911

3 years ago[lldb] Enable TestRuntimeTypes on Apple Silicon
Jonas Devlieghere [Fri, 11 Jun 2021 17:24:01 +0000 (10:24 -0700)]
[lldb] Enable TestRuntimeTypes on Apple Silicon

3 years ago[SLP][NFC] Fix condition that was supposed to save a bit of compile time.
Valery N Dmitriev [Fri, 11 Jun 2021 16:35:08 +0000 (09:35 -0700)]
[SLP][NFC] Fix condition that was supposed to save a bit of compile time.

It was found by chance revealing discrepancy between comment (few lines above),
the condition and how re-ordering of instruction is done inside the if statement
it guards. The condition was always evaluated to true.

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

3 years ago[gn build] Port c54d3050f7b9
LLVM GN Syncbot [Fri, 11 Jun 2021 16:57:34 +0000 (16:57 +0000)]
[gn build] Port c54d3050f7b9

3 years ago[libc++] NFC: Move indirect_concepts.h to __iterator/concepts.h
Louis Dionne [Thu, 10 Jun 2021 17:38:55 +0000 (13:38 -0400)]
[libc++] NFC: Move indirect_concepts.h to __iterator/concepts.h

There's no fundamental reason to separate those from the other iterator
concepts.

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

3 years ago[X86FixupLEAs] Sub register usage of LEA dest should block LEA/SUB optimization
Guozhi Wei [Fri, 11 Jun 2021 16:43:52 +0000 (09:43 -0700)]
[X86FixupLEAs] Sub register usage of LEA dest should block LEA/SUB optimization

In function searchALUInst, sub register usage of LEA dest should also block LEA/SUB optimization, otherwise the sub register usage gets an undefined value.

This patch fixes https://bugs.llvm.org/show_bug.cgi?id=50615.

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

3 years ago[libc++] Enable the synchronization library on Apple platforms
Louis Dionne [Tue, 16 Feb 2021 16:24:27 +0000 (11:24 -0500)]
[libc++] Enable the synchronization library on Apple platforms

The synchronization library was marked as disabled on Apple platforms
up to now because we were not 100% sure that it was going to be ABI
stable. However, it's been some time since we shipped it in upstream
libc++ now and there's been no changes so far. This patch enables the
synchronization library on Apple platforms, and hence commits the ABI
stability as far as that vendor is concerned.

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

3 years ago[gn build] Port 9106047ee3dd
LLVM GN Syncbot [Fri, 11 Jun 2021 16:34:49 +0000 (16:34 +0000)]
[gn build] Port 9106047ee3dd

3 years ago[libcxx][ranges] Add range.subrange.
zoecarver [Mon, 3 May 2021 21:37:42 +0000 (14:37 -0700)]
[libcxx][ranges] Add range.subrange.

Basically the title.

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

3 years ago[Matrix] In transpose opts, handle a^t * a^t
Adam Nemet [Fri, 11 Jun 2021 15:50:07 +0000 (08:50 -0700)]
[Matrix] In transpose opts, handle a^t * a^t

Without the fix the testcase crashes because we remove the same instruction
twice.

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

3 years ago[HIP] Fix --hip-version flag with 0 as component
Aaron En Ye Shi [Thu, 10 Jun 2021 21:24:38 +0000 (21:24 +0000)]
[HIP] Fix --hip-version flag with 0 as component

Allow the usage of minor version 0, for hip versions
such as 4.0. Change the default values when performing
version checks.

Reviewed By: yaxunl

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

3 years ago[lldb-vscode] Synchronize calls to SendTerminatedEvent
Ayush Sahay [Fri, 11 Jun 2021 15:52:15 +0000 (21:22 +0530)]
[lldb-vscode] Synchronize calls to SendTerminatedEvent

If an inferior exits prior to the processing of a disconnect request,
then the threads executing EventThreadFunction and request_discontinue
respectively may call SendTerminatedEvent simultaneously, in turn,
testing and/or setting g_vsc.sent_terminated_event without any
synchronization. In case the thread executing EventThreadFunction sets
it before the thread executing request_discontinue has had a chance to
test it, the latter would move ahead to issue a response to the
disconnect request. Said response may be dispatched ahead of the
terminated event compelling the client to terminate the debug session
without consuming any console output that might've been generated by
the execution of terminateCommands.

Reviewed By: clayborg, wallace

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

3 years agoUpdate the C status page somewhat.
Aaron Ballman [Fri, 11 Jun 2021 16:06:21 +0000 (12:06 -0400)]
Update the C status page somewhat.

This adds implementation information for N2607,
clarifies that C17 only resolved defect reports,
and adds -std= information for the different versions.

3 years ago[CodeGen][regalloc] Don't align stack slots if the stack can't be realigned
Tomas Matheson [Tue, 20 Apr 2021 18:03:09 +0000 (19:03 +0100)]
[CodeGen][regalloc] Don't align stack slots if the stack can't be realigned

Register allocation may spill virtual registers to the stack, which can
increase alignment requirements of the stack frame. If the the function
did not require stack realignment before register allocation, the
registers required to do so may not be reserved/available. This results
in a stack frame that requires realignment but can not be realigned.

Instead, only increase the alignment of the stack if we are still able
to realign.

The register SpillAlignment will be ignored if we can't realign, and the
backend will be responsible for emitting the correct unaligned loads and
stores. This seems to be the assumed behaviour already, e.g.
ARMBaseInstrInfo::storeRegToStackSlot and X86InstrInfo::storeRegToStackSlot
are both `canRealignStack` aware.

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

3 years ago[SLP]Allow reordering of insertelements.
Alexey Bataev [Wed, 9 Jun 2021 19:37:34 +0000 (12:37 -0700)]
[SLP]Allow reordering of insertelements.

After we added support for non-ordered insertelements, we can allow
their reordering.

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

3 years agoRevert "[Sema] Address-space sensitive check for unbounded arrays (v2)"
eahcmrh [Fri, 11 Jun 2021 15:44:06 +0000 (17:44 +0200)]
Revert "[Sema] Address-space sensitive check for unbounded arrays (v2)"

This reverts commit e42a347b74400b7212ceaaea6d39562a0435df42.

3 years ago[Sema] Address-space sensitive check for unbounded arrays (v2)
eahcmrh [Tue, 8 Jun 2021 17:00:42 +0000 (19:00 +0200)]
[Sema] Address-space sensitive check for unbounded arrays (v2)

Check applied to unbounded (incomplete) arrays and pointers to spot
cases where the computed address is beyond the largest possible
addressable extent of the array, based on the address space in which the
array is delcared, or which the pointer refers to.

Check helps to avoid cases of nonsense pointer math and array indexing
which could lead to linker failures or runtime exceptions.  Of
particular interest when building for embedded systems with small
address spaces.

This is version 2 of this patch -- version 1 had some testing issues
due to a sign error in existing code.  That error is corrected and
lit test for this chagne is extended to verify the fix.

Originally reviewed/accepted by: aaron.ballman
Original revision: https://reviews.llvm.org/D86796

Reviewed By: aaron.ballman, ebevhan

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

3 years ago[HWASan] Add basic stack tagging support for LAM.
Matt Morehouse [Fri, 11 Jun 2021 15:19:36 +0000 (08:19 -0700)]
[HWASan] Add basic stack tagging support for LAM.

Adds the basic instrumentation needed for stack tagging.

Currently does not support stack short granules or TLS stack histories,
since a different code path is followed for the callback instrumentation
we use.

We may simply wait to support these two features until we switch to
a custom calling convention.

Patch By: xiangzhangllvm, morehouse

Reviewed By: vitalybuka

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

3 years ago[lld/mac] Use sectionType() more
Nico Weber [Fri, 11 Jun 2021 15:15:11 +0000 (11:15 -0400)]
[lld/mac] Use sectionType() more

Not sure sectionType() carries its weight, but while we have it
we should use it consistently.

No behavior change.

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

3 years ago[SLP]Remove unnecessary UndefValue in CreateShuffle.
Alexey Bataev [Fri, 11 Jun 2021 12:13:31 +0000 (05:13 -0700)]
[SLP]Remove unnecessary UndefValue in CreateShuffle.

No need to use UndefValue in CreateShuffle call.

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

3 years ago[SLP][NFC]Add a test for unordered stores, NFC.
Alexey Bataev [Fri, 11 Jun 2021 15:00:15 +0000 (08:00 -0700)]
[SLP][NFC]Add a test for unordered stores, NFC.

3 years ago[mlir][VectorToGPU] First step to convert vector ops to GPU MMA ops
thomasraoux [Fri, 11 Jun 2021 14:39:01 +0000 (07:39 -0700)]
[mlir][VectorToGPU] First step to convert vector ops to GPU MMA ops

This is the first step to convert vector ops to MMA operations in order to
target GPUs tensor core ops. This currently only support simple cases,
transpose and element-wise operation will be added later.

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

3 years ago[lldb] Remove GCC XFAIL for TestTypedefArray
Raphael Isemann [Fri, 11 Jun 2021 14:24:58 +0000 (16:24 +0200)]
[lldb] Remove GCC XFAIL for TestTypedefArray

This passes with GCC>8.5 and ToT LLDB.

3 years ago[lldb] Fix compilation after removal of APInt::toString
Raphael Isemann [Fri, 11 Jun 2021 14:20:57 +0000 (16:20 +0200)]
[lldb] Fix compilation after removal of APInt::toString

3 years ago[lldb] Unmark TestInlines as XFAIL for gcc
Raphael Isemann [Fri, 11 Jun 2021 14:06:39 +0000 (16:06 +0200)]
[lldb] Unmark TestInlines as XFAIL for gcc

This works for GCC>8.5 and ToT LLDB.

3 years ago[gn build] Port 9907746f5db7
LLVM GN Syncbot [Fri, 11 Jun 2021 14:01:11 +0000 (14:01 +0000)]
[gn build] Port 9907746f5db7

3 years agoMove Function Specialization to its correct location. NFC.
Sjoerd Meijer [Fri, 11 Jun 2021 13:43:49 +0000 (14:43 +0100)]
Move Function Specialization to its correct location. NFC.

As a follow up of rGc4a0969b9c14, and as part of D104102, move it to
the IPO transformations directory.

3 years agoReferencing a static function defined in an opnemp clause, is
Zahira Ammarguellat [Wed, 2 Jun 2021 14:59:07 +0000 (07:59 -0700)]
Referencing a static function defined in an opnemp clause, is
generating an erroneous warning.

See here: https://godbolt.org/z/ajKPc36M7

3 years agoFix for error "'Run' overrides a member function but is not marked
Zahira Ammarguellat [Fri, 28 May 2021 20:15:26 +0000 (13:15 -0700)]
Fix for error "'Run' overrides a member function but is not marked
'override' [-Werror,-Wsuggest-override]" occuring during windows
debug self-build.

3 years ago[mlir][linalg] Prepare pad to static bounding box for scalar operands.
Tobias Gysi [Fri, 11 Jun 2021 13:21:32 +0000 (13:21 +0000)]
[mlir][linalg] Prepare pad to static bounding box for scalar operands.

Adapt pad to static bounding box to support structured ops taking scalar operands.

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

3 years agoFix extraneous ')' error.
Simon Pilgrim [Fri, 11 Jun 2021 13:50:03 +0000 (14:50 +0100)]
Fix extraneous ')' error.

3 years ago[SimplifyCFG] avoid crash on degenerate loop
Sanjay Patel [Fri, 11 Jun 2021 13:33:32 +0000 (09:33 -0400)]
[SimplifyCFG] avoid crash on degenerate loop

The problematic code pattern in the test is based on:
https://llvm.org/PR50638

If the IfCond is itself the phi that we are trying to remove,
then the loop around line 2835 can end up with something like:
%cmp = select i1 %cmp, i1 false, i1 true

That can then lead to a use-after-free and assert (although
I'm still not seeing that locally in my release + asserts build).

I think this can only happen with unreachable code.

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

3 years agoStringExtrasTest.cpp - add missing newline at the end of file. NFCI.
Simon Pilgrim [Fri, 11 Jun 2021 13:27:04 +0000 (14:27 +0100)]
StringExtrasTest.cpp - add missing newline at the end of file. NFCI.

3 years agoFix Wdocumentation missing parameter warnings. NFCI.
Simon Pilgrim [Fri, 11 Jun 2021 12:44:30 +0000 (13:44 +0100)]
Fix Wdocumentation missing parameter warnings. NFCI.

3 years ago[mlir][linalg] Prepare drop unit dims for scalar operands.
Tobias Gysi [Fri, 11 Jun 2021 12:53:21 +0000 (12:53 +0000)]
[mlir][linalg] Prepare drop unit dims for scalar operands.

Adapt drop unit dims for structured ops taking scalar operands.

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

3 years agoRevert "[lldb] Add support for evaluating expressions in static member functions"
Raphael Isemann [Fri, 11 Jun 2021 12:51:17 +0000 (14:51 +0200)]
Revert "[lldb] Add support for evaluating expressions in static member functions"

This reverts commit 00764c36edf88ae9806e8d57a6addb782e6ceae8 and the
follow up d2223c7a49973a61cc2de62992662afa8d19065a.

The original patch broke that one could use static member variables while
inside a static member functions without having a running target. It seems that
LLDB currently requires that static variables are only found via the global
variable lookup so that they can get materialized and mapped to the argument
struct of the expression.

After 00764c36edf88ae9806e8d57a6addb782e6ceae8 static variables of the current
class could be found via Clang's lookup which LLDB isn't observing. This
resulting in expressions actually containing these variables as normal
globals that can't be rewritten to a member of the argument struct.

More specifically, in the test TestCPPThis, the expression
`expr --j false -- s_a` is now only passing if we have a runnable target.

I'll revert the patch as the possible fixes aren't trivial and it degrades
the debugging experience more than the issue that the revert patch addressed.

The underlying bug can be reproduced before/after this patch by stopping
in `TestCPPThis` main function and running: `e -j false -- my_a; A<int>::s_a`.
The `my_a` will pull in the `A<int>` class and the second expression will
be resolved by Clang on its own (which causes LLDB to not materialize the
static variable).

Note: A workaround is to just do `::s_a` which will force LLDB to take the global
variable lookup.

3 years ago[mlir][[linalg] Remove deprecated structured op interface methods.
Tobias Gysi [Fri, 11 Jun 2021 12:13:27 +0000 (12:13 +0000)]
[mlir][[linalg] Remove deprecated structured op interface methods.

Cleanup the refactoring started by https://reviews.llvm.org/D103394.

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

3 years ago[Polly][Isl] Removing explicit operator bool() from isl C++ bindings. NFC.
patacca [Fri, 11 Jun 2021 11:13:07 +0000 (13:13 +0200)]
[Polly][Isl] Removing explicit operator bool() from isl C++ bindings. NFC.

This is part of an effort to reduce the differences between the custom C++ bindings used right now by polly in `lib/External/isl/include/isl/isl-noxceptions.h` and the official isl C++ interface.

Changes made:
 - Removing explicit operator bool() from all the classes in the isl C++ bindings.
 - Replace each call to operator bool() to method `is_null()`.
 - isl-noexceptions.h has been generated by this https://github.com/patacca/isl/commit/27396daac5a5ee8228d25511a12f4a814c92ba8f

Reviewed By: Meinersbur

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

3 years ago[lldb] DumpDataExtractor.cpp - replace APInt::toString() with llvm::toString(APInt)
Simon Pilgrim [Fri, 11 Jun 2021 12:39:14 +0000 (13:39 +0100)]
[lldb] DumpDataExtractor.cpp - replace APInt::toString() with llvm::toString(APInt)

APInt::toString() was removed rG61cdaf66fe22be2b5942ddee4f46a998b4f3ee29

3 years agoAPInt.h - add missing <utility> header.
Simon Pilgrim [Fri, 11 Jun 2021 12:34:02 +0000 (13:34 +0100)]
APInt.h - add missing <utility> header.

Some buildbots are complaining about std::move() after rG61cdaf66fe22be2b5942ddee4f46a998b4f3ee29

3 years ago[AST] Include the TranslationUnitDecl when traversing with TraversalScope
Sam McCall [Thu, 10 Jun 2021 22:16:14 +0000 (00:16 +0200)]
[AST] Include the TranslationUnitDecl when traversing with TraversalScope

Given `int foo, bar;`, TraverseAST reveals this tree:
  TranslationUnitDecl
   - foo
   - bar

Before this patch, with the TraversalScope set to {foo}, TraverseAST yields:
  foo

After this patch it yields:
  TranslationUnitDecl
  - foo

Also, TraverseDecl(TranslationUnitDecl) now respects the traversal scope.

---

The main effect of this today is that clang-tidy checks that match the
translationUnitDecl(), either in order to traverse it or check
parentage, should work.

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

3 years ago[ADT] Remove APInt/APSInt toString() std::string variants
Simon Pilgrim [Fri, 11 Jun 2021 12:19:00 +0000 (13:19 +0100)]
[ADT] Remove APInt/APSInt toString() std::string variants

<string> is currently the highest impact header in a clang+llvm build:

https://commondatastorage.googleapis.com/chromium-browser-clang/llvm-include-analysis.html

One of the most common places this is being included is the APInt.h header, which needs it for an old toString() implementation that returns std::string - an inefficient method compared to the SmallString versions that it actually wraps.

This patch replaces these APInt/APSInt methods with a pair of llvm::toString() helpers inside StringExtras.h, adjusts users accordingly and removes the <string> from APInt.h - I was hoping that more of these users could be converted to use the SmallString methods, but it appears that most end up creating a std::string anyhow. I avoided trying to use the raw_ostream << operators as well as I didn't want to lose having the integer radix explicit in the code.

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

3 years ago[VP][NFC] Format comment to 80 columns
Fraser Cormack [Fri, 11 Jun 2021 11:38:01 +0000 (12:38 +0100)]
[VP][NFC] Format comment to 80 columns

3 years ago[clangd] don't rename if the triggering loc is not actually being renamed.
Haojian Wu [Fri, 11 Jun 2021 11:07:14 +0000 (13:07 +0200)]
[clangd] don't rename if the triggering loc is not actually being renamed.

See context: https://github.com/clangd/clangd/issues/765

Reviewed By: sammccall

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

3 years ago[Test] One more elaborate test with selects for loop deletion
Max Kazantsev [Fri, 11 Jun 2021 11:40:44 +0000 (18:40 +0700)]
[Test] One more elaborate test with selects for loop deletion

3 years agoprecommit tests for D104042
Jingu Kang [Fri, 11 Jun 2021 11:31:25 +0000 (12:31 +0100)]
precommit tests for D104042

3 years ago[mlir] Provide minimal Python bindings for the math dialect
Alex Zinenko [Thu, 10 Jun 2021 17:00:34 +0000 (19:00 +0200)]
[mlir] Provide minimal Python bindings for the math dialect

Reviewed By: ulysseB

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

3 years ago[PowerPC] Allow wa inline asm to also accept floating point arguments
Zarko Todorovski [Thu, 10 Jun 2021 20:49:51 +0000 (16:49 -0400)]
[PowerPC] Allow wa inline asm to also accept floating point arguments

GCC documentation for the `wa` constraint states that:
```
wa

    A VSX register (VSR), vs0…vs63. This is either an FPR (vs0…vs31 are f0…f31)
    or a VR (vs32…vs63 are v0…v31).
```
This technically means that we could accept floating point parameters. In fact,
gcc itself does. The following testcase compiles and runs on all PPC platforms with GCC,
whereas clang/llc will assert:
```
#include <stdio.h>
double foo ( vector double a ) {
  double b, c;
  asm("xvabsdp  %x0, %x2        \n"
             "xxsldwi  %x1, %x0, %x0, 2 \n"
      :  "+wa"    (b),
         "=wa"    (c)
      :  "wa"    (a)
      );
  return b+c;
}
int main(void) {
  vector double a = {-3., -4.};
  double t = foo( a );
  printf("%g\n", t);
}
```
This patch allows clang/llc to build and run this testcase.

Reviewed By: nemanjai, #powerpc

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

3 years ago[Test] Add loop deletion test with switch
Max Kazantsev [Fri, 11 Jun 2021 10:42:33 +0000 (17:42 +0700)]
[Test] Add loop deletion test with switch

3 years ago[clang-tidy] NarrowingConversionsCheck should support inhibiting conversions of
Haojian Wu [Thu, 10 Jun 2021 15:12:12 +0000 (17:12 +0200)]
[clang-tidy] NarrowingConversionsCheck should support inhibiting conversions of
mixed integer and floating point types with WarnOnEquivalentBitWidth=0.

Also standardize control flow of handleX conversion functions to make it easier to be consistent.

Patch by Stephen Concannon!

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

3 years ago[ADT] Consistently use StringExtrasTest for the test suite filter. NFCI.
Simon Pilgrim [Fri, 11 Jun 2021 11:00:21 +0000 (12:00 +0100)]
[ADT] Consistently use StringExtrasTest for the test suite filter. NFCI.

Noticed while updating D103888 - some of the tests were using "StringExtras" for the test_suite_name instead of the expected "StringExtrasTest"

3 years ago[clang][NFC] Avoid assignment in condition
Nathan Sidwell [Thu, 10 Jun 2021 15:07:47 +0000 (08:07 -0700)]
[clang][NFC] Avoid assignment in condition

Refactor to avoid assignment inside condition by using 'if
(init-decl)'.  Also remove some unnecessary braces on a separate
if-nest.

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

3 years agoDo not generate calls to the 128-bit function __multi3() on 32-bit ARM
Koutheir Attouchi [Fri, 11 Jun 2021 10:37:16 +0000 (11:37 +0100)]
Do not generate calls to the 128-bit function __multi3() on 32-bit ARM

Re-applying this patch after bots failures. Should be fine now.

The function __multi3() is undefined on 32-bit ARM, so a call to it should
never be emitted. Instead, plain instructions need to be generated to
perform 128-bit multiplications.

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

3 years ago[CostModel][AArch64] Improve the cost estimate of CTPOP intrinsic
Rosie Sumpter [Wed, 9 Jun 2021 09:00:16 +0000 (10:00 +0100)]
[CostModel][AArch64] Improve the cost estimate of CTPOP intrinsic

Added a case for CTPOP to AArch64TTIImpl::getIntrinsicInstrCost so that
the cost estimate matches the codegen in
test/CodeGen/AArch64/arm64-vpopcnt.ll

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

3 years ago[OpenCL] Fix overloading resolution of addrspace constructors
Ole Strohm [Fri, 11 Jun 2021 09:42:41 +0000 (10:42 +0100)]
[OpenCL] Fix overloading resolution of addrspace constructors

This fixes the prioritization of address spaces when choosing a
constructor, stopping them from being considered equally good,
which made the construction of types that could be constructed
by more than one of the constructors.

It does this by preferring the most specific address space,
which is decided by seeing if one of the address spaces is
a superset of the other, and preferring the other.

Fixes: PR50329

Reviewed By: Anastasia

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

3 years agoclang-format: [JS] don't sort named imports if off.
Martin Probst [Fri, 11 Jun 2021 09:43:00 +0000 (11:43 +0200)]
clang-format: [JS] don't sort named imports if off.

The previous implementation would accidentally still sort the individual
named imports, even if the module reference was in a clang-format off
block.

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

3 years ago[llvm-stress] Fix dead code preventing us generating per-element vector selects
Simon Pilgrim [Fri, 11 Jun 2021 09:56:05 +0000 (10:56 +0100)]
[llvm-stress] Fix dead code preventing us generating per-element vector selects

This has been reported several times by the PVS Studio team as well as coming up in some static analysis.

getRandom() % 1 always returns 0 so we never actually test this codepath, (git blame suggests this has always been like this) - given that we have plenty of other "getRandom() & 1" the typo is pretty obvious, and matches the intention in the comment above - with this change we generate a nice mixture of scalar/vector condition selects of vectors.

I don't know llvm-stress that well - but I don't think we guarantee that the same seed value will always generate the same IR for later versions of the program - just that the same binary would.

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

3 years ago[analyzer] Refactor trackExpressionValue to accept TrackingOptions
Valeriy Savchenko [Thu, 3 Jun 2021 17:39:25 +0000 (20:39 +0300)]
[analyzer] Refactor trackExpressionValue to accept TrackingOptions

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

3 years ago[analyzer] Turn TrackControlDependencyCond into a tracking visitor
Valeriy Savchenko [Thu, 3 Jun 2021 16:51:19 +0000 (19:51 +0300)]
[analyzer] Turn TrackControlDependencyCond into a tracking visitor

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

3 years ago[analyzer] Refactor trackRValueExpression into ExpressionHandler
Valeriy Savchenko [Thu, 3 Jun 2021 16:32:04 +0000 (19:32 +0300)]
[analyzer] Refactor trackRValueExpression into ExpressionHandler

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

3 years ago[analyzer] Turn ReturnVisitor into a tracking visitor
Valeriy Savchenko [Thu, 3 Jun 2021 16:09:43 +0000 (19:09 +0300)]
[analyzer] Turn ReturnVisitor into a tracking visitor

Whenever Tracker spawns a visitor that needs to call tracker
back, we have to use TrackingBugReporterVisitor in order to maintain
all the hooks that the checker might've used.

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

3 years ago[analyzer] Hide and rename FindLastStoreBRVisitor
Valeriy Savchenko [Thu, 3 Jun 2021 15:54:32 +0000 (18:54 +0300)]
[analyzer] Hide and rename FindLastStoreBRVisitor

This component should not be used directly at this point and it is
simply an implementation detail, that's why StoreSiteFinder is
out of the header file.

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

3 years ago[analyzer] Change FindLastStoreBRVisitor to use Tracker
Valeriy Savchenko [Thu, 10 Jun 2021 10:57:39 +0000 (13:57 +0300)]
[analyzer] Change FindLastStoreBRVisitor to use Tracker

Additionally, this commit completely removes any uses of
FindLastStoreBRVisitor from the analyzer except for the
one in Tracker.

The next step is actually removing this class altogether
from the header file.

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

3 years ago[analyzer] Reimplement trackExpressionValue as ExpressionHandler
Valeriy Savchenko [Thu, 3 Jun 2021 13:47:33 +0000 (16:47 +0300)]
[analyzer] Reimplement trackExpressionValue as ExpressionHandler

This commit moves trackExpressionValue into the Tracker interface
as DefaultExpressionHandler.  It still can be split into smaller
handlers, but that can be a future change.

Additionally, this commit doesn't remove the original trackExpressionValue
interface, so it's not too big.  One of the next commits will address it.

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

3 years ago[analyzer] Introduce a new interface for tracking
Valeriy Savchenko [Thu, 3 Jun 2021 09:55:43 +0000 (12:55 +0300)]
[analyzer] Introduce a new interface for tracking

Tracking values through expressions and the stores is fundamental
for producing clear diagnostics.  However, the main components
participating in this process, namely `trackExpressionValue` and
`FindLastStoreBRVisitor`, became pretty bloated.  They have an
interesting dynamic between them (and some other visitors) that
one might call a "chain reaction". `trackExpressionValue` adds
`FindLastStoreBRVisitor`, and the latter calls `trackExpressionValue`.

Because of this design, individual checkers couldn't affect what's
going to happen somewhere in the middle of that chain.  Whether they
want to produce a more informative note or keep the overall tracking
going by utilizing some of the domain expertise.  This all lead to two
biggest problems that I see:

  * Some checkers don't use it
  This should probably never be the case for path-sensitive checks.

  * Some checkers incorporated their logic directly into those
    components
  This doesn't make the maintenance easier, breaks multiple
  architecture principles, and makes the code harder to read adn
  understand, thus, increasing the probability of the first case.

This commit introduces a prototype for a new interface that will be
responsible for tracking.  My main idea here was to make operations
that I want have as a checker developer easy to implement and hook
directly into the tracking process.

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

3 years ago[VectorCombine] scalarizeLoadExtract(): use computeAlignmentAfterScalarization()...
Roman Lebedev [Fri, 11 Jun 2021 09:31:09 +0000 (12:31 +0300)]
[VectorCombine] scalarizeLoadExtract(): use computeAlignmentAfterScalarization() helper

This results in slightly more optimistic alignments in some cases

3 years ago[NFC][VectorCombine] Extract computeAlignmentAfterScalarization() helper function
Roman Lebedev [Fri, 11 Jun 2021 09:22:02 +0000 (12:22 +0300)]
[NFC][VectorCombine] Extract computeAlignmentAfterScalarization() helper function

3 years ago[X86] Support __tile_stream_loadd intrinsic for new AMX interface
Bing1 Yu [Fri, 11 Jun 2021 09:20:58 +0000 (17:20 +0800)]
[X86] Support __tile_stream_loadd intrinsic for new AMX interface

Adding support for __tile_stream_loadd intrinsic.

Reviewed By: LuoYuanke

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

3 years agoSampleProf.h - fix spelling mistake in assert message. NFC.
Simon Pilgrim [Fri, 11 Jun 2021 09:20:59 +0000 (10:20 +0100)]
SampleProf.h - fix spelling mistake in assert message. NFC.

3 years ago[Analysis] Pass RecurrenceDescriptor as const reference. NFCI.
Simon Pilgrim [Fri, 11 Jun 2021 09:19:37 +0000 (10:19 +0100)]
[Analysis] Pass RecurrenceDescriptor as const reference. NFCI.

We were passing the RecurrenceDescriptor by value to most of the reduction analysis methods, despite it being rather bulky with TrackingVH members (that can be costly to copy). In all these cases we're only using the RecurrenceDescriptor for rather basic purposes (access to types/kinds etc.).

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

3 years agoFix implicit dependency on <string> header. NFCI.
Simon Pilgrim [Thu, 10 Jun 2021 12:01:03 +0000 (13:01 +0100)]
Fix implicit dependency on <string> header. NFCI.

3 years ago[OpenCL][NFC] Reorganize ClangOpenCLBuiltinEmitter comments
Sven van Haastregt [Fri, 11 Jun 2021 09:22:59 +0000 (10:22 +0100)]
[OpenCL][NFC] Reorganize ClangOpenCLBuiltinEmitter comments

Since 8866793b4e0a ("[OpenCL] Add OpenCL builtin test generator",
2021-06-09) there are two emitters in this file, so move the
file-level comment to the appropriate class.

3 years ago[compiler-rt] [builtins] [AArch64] Add missing AArch64 data synchronization barrier...
Stephen Hines [Fri, 11 Jun 2021 09:07:59 +0000 (02:07 -0700)]
[compiler-rt] [builtins] [AArch64] Add missing AArch64 data synchronization barrier (dsb) to __clear_cache

https://developer.arm.com/documentation/den0024/a/Caches/Cache-maintenance
covers how to properly clear caches on AArch64, and the builtin
implementation was missing a `dsb ish` after clearing the icache for the
selected range.

Reviewed By: kristof.beyls

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

3 years ago[clang-tidy] LIT test fix for Remark diagnostic
Ivan Murashko [Fri, 11 Jun 2021 08:44:56 +0000 (01:44 -0700)]
[clang-tidy] LIT test fix for Remark diagnostic

There is a followup fix for a unit test introduced at D102906. The test file was placed into a temp folder and test assumed that it would be visible without the full path specification.

This behaviour can be changed in future and it would be good to specify full path to the file at the test.

Test Plan:
```
ninja check-clang-tools
```

Reviewed By: DmitryPolukhin

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

3 years ago[mlir] Refactor ComplexOps.td [NFC]
Adrian Kuegel [Fri, 11 Jun 2021 07:37:01 +0000 (09:37 +0200)]
[mlir] Refactor ComplexOps.td [NFC]

Create a ComplexUnaryOp base class and use it for AbsOp, ReOp and ImOp.
Sort all ops in lexicographic order.

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

3 years ago[gn build] Port c4a0969b9c14
LLVM GN Syncbot [Fri, 11 Jun 2021 08:23:07 +0000 (08:23 +0000)]
[gn build] Port c4a0969b9c14

3 years agoFunction Specialization Pass
Sjoerd Meijer [Tue, 4 May 2021 14:12:44 +0000 (15:12 +0100)]
Function Specialization Pass

This adds a function specialization pass to LLVM. Constant parameters
like function pointers and constant globals are propagated to the callee by
specializing the function.

This is a first version with a number of limitations:
- The pass is off by default, so needs to be enabled on the command line,
- It does not handle specialization of recursive functions,
- It does not yet handle constants and constant ranges,
- Only 1 argument per function is specialised,
- The cost-model could be further looked into, and perhaps related,
- We are not yet caching analysis results.

This is based on earlier work by Matthew Simpson (D36432) and Vinay Madhusudan.
More recently this was also discussed on the list, see:

https://lists.llvm.org/pipermail/llvm-dev/2021-March/149380.html.

The motivation for this work is that function specialisation often comes up as
a reason for performance differences of generated code between LLVM and GCC,
which has this enabled by default from optimisation level -O3 and up. And while
this certainly helps a few cpu benchmark cases, this also triggers in real
world codes and is thus a generally useful transformation to have in LLVM.

Function specialisation has great potential to increase compile-times and
code-size.  The summary from some investigations with this patch is:
- Compile-time increases for short compile jobs is high relatively, but the
  increase in absolute numbers still low.
- For longer compile-jobs, the extra compile time is around 1%, and very much
  in line with GCC.
- It is difficult to blame one thing for compile-time increases: it looks like
  everywhere a little bit more time is spent processing more functions and
  instructions.
- But the function specialisation pass itself is not very expensive; it doesn't
  show up very high in the profile of the optimisation passes.

The goal of this work is to reach parity with GCC which means that eventually
we would like to get this enabled by default. But first we would like to address
some of the limitations before that.

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

3 years agoRevert "[Driver] Support libc++ in MSVC"
Petr Hosek [Fri, 11 Jun 2021 07:43:52 +0000 (00:43 -0700)]
Revert "[Driver] Support libc++ in MSVC"

This reverts commit 9625d61eb66c12388875e081b63ebed7e42c6bbb since
libc++ currently has issues with disabled exceptions which breaks
the runtimes build.

3 years agoRevert "[CMake] Don't use libc++ by default on Windows yet"
Petr Hosek [Fri, 11 Jun 2021 07:43:27 +0000 (00:43 -0700)]
Revert "[CMake] Don't use libc++ by default on Windows yet"

This reverts commit b413e44200e715c254fa9a41f6a86f8761c9b362.

3 years ago[lldb] Fix leak in test
Vitaly Buka [Fri, 11 Jun 2021 01:43:35 +0000 (18:43 -0700)]
[lldb] Fix leak in test

Test leaks if we run
tools/lldb/unittests/Host/HostTests without --gtest_filter

Reviewed By: teemperor

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

3 years ago[PowerPC] Relax register superclasses for paired memops
Qiu Chaofan [Fri, 11 Jun 2021 06:51:36 +0000 (14:51 +0800)]
[PowerPC] Relax register superclasses for paired memops

Relaxing superclass constraint for VSX register classes helps reducing
32-byte spills and copies when register pressure is high.

In test case affected, some of them introduces more copies due to new
allocation order. However, this patch should not be the root cause, and
we may be able to fix it in other places of register allocation.

Reviewed By: nemanjai

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