Sanjay Patel [Thu, 8 Dec 2022 15:46:49 +0000 (10:46 -0500)]
Revert "[InstCombine] improve efficiency of bool logic; NFC"
This reverts commit
b7c7fe3d0779b6e332fe6db64e87561deba2e56a.
As discussed in the planned follow-on to this patch (D138874),
this and the previous patch in this set can cause trouble for
the backend, and there's probably no quick fix. We may even
want to canonicalize in the opposite direction (towards insertelt).
Corentin Jabot [Thu, 8 Dec 2022 18:57:02 +0000 (19:57 +0100)]
Revert "Implement CWG2631"
This patch causes another link error,
reverting until I can investigate.
This reverts commit
a96a6ed83230265f3eab09a94f0e9525d05f8a74.
Vlad Serebrennikov [Thu, 8 Dec 2022 18:03:42 +0000 (21:03 +0300)]
[clang] Add test for CWG418
P1787: //[[ https://cplusplus.github.io/CWG/issues/418.html | CWG418 ]] is resolved by trivial rephrasing along with that necessary for the new using-declaration interpretation.//
Wording: see changes to [dcl.fct.default]/9 and [over.match.best]/4.
[over.match.best]/4 includes [[ https://eel.is/c++draft/over.match.best#general-example-8 | an example ]] that is not properly diagnosed by Clang.
Reviewed By: #clang-language-wg, shafik
Differential Revision: https://reviews.llvm.org/D139429
Joseph Huber [Thu, 8 Dec 2022 18:34:38 +0000 (13:34 -0500)]
[OpenMP][libomp] Fix version scripts after undefined version script changes
Summary:
Building with `lld` now errors on undefined symbols by default now. This
was causing `libomp` to think that the compiler didn't support version
scripts when checking linker features. This patch adds a new script that
exports all symbols to be used for testing. We also remove the old
workarounds for undefined versions now that it's no longer necessary.
Paul Walker [Thu, 8 Dec 2022 17:54:08 +0000 (17:54 +0000)]
[MC][AArch64] Remove bogus whitespace of markup'd immediate.
Aaron Ballman [Thu, 8 Dec 2022 18:16:29 +0000 (13:16 -0500)]
Update the status of a few more C DRs
This includes tests for DR085 and DR259.
Alexander Belyaev [Thu, 8 Dec 2022 18:06:19 +0000 (19:06 +0100)]
[mlir][linalg] Print broadcast, map, reduce, transpose ins/outs on one line.
Differential Revision: https://reviews.llvm.org/D139650
Paul Kirth [Thu, 8 Dec 2022 18:14:48 +0000 (18:14 +0000)]
Revert "Reland "[pgo] Avoid introducing relocations by using private alias"""
This reverts commit
071c39df8632561b599f7b1debd81b3cf6b5b396.
One of the new runtimes tests causes a failure with MSVC, so I'm
reverting until the test can be fixed.
Philip Reames [Thu, 8 Dec 2022 18:12:00 +0000 (10:12 -0800)]
[RISCV][InsertVSETVLI] vmv.s.x and fvmv.s.f do not depend on LMUL
We already have this rule encoded elsewhere in the file - which is why we don't see any test changes. I'm adding it here for completionism.
This is not technically NFC since there could be a test case which isn't caught by the specific rules, but is handled by the generic logic. I don't have such an example.
Kazu Hirata [Thu, 8 Dec 2022 18:07:43 +0000 (10:07 -0800)]
[ADT] Use std::nullopt instead of llvm::None in OptionalTest.cpp
This patch updates the test for the streaming operator for
llvm::Optional to use std::nullopt instead of llvm::None.
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
Differential Revision: https://reviews.llvm.org/D139513
Arthur Eubanks [Wed, 23 Nov 2022 22:13:49 +0000 (14:13 -0800)]
[lldb] Fix simple template names interaction with debug info declarations
Without checking template parameters, we would sometimes lookup the
wrong type definition for a type declaration because different
instantiations of the same template class had the same debug info name.
The added GetForwardDeclarationDIETemplateParams() shouldn't need a
cache because we'll cache the results of the declaration -> definition
lookup anyway. (DWARFASTParserClang::ParseStructureLikeDIE()
is_forward_declaration branch)
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D138834
Paul Kirth [Fri, 2 Dec 2022 00:21:20 +0000 (00:21 +0000)]
Reland "[pgo] Avoid introducing relocations by using private alias""
In many cases, we can use an alias to avoid a symbolic relocations,
instead of using the public, interposable symbol. When the instrumented
function is in a COMDAT, we can use a hidden alias, and still avoid
references to discarded sections.
Reviewed By: phosek
Differential Revision: https://reviews.llvm.org/D137982
Roman Lebedev [Thu, 8 Dec 2022 16:51:30 +0000 (19:51 +0300)]
[SROA] For non-speculatable `load`s of `select`s -- split block, insert then/else blocks, form two-entry PHI node, take 2
Currently, SROA is CFG-preserving.
Not doing so does not affect any pipeline test. (???)
Internally, SROA requires Dominator Tree, and uses it solely for the final `-mem2reg` call.
By design, we can't really SROA alloca if their address escapes somehow,
but we have logic to deal with `load` of `select`/`PHI`,
where at least one of the possible addresses prevents promotion,
by speculating the `load`s and `select`ing between loaded values.
As one would expect, that requires ensuring that the speculation is actually legal.
Even ignoring complexity bailouts, that logic does not deal with everything,
e.g. `isSafeToLoadUnconditionally()` does not recurse into hands of `select`.
There can also be cases where the load is genuinely non-speculate.
So if we can't prove that the load can be speculated,
unfold the select, produce two-entry phi node, and perform predicated load.
Now, that transformation must obviously update Dominator Tree,
since we require it later on. Doing so is trivial.
Additionally, we don't want to do this for the final SROA invocation (D136806).
In the end, this ends up having negative (!) compile-time cost:
https://llvm-compile-time-tracker.com/compare.php?from=
c6d7e80ec4c17a415673b1cfd25924f98ac83608&to=
ddf9600365093ea50d7e278696cbfa01641c959d&stat=instructions:u
Though indeed, this only deals with `select`s, `PHI`s are still using speculation.
Should we update some more analysis?
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D138238
This reverts commit
739611870d3b06605afe25cc07833f6a62de9545,
and recommits
03e6d9d9d1d48e43f3efc35eb75369b90d4510d5
with a fixed assertion - we should check that DTU is there,
not just assert false...
Michael Buch [Thu, 8 Dec 2022 17:08:00 +0000 (17:08 +0000)]
[lldb][Test] TestRerunAndExpr.py: explicitly delete a.out before rebuilding it
**Summary**
Older versions of `make` would occasionally fail to realize
that a pre-requisite for the `a.out` target has changed. This
resulted in roughly 1 out of 10 test runs to fail. Instead of
relying on `make` to resolve this dependency simply remove the
file before rebuilding; this will give make no option but to
remake `a.out`.
**Testing**
* Confirmed that the test passes on the host for 100 runs where
without the patch it would fail after ~10
**Details**
Adding `-d` to lldbtest's `make` invocation and running the
test without this patch sometimes yielded:
```
Removing child 0x600000308ff0 PID 19915 from chain.
Successfully remade target file `rebuild.o'.
Finished prerequisites of target file `a.out'.
Prerequisite `rebuild.o' is newer than target `a.out'.
No need to remake target `a.out'.
```
Differential Revision: https://reviews.llvm.org/D139643
Roman Lebedev [Thu, 8 Dec 2022 16:49:24 +0000 (19:49 +0300)]
Revert "[SROA] For non-speculatable `load`s of `select`s -- split block, insert then/else blocks, form two-entry PHI node"
The assertion about not modifying the CFG seems to not hold,
will recommit in a bit.
https://lab.llvm.org/buildbot#builders/139/builds/32412
This reverts commit
03e6d9d9d1d48e43f3efc35eb75369b90d4510d5.
This reverts commit
4f90f4ada33718f9025d0870a4fe3fe88276b3da.
bixia1 [Thu, 8 Dec 2022 16:22:37 +0000 (08:22 -0800)]
[mlir][sparse] Fix checks in a test.
Reviewed By: Peiming
Differential Revision: https://reviews.llvm.org/D139636
Roman Lebedev [Thu, 8 Dec 2022 16:40:35 +0000 (19:40 +0300)]
[NFCI][SROA] `rewriteSelectInstLoads()`: add forgotten false into assertion
Peter Klausler [Tue, 6 Dec 2022 22:00:21 +0000 (14:00 -0800)]
[flang] Restore old unit locking behavior
Rework the recursive I/O error check on I/O units so that
threads again hold a lock on a unit throughout an I/O statement.
Add an API to the runtime's Lock class implementation for pthreads
to allow detection of solf-deadlock without depending on EDEADLK
or recursive mutexes.
This should fix I/O from OpenMP threads.
Differential Revision: https://reviews.llvm.org/D139477
Jakub Kuderski [Thu, 8 Dec 2022 16:22:46 +0000 (11:22 -0500)]
[mlir][arith] Add missing heading comment. NFC.
Brett Wilson [Wed, 7 Dec 2022 18:26:04 +0000 (10:26 -0800)]
[clang-doc] Add template support.
Reads template information from the AST and adds template parameters and
specialization information to the corresponding clang-doc structures.
Add a "QualName" to the Reference struct which includes the full
qualified type name. The Reference object represents a link in the
HTML/MD generators so is based on the unqualified name. But this does
not encode C-V qualifiers or template information that decorate the
name. The new QualName member encodes all of this information and also
makes it easier for the generators or downsteam YAML consumers to
generate the full name (before they had to process the "Path").
In test code that was changed, remove made-up paths to built-in types
like "int". In addition to slightnly cleaning up the code, these types
do not have paths in real execution, and generating incorrect references
to nonexistant data may complicate future changes in the generators.
Convert llvm::Optional to std::optional (YAML library requires this for
the new usage, and this makes everything consistent according to the
llvm::Optional -> std::optional transition).
Differential Revision: https://reviews.llvm.org/D139154
bixia1 [Thu, 8 Dec 2022 00:14:22 +0000 (16:14 -0800)]
[mlir][sparse] Fix problems in creating complex zero for initialization.
Reviewed By: aartbik, wrengr
Differential Revision: https://reviews.llvm.org/D139591
Haojian Wu [Thu, 8 Dec 2022 15:15:34 +0000 (16:15 +0100)]
Add distinguished content to the empty test headers.
To make the lit test print-header-json.c passed on a file-content-hash
file system.
Sanjay Patel [Thu, 8 Dec 2022 14:58:17 +0000 (09:58 -0500)]
Revert "[InstCombine] canonicalize trunc + insert as bitcast + shuffle, part 2"
This reverts commit
dd8d0d21ce6d0665ef5d426372096aaed85b479a.
As discussed in the planned follow-on to this patch (D138874),
this and the previous patch in this set can cause trouble for
the backend, and there's probably no quick fix. We may even
want to canonicalize in the opposite direction (towards insertelt).
Krzysztof Parzyszek [Thu, 8 Dec 2022 01:34:42 +0000 (19:34 -0600)]
[SCEV] Convert Optional to std::optional
Guillaume Chatelet [Thu, 8 Dec 2022 14:33:20 +0000 (14:33 +0000)]
[NFC] Simplify documentation about alignment in MCStreamer
Roman Lebedev [Thu, 8 Dec 2022 13:50:19 +0000 (16:50 +0300)]
[SROA] For non-speculatable `load`s of `select`s -- split block, insert then/else blocks, form two-entry PHI node
Currently, SROA is CFG-preserving.
Not doing so does not affect any pipeline test. (???)
Internally, SROA requires Dominator Tree, and uses it solely for the final `-mem2reg` call.
By design, we can't really SROA alloca if their address escapes somehow,
but we have logic to deal with `load` of `select`/`PHI`,
where at least one of the possible addresses prevents promotion,
by speculating the `load`s and `select`ing between loaded values.
As one would expect, that requires ensuring that the speculation is actually legal.
Even ignoring complexity bailouts, that logic does not deal with everything,
e.g. `isSafeToLoadUnconditionally()` does not recurse into hands of `select`.
There can also be cases where the load is genuinely non-speculate.
So if we can't prove that the load can be speculated,
unfold the select, produce two-entry phi node, and perform predicated load.
Now, that transformation must obviously update Dominator Tree,
since we require it later on. Doing so is trivial.
Additionally, we don't want to do this for the final SROA invocation (D136806).
In the end, this ends up having negative (!) compile-time cost:
https://llvm-compile-time-tracker.com/compare.php?from=
c6d7e80ec4c17a415673b1cfd25924f98ac83608&to=
ddf9600365093ea50d7e278696cbfa01641c959d&stat=instructions:u
Though indeed, this only deals with `select`s, `PHI`s are still using speculation.
Should we update some more analysis?
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D138238
Simon Pilgrim [Thu, 8 Dec 2022 13:51:08 +0000 (13:51 +0000)]
[X86] Add HasCLFLUSH pseudo-predicate (Issue #19039)
Similar to what we've done for HasMFence - this puts into place a pseudo-predicate for CLFLUSH instructions that separates it from HasSSE2 to make it easier to use CLFLUSH even when SSE/fpmath has been disabled - technically CLFLUSH has its own CPUID bit, so could be available on x86 cores entirely without SSE, but I don't think thats ever happened or likely to happen.
Nico Weber [Wed, 7 Dec 2022 18:48:08 +0000 (13:48 -0500)]
[lld/mac] Abort link immediately on invalid -undefined argument
I tried `-undefined suppress` without `-flat_namespace`.
lld printed `'-undefined suppress' only valid with '-flat_namespace'`
followed by many many screenfuls of error messages about undefined
symbols, making the original diag hard to see.
This is probably the common case when using `-undefined`, so let's
just abort the link immediately when there's an invalid `-undefined`
arg.
Differential Revision: https://reviews.llvm.org/D139559
Sebastian Neubauer [Wed, 13 Jul 2022 16:42:40 +0000 (18:42 +0200)]
[AMDGPU] Add test that spills WWM CSRs twice
Add a test to show a deficit in the current wwm/spilling code that
creates double saves and restores for v40 and v41.
This case came up in D124193.
Differential Revision: https://reviews.llvm.org/D139626
Luke Lau [Thu, 8 Dec 2022 12:56:15 +0000 (12:56 +0000)]
[WebAssembly] Initialize missing passes in WebAssemblyTargetMachine
These passes were lying around but weren't initialized, so they weren't
showing up in -print-after-all.
Differential Revision: https://reviews.llvm.org/D139440
Haojian Wu [Thu, 8 Dec 2022 12:36:33 +0000 (13:36 +0100)]
[tooling] use std::optional in tooling StandardLibrary.h/.cpp, NFC
Alexandros Lamprineas [Thu, 8 Dec 2022 12:42:34 +0000 (12:42 +0000)]
Revert "[IPSCCP] Move the IPSCCP run function under the IPO directory."
This reverts commit
42c2dc401742266da3e0251b6c1ca491f4779963.
This broke some buildbots:
undefined reference to `llvm::createBitTrackingDCEPass()'
undefined reference to `llvm::createAlignmentFromAssumptionsPass()'
undefined reference to `llvm::createLoopUnrollPass(int, bool, bool, int, int, int, int, int, int)'
undefined reference to `llvm::createLICMPass(unsigned int, unsigned int, bool)'
undefined reference to `llvm::createWarnMissedTransformationsPass()'
undefined reference to `llvm::createAlignmentFromAssumptionsPass()'
undefined reference to `llvm::createCallSiteSplittingPass()'
undefined reference to `llvm::createCFGSimplificationPass(llvm::SimplifyCFGOptions, std::function<bool (llvm::Function const&)>)'
undefined reference to `llvm::createFloat2IntPass()'
undefined reference to `llvm::createLowerConstantIntrinsicsPass()'
undefined reference to `llvm::createLoopRotatePass(int, bool)'
undefined reference to `llvm::createLoopDistributePass()'
undefined reference to `llvm::createLoopSinkPass()'
undefined reference to `llvm::createInstSimplifyLegacyPass()'
undefined reference to `llvm::createDivRemPairsPass()'
undefined reference to `llvm::createCFGSimplificationPass(llvm::SimplifyCFGOptions, std::function<bool (llvm::Function const&)>)'
undefined reference to `llvm::SetLicmMssaOptCap'
undefined reference to `llvm::SetLicmMssaNoAccForPromotionCap'
undefined reference to `llvm::ForgetSCEVInLoopUnroll'
Alexandros Lamprineas [Thu, 8 Dec 2022 12:38:24 +0000 (12:38 +0000)]
Revert "[FuncSpec] Make the Function Specializer part of the IPSCCP pass."
This reverts commit
877a9f9abec61f06e39f1cd872e37b828139c2d1.
It depends on the parent revision
42c2dc401742266da3e0251b6c1ca491f4779963
which needs to be reverted as it broke some buildbots, so reverting both.
Aaron Ballman [Thu, 8 Dec 2022 12:33:42 +0000 (07:33 -0500)]
[C2x] Relaxing requirements for va_start
This implements WG14 N2975 relaxing requirements for va_start
(https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2975.pdf), which
does two things:
1) Allows the declaration of a variadic function without any named
arguments. e.g., void f(...) is now valid, as in C++.
2) Modified the signature of the va_start macro to be a variadic macro
that accepts one or more arguments; the second (and later) arguments
are not expanded or evaluated.
I followed the GCC implementation in terms of not modifying the
behavior of `__builtin_va_start` (it still requires exactly two
arguments), but this approach has led to several QoI issues that I've
documented with FIXME comments in the test. Specifically, the
requirement that we do not evaluate *or expand* the second and later
arguments means it's no longer possible to issue diagnostics for
compatibility with older C versions and C++. I am reaching out to
folks in WG14 to see if we can get an NB comment to address these
concerns (the US comment period has already closed, so I cannot file
the comment myself), so the diagnostic behavior may change in the
future.
I took this opportunity to add some documentation for all the related
builtins in this area, since there was no documentation for them yet.
Differential Revision: https://reviews.llvm.org/D139436
Nico Weber [Thu, 8 Dec 2022 12:29:31 +0000 (07:29 -0500)]
[gn build] port
eeee51e4bb (dsymutil no longer driver_executable for a while)
Alexandros Lamprineas [Mon, 28 Nov 2022 21:47:59 +0000 (21:47 +0000)]
[FuncSpec] Make the Function Specializer part of the IPSCCP pass.
The aim of this patch is to minimize the compilation time overhead of
running Function Specialization. It is about 40% slower to run as a
standalone pass (IPSCCP + FuncSpec vs IPSCCP with FuncSpec) according
to my measurements. I compiled the llvm testsuite with NewPM-O3 + LTO
and measured single threaded [user + system] time of IPSCCP and FuncSpec
by passing the '-time-passes' option to lld. Then I compared the two
configurations in terms of Instruction Count of the total compilation
(not of the individual passes) as in https://llvm-compile-time-tracker.com.
Geomean for non-LTO builds is -0.25% and LTO is -0.5% approximately.
You can find more info below:
https://discourse.llvm.org/t/rfc-should-we-enable-function-specialization/61518
Differential Revision: https://reviews.llvm.org/D126455
Alexandros Lamprineas [Mon, 28 Nov 2022 13:01:29 +0000 (13:01 +0000)]
[IPSCCP] Move the IPSCCP run function under the IPO directory.
The LLVMipo library no longer depends on the Scalar component.
The shared functions between IPSCCP and SCCP have been moved
under Utils, in the SCCPSolver.
This is preliminary work for D126455, in order to break a cyclic
dependency between LLVM libraries.
Differential Revision: https://reviews.llvm.org/D138654
Hui Li [Thu, 8 Dec 2022 11:59:11 +0000 (19:59 +0800)]
[LLDB][LoongArch] Make software single stepping work
Hardware single stepping is not currently supported by the linux kernel.
In order to support single step debugging, add EmulateInstructionLoongArch
to implement the software Single Stepping. This patch only support the
simplest single step execution of non-jump instructions.
Reviewed By: SixWeining, DavidSpickett
Differential Revision: https://reviews.llvm.org/D139158
Weining Lu [Thu, 8 Dec 2022 11:55:05 +0000 (19:55 +0800)]
Revert "[LLDB][LoongArch] Make software single stepping work"
This reverts commit
3a9e07b1e7f4718a0e117f3a732f1679c4bf2e30.
Reason to revert: author name is wrong.
David Green [Thu, 8 Dec 2022 11:53:25 +0000 (11:53 +0000)]
[DAG] Teach isConstOrConstSplat about SPLAT_VECTORs
This teaches the DemandedElts version of isConstOrConstSplat about
SPLAT_VECTORS, in the same way as the non-DemandedElts version by
calling the demanded-bits version from the non-demanded-bits version.
Differential Revision: https://reviews.llvm.org/D128919
Haojian Wu [Thu, 8 Dec 2022 11:43:15 +0000 (12:43 +0100)]
[clangd] Add a newline-eof to the system-include-extractor.test
This test is executed with config enabled, and it fails if there is an
extra (-Wnewline-eof) compile flag from the user config.
Bjorn Pettersson [Thu, 8 Dec 2022 11:23:49 +0000 (12:23 +0100)]
[test] Remove duplicate RUN lines
A few more that I missed in commit
3528e63d89305907b3d6e.
There could be more duplicates remaining, since I've only focused
on exactly duplicated "RUN: opt" lines (ignoring multi line RUN
lines ending with '\').
Simon Pilgrim [Thu, 8 Dec 2022 11:44:07 +0000 (11:44 +0000)]
Fix MSVC "not all control paths return a value" warning. NFC.
Carlos Galvez [Fri, 2 Dec 2022 12:48:16 +0000 (12:48 +0000)]
[clang-tidy] Do not warn about redundant static in misc-use-anonymous-namespace
The same functionality is already implemented in the
readability-static-definition-in-anonymous-namespace
check, including automatic fixes.
Differential Revision: https://reviews.llvm.org/D139197
Sebastian Neubauer [Thu, 8 Dec 2022 11:06:44 +0000 (12:06 +0100)]
Revert "[llvm] Replace llvm::Any with std::any"
msvc fails to link when using any_cast. This seems to be fixed recently
only.
https://developercommunity.visualstudio.com/t/stdany-doesnt-link-when-exceptions-are-disabled/376072
This reverts commit
aeac2e4884a3ce62c920cd51806a9396da64d9f7.
Weining Lu [Thu, 8 Dec 2022 11:06:07 +0000 (19:06 +0800)]
[LLDB][LoongArch] Make software single stepping work
Hardware single stepping is not currently supported by the linux kernel.
In order to support single step debugging, add EmulateInstructionLoongArch
to implement the software Single Stepping. This patch only support the
simplest single step execution of non-jump instructions.
Reviewed By: SixWeining, DavidSpickett
Differential Revision: https://reviews.llvm.org/D139158
Sebastian Neubauer [Thu, 8 Dec 2022 10:48:00 +0000 (11:48 +0100)]
[llvm] Replace llvm::Any with std::any
llvm::Any had several bugs in the past, due to being sensitive to symbol
visibility. (See D101972 and D108943)
Even with these fixes applied, I still encounter the same issue on
Windows.
Similar to llvm::Optional going away in favor of std::optional, we can
use std::any from C++17.
Using std::any fixes the problem and puts the burden to do it correctly
on the standard library.
Differential Revision: https://reviews.llvm.org/D139532
Bjorn Pettersson [Thu, 8 Dec 2022 10:28:30 +0000 (11:28 +0100)]
[test] Remove duplicate RUN lines in Transform tests
wanglei [Thu, 8 Dec 2022 10:08:51 +0000 (18:08 +0800)]
[LoongArch] Allow writing unaligned nop sequences
In case of unaligned nop sequences, pad to the nearest 4-byte boundary
with zeros before filling with `nop` instructions. This is consistent
with gas behavior, and is necessary to compile the Linux kernel with
LLVM IAS.
Replace `support::endian::write` with `OS.write` while at it. This is
simpler and correct because we only have little endian.
Reviewed By: SixWeining, xen0n
Differential Revision: https://reviews.llvm.org/D139285
Viktoriia Bakalova [Thu, 1 Dec 2022 10:28:06 +0000 (10:28 +0000)]
[include-cleaner] Handle base class member access from derived class.
Fix: https://github.com/llvm/llvm-project/issues/59251
Differential Revision: https://reviews.llvm.org/D139087
Nikita Popov [Thu, 8 Dec 2022 10:12:26 +0000 (11:12 +0100)]
[InstSimplify] Do not remove insertvalue of undef into poison
We cannot remove an insertvalue of undef if it inserts into a
potentially poison value. The new implementation matches that of
insertelement.
See https://alive2.llvm.org/ce/z/pCcFsW for the previously
incorrect transform.
Florian Hahn [Thu, 8 Dec 2022 10:28:33 +0000 (10:28 +0000)]
Revert "[AArch64] Select SMULL for zero extended vectors when top bit is zero"
This reverts commit
f9e0390751cb5eefbbbc191f851c52422acacab1.
The patch causes a crash for the IR below:
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
target triple = "arm64-apple-macosx"
define void @test(ptr %data, <8 x i16> %v) {
entry:
%0 = sext <8 x i16> %v to <8 x i32>
%1 = mul <8 x i32> %0, <i32 35584, i32 35584, i32 35584, i32 35584, i32 35584, i32 35584, i32 35584, i32 35584>
%2 = lshr <8 x i32> %1, <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>
%3 = trunc <8 x i32> %2 to <8 x i16>
store <8 x i16> %3, ptr %data, align 2
ret void
}
Viktoriia Bakalova [Mon, 28 Nov 2022 15:28:02 +0000 (15:28 +0000)]
[include-cleaner] Remove filtering from UsingDecl visit.
Removes filtering from the VisitUsingDecl method for implementation files.
Differential Revision: https://reviews.llvm.org/D138821
Nikita Popov [Thu, 8 Dec 2022 10:22:19 +0000 (11:22 +0100)]
[InstSimplify] Fix check lines (NFC)
Accidentally used the wrong binary in the previous commit.
Nikita Popov [Thu, 8 Dec 2022 10:16:25 +0000 (11:16 +0100)]
[InstSimplify] Add test for insertvalue of undef (NFC)
Lucas Prates [Mon, 5 Dec 2022 13:26:21 +0000 (13:26 +0000)]
[Arm][AArch64] Add support for v8.9-A/v9.4-A base extensions
This implements the base extensions that are part of the v8.9-A and
v9.4-A architecture versions, including:
* The Clear BHB Instruction (FEAT_CLRBHB)
* The Speculation Restriction Instruction (FEAT_SPECRES2)
* The SLC target for the PRFM instruction
* New system registers:
* ID_AA64PFR2_EL1
* ID_AA64MMFR3_EL1
* HFGITR2_EL2
* SCTLR2_EL3
More information on the new extensions can be found on:
* https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/arm-a-profile-architecture-2022
* https://developer.arm.com/downloads/-/exploration-tools
Contributors: Sam Elliott, Tomas Matheson and Son Tuan Vu.
Reviewed By: lenary
Differential Revision: https://reviews.llvm.org/D139424
Fangrui Song [Thu, 8 Dec 2022 09:53:40 +0000 (09:53 +0000)]
[ELF] Merge SHT_RISCV_ATTRIBUTES sections
Currently we take the first SHT_RISCV_ATTRIBUTES (.riscv.attributes) as the
output. If we link an object without an extension with an object with the
extension, the output Tag_RISCV_arch may not contain the extension and some
tools like objdump -d will not decode the related instructions.
This patch implements
Tag_RISCV_stack_align/Tag_RISCV_arch/Tag_RISCV_unaligned_access merge as
specified by
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#attributes
For the deprecated Tag_RISCV_priv_spec{,_minor,_revision}, dump the attribute to
the output iff all input agree on the value. This is different from GNU ld but
our simple approach should be ok for deprecated tags.
`RISCVAttributeParser::handler` currently warns about unknown tags. This
behavior is retained. In GNU ld arm, tags >= 64 (mod 128) are ignored with a
warning. If RISC-V ever wants to do something similar
(https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/352), consider
documenting it in the psABI and changing RISCVAttributeParser.
Like GNU ld, zero value integer attributes and empty string attributes are not
dumped to the output.
Reviewed By: asb, kito-cheng
Differential Revision: https://reviews.llvm.org/D138550
Nikita Popov [Thu, 8 Dec 2022 09:52:02 +0000 (10:52 +0100)]
[InstCombine] Regenerate test checks (NFC)
Update the check prefixes to allow auto-generation. WIN was
redundant with NOSTPCPY, and CHECK-IPRINTF should specialize
WITHSTPCPY.
Corentin Jabot [Sun, 23 Oct 2022 15:32:58 +0000 (17:32 +0200)]
Implement CWG2631
Implement https://cplusplus.github.io/CWG/issues/2631.html.
Immediate calls in default arguments and defaults members
are not evaluated.
Instead, we evaluate them when constructing a
`CXXDefaultArgExpr`/`BuildCXXDefaultInitExpr`.
The immediate calls are executed by doing a
transform on the initializing expression.
Note that lambdas are not considering subexpressions so
we do not need to transform them.
As a result of this patch, unused default member
initializers are not considered odr-used, and
errors about members binding to local variables
in an outer scope only surface at the point
where a constructor is defined.
Reviewed By: aaron.ballman, #clang-language-wg
Differential Revision: https://reviews.llvm.org/D136554
serge-sans-paille [Sun, 4 Dec 2022 08:33:14 +0000 (09:33 +0100)]
Store OptTable::Info::Name as a StringRef
This is a recommit of
8ae18303f97d5dcfaecc90b4d87effb2011ed82e,
with a few cleanups.
This avoids implicit conversion to StringRef at several points, which in
turns avoid redundant calls to strlen.
As a side effect, this greatly simplifies the implementation of
StrCmpOptionNameIgnoreCase.
It also eventually gives a consistent, humble speedup in compilation
time (timing updated since original commit).
https://llvm-compile-time-tracker.com/compare.php?from=
de4b6a1bc64db33643f001ad45fae7b92b4a4688&to=
c23a93d1292052b4be2fbe8c586fa31143d0c7ed&stat=instructions:u
Differential Revision: https://reviews.llvm.org/D139274
Nikita Popov [Thu, 8 Dec 2022 09:24:10 +0000 (10:24 +0100)]
[InstCombine] Regenerate test checks (NFC)
Use generated check with --check-globals to verify that the TBAA
metadata is correct.
Nikita Popov [Thu, 8 Dec 2022 09:20:21 +0000 (10:20 +0100)]
[InstCombine] Regenerate test checks (NFC)
Also clean up some redundant attributes / metadata while here.
Nikita Popov [Thu, 8 Dec 2022 09:16:06 +0000 (10:16 +0100)]
[Inline] Regenerate test checks (NFC)
Don't use anon names, convert to opaque pointers and use
generated check lines.
Nikita Popov [Thu, 8 Dec 2022 09:04:43 +0000 (10:04 +0100)]
[Inline] Convert some tests to opaque pointers (NFC)
Max Kazantsev [Thu, 8 Dec 2022 09:04:01 +0000 (16:04 +0700)]
[SCEV] Compute symbolic exit count for 'and' conditions
If loop exits by condition like `A < B && X < Y`, and at least one of symbolic max
exit counts for these conditions is known, it can be used as estimate of symbolic
max exit count for whole branch. If both are known, then we can use their umin
as the estimate.
Differential Revision: https://reviews.llvm.org/D139403
Reviewed By: nikic
Guillaume Chatelet [Wed, 7 Dec 2022 16:47:48 +0000 (16:47 +0000)]
[Alignment] Use Align in MCStreamer::emitTBSSSymbol
In the same vein as D139439, the patch is not NFC as there is no way to check all downstream implementations but the patch seems pretty safe.
Differential Revision: https://reviews.llvm.org/D139548
Jonas Hahnfeld [Thu, 1 Dec 2022 13:14:43 +0000 (14:14 +0100)]
[DebugInfo] Store optional DIFile::Source as pointer
getCanonicalMDString() also returns a nullptr for empty strings, which
tripped over the getSource() method. Solve the ambiguity of no source
versus an optional containing a nullptr by simply storing a pointer.
Differential Revision: https://reviews.llvm.org/D138658
Haojian Wu [Thu, 8 Dec 2022 08:56:32 +0000 (09:56 +0100)]
Fix an unused-variable warning in release build, NFC
Haojian Wu [Thu, 8 Dec 2022 08:51:34 +0000 (09:51 +0100)]
Update the bazel BUILD for dsymutil binary.
Reflect the change
eeee51e4bb9998c70737a8b771fc1a7884cfedd1
Valentin Clement [Thu, 8 Dec 2022 08:47:06 +0000 (09:47 +0100)]
[flang] Handle polymorphic passed object in elemental call
The passed object is placed in the passed arguments by semantics.
When the TBP to be called is an elemental subroutine or function it has to be
handled accordingly.
Reviewed By: jeanPerier, PeteSteinfeld
Differential Revision: https://reviews.llvm.org/D139537
Gregory Alfonso [Thu, 8 Dec 2022 08:42:50 +0000 (08:42 +0000)]
[llvm] Call reserve before push_back in a loop
It is generally good practice, if you know how big the vector is going to be in the end, to reserve before continually calling "push_back" or "emplace_back"
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D139483
Nikolas Klauser [Wed, 7 Dec 2022 11:05:32 +0000 (12:05 +0100)]
[libc++][NFC] Rename __libcpp_*_or_builtin to __constexpr_*
We normally use the `__libcpp_` prefix to backport functions, but that doesn't really make sense here. The functions are always available. Using `__constexpr_` makes the intended use of the functions clear.
Reviewed By: Mordante, #libc
Spies: libcxx-commits
Differential Revision: https://reviews.llvm.org/D139521
Jean Perier [Thu, 8 Dec 2022 08:33:01 +0000 (09:33 +0100)]
[flang] add hlfir.noreassoc codegen
Differential Revision: https://reviews.llvm.org/D139542
Jean Perier [Thu, 8 Dec 2022 08:30:32 +0000 (09:30 +0100)]
[flang] Add hlfir.as_expr character scalar codegen
Creates a copy of the operand.
Differential Revision: https://reviews.llvm.org/D139533
Max Kazantsev [Thu, 8 Dec 2022 08:26:18 +0000 (15:26 +0700)]
[Test] Add test for logical_and, rename old one into logical_or
gonglingqin [Thu, 8 Dec 2022 07:39:21 +0000 (15:39 +0800)]
[LoongArch] Rename the test file and separate the tests on LA32 and LA64. NFC.
Use intrinsic-la32*.c to test the intrinsics of loongarch32.
Use intrinsic-la64*.c to test the intrinsics of loongarch64.
chenglin.bi [Thu, 8 Dec 2022 08:20:11 +0000 (16:20 +0800)]
[AArch64] Add tests for logical op with not; NFC
Guray Ozen [Thu, 8 Dec 2022 08:06:00 +0000 (09:06 +0100)]
[mlir][spirv] Support conversion of `CopySignOp` to spirv for 1D vector with 1 element
Conversion of CopySignOp to SPIRV is supported for scalar and vectors but not 1D vectors with 1 element (aka vector<1xf32>). This revisions adds supports this by treating them as scalars.
An alternative solution would be to allow 0D vectors for SPIRV, but the spec [0] strictly defines the vector type as non-0D.
"Vector: An ordered homogeneous collection of two or more scalars. Vector sizes are quite restrictive and dependent on the execution model."
[0] https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_types
Reviewed By: ThomasRaoux
Differential Revision: https://reviews.llvm.org/D139518
Nikita Popov [Thu, 8 Dec 2022 07:51:16 +0000 (08:51 +0100)]
[SCEV] Track SymbolicMaxNotTaken in BECountUsers
jacquesguan [Wed, 7 Dec 2022 07:27:10 +0000 (15:27 +0800)]
[RISCV] Add test for extract the first element from mask vector.
Reviewed By: reames
Differential Revision: https://reviews.llvm.org/D139510
Quentin Colombet [Mon, 5 Dec 2022 15:11:44 +0000 (15:11 +0000)]
[mlir][ExpandStridedMetadata] Handle collapse_shape of dim of size 1 gracefully
Collapsing dimensions of size 1 with random strides (a.k.a.
non-contiguous w.r.t. collapsed dimensions) is a grey area that we'd
like to clean-up. (See https://reviews.llvm.org/D136483#3909856)
That said, the implementation in `memref-to-llvm` currently skips
dimensions of size 1 when computing the stride of a group.
While longer term we may want to clean that up, for now matches this
behavior, at least in the static case.
For the dynamic case, for this patch we stick to `min(group strides)`.
However, if we want to handle the dynamic cases correctly while allowing
non-truly-contiguous dynamic size of 1, we would need to `if-then-else`
every dynamic size. In other words `min(stride_i, for all i in group and
dim_i != 1)`.
I didn't implement that in this patch at the moment since
`memref-to-llvm` is technically broken in the general case for this. (It
currently would only produce something sensible for row major tensors.)
Differential Revision: https://reviews.llvm.org/D139329
Alex Brachet [Thu, 8 Dec 2022 07:31:11 +0000 (07:31 +0000)]
[llvm-driver] Rename dsynutil_main to main after removing from driver
Alex Brachet [Thu, 8 Dec 2022 07:19:05 +0000 (07:19 +0000)]
[llvm-driver] Temporarily remove dsymutil
A recent change made it such that target_link_libraries is always
called and not conditionally. target_link_libraries doesn't
currently work when LLVM_TOOL_LLVM_DRIVER_BUILD=On. This should
be fixed in the future, but for now let's just remove dsymutil
as part of the llvm-driver build.
Differential Revision: https://reviews.llvm.org/D139588
Zain Jaffal [Thu, 8 Dec 2022 06:21:53 +0000 (08:21 +0200)]
[AArch64] Select SMULL for zero extended vectors when top bit is zero
we can safely replace a `zext` instruction with `sext` if the top bit is zero. This is useful because we can select `smull` when both operands are sign extended.
Reviewed By: fhahn, dmgreen
Differential Revision: https://reviews.llvm.org/D134711
Johannes Doerfert [Fri, 7 Oct 2022 18:52:51 +0000 (11:52 -0700)]
[Attributor] Keep complex select and PHI instructions in AAPotentialValues
If a select or PHI instruction cannot be simplified to a single value it
is often beneficial to keep the value intact rather than looking at all
the operands. The reason is that various users require a single value
and consequently can deal with the select or PHI but not multiple
operands. Recursive calls of `Attributor::getAssumedSimplifiedValues`
will be required to take such select and PHI instructions apart.
Sameer Sahasrabuddhe [Tue, 1 Nov 2022 04:34:32 +0000 (10:04 +0530)]
[NFC][AAPointerInfo] rename OffsetAndSize to RangeTy
This is in preparation for future changes that introduce an actual list of
ranges per Access, to be called a RangeList.
Differential Revision: https://reviews.llvm.org/D138644
Xiang1 Zhang [Thu, 8 Dec 2022 06:42:53 +0000 (14:42 +0800)]
[X86] Add test masked_compressstore_isel.ll
Johannes Doerfert [Tue, 4 Oct 2022 14:45:54 +0000 (07:45 -0700)]
[OpenMP] Make barrier elimination work in the presence of llvm.assume
Assumptions are droppable and eliminating them to eliminate barriers
seems reasonable.
Kazu Hirata [Thu, 8 Dec 2022 06:34:09 +0000 (22:34 -0800)]
[ObjCopy] Use std::optional instead of llvm::Optional in COFFConfig.h (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
Kazu Hirata [Thu, 8 Dec 2022 06:34:07 +0000 (22:34 -0800)]
[ObjCopy] Use std::optional instead of llvm::Optional in CommonConfig.h (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
Johannes Doerfert [Tue, 4 Oct 2022 14:27:20 +0000 (07:27 -0700)]
[Attributor] Delete stores only required for assumes (with the assumes)
We keep loads if they feed into assumes but even if we cannot predict
their value we should delete them if the associated stores are deleted
as well. This is not perfect but prioritizes deleting stores now.
gonglingqin [Thu, 8 Dec 2022 01:17:39 +0000 (09:17 +0800)]
[Clang][LoongArch] Add intrinsic for csrrd, csrwr and csrxchg
These intrinsics are required by Linux [1].
[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/loongarch/include/asm/loongarch.h?h=v6.0&id=
4fe89d07dcc2804c8b562f6c7896a45643d34b2f#n232
Differential Revision: https://reviews.llvm.org/D139288
Max Kazantsev [Thu, 8 Dec 2022 06:05:44 +0000 (13:05 +0700)]
[Test] Add two more tests for symtolic count with arith and logical AND
Kazu Hirata [Thu, 8 Dec 2022 04:48:53 +0000 (20:48 -0800)]
[llvm] Don't include Optional.h (NFC)
These source files no longer use Optional<T>.
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
Kazu Hirata [Thu, 8 Dec 2022 04:34:41 +0000 (20:34 -0800)]
[llvm] Don't include STLForwardCompat.h (NFC)
STLForwardCompat.h defines remove_cvref and remove_cvref_t. These
source files use neither one of those.
Kazu Hirata [Thu, 8 Dec 2022 04:22:27 +0000 (20:22 -0800)]
[clang-tools-extra] Use std::nullopt instead of None in comments (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
Kazu Hirata [Thu, 8 Dec 2022 04:17:39 +0000 (20:17 -0800)]
[mlir] Use std::nullopt instead of None in comments (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 [Thu, 8 Dec 2022 03:49:54 +0000 (19:49 -0800)]
[RISCV] Use bseti for 2048 in RISCVMatInt when Zbs is enabled.
2048 requires an LUI and ADDI instruction due to ADDI using a
signed immediate. It can also be done with C.LI+C.SLLI for better
code size.
With Zbs we can use a single BSETI to have an instruction.
Reorder the checks so that BSETI is checked first, with an extra
qualification to prefer a single LUI or ADDI when possible. I'm
continuing to think about other ways to structure this code, but
this works for now.
Fixes PR59362.
Kazu Hirata [Thu, 8 Dec 2022 04:10:59 +0000 (20:10 -0800)]
[mlir] Use std::nullopt instead of llvm::None (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
Kazu Hirata [Thu, 8 Dec 2022 04:10:57 +0000 (20:10 -0800)]
[flang] Use std::nullopt instead of llvm::None (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