platform/upstream/llvm.git
19 months agoRevert "[APSInt] Fix bug in APSInt mentioned in https://github.com/llvm/llvm-project...
Peter Rong [Sun, 18 Dec 2022 22:01:08 +0000 (14:01 -0800)]
Revert "[APSInt] Fix bug in APSInt mentioned in https://github.com/llvm/llvm-project/issues/59515"

This reverts commit 7859d6e79ca90df2f3f206192a1dfa89e3cb10f1.

Signed-off-by: Peter Rong <PeterRong96@gmail.com>
19 months ago[gn] try porting 07af0e2d3e84 even more
Nico Weber [Sun, 18 Dec 2022 21:57:20 +0000 (16:57 -0500)]
[gn] try porting 07af0e2d3e84 even more

Possibly fixes tests on Linux. This corresponds to
`export_executable_symbols_for_plugins` calls in CMake.

19 months ago[APSInt] Fix bug in APSInt mentioned in https://github.com/llvm/llvm-project/issues...
Peter Rong [Wed, 14 Dec 2022 22:42:38 +0000 (14:42 -0800)]
[APSInt] Fix bug in APSInt mentioned in https://github.com/llvm/llvm-project/issues/59515

Also provide a `tryExtValue()` API like APInt did in D139683

Reviewed By: RKSimon

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

19 months ago[InstCombine] Try to fold `not` into `cmp` iff other users of `cmp` are freely invertible
Roman Lebedev [Sun, 18 Dec 2022 21:10:47 +0000 (00:10 +0300)]
[InstCombine] Try to fold `not` into `cmp` iff other users of `cmp` are freely invertible

There is still some such patterns that require collaboration
of folds to handle,that we don't currently do.

19 months ago[NFC][PatternMatching] Promote `m_LogicalOp` matchers into `PatternMatch.h`
Roman Lebedev [Sun, 18 Dec 2022 19:53:59 +0000 (22:53 +0300)]
[NFC][PatternMatching] Promote `m_LogicalOp` matchers into `PatternMatch.h`

19 months ago[MC] Use `MCRegister` instead of `unsigned` in `MCTargetAsmParser`
Sergei Barannikov [Sun, 18 Dec 2022 20:12:05 +0000 (12:12 -0800)]
[MC] Use `MCRegister` instead of `unsigned` in `MCTargetAsmParser`

Reviewed By: MaskRay

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

19 months ago[CMake] Fix LoongArchTests -DBUILD_SHARED_LIBS=on builds
Fangrui Song [Sun, 18 Dec 2022 20:07:43 +0000 (12:07 -0800)]
[CMake] Fix LoongArchTests -DBUILD_SHARED_LIBS=on builds

Similar to 1b9cd51d55b33cfaf68e21fa5396539ca54e5324

19 months agoRevert "[clang] Convert OptionalFileEntryRefDegradesToFileEntryPtr to std::optional"
Krzysztof Parzyszek [Sun, 18 Dec 2022 19:19:40 +0000 (11:19 -0800)]
Revert "[clang] Convert OptionalFileEntryRefDegradesToFileEntryPtr to std::optional"

This reverts commit 8f0df9f3bbc6d7f3d5cbfd955c5ee4404c53a75d.

The Optional*RefDegradesTo*EntryPtr types want to keep the same size as
the underlying type, which std::optional doesn't guarantee. For use with
llvm::Optional, they define their own storage class, and there is no way
to do that in std::optional.

On top of that, that commit broke builds with older GCCs, where
std::optional was not trivially copyable (static_assert in the clang
sources was failing).

19 months ago[libc++][CI] Fixes build failures.
Mark de Wever [Sun, 18 Dec 2022 17:58:28 +0000 (18:58 +0100)]
[libc++][CI] Fixes build failures.

Some clang diagnostics have changed causing build failures.

Reviewed By: #libc, Mordante

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

19 months ago[PoisonChecking] Add tests with selects.
Florian Hahn [Sun, 18 Dec 2022 18:51:15 +0000 (18:51 +0000)]
[PoisonChecking] Add tests with selects.

This adds test coverage for a suggestion in D111643.

19 months agoAMDGPU/GlobalISel: Use ptrtoint to legalize constant 32-bit addrspacecast
Matt Arsenault [Sun, 18 Dec 2022 18:00:24 +0000 (13:00 -0500)]
AMDGPU/GlobalISel: Use ptrtoint to legalize constant 32-bit addrspacecast

This was trying to merge 2 32-bit pointers into a 64-bit pointer. The
artifact combiner was assuming merges to pointers use scalar sources,
and ended up inserting invalid bitcast from a pointer to a scalar. It
should probably be a verifier error to have pointer merge sources with
a pointer result.

Fixes verifier errors with EXPENSIVE_CHECKS.

19 months agollvm-profgen: Fix use of stats to be under LLVM_ENABLE_STATS
David Blaikie [Sun, 18 Dec 2022 17:46:01 +0000 (17:46 +0000)]
llvm-profgen: Fix use of stats to be under LLVM_ENABLE_STATS

This caused a -Wunused-variable warning in a without-assert+with-stats
build (because the stats were included but their use was not).

Stat use is meant to be gated by LLVM_ENABLE_STATS which can be set
independently of assertions.

19 months ago[llvm-exegesis][X86] Explicitly not support `WRFSBASE` opcode.
Roman Lebedev [Sun, 18 Dec 2022 16:43:31 +0000 (19:43 +0300)]
[llvm-exegesis][X86] Explicitly not support `WRFSBASE` opcode.

We can't serialize if for latency measurements, and when measuring uops,
it crashes so hard even `CrashRecoveryContext` doesn't stop it.

Looks like *this* was the last crasher, now `--opcode-index=-1`
succeeds for all three benchmark modes here.
At least with Duplication repetitor.

19 months ago[NFC][llvm-exegesis] Improve `getOpcodesOrDie()`
Roman Lebedev [Sun, 18 Dec 2022 16:54:42 +0000 (19:54 +0300)]
[NFC][llvm-exegesis] Improve `getOpcodesOrDie()`

We already have opcode name -> opcode index map, use it.
Reserve memory where appropriate.

19 months ago[llvm-exegesis] Benchmark: gracefully handle lack of configurations to run
Roman Lebedev [Sun, 18 Dec 2022 16:39:45 +0000 (19:39 +0300)]
[llvm-exegesis] Benchmark: gracefully handle lack of configurations to run

Otherwise the progress meter would assert.

19 months ago[libc] Make string functions buildable with GCC
Guillaume Chatelet [Tue, 13 Dec 2022 15:47:26 +0000 (15:47 +0000)]
[libc] Make string functions buildable with GCC

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

19 months agoUse -Wstrict-prototypes with clang only
Guillaume Chatelet [Sun, 18 Dec 2022 14:54:21 +0000 (15:54 +0100)]
Use -Wstrict-prototypes with clang only

19 months ago[llvm-exegesis] Fix 'min' repetition mode in presence of missing measurements
Roman Lebedev [Sun, 18 Dec 2022 14:49:34 +0000 (17:49 +0300)]
[llvm-exegesis] Fix 'min' repetition mode in presence of missing measurements

This was a regression from 17e202424c021fd903950fec7a8b6cca2d83abce.
Previously we'd gracefully handle missing measurements,
but that handling got accidentally lost during the code move,
and we'd assert.

What we want to do, is to discard all measurements (from all repetitors
in a given config) if any of them failed, but do append the snippet,
and do emit the empty measurement.

19 months ago[NFC][llvm-exegesis] Benchmark: move DumpObjectToDisk handling into `runConfiguration()`
Roman Lebedev [Sun, 18 Dec 2022 14:36:32 +0000 (17:36 +0300)]
[NFC][llvm-exegesis] Benchmark: move DumpObjectToDisk handling into `runConfiguration()`

`getRunnableConfiguration()` may be executed in parallel,
and then this the output would become even less useful.

19 months ago[gn] port 7d2c1150d31b better
Nico Weber [Sun, 18 Dec 2022 14:07:53 +0000 (09:07 -0500)]
[gn] port 7d2c1150d31b better

19 months ago[mlir][Linalg] NFC - Add C++ builder to TileOp
Nicolas Vasilache [Sun, 18 Dec 2022 13:10:53 +0000 (05:10 -0800)]
[mlir][Linalg] NFC - Add C++ builder to TileOp

19 months ago[InstCombine] fold flooring sdiv by power-of-2 to ashr
Sanjay Patel [Sun, 18 Dec 2022 13:13:21 +0000 (08:13 -0500)]
[InstCombine] fold flooring sdiv by power-of-2 to ashr

It's a bigger match than usual, but I have not found any
sub-patterns that reduce:
(X / DivC) + sext ((X & (SMin | (DivC - 1)) >u SMin) --> X >>s log2(DivC)

https://alive2.llvm.org/ce/z/MJzlhl

Fixes issue #55741

19 months ago[InstCombine] add/adjust tests for flooring div; NFC
Sanjay Patel [Sun, 18 Dec 2022 13:04:15 +0000 (08:04 -0500)]
[InstCombine] add/adjust tests for flooring div; NFC

19 months agoAMDGPU/R600: Special case addrspacecast lowering for null
Matt Arsenault [Sat, 17 Dec 2022 21:49:04 +0000 (16:49 -0500)]
AMDGPU/R600: Special case addrspacecast lowering for null

Due to poor support for non-0 null pointers, clang always emits
addrspacecast from a null flat constant for private/local null. We can
trivially handle this case for old hardware.

Should fix issue 55679.

19 months agoAMDGPU: Lower addrspacecast on gfx6
Matt Arsenault [Sat, 17 Dec 2022 21:24:38 +0000 (16:24 -0500)]
AMDGPU: Lower addrspacecast on gfx6

Fixes inconsistent handling of constant-32bit case. Turns out we can
lower all the casts just fine, it's just accessing the flat results
that's a problem.

19 months ago[gn] port 7d2c1150d31bb
Nico Weber [Sun, 18 Dec 2022 12:39:49 +0000 (07:39 -0500)]
[gn] port 7d2c1150d31bb

19 months ago[gn build] Port rest of 07af0e2d3e84
Nico Weber [Sun, 18 Dec 2022 12:36:24 +0000 (07:36 -0500)]
[gn build] Port rest of 07af0e2d3e84

Test now passes, at least on macOS.

19 months ago[llvm-objdump][AArch64] Fix ADRP target label calculation
Kristina Bessonova [Sun, 18 Dec 2022 12:21:52 +0000 (14:21 +0200)]
[llvm-objdump][AArch64] Fix ADRP target label calculation

This patch makes ADRP target label address calculations the same as
label address calculations (see AArch64InstPrinter::printAdrpLabel()).

Otherwise the target label looks misleading as ADRP's immediate offset is,
actually, not an offset to this PC, but an offset to the current PC's
page address in pages.

See for example, `llvm-objdump/ELF/AArch64/pcrel-address.yaml`.
Before this patch the target label `<_start+0x80>` represents the
address `0x200100 + 0x80` while `0x220000` is expected.

Note that with this patch llvm-objdump output matches GNU objdump.

Reviewed By: simon_tatham

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

19 months ago[gn build] Port some of 07af0e2d3e84
Nico Weber [Sun, 18 Dec 2022 12:15:02 +0000 (07:15 -0500)]
[gn build] Port some of 07af0e2d3e84

Enough to get the build fixed, but doesn't add the plugin yet, so the test
fails for now.

19 months ago[gn] port ae3e228af7
Nico Weber [Sun, 18 Dec 2022 12:14:16 +0000 (07:14 -0500)]
[gn] port ae3e228af7

19 months ago[InstCombine] canonicalize insertelement order based on index
Sanjay Patel [Sun, 18 Dec 2022 11:55:37 +0000 (06:55 -0500)]
[InstCombine] canonicalize insertelement order based on index

This puts lower insert indexes before higher. This is independent
of endian, so it requires an adjustment to a fold added with
4446f71ce392, but it makes that fold more robust.
That's also where this patch was suggested - D139668.

This matches what we already do in DAGCombiner, but there is one
more constraint because there's an existing canonicalization for
insert-of-scalar-constant. I'm not sure if that is still needed,
so it may be adjusted/removed as a follow-up.

19 months ago[InstCombine] add tests for flooring division; NFC
Sanjay Patel [Sun, 18 Dec 2022 11:48:09 +0000 (06:48 -0500)]
[InstCombine] add tests for flooring division; NFC

issue #57741

19 months ago[InstCombine] avoid IR values named 'tmp' in tests; NFC
Sanjay Patel [Thu, 15 Dec 2022 21:32:52 +0000 (16:32 -0500)]
[InstCombine] avoid IR values named 'tmp' in tests; NFC

The auto-generation CHECK script warns of possible conflict on these files.

19 months ago[InlineAdvisor] Fix dependencies for InlineAdvisorPlugin
ibricchi [Sun, 18 Dec 2022 09:20:24 +0000 (01:20 -0800)]
[InlineAdvisor] Fix dependencies for InlineAdvisorPlugin

Reviewed By: akyrtzi

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

19 months ago[C++20][Modules] Elide unused guard variables in Itanium ABI module initializers.
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

19 months agoInclude <optional> instead of "llvm/ADT/Optional.h"
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

19 months ago[AAPointerInfo] handle multiple offsets in PHI
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

19 months agoReland 3nd attempt: [lld-macho] Fix bug in reading cpuSubType field.
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

19 months ago[mlir] Add an overload of parseOptionalAttribute for SymbolRefAttr
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.

19 months ago[Attributor][FIX] Ensure to delete all AAs
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.

19 months ago[AArch64][SVE] Allow to lower WHILEop with constant operands to PTRUE
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

19 months ago[flang] Fix crash in name resolution
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

19 months ago[NFC][llvm-exegesis] Extract `runBenchmarkConfigurations()` out of `benchmarkMain()`
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.

19 months ago[NFC][llvm-exegesis] `BenchmarkRunner`: split `runConfiguration()` into `getRunnableC...
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.

19 months ago[NFC][llvm-exegesis] `InstructionBenchmark`: only allow move constructor
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

19 months ago[lldb] Remove redundant .c_str() and .get() calls
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.

19 months ago[llvm-exegesis] Unbreak `--benchmarks-file=<f>`
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...

19 months agoRemove redundant .c_str() and .get() calls
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

19 months agocmake: Enable 64bit off_t on 32bit glibc systems
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

19 months ago[flang] Check constant arguments to bit manipulation intrinsics even if not foldable
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

19 months ago[clang] Convert OptionalFileEntryRefDegradesToFileEntryPtr to std::optional
Krzysztof Parzyszek [Sat, 17 Dec 2022 21:57:30 +0000 (13:57 -0800)]
[clang] Convert OptionalFileEntryRefDegradesToFileEntryPtr to std::optional

19 months ago[llvm][ADT] Allow returning `std::nullopt` in TypeSwitch
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

19 months agoOptional: Deprecated value()
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.

19 months agoOptional: Avoid value() uses
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.

19 months ago[flang] llvm::Optional::value() => => operator*/operator->
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.

19 months ago[X86] SandyBridge - fix ADC RMW uop count
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

19 months ago[flang] Fixed buildbot failured after D140236.
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

19 months agoprecommit APSInt format for D140059
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>
19 months ago[NFC][CMake] Fix AnalysisTests build after 07af0e2d3e8485ad6f84da1ad9851538b62d2942
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.

19 months ago[X86] Fix BMI uop/throughputs on znver1/znver2
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

19 months ago[lldb] llvm::Optional::value() && => operator*/operator->
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.

19 months ago[NFC][flang] Removed pgmath handling from lowering.
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

19 months ago[NFCI][llvm-exegesis] `BenchmarkRunner::runConfiguration()`: extract `assembleSnippet...
Roman Lebedev [Sat, 17 Dec 2022 20:07:45 +0000 (23:07 +0300)]
[NFCI][llvm-exegesis] `BenchmarkRunner::runConfiguration()`: extract `assembleSnippet()` helper

19 months ago[NFC][llvm-exegesis] `BenchmarkRunner::runConfiguration()`: deduplicate `DumpObjectTo...
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.

19 months ago[NFC][llvm-exegesis] `BenchmarkRunner::runConfiguration()`: reformat
Roman Lebedev [Sat, 17 Dec 2022 17:51:37 +0000 (20:51 +0300)]
[NFC][llvm-exegesis] `BenchmarkRunner::runConfiguration()`: reformat

19 months ago[NFCI][llvm-exegesis] Extract 'Min' repetition handling from `BenchmarkRunner` into...
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.

19 months ago[clang-tools-extra] llvm::Optional::value => operator*/operator->
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.

19 months ago[clang] llvm::Optional::value() && => operator*/operator->
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.

19 months ago[mlir] llvm::Optional::value() && => operator*/operator->
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.

19 months ago[mlir] llvm::Optional::value => operator*/operator->
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.

19 months ago[flang] Check for another case of ambiguous generic resolution
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

19 months agoReapply "[InlineAdvisor] Allow loading advisors as plugins"
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.

19 months ago[flang] Check C854, C855, & C856 on PROTECTED entities
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

19 months ago[flang] Apply definability checks in ALLOCATE/DEALLOCATE statements
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

19 months agoFix unused variable warnings in SIFrameLowering.cpp for release build, NFC
Haojian Wu [Sat, 17 Dec 2022 17:22:18 +0000 (18:22 +0100)]
Fix unused variable warnings in SIFrameLowering.cpp for release build, NFC

19 months agoUpdate the bazel's llvm-config.h.cmake file
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.

19 months ago[flang] Enforce C1529 as a warning, C919 as an error
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

19 months agoFix unused variable warning in release build, NFC.
Haojian Wu [Sat, 17 Dec 2022 17:04:28 +0000 (18:04 +0100)]
Fix unused variable warning in release build, NFC.

19 months ago[X86] All the WriteBLS instructions take 2uops, not 1uop
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

19 months ago[AggressiveInstCombine] Fix invalid TypeSize conversion when combining loads.
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

19 months ago[flang] Impose DATA initialization size limit to avoid crashing
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

19 months ago[dsymutil] fix accidental 32bit truncation in patchFrameInfoForObject
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

19 months agoRevert "Reland 2nd attempt: [lld-macho] Fix bug in reading cpuSubType field."
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

19 months ago[NFC][llvm-exegesis] LLVMState: only store references to reg/op names
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.

19 months ago[llvm-exegesis][X86] Use the same AGU counter estimate mapping for znver1 as znver2...
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

19 months ago[NFC][InstCombine] Move nested-select testcase into proper place, adjust comment
Roman Lebedev [Sat, 17 Dec 2022 13:38:24 +0000 (16:38 +0300)]
[NFC][InstCombine] Move nested-select testcase into proper place, adjust comment

19 months ago[libc++][format] Renames __null_sentinel.
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

19 months ago[X86] AMD Zen 4 Initial enablement
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

19 months agomlir/tblgen: use std::optional in generation
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

19 months agoRevert "[RISCV] Support the short-forward-branch predicatd ops in RISCVSExtWRemoval."
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.

19 months ago[clang] llvm::Optional::value => operator*/operator->
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.

19 months agoEnsure newlines at the end of files (NFC)
Kazu Hirata [Sat, 17 Dec 2022 07:36:51 +0000 (23:36 -0800)]
Ensure newlines at the end of files (NFC)

19 months ago[RISCV] Support the short-forward-branch predicatd ops in RISCVSExtWRemoval.
Craig Topper [Sat, 17 Dec 2022 07:25:20 +0000 (23:25 -0800)]
[RISCV] Support the short-forward-branch predicatd ops in RISCVSExtWRemoval.

19 months ago[BinaryFormat] Use std::optional instead of llvm::Optional (NFC)
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

19 months ago[MLIR] Enhance getLargestKnownDivisor for AffineExpr floordiv/ceildiv
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

19 months ago[NVPTX] Use std::optional instead of llvm::Optional (NFC)
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

19 months ago[RISCV] Add support for predicating AND/OR/XOR/ADD/SUB with short-forward-branch...
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

19 months ago[M68k] Fix spillCalleeSavedRegisters after D138656
Fangrui Song [Sat, 17 Dec 2022 06:51:04 +0000 (06:51 +0000)]
[M68k] Fix spillCalleeSavedRegisters after D138656

19 months agollvm::Optional::value => operator*/operator->
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.

19 months ago[AMDGPU][SILowerSGPRSpills] Spill SGPRs to virtual VGPRs
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