Iain Sandoe [Sat, 24 Sep 2022 15:01:44 +0000 (16:01 +0100)]
[C++20][Modules] Elide unused guard variables in Itanium ABI module initializers.
For the Itanium ABI, we emit an initializer for each module. This is responsible
for handling initialization of global vars. Relates to P1874R1.
The initializer has a known mangling and is automatically called from any TU that
imports a module. Since, at present, the importer has no way to determine that an
imported module does not require an initializer, we generate the initializer for
all cases (even when it is empty).
Initializers must be run once, with the ordering guaranteed by the import graph
and this is ensured in the current code by addition of a guard variable.
In the case that a module has no requirement for global initializers, and also does
not import any other modules, we can elide the guard variable.
Differential Revision: https://reviews.llvm.org/D134589
Kazu Hirata [Sun, 18 Dec 2022 08:28:54 +0000 (00:28 -0800)]
Include <optional> instead of "llvm/ADT/Optional.h"
This is part of an effort to migrate from llvm::Optional to
std::optional:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
Sameer Sahasrabuddhe [Sun, 18 Dec 2022 05:21:20 +0000 (10:51 +0530)]
[AAPointerInfo] handle multiple offsets in PHI
Previously reverted in
8b446ea2ba39e406bcf940ea35d6efb4bb9afe95
Reapplying because this commit is NOT DEPENDENT on the reverted commit
fc21f2d7bae2e0be630470cc7ca9323ed5859892, which broke the ASAN buildbot.
See https://reviews.llvm.org/rGfc21f2d7bae2e0be630470cc7ca9323ed5859892 for
more information.
The arguments to a PHI may represent a recurrence by eventually using the output
of the PHI itself. This is now handled by checking for cycles in the control
flow. If a PHI is not in a recurrence, it is now able to report multiple offsets
instead of conservatively reporting unknown.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D138991
Vy Nguyen [Sun, 18 Dec 2022 03:53:44 +0000 (22:53 -0500)]
Reland 3nd attempt: [lld-macho] Fix bug in reading cpuSubType field.
This reverts commit
09c5aab7f88178c1af92de0b00417416da9db6c1.
New changes:
Temporarily skip checking the output bundle's cpu/cpu-subtype
Suspected there's a bug in selecting targets which caused the produced bundle
to be arm64 bundle (even though it was specifically linked with -arch x86_64).
The current test that link succeeded should be sufficient, because
it would have failed with "unable to find matching tagets" prior to this patch.
Differential Revision: https://reviews.llvm.org/D139572
River Riddle [Sun, 18 Dec 2022 03:54:11 +0000 (19:54 -0800)]
[mlir] Add an overload of parseOptionalAttribute for SymbolRefAttr
Avoids parsing other types of attributes when checking if there is
a SymbolRefAttr.
Johannes Doerfert [Sun, 18 Dec 2022 00:22:22 +0000 (16:22 -0800)]
[Attributor][FIX] Ensure to delete all AAs
Before we might have missed calling the destructor on an abstract
attribute if it was created outside the seeding or update phase.
All AAs are now in the AAMap and we can use it to delete them all.
Dinar Temirbulatov [Sun, 18 Dec 2022 01:27:03 +0000 (01:27 +0000)]
[AArch64][SVE] Allow to lower WHILEop with constant operands to PTRUE
This allows it to fold WHILEop with constant operand to PTRUE instruction in
the case given range is fitted to predicate format. Also, this change
fixes the unsigned overflow error introduced in D137547 for WHILELO lowering.
Differential Revision: https://reviews.llvm.org/D139068
Peter Klausler [Sat, 17 Dec 2022 23:25:45 +0000 (15:25 -0800)]
[flang] Fix crash in name resolution
In an error recovery situation, the name resolution code for a
SELECT TYPE statement must check the presence of an optional
expression before calling GetType() upon it.
Differential Revision: https://reviews.llvm.org/D140153
Roman Lebedev [Sat, 17 Dec 2022 21:28:52 +0000 (00:28 +0300)]
[NFC][llvm-exegesis] Extract `runBenchmarkConfigurations()` out of `benchmarkMain()`
`benchmarkMain()` is already bigger than it should be,
let's extract the important chunk before making it even larger.
Roman Lebedev [Sun, 18 Dec 2022 01:15:04 +0000 (04:15 +0300)]
[NFC][llvm-exegesis] `BenchmarkRunner`: split `runConfiguration()` into `getRunnableConfiguration()` + `runConfiguration()`
We can run as many `getRunnableConfiguration()` in parallel as we want,
but `runConfiguration()` must be run *completely* standalone from everything.
This is a step towards enabling threading.
Roman Lebedev [Sat, 17 Dec 2022 20:48:57 +0000 (23:48 +0300)]
[NFC][llvm-exegesis] `InstructionBenchmark`: only allow move constructor
We don't ever legitimately need to copy it, so let's make that explicit
Fangrui Song [Sun, 18 Dec 2022 01:15:25 +0000 (01:15 +0000)]
[lldb] Remove redundant .c_str() and .get() calls
Removing .c_str() has a semantics difference, but the use scenarios
likely do not matter as we don't have NUL in the strings.
Roman Lebedev [Sun, 18 Dec 2022 00:44:13 +0000 (03:44 +0300)]
[llvm-exegesis] Unbreak `--benchmarks-file=<f>`
I'm absolutely flabbergasted by this.
I was absolutely sure this worked.
But apparently not.
When outputting to the file, we'd write a single `InstructionBenchmark`
to it, and then close the file. And for the next `InstructionBenchmark`,
we'd reopen the file, truncating it in process,
and thus the first `InstructionBenchmark` would be gone...
Gregory Alfonso [Sun, 18 Dec 2022 00:33:53 +0000 (00:33 +0000)]
Remove redundant .c_str() and .get() calls
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D139485
Khem Raj [Sun, 18 Dec 2022 00:13:29 +0000 (00:13 +0000)]
cmake: Enable 64bit off_t on 32bit glibc systems
Pass -D_FILE_OFFSET_BITS=64 to compiler flags on 32bit glibc based
systems. This will make sure that 64bit versions of LFS functions are
used e.g. seek will behave same as lseek64. Also revert [1] partially
because this added a cmake test to detect lseek64 but then forgot to
pass the needed macro to actual compile, this test was incomplete too
since libc implementations like musl has 64bit off_t by default on 32bit
systems and does not bundle[2] -D_LARGEFILE64_SOURCE under -D_GNU_SOURCE
like glibc, which means the compile now fails on musl because the cmake
check passes but we do not have _LARGEFILE64_SOURCE defined. Using the
*64 function was transitional anyways so use -D_FILE_OFFSET_BITS=64
instead
[1] https://github.com/llvm/llvm-project/commit/
8db7e5e4eed4c4e697dc3164f2c9351d8c3e942b
[2] https://git.musl-libc.org/cgit/musl/commit/?id=
25e6fee27f4a293728dd15b659170e7b9c7db9bc
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D139752
Peter Klausler [Sat, 17 Dec 2022 18:48:27 +0000 (10:48 -0800)]
[flang] Check constant arguments to bit manipulation intrinsics even if not foldable
When some arguments that specify bit positions, shift counts, and field sizes are
constant at compilation time, but other arguments are not constant, the compiler
should still validate the constant ones. In the current sources, validation is
only performed for intrinsic references that can be folded to constants.
Differential Revision: https://reviews.llvm.org/D140152
Krzysztof Parzyszek [Sat, 17 Dec 2022 21:57:30 +0000 (13:57 -0800)]
[clang] Convert OptionalFileEntryRefDegradesToFileEntryPtr to std::optional
Markus Böck [Sat, 17 Dec 2022 21:42:30 +0000 (22:42 +0100)]
[llvm][ADT] Allow returning `std::nullopt` in TypeSwitch
Returning `std::nullopt` from the case of a `TypeSwitch` yields broken results, by either falling through to another case, or falling of the switch entirely and hitting an assertion. This is simply due to the use of `operator=` of what is now `std::optional`, which has an overload specifically for `std::nullopt`, causing the internal optional, used for the `TypeSwitch` result to be reset, instead of a value being constructed from the `std::nullopt`.
The fix is to simply use the `emplace` method of `std::optional`, causing a value to always be constructed from the value returned by the case function.
Differential Revision: https://reviews.llvm.org/D140265
Fangrui Song [Sat, 17 Dec 2022 22:43:03 +0000 (22:43 +0000)]
Optional: Deprecated value()
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716/19
value() is a 15.0.0 API for std::optional migration.
std::optional::value() has undesired exception checking semantics and is
unavailable in older Xcode (see
_LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS). Deprecate value() to prevent
new in-tree uses which may accidentally cause build breakage for older
Xcode when contributors perform std::optional migrating.
Some downtream MLIR projects such as tensorflow/mlir-hlo, stablehlo use
value(), so we do not remove it now.
Fangrui Song [Sat, 17 Dec 2022 22:30:35 +0000 (22:30 +0000)]
Optional: Avoid value() uses
prerequisite to deprecate the new API value() whose counterpart in
std::optional has undesired exception checking semantics and is
unavailable in older Xcode.
Fangrui Song [Sat, 17 Dec 2022 22:22:47 +0000 (22:22 +0000)]
[flang] llvm::Optional::value() => => operator*/operator->
std::optional::value() has undesired exception checking semantics and is
unavailable in older Xcode (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS). The
call sites block std::optional migration.
Simon Pilgrim [Sat, 17 Dec 2022 21:52:35 +0000 (21:52 +0000)]
[X86] SandyBridge - fix ADC RMW uop count
These should consistently use the fused domain count, not the unfused domain
Confirmed with Agner + uops.info
Slava Zakharin [Sat, 17 Dec 2022 21:03:54 +0000 (13:03 -0800)]
[flang] Fixed buildbot failured after D140236.
Removed unused functions searchFunctionInLibrary and getFuncOp.
Differential Revision: https://reviews.llvm.org/D140236
Peter Rong [Sat, 17 Dec 2022 20:59:59 +0000 (12:59 -0800)]
precommit APSInt format for D140059
Signed-off-by: Peter Rong <PeterRong96@gmail.com>
Roman Lebedev [Sat, 17 Dec 2022 20:53:36 +0000 (23:53 +0300)]
[NFC][CMake] Fix AnalysisTests build after
07af0e2d3e8485ad6f84da1ad9851538b62d2942
The new code uses ModuleInliner, but does not link to the library
that provides it.
Simon Pilgrim [Sat, 17 Dec 2022 20:38:36 +0000 (20:38 +0000)]
[X86] Fix BMI uop/throughputs on znver1/znver2
Most BMI ops are 2uop and 0.5 throughput - interestingly TZCNTrm doesn't take an extra uop but the other instructions do
Confirmed by AMD SoG + Agner
Fangrui Song [Sat, 17 Dec 2022 20:37:13 +0000 (20:37 +0000)]
[lldb] llvm::Optional::value() && => operator*/operator->
std::optional::value() has undesired exception checking semantics and is
unavailable in older Xcode (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS). The
call sites block std::optional migration.
Slava Zakharin [Fri, 16 Dec 2022 18:08:25 +0000 (10:08 -0800)]
[NFC][flang] Removed pgmath handling from lowering.
I kept the possibility to use pgmath in constant folding
just in case. We can remove it later, if it is proven to be redundant.
Differential Revision: https://reviews.llvm.org/D140236
Roman Lebedev [Sat, 17 Dec 2022 20:07:45 +0000 (23:07 +0300)]
[NFCI][llvm-exegesis] `BenchmarkRunner::runConfiguration()`: extract `assembleSnippet()` helper
Roman Lebedev [Sat, 17 Dec 2022 18:15:17 +0000 (21:15 +0300)]
[NFC][llvm-exegesis] `BenchmarkRunner::runConfiguration()`: deduplicate `DumpObjectToDisk` handling
Always assemble into buffer, that is then optionally dumped into file.
Roman Lebedev [Sat, 17 Dec 2022 17:51:37 +0000 (20:51 +0300)]
[NFC][llvm-exegesis] `BenchmarkRunner::runConfiguration()`: reformat
Roman Lebedev [Sat, 17 Dec 2022 17:43:07 +0000 (20:43 +0300)]
[NFCI][llvm-exegesis] Extract 'Min' repetition handling from `BenchmarkRunner` into it's caller
If `BenchmarkRunner::runConfiguration()` deals with more than a single
repetitor, tasking will be less straight-forward to implement.
But i think dealing with that in it's callee is even more readable.
Fangrui Song [Sat, 17 Dec 2022 20:03:01 +0000 (20:03 +0000)]
[clang-tools-extra] llvm::Optional::value => operator*/operator->
std::optional::value() has undesired exception checking semantics and is
unavailable in older Xcode (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS). The
call sites block std::optional migration.
Fangrui Song [Sat, 17 Dec 2022 19:47:45 +0000 (19:47 +0000)]
[clang] llvm::Optional::value() && => operator*/operator->
std::optional::value() has undesired exception checking semantics and is
unavailable in older Xcode (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS). The
call sites block std::optional migration.
Fangrui Song [Sat, 17 Dec 2022 19:23:50 +0000 (19:23 +0000)]
[mlir] llvm::Optional::value() && => operator*/operator->
std::optional::value() has undesired exception checking semantics and is
unavailable in older Xcode (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS). The
call sites block std::optional migration.
Fangrui Song [Sat, 17 Dec 2022 19:07:38 +0000 (19:07 +0000)]
[mlir] llvm::Optional::value => operator*/operator->
std::optional::value() has undesired exception checking semantics and is
unavailable in older Xcode (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS). The
call sites block std::optional migration.
Peter Klausler [Sat, 17 Dec 2022 18:19:42 +0000 (10:19 -0800)]
[flang] Check for another case of ambiguous generic resolution
When specific procedures of a generic have dummy procedures,
underspecified actual procedures can match more than one specific
procedure. This can happen with actual procedures that are
externals with implicit interfaces, including the completely
unspecified case of a PROCEDURE() or EXTERNAL that doesn't even
differentiate between a subroutine and a function.
Generic resolution can already handle cases of ambiguous resolution
due to the use of NULL() actual arguments with no MOLD= arguments
to define their types. Extend the handling of ambiguous actual
arguments to include the case of underspecified actual procedures.
Differential Revision: https://reviews.llvm.org/D140151
ibricchi [Sat, 17 Dec 2022 17:58:23 +0000 (09:58 -0800)]
Reapply "[InlineAdvisor] Allow loading advisors as plugins"
This reverts commit
8d22a63e2c8b4931113ca9d1ee8b17f7ff453e81.
Fix was missing dependency.
Peter Klausler [Sat, 17 Dec 2022 17:47:21 +0000 (09:47 -0800)]
[flang] Check C854, C855, & C856 on PROTECTED entities
Check for things that are not allowed to bear the PROTECTED
attribute.
Differential Revision: https://reviews.llvm.org/D140150
Peter Klausler [Sat, 17 Dec 2022 17:11:40 +0000 (09:11 -0800)]
[flang] Apply definability checks in ALLOCATE/DEALLOCATE statements
The pointers and allocatables that appear in ALLOCATE and DEALLOCATE
statements need to be subject to the general definability checks so
that problems with e.g. PROTECTED objects can be caught.
(Also: regularize the capitalization of the DEALLOCATE error messages
while I'm in here so that they're consistent with the messages that
can come out for ALLOCATE.)
Differential Revision: https://reviews.llvm.org/D140149
Haojian Wu [Sat, 17 Dec 2022 17:22:18 +0000 (18:22 +0100)]
Fix unused variable warnings in SIFrameLowering.cpp for release build, NFC
Haojian Wu [Sat, 17 Dec 2022 17:14:10 +0000 (18:14 +0100)]
Update the bazel's llvm-config.h.cmake file
Reflect the change
7d2c1150d31bb3692c81f6ecb0dbe61170e31212, fix the bazel test
breakage.
Peter Klausler [Sat, 17 Dec 2022 15:33:04 +0000 (07:33 -0800)]
[flang] Enforce C1529 as a warning, C919 as an error
Constraint C1529 requires that the base object of a type-bound procedure
reference be a scalar if the TBP has the NOPASS attribute. Most
compilers do not enforce this constraint and it does not appear to
have any implementation justification, so emit portability warning.
On the other hand, we fail to enforce C919 for references to
procedure pointer components, whose base objects must of course
be scalars in order to avoid ambiguity and empty arrays, whether
NOPASS is present or not.
Differential Revision: https://reviews.llvm.org/D140148
Haojian Wu [Sat, 17 Dec 2022 17:04:28 +0000 (18:04 +0100)]
Fix unused variable warning in release build, NFC.
Simon Pilgrim [Sat, 17 Dec 2022 15:33:04 +0000 (15:33 +0000)]
[X86] All the WriteBLS instructions take 2uops, not 1uop
Confirmed by AMD SoG + Agner + uops.info
Paul Walker [Thu, 15 Dec 2022 14:59:51 +0000 (14:59 +0000)]
[AggressiveInstCombine] Fix invalid TypeSize conversion when combining loads.
Much of foldLoadsRecursive relies on knowing the size of loaded
data, which is not possible for scalable vector types. However,
the logic of combining two small loads into one bigger load does
not apply for vector types so rather than converting the algorithm
to use TypeSize I've simply added an early exit for vectors.
Fixes #59510
Differential Revision: https://reviews.llvm.org/D140106
Peter Klausler [Mon, 12 Dec 2022 21:58:07 +0000 (13:58 -0800)]
[flang] Impose DATA initialization size limit to avoid crashing
Impose a large but finite limit on the size of a variable being
initialized in a DATA statement to provide a readable error message
for artificial test cases that's better than a memory allocation
failure crash.
Differential Revision: https://reviews.llvm.org/D140146
Alessandro Arzilli [Sat, 17 Dec 2022 12:22:05 +0000 (13:22 +0100)]
[dsymutil] fix accidental 32bit truncation in patchFrameInfoForObject
patchFrameInfoForObject accidentally truncates FDE addresses
to the least significant 32bits, which causes the Go bug: https://github.com/golang/go/issues/25841.
Patch by Alessandro Arzilli
Differential Revision: https://reviews.llvm.org/D138763
Nico Weber [Sat, 17 Dec 2022 14:25:42 +0000 (09:25 -0500)]
Revert "Reland 2nd attempt: [lld-macho] Fix bug in reading cpuSubType field."
This reverts commit
b08acee423935c16a1503335d78b84ccbbae4ef8.
Still breaks tests, see https://reviews.llvm.org/D139572#4003191
Roman Lebedev [Sat, 17 Dec 2022 13:48:07 +0000 (16:48 +0300)]
[NFC][llvm-exegesis] LLVMState: only store references to reg/op names
We know that the original reference from which we've built these maps
will persist, so we do not need to copy the names.
Simon Pilgrim [Sat, 17 Dec 2022 14:06:26 +0000 (14:06 +0000)]
[llvm-exegesis][X86] Use the same AGU counter estimate mapping for znver1 as znver2, and count RMW ops as well
znver2 can use the ld/st dispatch counters to make a reasonable estimate for the AGU usage (although it misses complex LEA ops which I don't think we can fix), although it wasn't accounting for RMW ld-st uops which are counted separately - the same approach can be used for znver1 (ymm double-pumping ld/st agu is correctly measured as 2uops)
This change is mainly academic, but was noticed as the znver1/2 models incorrectly assume scalar RMW ops take 2uops
Roman Lebedev [Sat, 17 Dec 2022 13:38:24 +0000 (16:38 +0300)]
[NFC][InstCombine] Move nested-select testcase into proper place, adjust comment
Mark de Wever [Thu, 15 Dec 2022 17:58:17 +0000 (18:58 +0100)]
[libc++][format] Renames __null_sentinel.
While the FreeBSD CI was enabled in D128084 it was discovered libc++
uses the name of a system macro on FreeBSD. This renames the macro to
fix the issue.
Reviewed By: emaste, #libc, philnik
Differential Revision: https://reviews.llvm.org/D140117
Ganesh Gopalasubramanian [Thu, 15 Dec 2022 13:58:34 +0000 (19:28 +0530)]
[X86] AMD Zen 4 Initial enablement
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D139073
Ramkumar Ramachandra [Wed, 14 Dec 2022 10:39:19 +0000 (11:39 +0100)]
mlir/tblgen: use std::optional in generation
This is part of an effort to migrate from llvm::Optional to
std::optional. This patch changes the way mlir-tblgen generates .inc
files, and modifies tests and documentation appropriately. It is a "no
compromises" patch, and doesn't leave the user with an unpleasant mix of
llvm::Optional and std::optional.
A non-trivial change has been made to ControlFlowInterfaces to split one
constructor into two, relating to a build failure on Windows.
See also: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
Signed-off-by: Ramkumar Ramachandra <r@artagnon.com>
Differential Revision: https://reviews.llvm.org/D138934
Craig Topper [Sat, 17 Dec 2022 08:11:19 +0000 (00:11 -0800)]
Revert "[RISCV] Support the short-forward-branch predicatd ops in RISCVSExtWRemoval."
This reverts commit
9e586217f4e331bca241df00648ca0b71edd3ef6.
I think there's at least one mistake in this.
Fangrui Song [Sat, 17 Dec 2022 08:10:45 +0000 (08:10 +0000)]
[clang] llvm::Optional::value => operator*/operator->
std::optional::value() has undesired exception checking semantics and is
unavailable in older Xcode (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS). The
call sites block std::optional migration.
This makes `ninja check-clang` work in the absence of llvm::Optional::value.
Kazu Hirata [Sat, 17 Dec 2022 07:36:51 +0000 (23:36 -0800)]
Ensure newlines at the end of files (NFC)
Craig Topper [Sat, 17 Dec 2022 07:25:20 +0000 (23:25 -0800)]
[RISCV] Support the short-forward-branch predicatd ops in RISCVSExtWRemoval.
Kazu Hirata [Sat, 17 Dec 2022 07:20:11 +0000 (23:20 -0800)]
[BinaryFormat] Use std::optional instead of llvm::Optional (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
Uday Bondhugula [Thu, 15 Dec 2022 15:24:19 +0000 (20:54 +0530)]
[MLIR] Enhance getLargestKnownDivisor for AffineExpr floordiv/ceildiv
The largest known divisor for expressions like (32 * d0 + 32, 128)
ceildiv 8 wasn't being computed tightly; a conservative value of 1 was
being returned. Address this. This leads to a broad improvement for
several affine analyses and rewrites that depend on knowing whether
something is a multiple of a specific constant or such largest known
constant.
Differential Revision: https://reviews.llvm.org/D140185
Kazu Hirata [Sat, 17 Dec 2022 06:38:57 +0000 (22:38 -0800)]
[NVPTX] Use std::optional instead of llvm::Optional (NFC)
This is part of an effort to migrate from llvm::Optional to
std::optional:
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
Craig Topper [Sat, 17 Dec 2022 06:37:14 +0000 (22:37 -0800)]
[RISCV] Add support for predicating AND/OR/XOR/ADD/SUB with short-forward-branch-opt.
sifive-7-series can predicate ALU instructions in the shadow of a
branch not just move instructions.
This patch implements analyzeSelect/optimizeSelect to predicate
these operations. This is based on ARM's implementation which can
predicate using flags and condition codes.
I've restricted it to just the instructions we have test cases for,
but it can be extended in the future.
Reviewed By: reames
Differential Revision: https://reviews.llvm.org/D140053
Fangrui Song [Sat, 17 Dec 2022 06:51:04 +0000 (06:51 +0000)]
[M68k] Fix spillCalleeSavedRegisters after D138656
Fangrui Song [Sat, 17 Dec 2022 06:37:59 +0000 (06:37 +0000)]
llvm::Optional::value => operator*/operator->
std::optional::value() has undesired exception checking semantics and is
unavailable in older Xcode (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS). The
call sites block std::optional migration.
This makes `ninja clang` work in the absence of llvm::Optional::value.
Christudasan Devadasan [Thu, 14 Apr 2022 14:09:59 +0000 (19:39 +0530)]
[AMDGPU][SILowerSGPRSpills] Spill SGPRs to virtual VGPRs
Currently, the custom SGPR spill lowering pass spills
SGPRs into physical VGPR lanes and the remaining VGPRs
are used by regalloc for vector regclass allocation.
This imposes many restrictions that we ended up with
unsuccessful SGPR spilling when there won't be enough
VGPRs and we are forced to spill the leftover into
memory during PEI. The custom spill handling during PEI
has many edge cases and often breaks the compiler time
to time.
This patch implements spilling SGPRs into virtual VGPR
lanes. Since we now split the register allocation for
SGPRs and VGPRs, the virtual registers introduced for
the spill lanes would get allocated automatically in
the subsequent regalloc invocation for VGPRs.
Spill to virtual registers will always be successful,
even in the high-pressure situations, and hence it avoids
most of the edge cases during PEI. We are now left with
only the custom SGPR spills during PEI for special registers
like the frame pointer which isn an unproblematic case.
This patch also implements the whole wave spills which
might occur if RA spills any live range of virtual registers
involved in the whole wave operations. Earlier, we had
been hand-picking registers for such machine operands.
But now with SGPR spills into virtual VGPR lanes, we are
exposing them to the allocator.
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D124196
Christudasan Devadasan [Thu, 24 Nov 2022 08:17:01 +0000 (13:47 +0530)]
[CodeGen] Additional Register argument to storeRegToStackSlot/loadRegFromStackSlot
With D134950, targets get notified when a virtual register is created and/or
cloned. Targets can do the needful with the delegate callback. AMDGPU propagates
the virtual register flags maintained in the target file itself. They are useful
to identify a certain type of machine operands while inserting spill stores and
reloads. Since RegAllocFast spills the physical register itself, there is no way
its virtual register can be mapped back to retrieve the flags. It can be solved
by passing the virtual register as an additional argument. This argument has no
use when the spill interfaces are called during the greedy allocator or even the
PrologEpilogInserter and can pass a null register in such cases.
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D138656
Christudasan Devadasan [Tue, 22 Nov 2022 19:15:57 +0000 (00:45 +0530)]
[CodeGen] Use cloneVirtualRegister in LiveIntervals and LiveRangeEdit
It is needed to invoke the delegate methods effectively whenever a
virtual register is cloned from an existing register of the same class.
Reviewed By: qcolombet
Differential Revision: https://reviews.llvm.org/D138517
Christudasan Devadasan [Fri, 30 Sep 2022 07:50:58 +0000 (13:20 +0530)]
[CodeGen] Use delegate to notify targets when virtual registers are created
This will help targets to customize certain codegen decisions based on
the virtual registers involved in special operations. This patch also
extends the existing delegate in MRI to start support multicast.
Reviewed By: qcolombet
Differential Revision: https://reviews.llvm.org/D134950
Christudasan Devadasan [Fri, 30 Sep 2022 03:17:06 +0000 (08:47 +0530)]
[AMDGPU][SIFrameLowering] Use the right frame register in CSR spills
Unlike the callee-saved VGPR spill instructions emitted by
`PEI::spillCalleeSavedRegs`, the CS VGPR spills inserted during
emitPrologue/emitEpilogue require the exec bits flipping to avoid
clobbering the inactive lanes of VGPRs used for SGPR spilling.
Currently, these spill instructions are referenced from the SP at
function entry and when the callee performs a stack realignment,
they ended up getting incorrect stack offsets. Even if we try to
adjust the offsets, the FP-SP becomes a runtime entity with dynamic
stack realignment and the offsets would still be inaccurate.
To fix it, use FP as the frame base in the spill instructions
whenever the function has FP. The offsets obtained for the CS
objects would always be the right values from FP.
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D134949
Christudasan Devadasan [Fri, 23 Sep 2022 09:43:09 +0000 (15:13 +0530)]
[AMDGPU] Preserve only the inactive lanes of scratch vgprs
In general, a callee is free to use a scratch register without
preserving its previous state. However, the VGPR used for SGPR
spilling can potentially have its inactive lanes overwritten by
the writelane instructions. When the function returns, it can
cause unexpected behavior if the VGPR value is not preserved
appropriately.
The current scheme to preserve the inactive lanes of such
scratch VGPRs is not done rightly. It preserves all lanes
and causes the outgoing values (if any) getting overwritten
by the epilog restores. It then corrupts the return value.
To avoid such situation with scratch VGPRs, this patch ensures
we preserve only their inactive lanes.
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D134526
Christudasan Devadasan [Thu, 18 Aug 2022 04:56:09 +0000 (10:26 +0530)]
[AMDGPU][SIFrameLowering] Unify PEI SGPR spill saves and restores
There is a lot of customization and eventually code duplication in the
frame lowering that handles special SGPR spills like the one needed for
the Frame Pointer. Incorporating any additional SGPR spill currently
makes it difficult during PEI. This patch introduces a new spill builder
to efficiently handle such spill requirements. Various spill methods are
special handled using a separate class.
Reviewed By: sebastian-ne, scott.linder
Differential Revision: https://reviews.llvm.org/D132436
Christudasan Devadasan [Wed, 13 Apr 2022 05:58:59 +0000 (11:28 +0530)]
[AMDGPU] Separate out SGPR spills to VGPR lanes during PEI
SILowerSGPRSpills pass handles the lowering of SGPR spills
into VGPR lanes. Some SGPR spills are handled later during
PEI. There is a common function used in both places to find
the free VGPR lane. This patch eliminates that dependency to
find the free VGPR by handling it separately for PEI. It is a
prerequisite patch for a future work to allow SGPR spills to
virtual VGPR lanes during SILowerSGPRSpills.
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D124195
Christudasan Devadasan [Sun, 17 Apr 2022 12:14:39 +0000 (17:44 +0530)]
[AMDGPU] Correctly set IsKill flag for VGPR spills in the prolog
We always assume the vector register is dead or killed while
inserting the VGPR spills in the prolog. It is not always
true. Used the entry block liveIn data while setting the flag.
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D124194
Christudasan Devadasan [Tue, 19 Apr 2022 07:04:12 +0000 (12:34 +0530)]
[AMDGPU] Add WWM reserved VGPRs to WWMSpills
The custom VGPR spills inserted during frame lowering
maintain a separate list for WWM reserved registers.
Added them into WWMSpills that already tracks such
reserved registers. It unifies the spill insertion.
Reviewed By: nhaehnle, arsenm
Differential Revision: https://reviews.llvm.org/D124193
Christudasan Devadasan [Mon, 13 Jun 2022 13:12:02 +0000 (18:42 +0530)]
[AMDGPU] Callee must always spill writelane VGPRs
Since the writelane instruction used for SGPR spills can
modify inactive lanes, the callee must preserve the VGPR
this instruction modifies even if it was marked Caller-saved.
Reviewed By: arsenm, nhaehnle
Differential Revision: https://reviews.llvm.org/D124192
Fangrui Song [Sat, 17 Dec 2022 05:27:33 +0000 (05:27 +0000)]
[mlir] llvm::Optional::value => operator*/operator->
std::optional::value() has undesired exception checking semantics and is
unavailable in some older Xcode. The call sites block std::optional migration.
Fangrui Song [Sat, 17 Dec 2022 05:23:45 +0000 (05:23 +0000)]
[llvm] llvm::Optional::value => operator*/operator->
std::optional::value() has undesired exception checking semantics and is
unavailable in some older Xcode. The call sites block std::optional migration.
Fangrui Song [Sat, 17 Dec 2022 05:15:07 +0000 (05:15 +0000)]
[clang] llvm::Optional::value => operator*/operator->
std::optional::value() has undesired exception checking semantics and is
unavailable in some older Xcode. The call sites block std::optional migration.
Fangrui Song [Sat, 17 Dec 2022 05:11:01 +0000 (05:11 +0000)]
[clangd] llvm::Optional::value => operator*/operator->
std::optional::value() has undesired exception checking semantics and is
unavailable in some older Xcode. The call sites block std::optional migration.
ziqingluo-90 [Sat, 17 Dec 2022 04:59:40 +0000 (20:59 -0800)]
[-Wunsafe-buffer-usage] Ignore array subscript on literal zero
Unsafe Buffer Usage analysis only warns unsafe buffer accesses but not
pointer dereferences. An array subscript on a literal zero is
equivalent to dereference a pointer thus we do not want to warn it.
Reviewed By: NoQ
Differential Revision: https://reviews.llvm.org/D138321
Fangrui Song [Sat, 17 Dec 2022 05:03:57 +0000 (05:03 +0000)]
[lld] llvm::Optional::value => operator*/operator->
std::optional::value() has undesired exception checking semantics and is
unavailable in some older Xcode. The call sites block std::optional migration.
Fangrui Song [Sat, 17 Dec 2022 05:01:54 +0000 (05:01 +0000)]
[lldb] llvm::Optional::value => operator*/operator->
std::optional::value() has undesired exception checking semantics and is
unavailable in some older Xcode. The call sites block std::optional migration.
Fangrui Song [Sat, 17 Dec 2022 04:45:11 +0000 (04:45 +0000)]
llvm::Optional::value => operator*/operator->
std::optional::value() has undesired exception checking semantics and is
unavailable in some older Xcode. The call sites block std::optional migration.
ziqingluo-90 [Sat, 17 Dec 2022 04:35:41 +0000 (20:35 -0800)]
[-Wunsafe-buffer-usage] Improve pointer matching pattern
Generalize the pointer expression AST matcher in Unsafe Buffer Usage analysis.
Add test cases for various kinds of pointer usages.
Reviewed By: NoQ, aaron.ballman, xazax.hun
Differential Revision: https://reviews.llvm.org/D138318
Fangrui Song [Sat, 17 Dec 2022 04:38:27 +0000 (04:38 +0000)]
[mlir] std::optional::value => operator*/operator->
value() has undesired exception checking semantics and calls
__throw_bad_optional_access in libc++. Moreover, the API is unavailable without
_LIBCPP_NO_EXCEPTIONS on older Mach-O platforms (see
_LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS).
Fangrui Song [Sat, 17 Dec 2022 04:11:55 +0000 (04:11 +0000)]
[flang] std::optional::value => operator*/operator->
Fangrui Song [Sat, 17 Dec 2022 03:19:47 +0000 (03:19 +0000)]
[lld] std::optional::value => operator*/operator->
Wenzel Jakob [Sat, 17 Dec 2022 02:11:56 +0000 (13:11 +1100)]
[C-API] Add example code to exercise new MCJIT-like-memory-manager API.
This example shows how to use the newly added
LLVMOrcCreateRTDyldObjectLinkingLayerWithMCJITMemoryManagerLikeCallbacks API.
Lang Hames [Sat, 17 Dec 2022 02:01:08 +0000 (13:01 +1100)]
[C-API] LLVMOrcCreateRTDyldObjectLinkingLayerWithMCJITMemoryManagerLikeCallbacks
Adds a LLVMOrcCreateRTDyldObjectLinkingLayerWithMCJITMemoryManagerLikeCallbacks
function that can be used to create an RTDyldObjectLinkingLayer using callbacks
that are similar (but not identical) to those used in
LLVMCreateSimpleMCJITMemoryManager. This is intended to ease the transition to
ORC for MCJIT C-API clients.
Differential Revision: https://reviews.llvm.org/D139393
Fangrui Song [Sat, 17 Dec 2022 03:12:04 +0000 (03:12 +0000)]
std::optional::value => operator*/operator->
value() has undesired exception checking semantics and calls
__throw_bad_optional_access in libc++. Moreover, the API is unavailable without
_LIBCPP_NO_EXCEPTIONS on older Mach-O platforms (see
_LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS).
This fixes check-clang-tools.
Vy Nguyen [Fri, 16 Dec 2022 20:17:06 +0000 (15:17 -0500)]
Reland 2nd attempt: [lld-macho] Fix bug in reading cpuSubType field.
This reverts commit
52a118d08fbb0a45cba8c34346d9ccb14f599c6a.
New changes:
Fix tests to dump both slices in the fat-archive because otool
isn't deterministic about which slice it prints across different archs.
(It printed x86 on x86 machines but arm64 on arm64, this was why
the test failed on arm64)
Differential Revision: https://reviews.llvm.org/D139572
Yingchi Long [Fri, 9 Dec 2022 16:53:57 +0000 (00:53 +0800)]
[RISCV][VP] support vp.reduce.mul by ExpandVectorPredication
Most of VP intrinsics are implemented in RISC-V backends, but
vp.reduce.mul (element length > 1) does not yet. Legalizes vp.reduce.mul
using ExpandVectorPredication Pass.
Reviewed By: reames
Differential Revision: https://reviews.llvm.org/D139721
Artem Dergachev [Sat, 17 Dec 2022 01:52:02 +0000 (17:52 -0800)]
[-Wunsafe-buffer-usage] NFC: Implement fix-strategies and variable-use-claiming.
This patch adds more abstractions that we'll need later for emitting
-Wunsafe-buffer-usage fixits. It doesn't emit any actual fixits,
so no change is observed behavior, but it introduces a way to emit fixits,
and existing tests now verify that the compiler still emits no fixits,
despite knowing how to do so.
The purpose of our code transformation analysis is to fix variable types
in the code from raw pointer types to C++ standard collection/view types.
The analysis has to decide on its own which specific type is
the most appropriate for every variable. This patch introduces
the Strategy class that maps variables to their most appropriate types.
In D137348 we've introduced the Gadget abstraction, which describes
a rigid AST pattern that the analysis "fully understands" and may need
to fix. Which specific fix is actually necessary for a given Gadget,
and whether it's necessary at all, and whether it's possible in the first place,
depends on the Strategy. So, this patch adds a virtual method which every
gadget can implement in order to teach the analysis how to fix that gadget:
Gadget->getFixits(Strategy)
However, even if the analysis knows how to fix every Gadget, doesn't
necessarily mean it can fix the variable. Some uses of the variable may have
never been covered by Gadgets, which corresponds to the situation that
the analysis doesn't fully understand how the variable is used. This patch
introduces a Tracker class that tracks all variable uses (i.e. DeclRefExprs)
in the function. Additionally, each Gadget now provides a new virtual method
Gadget->getClaimedVarUseSites()
that the Tracker can call to see which DeclRefExprs are "claimed" by the Gadget.
In order to fix the variable with a certain Strategy, the Tracker needs to
confirm that there are no unclaimed uses, and every Gadget has to provide
a fix for that Strategy.
This "conservative" behavior guarantees that fixes emitted by our analysis
are correct by construction. We can now be sure that the analysis won't
attempt to emit a fix if it doesn't understand the code. Later, as we implement
more getFixits() methods in individual Gadget classes, we'll start
progressively emitting more and more fixits.
Differential Revision: https://reviews.llvm.org/D138253
Benoit Jacob [Thu, 15 Dec 2022 02:00:39 +0000 (02:00 +0000)]
Allow non-constant divisors in affine mod, floordiv, ceildiv.
The requirement that divisor>0 is not enforced here outside of the
constant case, but how to enforce it? If I understand correctly, it is
UB and while it is nice to be able to deterministically intercept UB,
that isn't always feasible. Hopefully, keeping the existing
enforcement in the constant case is enough.
Differential Revision: https://reviews.llvm.org/D140079
Roman Lebedev [Sat, 17 Dec 2022 02:13:30 +0000 (05:13 +0300)]
Reland "[SimplifyCFG] `FoldBranchToCommonDest()`: deal with mismatched IV's in PHI's in common successor block"
This reverts commit
37b8f09a4b61bf9bf9d0b9017d790c8b82be2e17,
and returns commit
1bd0b82e508d049efdb07f4f8a342f35818df341.
The miscompile was in InstCombine, and it has been addressed.
This tries to approach the problem noted by @arsenm:
terrible codegen for `__builtin_fpclassify()`:
https://godbolt.org/z/388zqdE37
Just because the PHI in the common successor happens to have different
incoming values for these two blocks, doesn't mean we have to give up.
It's quite easy to deal with this, we just need to produce a select:
https://alive2.llvm.org/ce/z/000srb
Now, the cost model for this transform is rather overly strict,
so this will basically never fire. We tally all (over all preds)
the selects needed to the NumBonusInsts
Differential Revision: https://reviews.llvm.org/D139275
Roman Lebedev [Sat, 17 Dec 2022 01:57:58 +0000 (04:57 +0300)]
[IR][PatternMatch] `m_Not`: do not apply inner matcher unless `Not` matched
This is consistent with how other commutative matchers operate,
and i assumed that is how this one worked, alas it did not,
and thus `foldNestedSelects()` was miscompiling stuff.
Roman Lebedev [Sat, 17 Dec 2022 01:20:28 +0000 (04:20 +0300)]
[NFC][InstCombine] Simplify miscompile testcase
Roman Lebedev [Fri, 16 Dec 2022 21:22:11 +0000 (00:22 +0300)]
[NFC][InstCombine] Add some readability by using `DecomposedSelect` struct
Peter Klausler [Sat, 17 Dec 2022 00:47:06 +0000 (16:47 -0800)]
[flang] Catch attempts to initialize allocatable components with DATA statement
Nice try, but no, you can't initialize an instance of a derived type using a
structure constructor that has a component corresponding to an allocatable
component.
Differential Revision: https://reviews.llvm.org/D140144