platform/upstream/llvm.git
2 years ago[MLIR] Fix block label parsing bug
Uday Bondhugula [Sat, 12 Mar 2022 02:08:10 +0000 (07:38 +0530)]
[MLIR] Fix block label parsing bug

Fix bug in `Block` label parsing:
https://github.com/llvm/llvm-project/issues/54343

The `parseOptionalBlockArgList` method was doing the wrong thing
(contrary to its doc comment) and its calling context was also
incorrect. This led to a parse failure for something like "^bb0()".

Fixes #54343

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

2 years ago[libc++] Remove unneeded tests.
Mark de Wever [Sat, 12 Mar 2022 11:15:26 +0000 (12:15 +0100)]
[libc++] Remove unneeded tests.

As suggested in D120742.

2 years ago[libc++][NFC] Use TEST_HAS_NO_EXCEPTIONS.
Mark de Wever [Sat, 12 Mar 2022 11:11:00 +0000 (12:11 +0100)]
[libc++][NFC] Use TEST_HAS_NO_EXCEPTIONS.

The test should use the already available test macro.

2 years ago[libc++] Add a missing test case.
Mark de Wever [Sat, 12 Mar 2022 11:07:54 +0000 (12:07 +0100)]
[libc++] Add a missing test case.

2 years ago[clang][deps] Attempt to fix Windows test failure
Jan Svoboda [Sat, 12 Mar 2022 11:09:10 +0000 (12:09 +0100)]
[clang][deps] Attempt to fix Windows test failure

2 years ago[clang][deps] Remove '-fmodules-cache-path=' arguments
Jan Svoboda [Sat, 12 Mar 2022 10:42:04 +0000 (11:42 +0100)]
[clang][deps] Remove '-fmodules-cache-path=' arguments

With explicit modules build, the '-fmodules-cache-path=' argument is unused.

This patch removes the argument to avoid warnings or errors (with '-Werror') stemming from that.

Depends on D118915.

Reviewed By: dexonsmith

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

2 years ago[clang][deps] Generate '-fmodule-file=' only for direct dependencies
Jan Svoboda [Sat, 12 Mar 2022 10:32:47 +0000 (11:32 +0100)]
[clang][deps] Generate '-fmodule-file=' only for direct dependencies

The `clang-scan-deps` tool currently generates `-fmodule-file=` command-line arguments for the whole transitive closure of modular dependencies. This is not necessary, we only need to provide the direct dependencies on the command line. Information about transitive dependencies is stored within the `.pcm` files of direct dependencies. This makes the command lines shorter, but should be a NFC otherwise (unless there are bugs in the loading mechanism for explicit modules).

Depends on D120465.

Reviewed By: Bigcheese

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

2 years ago[clang][deps] Disable implicit module maps
Jan Svoboda [Sat, 12 Mar 2022 10:04:17 +0000 (11:04 +0100)]
[clang][deps] Disable implicit module maps

Since D113473, we don't report any module map files via `-fmodule-map-file=` in explicit builds. The ultimate goal here is to make sure Clang doesn't open/read/parse/evaluate unnecessary module maps.

However, implicit module maps still end up reading all reachable module maps. This patch disables implicit module maps in explicit builds.

Unfortunately, we still need to report some module map files that aren't encoded in PCM files of dependencies: module maps that are necessary to correctly evaluate includes in modules marked as `[no_undeclared_includes]`.

Depends on D120464.

Reviewed By: dexonsmith

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

2 years ago[Attributor] Remove capture tracker usage and follow uses explicitly
Johannes Doerfert [Tue, 8 Mar 2022 21:49:26 +0000 (15:49 -0600)]
[Attributor] Remove capture tracker usage and follow uses explicitly

Before we used the capture tracker to follow pointer uses, now we do it
explicitly ourselves through the Attributor API. There are multiple
benefits: For one, the boilerplate is cut down by a lot. The class,
potential copies vector, etc. is all not needed anymore. We also do
avoid explicitly looking through memory here, something that was
duplicated and should only live in the `checkForAllUses~ helper. More
importantly, as we do simplifications we need to make sure all parties
are in sync when they reason about uses. The old way did not allow us to
do this but the new one does as every use visiting AA goes through
`checkForAllUses` now..

2 years ago[CaptureTracking][NFCI] Expose capture tracking logic
Johannes Doerfert [Tue, 8 Mar 2022 21:02:36 +0000 (15:02 -0600)]
[CaptureTracking][NFCI] Expose capture tracking logic

The logic exposed by this patch via `llvm::DetermineUseCaptureKind` was
part of `llvm::PointerMayBeCaptured`. In the Attributor we want to keep
track of the work list items but still reuse the logic if a use might
capture a value. A follow up for the Attributor removes ~100 lines of
code and complexity while making future handling of simplified values
possible.

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

2 years ago[lsan] ppc64: dynamically pick address range for allocator
Fangrui Song [Sat, 12 Mar 2022 04:16:17 +0000 (20:16 -0800)]
[lsan] ppc64: dynamically pick address range for allocator

For ppc64 PIE, it seems that [0xa00000000000,0xc00000000000) may be occupied
which will lead to a segfault in certain kernel configurations
(clang-ppc64le-rhel). Use the `!kUsingConstantSpaceBeg` code path like Fuchsia.

Reviewed By: jsji

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

2 years ago[MC] Fix letter case of some MCSection member functions
Fangrui Song [Sat, 12 Mar 2022 04:07:00 +0000 (20:07 -0800)]
[MC] Fix letter case of some MCSection member functions

2 years ago[Attributor] Avoid replacing return operands twice
Johannes Doerfert [Fri, 25 Feb 2022 22:57:18 +0000 (16:57 -0600)]
[Attributor] Avoid replacing return operands twice

As replacements will become more complex it is better to have a single
AA responsible for replacing a use. Before this patch AAValueSimplify*
and AAValueSimplifyReturned could both try to replace the returned
value. The latter was marginally better for the old pass manager
when a function was already carrying a `returned` attribute and when
the context of the return instruction was important. The second
shortcoming was resolved by looking for return attributes in the
AAValueSimplifyCallSiteReturned initialization. The old PM impact is
not concerning.

This is yet another step towards the removal of AAReturnedValues, the
very first AA we should now try to eliminate due to the overlapping
logic with value simplification.

2 years ago[MC] Destroy WasmAllocator in MCContext::reset
Fangrui Song [Sat, 12 Mar 2022 03:55:07 +0000 (19:55 -0800)]
[MC] Destroy WasmAllocator in MCContext::reset

To not leave lingering getWasmSection instances.

2 years ago[RISCV] Move GORCIW/GREVIW formation to isel patterns.
Craig Topper [Sat, 12 Mar 2022 01:10:03 +0000 (17:10 -0800)]
[RISCV] Move GORCIW/GREVIW formation to isel patterns.

Type legalize narrow RISCVISD::GREV/GORC with constant to a larger
type without switching to W. Detect sext_inreg+gorci/grevi with a
uimm5 immediate during isel to emit GREVIW/GORCIW.

This allows us to better propagate known bits information through
extended bits after type legalization. It will also simplify a
change I'm considering for BREV8 with Zbkb.

A future patch will add computeKnownBits support for GORC.

A further improvement here would be to use hasAllWUsers and
doPeepholeSExtW like we do for SLLIW, but I don't think we have
the test coverage for that yet.

2 years ago[RISCV] Add test cases that show that we're too aggressive about using greviw/gorciw...
Craig Topper [Fri, 11 Mar 2022 23:29:26 +0000 (15:29 -0800)]
[RISCV] Add test cases that show that we're too aggressive about using greviw/gorciw. NFC

We currently type legalize to the W form, but type legalization
doesn't place any requirements on the extended bits. So we are ok
to use GREVI/GORCI for type legalization as long as the control
doesn't cross any bits from the extended bits into the lower bits.

This can allow us to recognize cases where the extended bits end
up being all zeros and we can propagate that information through.

My plan is to move greviw/gorciw formation to isel patterns similar
to slliw.

2 years ago[gn build] Port ee0f8c401030
LLVM GN Syncbot [Sat, 12 Mar 2022 00:46:45 +0000 (00:46 +0000)]
[gn build] Port ee0f8c401030

2 years ago[libc++][ranges] Implement ranges::find{, _if, _if_not}
Nikolas Klauser [Sat, 12 Mar 2022 00:45:35 +0000 (01:45 +0100)]
[libc++][ranges] Implement ranges::find{, _if, _if_not}

Reviewed By: var-const, #libc, ldionne

Spies: ldionne, tcanens, libcxx-commits, mgorny

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

2 years ago[Attributor][FIX] Make sure to not ignore non-load users of stores
Johannes Doerfert [Sat, 12 Mar 2022 00:39:21 +0000 (18:39 -0600)]
[Attributor][FIX] Make sure to not ignore non-load users of stores

When we look through memory for a store we used to allow any other use
of the memory that is reachable. This is generally OK but we need to
make sure to actually let the user look at these properly. For now,
we simply require loads (via exact reloads).

2 years ago[mlir] Update function referenced in comment (NFC)
Jacques Pienaar [Sat, 12 Mar 2022 00:31:54 +0000 (16:31 -0800)]
[mlir] Update function referenced in comment (NFC)

2 years ago[builtins] Do not force thumb mode directive in arm/sync-ops.h
Khem Raj [Sat, 12 Mar 2022 00:25:49 +0000 (16:25 -0800)]
[builtins] Do not force thumb mode directive in arm/sync-ops.h

.thumb_func was not switching mode until [1]
so it did not show up but now that .thumb_func (without argument) is
switching mode, its causing build failures on armv6 ( rpi0 ) even when
build is explicitly asking for this file to be built with -marm (ARM
mode), therefore use DEFINE_COMPILERRT_FUNCTION macro to add function
header which considers arch and mode from compiler cmdline to decide if
the function is built using thumb mode or arm mode.

[1] https://reviews.llvm.org/D101975

Note that it also needs https://reviews.llvm.org/D99282

Reviewed By: peter.smith, MaskRay

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

2 years ago[gn build] Port b1b4b6f36695
LLVM GN Syncbot [Sat, 12 Mar 2022 00:10:18 +0000 (00:10 +0000)]
[gn build] Port b1b4b6f36695

2 years ago[Clang][VE] Add vector load intrinsics
Kazushi (Jam) Marukawa [Sat, 5 Mar 2022 16:17:04 +0000 (01:17 +0900)]
[Clang][VE] Add vector load intrinsics

Add vector load intrinsic instructions for VE.

Reviewed By: simoll

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

2 years agoRename EHFrameSplitter to DWARFRecordSectionSplitter
Shubham Sandeep Rastogi [Fri, 11 Mar 2022 20:14:05 +0000 (12:14 -0800)]
Rename EHFrameSplitter to DWARFRecordSectionSplitter

EHFrameSplitter does the exact same work to split up the eh_frame as it would need for any section that follows the DWARF record, therefore this patch just changes the name of it to DWARFRecordSectionSplitter to be more general.

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

2 years ago[CMake] Rename TARGET_TRIPLE to LLVM_TARGET_TRIPLE
Petr Hosek [Thu, 2 Dec 2021 09:04:46 +0000 (01:04 -0800)]
[CMake] Rename TARGET_TRIPLE to LLVM_TARGET_TRIPLE

This clarifies that this is an LLVM specific variable and avoids
potential conflicts with other projects.

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

2 years ago[nfc][openmp] Swap arguments to remove noise from upcoming diff
Jon Chesterfield [Fri, 11 Mar 2022 23:07:11 +0000 (23:07 +0000)]
[nfc][openmp] Swap arguments to remove noise from upcoming diff

2 years ago[InlineCost] Add cl::opt for target attributes compatibility check. NFC
Anna Thomas [Fri, 11 Mar 2022 21:47:40 +0000 (16:47 -0500)]
[InlineCost] Add cl::opt for target attributes compatibility check. NFC

This patch adds a CL option for avoiding the attribute compatibility
check between caller and callee in TTI. TTI attribute compatibility
checks for target CPU and target features.
In our downstream compiler, this attribute always remains the same
between callee and caller. By avoiding the addition of this attribute to
each of our inline candidate (and then checking them here during inline
cost), we save some compile time.

The option is kept false, so this change is an NFC upstream.

2 years ago[NFC] Improve comment and rename test file
Julian Lettner [Fri, 11 Mar 2022 22:23:11 +0000 (14:23 -0800)]
[NFC] Improve comment and rename test file

2 years ago[Attributor] Allow not to default initialize AAs for live internal functions
Johannes Doerfert [Fri, 11 Mar 2022 18:51:24 +0000 (12:51 -0600)]
[Attributor] Allow not to default initialize AAs for live internal functions

Outside users of the Attributor, e.g., OpenMP-opt, want to seed AAs
themselves. We should not seed all default AAs one an internal function
becomes live. That said, there should be a callback such that they can
do lazy seeding as well.

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

2 years ago[Attributor] Cleanup manifest and liveness for CGSCC passes
Johannes Doerfert [Thu, 10 Mar 2022 18:17:38 +0000 (12:17 -0600)]
[Attributor] Cleanup manifest and liveness for CGSCC passes

There was some ad-hoc handling of liveness and manifest to avoid
breaking CGSCC guarantees. Things always slipped through though.
This cleanup will:

1) Prevent us from manifesting any "information" outside the CGSCC.
   This might be too conservative but we need to opt-in to annotation
   not try to avoid some problematic ones.
2) Avoid running any liveness analysis outside the CGSCC. We did have
   some AAIsDeadFunction handling to this end but we need this for all
   AAIsDead classes. The reason is that AAIsDead information is only
   correct if we actually manifest it, since we don't (see point 1) we
   cannot actually derive/use it at all. We are currently trying to
   avoid running any AA updates outside the CGSCC but that seems to
   impact things quite a bit.
3) Assert, don't check, that our modifications (during cleanup) modifies
   only CGSCC functions.

2 years ago[MC][test] Improve compression.s
Fangrui Song [Fri, 11 Mar 2022 22:42:07 +0000 (14:42 -0800)]
[MC][test] Improve compression.s

* Actually test compressed .debug_line for 32-bit
* Test .debug_frame can be compressed
* Test a section not named .debug_* is not compressed

2 years ago[clang-format][NFC] Group QualifierAlignment with other C++ passes
owenca [Fri, 11 Mar 2022 02:16:12 +0000 (18:16 -0800)]
[clang-format][NFC] Group QualifierAlignment with other C++ passes

Also increases the initial size of Passes to 8 and move the
definition of BracesInserter up.

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

2 years ago[clang-tidy] Refactor: Prefer single quoted strings over double quoted strings [NFC]
Richard [Mon, 3 Jan 2022 18:38:42 +0000 (11:38 -0700)]
[clang-tidy] Refactor: Prefer single quoted strings over double quoted strings [NFC]

2 years ago[MC] Remove unneeded zlib opt-out for .debug_frame
Fangrui Song [Fri, 11 Mar 2022 21:32:24 +0000 (13:32 -0800)]
[MC] Remove unneeded zlib opt-out for .debug_frame

The opt-out from rL236267 (2015) is untested and seems no longer needed (or not
needed when rL236267 was committed): there is nothing special with uncompressed
alignment. This brings us in line with GCC which compresses .debug_frame .

Checked that -g -fno-asynchronous-unwind-tables + objcopy
--decompress-debug-sections output is identical to -g
-fno-asynchronous-unwind-tables -gz + objcopy --decompress-debug-sections
output.

2 years ago[lldb] Removed scoped timer from ReadMemoryFromFileCache
Dave Lee [Fri, 11 Mar 2022 20:45:47 +0000 (12:45 -0800)]
[lldb] Removed scoped timer from ReadMemoryFromFileCache

`ReadMemoryFromFileCache` can be called at a high rate, and has fast execution.
Signposts for high rate & brief duration can have a negative impact on tracing;
emitting a high volume signposts can lead to blocking, affecting performance,
and total volume makes human review of the trace harder because of the noise.

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

2 years ago[lldb] Move FindTypes scoped timer to SymbolFileDWARFDebugMap
Dave Lee [Fri, 11 Mar 2022 19:16:06 +0000 (11:16 -0800)]
[lldb] Move FindTypes scoped timer to SymbolFileDWARFDebugMap

2 years ago[lldb] Include lldb/Host/HostInfo.h in ProcessWindows.cpp
Jonas Devlieghere [Fri, 11 Mar 2022 20:34:41 +0000 (12:34 -0800)]
[lldb] Include lldb/Host/HostInfo.h in ProcessWindows.cpp

2 years ago[AMDGPU] Support v_mov_b64 in dpp combine
Stanislav Mekhanoshin [Thu, 10 Mar 2022 21:46:55 +0000 (13:46 -0800)]
[AMDGPU] Support v_mov_b64 in dpp combine

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

2 years ago[AMDGPU] gfx940 MUBUF format changes
Stanislav Mekhanoshin [Tue, 8 Mar 2022 18:28:23 +0000 (10:28 -0800)]
[AMDGPU] gfx940 MUBUF format changes

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

2 years ago[lldb] Fix typo in ProcessWindows.h
Jonas Devlieghere [Fri, 11 Mar 2022 19:32:21 +0000 (11:32 -0800)]
[lldb] Fix typo in ProcessWindows.h

2 years ago[mlir][spirv] Make EntryPointABIAttr.local_size optional
Ivan Butygin [Wed, 23 Feb 2022 11:12:07 +0000 (14:12 +0300)]
[mlir][spirv] Make EntryPointABIAttr.local_size optional

* It doesn't required by OpenCL/Intel Level Zero and can be set programmatically.
* Add GPU to spirv lowering in case when attribute is not present.
* Set higher benefit to WorkGroupSizeConversion pattern so it will always try to lower first from the attribute.

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

2 years ago[CommandLine] Remove `may only occur zero or one times!` error
Fangrui Song [Fri, 11 Mar 2022 19:25:04 +0000 (11:25 -0800)]
[CommandLine] Remove `may only occur zero or one times!` error

Early adoption of new technologies or adjusting certain code generation/IR optimization thresholds
is often available through some cl::opt options (which have unstable surfaces).
Specifying such an option twice will lead to an error.

```
% clang -c a.c -mllvm -disable-binop-extract-shuffle -mllvm -disable-binop-extract-shuffle
clang (LLVM option parsing): for the --disable-binop-extract-shuffle option: may only occur zero or one times!
% clang -c a.c -mllvm -hwasan-instrument-reads=0 -mllvm -hwasan-instrument-reads=0
clang (LLVM option parsing): for the --hwasan-instrument-reads option: may only occur zero or one times!
% clang -c a.c -mllvm --scalar-evolution-max-arith-depth=32 -mllvm --scalar-evolution-max-arith-depth=16
clang (LLVM option parsing): for the --scalar-evolution-max-arith-depth option: may only occur zero or one times!
```

The option is specified twice, because there is sometimes a global setting and
a specific file or project may need to override (or duplicately specify) the
value.

The error is contrary to the common practice of getopt/getopt_long command line
utilities that let the last option win and the `getLastArg` behavior used by
Clang driver options. I have seen such errors for several times. I think the
error just makes users inconvenient, while providing very little value on
discouraging production usage of unstable surfaces (this goal is itself
controversial, because developers might not want to commit to a stable surface
too early, or there is just some subtle codegen toggle which is infeasible to
have a driver option). Therefore, I suggest we drop the diagnostic, at least
before the diagnostic gets sufficiently better support for the overridding needs.

Removing the error is a degraded error checking experience. I think this error
checking behavior, if desirable, should be enabled explicitly by tools. Users
preferring the behavior can figure out a way to do so.

Reviewed By: jhenderson, rnk

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

2 years ago[lldb] Add a getter for the process' system architecture
Jonas Devlieghere [Fri, 11 Mar 2022 18:50:10 +0000 (10:50 -0800)]
[lldb] Add a getter for the process' system architecture

This patch adds a getter for the process' system architecture. I went
with Process::GetSystemArchitecture to match
Platform::GetSystemArchitecture.

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

2 years ago[lld-macho] Don't allocate memory in parallelForEach
Jez Ng [Fri, 11 Mar 2022 18:31:20 +0000 (13:31 -0500)]
[lld-macho] Don't allocate memory in parallelForEach

... since BumpPtrAllocator isn't thread-safe.

Reviewed By: #lld-macho, Roger

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

2 years ago[mlir][memref] memref.reinterpret_cast folding
Ivan Butygin [Mon, 21 Feb 2022 12:16:34 +0000 (15:16 +0300)]
[mlir][memref] memref.reinterpret_cast folding

* reinterpret_cast(reinterpret_cast(x)) -> reinterpret_cast(x)
* reinterpret_cast(cast(x)) -> reinterpret_cast(x)
* reinterpret_cast(subview(x)) -> reinterpret_cast(x) if subview offsets are 0

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

2 years ago[LoopUnswitch] Use SmallPtrSet instead of std::set. NFCI.
Benjamin Kramer [Fri, 11 Mar 2022 18:13:58 +0000 (19:13 +0100)]
[LoopUnswitch] Use SmallPtrSet instead of std::set. NFCI.

2 years ago[VPlan] Implement VPCanonicalIVPHIRecipe::onlyFirstLaneUsed.
Florian Hahn [Fri, 11 Mar 2022 17:56:54 +0000 (17:56 +0000)]
[VPlan] Implement VPCanonicalIVPHIRecipe::onlyFirstLaneUsed.

The recipe only uses the first lane of its operands.

Suggested & split off D120827.

2 years ago[RISCV] Optimize vfmv.s.f intrinsic with scalar 0.0 to vmv.s.x with x0.
Craig Topper [Fri, 11 Mar 2022 01:56:17 +0000 (17:56 -0800)]
[RISCV] Optimize vfmv.s.f intrinsic with scalar 0.0 to vmv.s.x with x0.

We already do this for RISCVISD::VFMV_S_F_VL and the vfmv.v.f
intrinsic.

Reviewed By: kito-cheng

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

2 years ago[flang][NFC] rename IsKindParameterizedDerivedType and fix comment typos
Jean Perier [Fri, 11 Mar 2022 18:03:19 +0000 (19:03 +0100)]
[flang][NFC] rename IsKindParameterizedDerivedType and fix comment typos

Following post-review feedback on https://reviews.llvm.org/D120804 and
https://reviews.llvm.org/D120801 about type descriptor changes, fix typos in
comments and rename IsKindParameterizedDerivedType to
IsDerivedTypeWithKindParameter. Remove a useless `;`.

Reviewed By: clementval, PeteSteinfeld

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

2 years agoReturn an error when dsymutil might produce an invalid mach-o file.
Greg Clayton [Thu, 10 Mar 2022 19:29:45 +0000 (11:29 -0800)]
Return an error when dsymutil might produce an invalid mach-o file.

64 bit mach-o files have sections that only have 32 bit file offsets. If dsymutil tries to produce an invalid mach-o file, then error out with a good error string.

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

2 years ago[flang] Add tests for allocatable global
Valentin Clement [Fri, 11 Mar 2022 17:39:33 +0000 (18:39 +0100)]
[flang] Add tests for allocatable global

This patch adds couple of tests for allocatable
globals and missing lowering for them

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[flang] Lower of elemental calls in array expression
Valentin Clement [Fri, 11 Mar 2022 17:38:08 +0000 (18:38 +0100)]
[flang] Lower of elemental calls in array expression

This patch adds tests and missing lowering
code to lower elemental function/subroutine calls
in array expression

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[NFC][Clang][OpaquePtr] Remove calls to Address::deprecated in a couple
Akira Hatanaka [Fri, 11 Mar 2022 17:30:31 +0000 (09:30 -0800)]
[NFC][Clang][OpaquePtr] Remove calls to Address::deprecated in a couple
more files

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

2 years ago[lldb] Don't overwrite the host arch with the process arch
Jonas Devlieghere [Fri, 11 Mar 2022 06:52:20 +0000 (22:52 -0800)]
[lldb] Don't overwrite the host arch with the process arch

Don't overwrite the host architecture (obtained from qHostInfo) with the
process info (obtained from qProcessInfo).

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

2 years ago[ASan] Export optimized callbacks.
Kirill Stoimenov [Fri, 11 Mar 2022 15:47:06 +0000 (15:47 +0000)]
[ASan] Export optimized callbacks.

This is a part of optimized callback reverts. This is needed to export the callbacks from the rt-asan libraries.

Reviewed By: kstoimenov

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

2 years ago[X86] Add PR38960 comineqss test case
Simon Pilgrim [Fri, 11 Mar 2022 16:46:47 +0000 (16:46 +0000)]
[X86] Add PR38960 comineqss test case

This inverts the flags result compared to the original PR38960 comieqss test case

2 years ago[Bitcode] Don't confuse type attributes on declaration and call
Nikita Popov [Fri, 11 Mar 2022 16:30:34 +0000 (17:30 +0100)]
[Bitcode] Don't confuse type attributes on declaration and call

We should not be using APIs here that try to fetch the attribute
from both the call attributes and the function attributes. Otherwise
we'll try to upgrade a non-existent sret attribute on the call using
the attribute on the function.

2 years ago[AsmParser] Check forward reference type with opaque pointers
Nikita Popov [Fri, 11 Mar 2022 16:14:48 +0000 (17:14 +0100)]
[AsmParser] Check forward reference type with opaque pointers

While we don't need to check the element type in this case, we
do need to make sure that the pointers have the same address space,
otherwise RAUW will assert.

2 years ago[flang] Fix DYLIB builds
Andrzej Warzynski [Fri, 11 Mar 2022 14:02:30 +0000 (14:02 +0000)]
[flang] Fix DYLIB builds

https://reviews.llvm.org/D120568 broke builds that set
both `LLVM_BUILD_LLVM_DYLIB` and `LLVM_LINK_LLVM_DYLIB`. This patch
fixes that.

The build failure was caused by the fact that some LLVM libraries (which
are also LLVM components) were listed directly as link-time dependencies
instead of using `LINK_COMPONENTS` in CMake files. This lead to a linker
invocation like this (simplified version to demonstrate the problem):
```
ld lib/libLLVM.so lib/libLLVMAnalysis.a lib/libLLVMTarget.a
```
That's problematic and unnecessary because `libLLVM.so` incorporates
`libLLVMAnalysis` and `libLLVMTarget`. A correct invocation would look
like this (`LLVM_LINK_LLVM_DYLIB` _is not_ set):
```
ld  lib/libLLVMAnalysis.a lib/libLLVMTarget.a
```
or this (`LLVM_LINK_LLVM_DYLIB` _is_ set):
```
ld lib/libLLVM.so
```

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

2 years ago[Attributor][FIX] Avoid double free (and useless state copy)
Johannes Doerfert [Fri, 11 Mar 2022 16:08:34 +0000 (10:08 -0600)]
[Attributor][FIX] Avoid double free (and useless state copy)

In an attempt to remove the memory leak we introduced a double free.
The problem was that we allowed a plain copy of the state and it was
actually used. The use was useless, so it is gone now. The copy
constructor is gone as well. The move constructor ensures the Accesses
pointers are owned by a single state, I hope.

Reported by: https://lab.llvm.org/buildbot/#/builders/16/builds/25820

2 years ago[mlir][sparse][taco] Add a few unary operations.
Bixia Zheng [Thu, 10 Mar 2022 17:40:54 +0000 (09:40 -0800)]
[mlir][sparse][taco] Add a few unary operations.

Add operations -, abs, ceil and floor to the index notation.

Add test cases.

Reviewed By: aartbik

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

2 years ago[clang][SVE] Add aarch64-registered-target to sve vector op tests
David Truby [Fri, 11 Mar 2022 16:01:00 +0000 (16:01 +0000)]
[clang][SVE] Add aarch64-registered-target to sve vector op tests

This fixes failing tests where aarch64 isn't available.

2 years ago[Attributor][FIX] Remove memory leak
Johannes Doerfert [Fri, 11 Mar 2022 15:50:38 +0000 (09:50 -0600)]
[Attributor][FIX] Remove memory leak

The leak was introduced when we made things deterministic. It was
reported by the sanitizer buildbot:
 https://lab.llvm.org/buildbot/#/builders/168

2 years ago[Bitcode] Clarify that extractvalue/insertvalue constexprs are not supported
Nikita Popov [Fri, 11 Mar 2022 15:48:39 +0000 (16:48 +0100)]
[Bitcode] Clarify that extractvalue/insertvalue constexprs are not supported

Bitcode currently cannot encode these. Throw a more obvious error
in this case, rather than failing an operand count assertion.

2 years ago[clang][SVE] Add support for arithmetic operators on SVE types
David Truby [Mon, 28 Feb 2022 11:45:49 +0000 (11:45 +0000)]
[clang][SVE] Add support for arithmetic operators on SVE types

This patch implements support for the +, -, *, / and % operators on sizeless SVE
types. Support for these operators on svbool_t is excluded.

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

2 years ago[Bitcode] Enumerate constexpr GEP source element type in initializer
Nikita Popov [Fri, 11 Mar 2022 15:36:56 +0000 (16:36 +0100)]
[Bitcode] Enumerate constexpr GEP source element type in initializer

The constexpr source element type was enumerated if the GEP was
used as part of an instruction. However, things like global
initializers go through a different code path, and we need to
enumerate the type there as well.

2 years ago[analyzer] Fix include typo introduced by e61a1a9
Balazs Benics [Fri, 11 Mar 2022 15:07:43 +0000 (16:07 +0100)]
[analyzer] Fix include typo introduced by e61a1a9

2 years ago[Bitcode] Encode alloca address space
Nikita Popov [Fri, 11 Mar 2022 15:06:02 +0000 (16:06 +0100)]
[Bitcode] Encode alloca address space

Since D101045, allocas are no longer required to be part of the
default alloca address space. There may be allocas in multiple
different address spaces. However, the bitcode reader would
simply assume the default alloca address space, resulting in
either an error or incorrect IR.

Add an optional record for allocas which encodes the address
space.

2 years agoConditional include of missing headers under Z3
serge-sans-paille [Fri, 11 Mar 2022 14:52:10 +0000 (15:52 +0100)]
Conditional include of missing headers under Z3

2 years agoConditional include of Twine.h under Z3
serge-sans-paille [Fri, 11 Mar 2022 14:48:06 +0000 (15:48 +0100)]
Conditional include of Twine.h under Z3

2 years ago[BFI] Use SmallPtrSets. NFCI.
Benjamin Kramer [Fri, 11 Mar 2022 14:18:52 +0000 (15:18 +0100)]
[BFI] Use SmallPtrSets. NFCI.

2 years ago[libc++] Remove workaround for missing declarations on Windows store apps
Louis Dionne [Tue, 24 Aug 2021 14:37:07 +0000 (10:37 -0400)]
[libc++] Remove workaround for missing declarations on Windows store apps

We don't need preprocessor logic to exclude those declarations when compiling for
the Windows App Store, because that is handled by using_if_exists now.

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

2 years ago[libc++] Remove workaround for C11 features on compilers that don't support using_if_...
Louis Dionne [Wed, 18 Aug 2021 13:08:17 +0000 (09:08 -0400)]
[libc++] Remove workaround for C11 features on compilers that don't support using_if_exists

Instead of carrying around #ifdefs to determine whether those functions
are available on the platform, unconditionally use the using_if_exists
attribute to import it into namespace std only when available. That was
the purpose of this attribute from the start.

This change means that trying to use libc++ with an old SDK (or on an
old platform for platforms that ship system headers in /usr/include)
will require a recent Clang that supports the using_if_exists attribute.
When using an older Clang or GCC, the underlying platform has to support
a C11 standard library.

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

2 years ago[libc++] Remove raw call to debug handler from __char_traits_length_checked
Louis Dionne [Tue, 8 Mar 2022 18:05:55 +0000 (13:05 -0500)]
[libc++] Remove raw call to debug handler from __char_traits_length_checked

As a fly-by fix, also move it closer to where it is needed, and add a
comment explaining the existence of this weird function.

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

2 years ago[Verifier] Check type of swifterror alloca
Nikita Popov [Fri, 11 Mar 2022 13:51:20 +0000 (14:51 +0100)]
[Verifier] Check type of swifterror alloca

Per LangRef, swifterror alloca must be a pointer.

Not checking this may result in a verifier error after transforms
instead, so make sure it's discarded early.

2 years ago[VPlan] Helper to check if a recipe uses scalar values of op.
Florian Hahn [Fri, 11 Mar 2022 13:41:08 +0000 (13:41 +0000)]
[VPlan] Helper to check if a recipe uses scalar values of op.

This patch adds a helper to check if a recipe only uses scalars of a
given operand. This is similar to onlyFirstLaneUsed, which was
introduced earlier.

By default, usesScalars falls back on onlyFirstLaneUsed.

Will be used by D120828.

Reviewed By: Ayal

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

2 years ago[ConstantFold] Fix scalable shufflevector fold with all-undef mask
Nikita Popov [Fri, 11 Mar 2022 13:30:02 +0000 (14:30 +0100)]
[ConstantFold] Fix scalable shufflevector fold with all-undef mask

If the input is scalable, we should not be returning a fixed-width
vector as a result.

2 years ago[FuzzMutate] Support scalable shufflevector
Nikita Popov [Fri, 11 Mar 2022 13:19:00 +0000 (14:19 +0100)]
[FuzzMutate] Support scalable shufflevector

2 years ago[IRMutator] Handle module with only declarations
Nikita Popov [Fri, 11 Mar 2022 13:14:16 +0000 (14:14 +0100)]
[IRMutator] Handle module with only declarations

There was a mismatch here, with one check checking whether there
are any functions, and the other collecting only non-declaration
functions.

2 years ago[ConstFold] Don't fold calls with mismatching function type
Nikita Popov [Fri, 11 Mar 2022 13:08:06 +0000 (14:08 +0100)]
[ConstFold] Don't fold calls with mismatching function type

With opaque pointers, this is no longer ensured through pointer
type identity.

2 years ago[libc] Implement expf function that is correctly rounded for all rounding modes.
Tue Ly [Fri, 11 Mar 2022 05:08:34 +0000 (00:08 -0500)]
[libc] Implement expf function that is correctly rounded for all rounding modes.

Implement expf function that is correctly rounded for all rounding modes.

Reviewed By: sivachandra, zimmermann6

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

2 years ago[clang-format] Refactor condition in AnnotatingParser::modifyContext(). NFC.
Marek Kurdej [Fri, 11 Mar 2022 11:12:27 +0000 (12:12 +0100)]
[clang-format] Refactor condition in AnnotatingParser::modifyContext(). NFC.

2 years ago[FunctionAttrs] Rename addReadAttrs -> addMemoryAttrs.
Florian Hahn [Fri, 11 Mar 2022 11:49:22 +0000 (11:49 +0000)]
[FunctionAttrs] Rename addReadAttrs -> addMemoryAttrs.

The addReadAttrs name is out of date, as the function also adds
the writeonly attribute. addMemoryAttrs is more accurate.

2 years ago[flang] Remove deprecated fields from FIROps.td
Andrzej Warzynski [Thu, 10 Mar 2022 16:46:03 +0000 (16:46 +0000)]
[flang] Remove deprecated fields from FIROps.td

This patch removes deprecated parser/printer/verifier fields from
FIROps.td. This is a follow-up of https://reviews.llvm.org/D119776 - it
takes care of operations deriving from `fir_IntegralSwitchTerminatorOp`
and `region_Op`.

No new functionality is added, hence no tests. This patch addresses:
https://github.com/llvm/llvm-project/issues/54314.

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

Some changes were extracted from D121090 (by River Riddle).

co-authored-by: River Riddle <riddleriver@gmail.com>

2 years ago[AArch64][SVE][Clang] Fix crash for incorrect svptrue and svcnt parameters
Matt Devereau [Wed, 9 Mar 2022 15:44:33 +0000 (15:44 +0000)]
[AArch64][SVE][Clang] Fix crash for incorrect svptrue and svcnt parameters

Giving an int parameter to SVE intrinsics svptrue and svcnt caused Clang
to crash on compilation. Changing their parameter types to void instead of
omitting args results in a diagnostic error message instead.

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

2 years ago[Bitcode] Check for type mismatch when assigning value
Nikita Popov [Fri, 11 Mar 2022 11:10:00 +0000 (12:10 +0100)]
[Bitcode] Check for type mismatch when assigning value

If the value is forward-declared, then the type must match,
otherwise we can't RAUW.

2 years agoCleanup include: TableGen
serge-sans-paille [Wed, 9 Mar 2022 21:28:44 +0000 (22:28 +0100)]
Cleanup include: TableGen

This also includes a few cleanup from Support.

Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup
Differential Revision: https://reviews.llvm.org/D121331

2 years ago[Bitcode] Delete phi node on error
Nikita Popov [Fri, 11 Mar 2022 10:35:15 +0000 (11:35 +0100)]
[Bitcode] Delete phi node on error

These error conditions are checked after the phi node has been
created, so we also need to delete it.

2 years ago[Bitcode] Improve some error messages
Nikita Popov [Fri, 11 Mar 2022 10:07:23 +0000 (11:07 +0100)]
[Bitcode] Improve some error messages

It's not particularly helpful if 95% of our errors just say
"Invalid record". This at least adds the record type to a subset
of errors.

2 years ago[AArch64] Improve costs for some conversions to fp16.
Florian Hahn [Fri, 11 Mar 2022 10:27:17 +0000 (10:27 +0000)]
[AArch64] Improve costs for some conversions to fp16.

Currently the cost model under-estimates the cost of certain
FP16 conversions.

This patch updates getCastInstrCost to return more accurate costs for
the cases improved in c2ed9fd05479.

Reviewed By: dmgreen

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

2 years ago[ADT] Make BitmaskEnum operations constant expressions
Pavel Labath [Wed, 9 Mar 2022 12:07:33 +0000 (13:07 +0100)]
[ADT] Make BitmaskEnum operations constant expressions

This avoids runtime initialization (a global constructor) whenever they appear
in the initializer.

The patch just adds the constexpr keyword to a couple of functions.

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

2 years ago[AArch64][SVE] Change the asserts in LowerToPredicatedOp to check for legal types
David Sherwood [Wed, 9 Mar 2022 14:39:12 +0000 (14:39 +0000)]
[AArch64][SVE] Change the asserts in LowerToPredicatedOp to check for legal types

When building the LLVM test suite with SVE I discovered a crash
when compiling some Halide tests, which occurs because we try to
use SVE to lower 64-bit vector multiplies and there is no
vscale_range attribute on the function. In this case the min SVE
vector bits was 0, which caused an assert in LowerToPredicatedOp
to fire. I have amended the asserts in this function to check that the
fixed-width type is legal. If the fixed-width type is larger than NEON
and is legal then it must be because we've set the min SVE vector
bits to something > 128. Or if the min SVE bits is 0, then the only
legal types allowed are 128 bit types - for any other types the assert
will fire.

Tests added here:

  CodeGen/AArch64/sve-fixed-length-no-vscale-range.ll

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

2 years ago[InstSimplify] Handle vector GEP when simplifying zero indices
Nikita Popov [Fri, 11 Mar 2022 09:55:48 +0000 (10:55 +0100)]
[InstSimplify] Handle vector GEP when simplifying zero indices

If the base is a scalar and the index is a vector, we can't
simplify, as this is effectively a splat operation.

2 years ago[Bitcode] Delete instruction on error
Nikita Popov [Fri, 11 Mar 2022 09:38:00 +0000 (10:38 +0100)]
[Bitcode] Delete instruction on error

As these errors are detected after the instruction has already been
created (but before it has been inserted into the function), we
also need to delete it.

2 years ago[MLIR][python binding] Add OpaqueAttribute to python binding.
Yun Long [Fri, 11 Mar 2022 09:50:10 +0000 (10:50 +0100)]
[MLIR][python binding] Add OpaqueAttribute to python binding.

Reviewed By: ftynse

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

2 years ago[clang-repl] Add an accessor to our underlying execution engine
Vassil Vassilev [Fri, 11 Mar 2022 08:12:11 +0000 (08:12 +0000)]
[clang-repl] Add an accessor to our underlying execution engine

This patch will allow better incremental adoption of these changes in downstream
cling and other users which want to experiment by customizing the execution
engine.

2 years ago[Bitcode] Report error for missing element type for attr upgrade
Nikita Popov [Fri, 11 Mar 2022 09:17:31 +0000 (10:17 +0100)]
[Bitcode] Report error for missing element type for attr upgrade

Otherwise this is going to crash either the TypeFinder or the
Verifier.

2 years agoFixed a roll-over on size_t in getNewUninitMemBuffer()
Dmitry Vassiliev [Fri, 11 Mar 2022 09:16:58 +0000 (13:16 +0400)]
Fixed a roll-over on size_t in getNewUninitMemBuffer()

Reviewed By: serge-sans-paille

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

2 years ago[docs] Update opaque pointers transition state (NFC)
Nikita Popov [Fri, 11 Mar 2022 08:34:37 +0000 (09:34 +0100)]
[docs] Update opaque pointers transition state (NFC)

Bitcode is now supported.

2 years ago[llvm-c] Document that LLVMGetElementType on pointers is deprecated (NFC)
Nikita Popov [Fri, 11 Mar 2022 08:27:22 +0000 (09:27 +0100)]
[llvm-c] Document that LLVMGetElementType on pointers is deprecated (NFC)

We can't actually deprecate the function, because it is also used
for arrays and vectors, so we can only document this.