platform/upstream/llvm.git
19 months agoRevert "[AArch64][compiler-rt] Fix HWCAP_CPUID not defined in some cases."
Mitch Phillips [Wed, 21 Dec 2022 01:15:38 +0000 (17:15 -0800)]
Revert "[AArch64][compiler-rt] Fix HWCAP_CPUID not defined in some cases."

This reverts commit a43f36142c501e2d3f4797ef938db4e0c5e0eeec.

Reason: Depends on reverted change https://reviews.llvm.org/D127812

19 months ago[mlir][sparse] refactored codegen environment into its own file
Aart Bik [Tue, 20 Dec 2022 23:42:11 +0000 (15:42 -0800)]
[mlir][sparse] refactored codegen environment into its own file

Also, as a proof of concept, all functionality related to reductions
has been refactored into private fields and a clean public API. As a
result, some dead code was found as well. This approach also simplifies
asserting on a proper environment state for each call.

NOTE: making all other fields private and migrating more methods into
      this new class is still TBD in yes another next revision!

Reviewed By: Peiming

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

19 months ago[clang] Re-apply change to avoid passing -stdlib=libc++ spuriously to CC1 on Darwin
Louis Dionne [Tue, 20 Dec 2022 23:04:53 +0000 (18:04 -0500)]
[clang] Re-apply change to avoid passing -stdlib=libc++ spuriously to CC1 on Darwin

Previously, we would be passing down -stdlib=libc++ from the Driver
to CC1 whenever the default standard library on the platform was libc++,
even if -stdlib= had not been passed to the Driver. This meant that we
would pass -stdlib=libc++ in nonsensical circumstances, such as when
compiling C code.

This logic had been added in b534ce46bd40 to make sure that header
search paths were set up properly. However, since libc++ is now the
default Standard Library on Darwin, passing this explicitly is not
required anymore. Indeed, if no -stdlib= is specified, CC1 will end
up using libc++ if it queries which standard library to use, without
having to be told.

Not passing -stdlib= at all to CC1 on Darwin should become possible
once CC1 stops relying on it to set up framework search paths.

Furthermore, this commit also removes a diagnostic checking whether the
deployment target is too old to support libc++. Nowadays, all supported
deployment targets use libc++ and compiling with libstdc++ is not
supported anymore. The Driver was the wrong place to issue this
diagnostic since it doesn't know whether libc++ will actually be linked
against (e.g. C vs C++), which would lead to spurious diagnostics.
Given that these targets are not supported anymore, we simply drop
the diagnostic instead of trying to refactor it into CC1.

This is a re-application of 6540f32db09c which had been reverted in
49dd02bd0819 because it broke a compiler-rt test. The test had broken
because we were compiling C code and passing -stdlib=libc++, which Clang
will now warn about.

rdar://103198514

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

19 months ago[mlir][sparse] introduce LevelFormat which do not encoding level properties of a...
Peiming Liu [Tue, 20 Dec 2022 23:49:17 +0000 (23:49 +0000)]
[mlir][sparse] introduce LevelFormat which do not encoding level properties of a sparse tensor level.

Reviewed By: aartbik, wrengr

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

19 months ago[NFC][llvm-exegesis] Ensure that target options show up in --help
Roman Lebedev [Wed, 21 Dec 2022 00:38:10 +0000 (03:38 +0300)]
[NFC][llvm-exegesis] Ensure that target options show up in --help

Fixes https://github.com/llvm/llvm-project/issues/59377

19 months ago[-Wunsafe-buffer-usage] Suppress an assertion for visiting VarDecl twice.
Artem Dergachev [Tue, 20 Dec 2022 22:58:35 +0000 (14:58 -0800)]
[-Wunsafe-buffer-usage] Suppress an assertion for visiting VarDecl twice.

The assertion doesn't seem to hold due to ASTMatchers traversing code
inside GNU StmtExpr twice. This can screw up our algorithm's invariants.
We need a further investigation to properly fix this issue, but for now
let's avoid the crash.

19 months agollvm-reduce: Disable crash reports, symbolization and core dumps
Matt Arsenault [Tue, 20 Dec 2022 12:32:55 +0000 (07:32 -0500)]
llvm-reduce: Disable crash reports, symbolization and core dumps

These are going to waste a lot of time and produce clutter when we're
bulk introducing crashes. Add a flag to disable this behavior in case
this matters to a reproducer.

19 months ago[BOLT][NFC] Remove unused PrintInstructions argument
Maksim Panchenko [Tue, 20 Dec 2022 23:16:32 +0000 (15:16 -0800)]
[BOLT][NFC] Remove unused PrintInstructions argument

PrintInstructions was unused in BinaryFunction::print() and dump().

Reviewed By: Amir

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

19 months ago[llvm] Remove redundant initialization of std::optional (NFC)
Kazu Hirata [Tue, 20 Dec 2022 23:53:38 +0000 (15:53 -0800)]
[llvm] Remove redundant initialization of std::optional (NFC)

19 months ago[llvm] Use std::optional instead of Optional
Kazu Hirata [Tue, 20 Dec 2022 23:42:32 +0000 (15:42 -0800)]
[llvm] Use std::optional instead of Optional

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[dsymutil] Require x86 backend for odr-two-units-in-single-file.test
Jonas Devlieghere [Tue, 20 Dec 2022 23:35:54 +0000 (15:35 -0800)]
[dsymutil] Require x86 backend for odr-two-units-in-single-file.test

19 months ago[libc][Obvious] Remove the unused cpp::vector class.
Siva Chandra Reddy [Tue, 20 Dec 2022 23:21:56 +0000 (23:21 +0000)]
[libc][Obvious] Remove the unused cpp::vector class.

This can be easily resurrected if required in future. It calls malloc
directly. So, instead of updating an unused piece to the newer pattern
of using the custom operator new, this patch just deletes it.

19 months ago[ADT] Fix an unused variable warning
Kazu Hirata [Tue, 20 Dec 2022 23:02:48 +0000 (15:02 -0800)]
[ADT] Fix an unused variable warning

This patch fixes:

  llvm/include/llvm/ADT/GenericUniformityImpl.h:752:8: error: unused
  variable 'printBlockSet' [-Werror,-Wunused-variable]

19 months ago[llvm-exegesis] `AliasingConfigurations`: pay attention to forbidden registers
Roman Lebedev [Tue, 20 Dec 2022 20:57:10 +0000 (23:57 +0300)]
[llvm-exegesis] `AliasingConfigurations`: pay attention to forbidden registers

When trying to measure latency of certain opcodes, e.g.
`./bin/llvm-exegesis --opcode-name=BT32ri8 --mode=latency --repetition-mode=loop  --benchmarks-file=- --max-configs-per-opcode=65536`,
we'd pick such an aliasing instruction, and such an aliasing registers,
that would alias with forbidden registers.

And in particular with loop counter in `loop` repetition mode,
which made the measurements never finish.
This does not address all such cases, only the most obvious one.

The added test case fails without the patch.

Fixes https://github.com/llvm/llvm-project/issues/59441

19 months ago[AArch64][NFC] Fix aarch64 target features test.
Pavel Iliin [Tue, 20 Dec 2022 22:26:48 +0000 (22:26 +0000)]
[AArch64][NFC] Fix aarch64 target features test.

19 months ago[llvm][X86ISelDAGToDAG] support -{start|stop}-{before|after}=x86-isel
Nick Desaulniers [Tue, 20 Dec 2022 22:08:37 +0000 (14:08 -0800)]
[llvm][X86ISelDAGToDAG] support -{start|stop}-{before|after}=x86-isel

Follow a similar pattern as AMDGPUDAGToDAGISel's constructor so that we
can use INITIALIZE_PASS to register a pass. This allows for more fine
grain testability of SelectionDAGISel.

Link: https://github.com/llvm/llvm-project/issues/59538
Reviewed By: craig.topper

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

19 months agoInstCombine: Fold fneg (copysign x, y) -> copysign x, (fneg y)
Matt Arsenault [Tue, 6 Dec 2022 13:05:54 +0000 (08:05 -0500)]
InstCombine: Fold fneg (copysign x, y) -> copysign x, (fneg y)

19 months ago[llvm][PassSupport] don't require passes to be default constructible
Nick Desaulniers [Tue, 20 Dec 2022 22:00:51 +0000 (14:00 -0800)]
[llvm][PassSupport] don't require passes to be default constructible

Quite a few passes are not default constructible. In order to properly
support -{start|stop}-{before|after}= for these passes, we would like to
continue to use INITIALIZE_PASS, but not necessarily provide a default
constructor.

Delete the default constructors of classes derived from
SelectionDAGISel.

Link: https://github.com/llvm/llvm-project/issues/59538
Reviewed By: efriedma

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

19 months ago[bazel] Add missing Passes dependency to llvm-extract
Haojian Wu [Tue, 20 Dec 2022 21:27:10 +0000 (22:27 +0100)]
[bazel] Add missing Passes dependency to llvm-extract

19 months ago[llvm-extract] Add missing IRPrinter dependency
Arthur Eubanks [Tue, 20 Dec 2022 21:12:53 +0000 (13:12 -0800)]
[llvm-extract] Add missing IRPrinter dependency

19 months ago[PowerPC][NFC] Update p10 scheduler
Lei Huang [Tue, 20 Dec 2022 20:57:26 +0000 (14:57 -0600)]
[PowerPC][NFC] Update p10 scheduler

19 months ago[llvm-extract] Use new pass manager instead of legacy pass manager
Arthur Eubanks [Tue, 20 Dec 2022 20:55:05 +0000 (12:55 -0800)]
[llvm-extract] Use new pass manager instead of legacy pass manager

Removes some legacy passes specific to llvm-extract

19 months ago[dsymutil] Verify the keep chain when asserts are enabled
Jonas Devlieghere [Tue, 20 Dec 2022 20:48:00 +0000 (12:48 -0800)]
[dsymutil] Verify the keep chain when asserts are enabled

Verify that every DIE that's marked as kept, has a parent that's kept as
well. This invariant should always hold and is easy to verify when
asserts are enabled.

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

19 months ago[dsymutil] Track uncloned references in the DIEInfo.
Jonas Devlieghere [Tue, 20 Dec 2022 19:28:57 +0000 (11:28 -0800)]
[dsymutil] Track uncloned references in the DIEInfo.

To improve deduplication across CUs within a single object file,
2b747241a6a0 changed the way we track ODR canonical candidates. The
result is that some assumptions no longer hold. Because of the
aforementioned change, the following condition

  assert(Ref > InputDIE.getOffset());

in DWARFLinker::DIECloner::cloneDieReferenceAttribute is no longer an
invariant. An example of a situation where this assertion no longer
holds is when we have decided to replace a backward reference in the
current CU with a forward reference in a subsequent CU. The ODR
canonical DIE hasn't been emitted yet, but the references DIE has an
offset smaller than the current DIE. The assertion is only true if the
referenced DIE was the ODR canonical DIE, which is no longer guaranteed
to be part of the same CU.

Big thanks to Alexey for putting a test together.

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

19 months ago[libc++] Granularize <type_traits> includes in <concepts>
Nikolas Klauser [Tue, 20 Dec 2022 17:01:34 +0000 (18:01 +0100)]
[libc++] Granularize <type_traits> includes in <concepts>

Reviewed By: ldionne, Mordante, #libc

Spies: jloser, libcxx-commits

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

19 months ago[RISCV] Move -riscv-v-vector-bits-max/min options to RISCVTargetMachine.
Craig Topper [Tue, 20 Dec 2022 19:52:52 +0000 (11:52 -0800)]
[RISCV] Move -riscv-v-vector-bits-max/min options to RISCVTargetMachine.

Split from D139873.

Reviewed By: reames, kito-cheng

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

19 months ago[BuildLibCalls][RISCV] Sign extend return value of bcmp on riscv64.
Craig Topper [Tue, 20 Dec 2022 19:37:51 +0000 (11:37 -0800)]
[BuildLibCalls][RISCV] Sign extend return value of bcmp on riscv64.

riscv64 wants callees to sign extend signed and unsigned int returns.

The caller can use this to avoid a sign extend if the result is
used by a comparison since riscv64 only has 64-bit compares.

InstCombine/SimplifyLibCalls aggressively turn memcmps that are only
used by an icmp eq 0 into bcmp, but we lose the signext attribute that
would have been present on the memcmp. This causes an unneeded sext.w
in the generated assembly.

This looks even sillier if bcmp is implemented alias to memcmp. In
that case, not only did we not get any savings by using bcmp, we added
an instruction.

This probably applies to other functions, this just happens to be
the one I noticed so far.

See also the discussion here https://discourse.llvm.org/t/can-we-preserve-signext-return-attribute-when-converting-memcmp-to-bcmp/67126

Reviewed By: efriedma

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

19 months ago[libc] Add a baremetal config.
Siva Chandra Reddy [Tue, 20 Dec 2022 07:11:55 +0000 (07:11 +0000)]
[libc] Add a baremetal config.

The config currently includes ctype, math, stdlib, inttypes and string
functions.

Reviewed By: lntue

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

19 months ago[OpenMP] Fix leftover use of removed function
Joseph Huber [Tue, 20 Dec 2022 19:42:18 +0000 (13:42 -0600)]
[OpenMP] Fix leftover use of removed function

Summary:
Didn't notice this one floating around as it was still cached somewhere.
Delete it.

19 months ago[OpenMP] Disable libomptarget integration on unsupported platforms
Guilherme Valarini [Tue, 20 Dec 2022 19:41:26 +0000 (16:41 -0300)]
[OpenMP] Disable libomptarget integration on unsupported platforms

Reviewed By: jhuber6

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

19 months ago[OpenMP][NFC] Fix message to recommend C++17 instead of C++14
Joseph Huber [Tue, 20 Dec 2022 19:39:44 +0000 (13:39 -0600)]
[OpenMP][NFC] Fix message to recommend C++17 instead of C++14

Summary:
This was changed in LLVM 16.0.

19 months ago[OpenMP] Remove folding logic for removed runtime function
Joseph Huber [Tue, 20 Dec 2022 15:50:27 +0000 (09:50 -0600)]
[OpenMP] Remove folding logic for removed runtime function

This function was removed from the device runtime at some point but we
still have specialized code for it and an entry in the runtime kinds.
Remove it as it is no longer necessary.

Reviewed By: tianshilei1992

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

19 months ago[libc] Add check for locally installed GPUs
Joseph Huber [Tue, 20 Dec 2022 19:06:40 +0000 (13:06 -0600)]
[libc] Add check for locally installed GPUs

We need to know which, if any, GPUs the user has on their system if we
want to be able to test the `libc` source code for the GPU. This patch
adds a basic check using the `amdgpu-arch` utility which is provided by
`clang`.

Checking for NVIDIA GPUs will be done later as this is a little
problematic right now. CMake provides a method that we use for Clang but
it will soon be deprecated, the replacement requires a newer CMake
version that we will have in the LLVM 17 branch in the future. CUDA also
provides `__nvcc_device_query` but it's very new so I'm not sure if we
should rely on it. I may introduce a new tool to do it similar to
`amdgpu-arch`.

Reviewed By: sivachandra

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

19 months ago[RISCV] Add more XVentanaCondOps tests with icmp conditions. NFC
Craig Topper [Tue, 20 Dec 2022 19:36:28 +0000 (11:36 -0800)]
[RISCV] Add more XVentanaCondOps tests with icmp conditions. NFC

Most of our existing tests use i1 arguments for the conditions.
With icmp conditions there are opportunities for improving the
generated code.

Reviewed By: reames

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

19 months ago[mlir][sparse] factorized merger/emitter/codegen into single environment
Aart Bik [Tue, 20 Dec 2022 02:43:49 +0000 (18:43 -0800)]
[mlir][sparse] factorized merger/emitter/codegen into single environment

This cleans up a lot of parameter passing. It also prepares adding
proper "delegate" functions to the new environment and moving this
out into its own class with a better OO design.

Reviewed By: Peiming

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

19 months agoRevert "[Bazel] Remove define HAVE_LSEEK64 to match cmake config."
Benjamin Kramer [Tue, 20 Dec 2022 19:33:20 +0000 (20:33 +0100)]
Revert "[Bazel] Remove define HAVE_LSEEK64 to match cmake config."

This reverts commit 5d65f8a7931c160fe5a11c120796779ba59789b9. Dependent
commit ae3e228af7 was reverted in f31a36e7767e.

19 months ago[AArch64][compiler-rt] Fix HWCAP_CPUID not defined in some cases.
Pavel Iliin [Tue, 20 Dec 2022 19:06:09 +0000 (19:06 +0000)]
[AArch64][compiler-rt] Fix HWCAP_CPUID not defined in some cases.

Define HWCAP_CPUID to fix commit e43924a75145d2f9e722f74b673145c3e62bfd07.

19 months ago[libc][NFC] Simplify how the definiton of NULL macro is added to string.h.
Siva Chandra Reddy [Tue, 20 Dec 2022 08:59:54 +0000 (08:59 +0000)]
[libc][NFC] Simplify how the definiton of NULL macro is added to string.h.

We do not list macro definitions in api.td files anymore. Not all macros
definitions have been moved out. This change moves the definition of the
NULL macro out.

Reviewed By: lntue, jhuber6

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

19 months ago[bazel] add TargetParser
Mikhail Goncharov [Tue, 20 Dec 2022 19:09:00 +0000 (20:09 +0100)]
[bazel] add TargetParser

19 months ago[libc] Simplify generation of errno.h.
Siva Chandra Reddy [Tue, 20 Dec 2022 08:45:50 +0000 (08:45 +0000)]
[libc] Simplify generation of errno.h.

Reviewed By: lntue

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

19 months ago[CMake] Depend on TargetParser after f09cf34d00625e57dea5317a3ac0412c07292148
Fangrui Song [Tue, 20 Dec 2022 18:50:09 +0000 (10:50 -0800)]
[CMake] Depend on TargetParser after f09cf34d00625e57dea5317a3ac0412c07292148

19 months ago[libc] add fuzz target for strtointeger functions
Michael Jones [Fri, 16 Dec 2022 00:36:59 +0000 (16:36 -0800)]
[libc] add fuzz target for strtointeger functions

The string to integer conversion functions are well suited to
differential fuzzing, and this patch adds a target to enable just that.
It also fixes a bug in the fuzzing comparison logic and changes atoi
slightly to match the behavior described in the C standard.

Reviewed By: sivachandra, lntue

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

19 months ago[TEST] Pre-commit test for GVN PRE load
Guozhi Wei [Tue, 20 Dec 2022 18:43:31 +0000 (18:43 +0000)]
[TEST] Pre-commit test for GVN PRE load

This is a test case for D139582.

In this test case, %v4 and %v5 can be moved to predecessors, %v3 can be changed to a PHI instruction.

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

19 months agoRevert "[gn] port ae3e228af7"
Nico Weber [Tue, 20 Dec 2022 18:31:37 +0000 (13:31 -0500)]
Revert "[gn] port ae3e228af7"

This reverts commit b65fbf821a5f4dada7018068b93d4a1ae7c068ff.
ae3e228af7 was reverted in f31a36e7767e.

19 months agoFix module build after TargetParser
Steven Wu [Tue, 20 Dec 2022 18:27:50 +0000 (10:27 -0800)]
Fix module build after TargetParser

Need to include the textual header from the correct module.

19 months ago[bazel] Port TargetParser f09cf34d00625e57dea5317a3ac0412c07292148
Fangrui Song [Tue, 20 Dec 2022 18:30:05 +0000 (10:30 -0800)]
[bazel] Port TargetParser f09cf34d00625e57dea5317a3ac0412c07292148

Moving files into a new target :TargetParser is left as an exercise.

19 months agoValueTracking: Document some difficult isKnownNeverInfinity cases
Matt Arsenault [Sun, 4 Dec 2022 15:18:59 +0000 (10:18 -0500)]
ValueTracking: Document some difficult isKnownNeverInfinity cases

Add a comment and some negative tests. I'd like to have test coverage
and explicit handling of all the math operations for clarity.

19 months ago[libc][NFC] make atoi undefined cases match std
Michael Jones [Mon, 19 Dec 2022 21:35:45 +0000 (13:35 -0800)]
[libc][NFC] make atoi undefined cases match std

The standard describes atoi as:

"equivalent to atoi: (int)strtol(nptr, (char **)NULL, 10)"

Previously, our behavior was slightly different on numbers larger than
INT_MAX, but this patch changes it to just do the cast instead. Both of
these are valid since the standard says

"If the value of the result cannot be represented, the
behavior is undefined."

But matching existing behavior makes differential fuzzing easier.

Reviewed By: sivachandra

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

19 months agoValueTracking: Add tests for isKnownNeverInfinity for llvm.log*
Matt Arsenault [Sun, 4 Dec 2022 15:08:49 +0000 (10:08 -0500)]
ValueTracking: Add tests for isKnownNeverInfinity for llvm.log*

19 months agoValueTracking: Teach isKnownNeverInfinity about llvm.sin/llvm.cos
Matt Arsenault [Sun, 4 Dec 2022 14:42:17 +0000 (09:42 -0500)]
ValueTracking: Teach isKnownNeverInfinity about llvm.sin/llvm.cos

19 months agoValueTracking: Add isKnownNeverInfinity tests for sin/cos
Matt Arsenault [Sun, 4 Dec 2022 14:40:29 +0000 (09:40 -0500)]
ValueTracking: Add isKnownNeverInfinity tests for sin/cos

19 months ago[OpenMP] Clang Support for taskwait nowait clause
Sunil Kuravinakop [Tue, 20 Dec 2022 18:13:26 +0000 (12:13 -0600)]
[OpenMP] Clang Support for taskwait nowait clause

Support for taskwait nowait clause with placeholder for runtime changes.

Reviewed By: cchen, ABataev

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

19 months ago[lldb] Prevent false positives with simple template names in SymbolFileDWARF::FindTypes
Arthur Eubanks [Fri, 16 Dec 2022 19:48:21 +0000 (11:48 -0800)]
[lldb] Prevent false positives with simple template names in SymbolFileDWARF::FindTypes

The provided test case was crashing because of confusion attempting to find types for `ns::Foo` under -gsimple-template-names. (This looks broken normally because it's attempting to find `ns::Foo` rather than `ns::Foo<T>`)

Looking up types can't give false positives, as opposed to looking up functions as mentioned in https://reviews.llvm.org/D137098.

Reviewed By: Michael137

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

19 months agoAdd missing textual header to module map
Adrian Prantl [Tue, 20 Dec 2022 18:05:40 +0000 (10:05 -0800)]
Add missing textual header to module map

19 months agoValueTracking: Teach isKnownNeverInfinity about sqrt
Matt Arsenault [Sun, 4 Dec 2022 14:26:16 +0000 (09:26 -0500)]
ValueTracking: Teach isKnownNeverInfinity about sqrt

19 months agoValueTracking: Add base test for isKnownNeverInfinity of sqrt
Matt Arsenault [Sun, 4 Dec 2022 14:35:55 +0000 (09:35 -0500)]
ValueTracking: Add base test for isKnownNeverInfinity of sqrt

19 months agollvm-reduce: Fix build
Matt Arsenault [Tue, 20 Dec 2022 18:02:07 +0000 (13:02 -0500)]
llvm-reduce: Fix build

Fix build after e49f8eef41d58a9b55cb4347826d353ecf170f8b

19 months agoFix modules build after D137838
Adrian Prantl [Tue, 20 Dec 2022 17:59:05 +0000 (09:59 -0800)]
Fix modules build after D137838

19 months ago[DebugInfo] Unify location selection logic for values in InstrRefBasedImpl
Stephen Tozer [Tue, 20 Dec 2022 14:52:11 +0000 (14:52 +0000)]
[DebugInfo] Unify location selection logic for values in InstrRefBasedImpl

Currently the instruction referencing live debug values has 3 separate
places where we iterate over all known locations to find the best machine
location for a set of values at a given point in the program. Each of these
places has an implementation of this check, and one of them has slightly
different logic to the others. This patch moves the check for the "quality"
of a machine location into a separate function, which also avoids repeatedly
calling expensive functions, giving a slight performance improvement.

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

19 months agoValueTracking: Teach isKnownNeverInfinity about min/max functions
Matt Arsenault [Sun, 4 Dec 2022 14:18:49 +0000 (09:18 -0500)]
ValueTracking: Teach isKnownNeverInfinity about min/max functions

19 months agoValueTracking: Add tests for isKnownNeverInfinity for min/max intrinsics
Matt Arsenault [Sun, 4 Dec 2022 14:29:12 +0000 (09:29 -0500)]
ValueTracking: Add tests for isKnownNeverInfinity for min/max intrinsics

19 months agoRevert D139752 "cmake: Enable 64bit off_t on 32bit glibc systems"
Fangrui Song [Tue, 20 Dec 2022 17:45:28 +0000 (09:45 -0800)]
Revert D139752 "cmake: Enable 64bit off_t on 32bit glibc systems"

This reverts commit ae3e228af77fea9ff4c45cca88a7a0de2cad662b.

Seems that it may form a wrong command line for 32-bit Halide builds

`-D_FILE_OFFSET_BITS="64 -D_DEBUG -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DSTDC_CONSTANT_MACROS -DSTDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"` according to

19 months agoValueTracking: Teach isKnownNeverInfinity about rounding intrinsics
Matt Arsenault [Sun, 4 Dec 2022 13:29:17 +0000 (08:29 -0500)]
ValueTracking: Teach isKnownNeverInfinity about rounding intrinsics

19 months agoValueTracking: Add tests for isKnownNeverInfinity for rounding intrinsics
Matt Arsenault [Sun, 4 Dec 2022 14:04:07 +0000 (09:04 -0500)]
ValueTracking: Add tests for isKnownNeverInfinity for rounding intrinsics

19 months ago[NFC][llvm-reduce] Do show `-ir-passes` in help
Roman Lebedev [Tue, 20 Dec 2022 17:35:08 +0000 (20:35 +0300)]
[NFC][llvm-reduce] Do show `-ir-passes` in help

It's a bit non-useful when llvm-reduce runs a pass,
a testcase for a crash in which is being reduced in the first place :)

19 months ago[scudo][standalone] Precommit pages
Yaneury Fermin [Tue, 20 Dec 2022 17:37:48 +0000 (17:37 +0000)]
[scudo][standalone] Precommit pages

On Fuchsia, this CL changes garbage collection
to precommit all pages if the |Buffer| doesn't
fit into the static buffer size.

A test program (scudotest) was used that deliberately
grows a size class high water mark to the point where
the pre-allocated static buffer is no longer used for
garbage collection.

Traces showed that precommiting the Vmar removes ~30 page faults
and ~.22ms of wall time.*

Before: https://ui.perfetto.dev/#!/?s=7da19fc3f59448eef51fd6fd03283bb87b702cf1a565bcbe6c9c28371671
After: https://ui.perfetto.dev/#!/?s=97707cd99b2c9efd1e6569b2deb97e3d16f8be532c59a0cc12463c37fbb1d8

*: Use the added `zx_vmar_op_range` as a reference point to observe
the differences.

For more context, see https://fxbug.dev/115594.

Reviewed By: Chia-hungDuan

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

19 months ago[CMake] add_definitions => add_compile_definitions after D139752
Fangrui Song [Tue, 20 Dec 2022 17:34:14 +0000 (09:34 -0800)]
[CMake] add_definitions => add_compile_definitions after D139752

Suggested by alexreinking (Alex Reinking)

19 months ago[InstCombine] Disallow constant expressions in `not` canonicalization
Roman Lebedev [Tue, 20 Dec 2022 16:55:09 +0000 (19:55 +0300)]
[InstCombine] Disallow constant expressions in `not` canonicalization

As per post-commit feedback - we generally do not like Constant Expressions,
and trying to deal with them leads to inconsistent results
that may very well be non-optimal. So just don't.

19 months agoAdd TargetExtTyID to switch statements in Hexagon and DXIL backend code.
Joshua Cranmer [Tue, 20 Dec 2022 16:43:15 +0000 (11:43 -0500)]
Add TargetExtTyID to switch statements in Hexagon and DXIL backend code.

19 months agoRevert "[clang] Don't spuriously pass -stdlib=libc++ to CC1 on Darwin"
Hans Wennborg [Tue, 20 Dec 2022 16:22:53 +0000 (17:22 +0100)]
Revert "[clang] Don't spuriously pass -stdlib=libc++ to CC1 on Darwin"

This broke the instrprof-darwin-exports.c test on mac, see e.g.
https://green.lab.llvm.org/green/job/clang-stage1-RA/32351/

> Previously, we would be passing down -stdlib=libc++ from the Driver
> to CC1 whenever the default standard library on the platform was libc++,
> even if -stdlib= had not been passed to the Driver. This meant that we
> would pass -stdlib=libc++ in nonsensical circumstances, such as when
> compiling C code.
>
> This logic had been added in b534ce46bd40 to make sure that header
> search paths were set up properly. However, since libc++ is now the
> default Standard Library on Darwin, passing this explicitly is not
> required anymore. Indeed, if no -stdlib= is specified, CC1 will end
> up using libc++ if it queries which standard library to use, without
> having to be told.
>
> Not passing -stdlib= at all to CC1 on Darwin should become possible
> once CC1 stops relying on it to set up framework search paths.
>
> Furthermore, this commit also removes a diagnostic checking whether the
> deployment target is too old to support libc++. Nowadays, all supported
> deployment targets use libc++ and compiling with libstdc++ is not
> supported anymore. The Driver was the wrong place to issue this
> diagnostic since it doesn't know whether libc++ will actually be linked
> against (e.g. C vs C++), which would lead to spurious diagnostics.
> Given that these targets are not supported anymore, we simply drop
> the diagnostic instead of trying to refactor it into CC1.
>
> rdar://103198514
>
> Differential Revision: https://reviews.llvm.org/D139938

This reverts commit 6540f32db09cf6b367812642fbd91d44cbb6638d.

19 months ago[RISCV] Use default attributes for intrinsics
Craig Topper [Tue, 20 Dec 2022 16:21:06 +0000 (08:21 -0800)]
[RISCV] Use default attributes for intrinsics

This switches a large subset of RISC-V intrinsics to use default
attributes (nosync, nofree, nocallback and willreturn).

I didn't reformat a lot of this. I can spend more time on that if
we think it's important.

Reviewed By: nikic, asb, eopXD

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

19 months ago[IR] Add a target extension type to LLVM.
Joshua Cranmer [Tue, 20 Dec 2022 16:02:11 +0000 (11:02 -0500)]
[IR] Add a target extension type to LLVM.

Target-extension types represent types that need to be preserved through
optimization, but otherwise are not introspectable by target-independent
optimizations. This patch doesn't add any uses of these types by an existing
backend, it only provides basic infrastructure such that these types would work
correctly.

Reviewed By: nikic, barannikov88

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

19 months ago[AArch64] FMV support and necessary target features dependencies.
Pavel Iliin [Wed, 15 Dec 2021 02:12:37 +0000 (02:12 +0000)]
[AArch64] FMV support and necessary target features dependencies.

This is Function Multi Versioning (FMV) implementation for AArch64 target in
accordance with Beta Arm C Language Extensions specification
https://github.com/ARM-software/acle/blob/main/main/acle.md#function-multi-versioning
It supports new "target_version" function attribute and extends existing
"target_clones" one. Also missing dependencies for target features were added.

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

19 months agoEnable roundeven.
Leon Clark [Tue, 20 Dec 2022 14:23:31 +0000 (14:23 +0000)]
Enable roundeven.

Add support for roundeven and implement appropriate tests.

Reviewed By: arsenm

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

19 months agoRevert "[InstCombine] Fold nested selects"
Roman Lebedev [Tue, 20 Dec 2022 15:31:24 +0000 (18:31 +0300)]
Revert "[InstCombine] Fold nested selects"

One of these two changes is exposing (or causing) some more miscompiles.
A reproducer is in progress, so reverting until resolved.

This reverts commit 9ddff66d0c9c3e18d56e6b20aa26a2a8cdfb6d2b.

19 months agoRevert "Reland "[SimplifyCFG] `FoldBranchToCommonDest()`: deal with mismatched IV...
Roman Lebedev [Tue, 20 Dec 2022 15:25:37 +0000 (18:25 +0300)]
Revert "Reland "[SimplifyCFG] `FoldBranchToCommonDest()`: deal with mismatched IV's in PHI's in common successor block""

One of these two changes is exposing (or causing) some more miscompiles.
A reproducer is in progress, so reverting until resolved.

This reverts commit 428f36401b1b695fd501ebfdc8773bed8ced8d4e.

19 months ago[xray] Convert tests to check 'target=...'
Paul Robinson [Tue, 20 Dec 2022 15:35:25 +0000 (07:35 -0800)]
[xray] Convert tests to check 'target=...'

Part of the project to eliminate special handling for triples in lit
expressions.

19 months ago[AArch64][ARM] Remove load from dup and vmul tests. NFC
David Green [Tue, 20 Dec 2022 15:23:38 +0000 (15:23 +0000)]
[AArch64][ARM] Remove load from dup and vmul tests. NFC

These tests needn't use loads in their testing of dup and mul
instructions, and as the load changes the test may no longer test what
they are intending (as in D140069).

19 months ago[InstCombine] Fix inversion of constants
Roman Lebedev [Tue, 20 Dec 2022 15:15:19 +0000 (18:15 +0300)]
[InstCombine] Fix inversion of constants

`canFreelyInvertAllUsersOf()`, in general, does not make sense
for constants, and constant expressions are likely even more problematic.
For those, we just want to create a simple constant expression and be done.

Fixes https://github.com/llvm/llvm-project/issues/59613

19 months ago[RISCV] Reduce duplicated code in RISCVMergeBaseOffsetOpt::detectFoldable. NFC
Craig Topper [Tue, 20 Dec 2022 15:06:15 +0000 (07:06 -0800)]
[RISCV] Reduce duplicated code in RISCVMergeBaseOffsetOpt::detectFoldable. NFC

The LUI and AUIPC share quite a few similarities. This refactors the code
to share what we can.

Reviewed By: asb

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

19 months ago[RISCV] Teach RISCVMergeBaseOffset to handle constant pools.
Craig Topper [Tue, 20 Dec 2022 15:05:37 +0000 (07:05 -0800)]
[RISCV] Teach RISCVMergeBaseOffset to handle constant pools.

Primarily this allows us to fold the addi from PseudoLLA expansion
into a load.

If the linker is able to GP relax the constant pool access we'll
end up with a GP relative load.

Reviewed By: asb

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

19 months ago[gn] Add explicit deps on TargetParser
Nico Weber [Tue, 20 Dec 2022 15:06:28 +0000 (10:06 -0500)]
[gn] Add explicit deps on TargetParser

This diff was generated by the following script:

    #!/usr/bin/env python3
    import os, subprocess
    r = subprocess.run('git show --pretty='' --name-only f09cf34d00'.split(),
                       stdout=subprocess.PIPE, text=True)
    for line in r.stdout.splitlines():
      if not line.endswith('CMakeLists.txt'): continue
      gn = 'llvm/utils/gn/secondary/' + os.path.dirname(line) + '/BUILD.gn'
      if not os.path.exists(gn): continue
      with open(gn) as f:
        contents = f.read()
      if contents.count('"//llvm/lib/Support",') == 1:
        contents = contents.replace(
            '"//llvm/lib/Support",',
            '"//llvm/lib/Support", "//llvm/lib/TargetParser",')
      elif contents.count(' deps = [') == 1:
        contents = contents.replace(
            ' deps = [',
            ' deps = [ "//llvm/lib/TargetParser",')
      else:
        print('needs manual fixup:', gn)
        continue
      with open(gn, 'w') as f:
        f.write(contents)

I then manually fixed up the BUILD.gn files for Support (should not depend on
TargetParser) and TargetParser (should depend on Support) and ran `gn format`
on all touched files.

19 months ago[libc][llvm] Forward `LIBC_` options as well in a runtime build
Joseph Huber [Tue, 20 Dec 2022 15:02:24 +0000 (09:02 -0600)]
[libc][llvm] Forward `LIBC_` options as well in a runtime build

Summary:
We need to forward certain CMake definitions to the runtimes build when
using `-DLLVM_ENABLE_RUNTIMES=libc`. The `libc` project uses both
`LLVM_LIBC` and `LIBC` prefixes. Previously we only forwarded
`LLVM_LIBC`. This patch adds the `LIBC_` prefix, using the underscore to
separate it from `LIBCXX`.

19 months ago[gn] run `gn format` on new build file
Nico Weber [Tue, 20 Dec 2022 15:04:39 +0000 (10:04 -0500)]
[gn] run `gn format` on new build file

19 months ago[AArch64] Add Neon int instructions to isAssociativeAndCommutative
KAWASHIMA Takahiro [Mon, 12 Dec 2022 05:25:32 +0000 (14:25 +0900)]
[AArch64] Add Neon int instructions to isAssociativeAndCommutative

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

19 months ago[AArch64] Add FP16 instructions to isAssociativeAndCommutative
KAWASHIMA Takahiro [Mon, 12 Dec 2022 05:25:31 +0000 (14:25 +0900)]
[AArch64] Add FP16 instructions to isAssociativeAndCommutative

`-mcpu=` in `llvm/test/CodeGen/AArch64/machine-combiner.ll` is changed
to `neoverse-n2` to use FP16 and SVE/SVE2 instructions. By this, the
register allocation and/or instruction scheduling are slightly changed
and some existing `CHECK` lines need to be updated.

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

19 months ago[gn build] Port core part of f09cf34d0062
Nico Weber [Tue, 20 Dec 2022 14:42:45 +0000 (09:42 -0500)]
[gn build] Port core part of f09cf34d0062

For now, this adds a dep from Support on the new TargetParser library
instead of the other way round. That'll be fixed in a mechanical follow-up.

19 months ago[libc++] accept ELF Tool Chain readelf format in tooling
Ed Maste [Mon, 19 Dec 2022 17:13:42 +0000 (12:13 -0500)]
[libc++] accept ELF Tool Chain readelf format in tooling

ELF Tool Chain provides alternatives to most GNU binutils tools,
including readelf.  These tools are currently used by FreeBSD.

ELF Tool Chain's readelf currently emits headings for symbol table
information in a slightly different format compared to GNU or LLVM
readelf.  Accept both formats.

Reviewed by: philnik
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D140313

19 months ago[AAch64] Optimize muls with operands having enough zero bits.
bipmis [Tue, 20 Dec 2022 14:34:17 +0000 (14:34 +0000)]
[AAch64] Optimize muls with operands having enough zero bits.

Muls with 64bit operands where each of the operand is having top 32 bits as zero, we can generate a single umull instruction on a 32bit operand.

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

19 months ago[CodeGen][AArch64] Fix AArch64ABIInfo::EmitAAPCSVAArg crash with empty record type...
yronglin [Tue, 20 Dec 2022 13:34:00 +0000 (21:34 +0800)]
[CodeGen][AArch64] Fix AArch64ABIInfo::EmitAAPCSVAArg crash with empty record type in variadic arg

Fix AArch64ABIInfo::EmitAAPCSVAArg crash with empty record type in variadic arg

Open issue: https://github.com/llvm/llvm-project/issues/59034

Reviewed By: rjmccall

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

19 months ago[AArch64] Combine to UMULL if top bits are known zero
David Green [Tue, 20 Dec 2022 13:50:34 +0000 (13:50 +0000)]
[AArch64] Combine to UMULL if top bits are known zero

Given mul(zext(a), b), we can convert to a umull so long as we know that
the top bits of b are zero. This uses MaskedValueIsZero to detect that
case for NEON UMULL patterns.

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

19 months ago[compiler-rt] Add TargetParser to symbolizer
Archibald Elliott [Tue, 20 Dec 2022 13:43:25 +0000 (13:43 +0000)]
[compiler-rt] Add TargetParser to symbolizer

19 months ago[PhaseOrdering] Add test for vector promotion regression (NFC)
Nikita Popov [Tue, 20 Dec 2022 13:39:57 +0000 (14:39 +0100)]
[PhaseOrdering] Add test for vector promotion regression (NFC)

Sample test where cfd594f8bb5e779c81171e7c1e61ae8436efabd3 causes
optimization regressions.

19 months ago[X86] Fix SLM uops/resources counts for CMPXCHG instructions
Simon Pilgrim [Mon, 19 Dec 2022 18:27:50 +0000 (18:27 +0000)]
[X86] Fix SLM uops/resources counts for CMPXCHG instructions

LOCK + CMPXCHG8/CMPXCHG16 variants still need overriding as they are not completely correct - already much better though

Based off llvm-exegesis captures, confirmed with Agner + uops.info

19 months ago[flang] Do not convey captured globals through host link
Jean Perier [Tue, 20 Dec 2022 12:49:38 +0000 (13:49 +0100)]
[flang] Do not convey captured globals through host link

Addresses and properties (bounds, length parameters) of host
variables associated in an internal procedure were all passed via
an extra tuple argument of the internal procedure.
This extra tuple is in general an overhead: it must be created and
passed, and require creating thunks when taking the address of the
internal procedure.
This patch allows not using the tuple for host global variables
(from modules, common block, or local saved variables) since they can
be instantiated from the fir.global symbol in the internal procedure
instead.
Add a fir.internal_proc attribute to mlir::FuncOp for internal procedures
so that ArrayValueCopy can still detect internal procedures even if they
do not have a tuple argument.

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

19 months ago[Examples] Fix TargetParser Dependency
Archibald Elliott [Tue, 20 Dec 2022 12:49:02 +0000 (12:49 +0000)]
[Examples] Fix TargetParser Dependency

19 months ago[llvm] Make llvm::Any similar to std::any
Sebastian Neubauer [Tue, 20 Dec 2022 12:28:30 +0000 (13:28 +0100)]
[llvm] Make llvm::Any similar to std::any

This facilitates replacing llvm::Any with std::any.
- Deprecate any_isa in favor of using any_cast(Any*) and checking for
  nullptr because C++17 has no any_isa.
- Remove the assert from any_cast(Any*), so it returns nullptr if the
  type is not correct. This aligns it with std::any_cast(any*).

Use any_cast(Any*) throughout LLVM instead of checks with any_isa.

This is the first part outlined in
https://discourse.llvm.org/t/rfc-switching-from-llvm-any-to-std-any/67176

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

19 months ago[ADT] Correct Comment in Triple.h
Archibald Elliott [Tue, 20 Dec 2022 12:12:23 +0000 (12:12 +0000)]
[ADT] Correct Comment in Triple.h

19 months ago[mlir][linalg] Bring populateFoldUnitExtentDimsVia(Reshapes/Slices)Patterns in sync
Matthias Springer [Tue, 20 Dec 2022 12:08:59 +0000 (13:08 +0100)]
[mlir][linalg] Bring populateFoldUnitExtentDimsVia(Reshapes/Slices)Patterns in sync

Make sure that both functions populate patterns with the same functionality. Both should be refactored at some point so that canonicalization patterns are not populated.

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

19 months ago[DebugInfo] Variables with only empty values emitting when one is variadic
Stephen Tozer [Tue, 20 Dec 2022 10:01:56 +0000 (10:01 +0000)]
[DebugInfo] Variables with only empty values emitting when one is variadic

This patch fixes a simple bug in DbgValueHistoryMap::hasNonEmptyLocation
that caused it to treat empty DBG_VALUE_LIST instructions as non-empty
when determining whether to emit a variable or not.

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