Alex Brachet [Mon, 26 Jun 2023 13:49:22 +0000 (13:49 +0000)]
[CMake][Fuchsia] Enable standalone libatomic
BUILTINS_${target}_COMPILER_RT_BUILD_STANDALONE_LIBATOMIC
actually builds libatomic, and
RUNTIMES_${target}_COMPILER_RT_BUILD_STANDALONE_LIBATOMIC
tells the compiler-rt tests that we built it and it is
safe to use in tests.
Differential Revision: https://reviews.llvm.org/D151681
Alex Brachet [Mon, 26 Jun 2023 13:40:22 +0000 (13:40 +0000)]
[compiler-rt] Stop using system ldd to detect libc version
The system libc may be different from the libc passed in
CMAKE_SYSROOT. Instead of using the ldd in PATH to detect
glibc version, use the features.h header file.
Differential Revision: https://reviews.llvm.org/D151678
Graham Hunter [Fri, 10 Mar 2023 11:17:04 +0000 (11:17 +0000)]
[AArch64][CodeGen] Lower (de)interleave2 intrinsics to ld2/st2
The InterleavedAccess pass currently matches (de)interleaving
shufflevector instructions with loads or stores, and calls into
target lowering to generate ldN or stN instructions.
Since we can't use shufflevector for scalable vectors (besides a
splat with zeroinitializer), we have interleave2 and deinterleave2
intrinsics. This patch extends InterleavedAccess to recognize those
intrinsics and if possible replace them with ld2/st2.
Reviewed By: paulwalker-arm
Differential Revision: https://reviews.llvm.org/D146218
Louis Dionne [Mon, 5 Jun 2023 19:27:38 +0000 (12:27 -0700)]
[libc++][filesystem] Avoid using anonymous namespaces in support headers
This avoids using anonymous namespaces in headers and ensures that
the various helper functions get deduplicated across the TUs
implementing <filesystem>. Otherwise, we'd get a definition of
these helper functions in each TU where they are used, which is
entirely unnecessary.
Differential Revision: https://reviews.llvm.org/D152378
Zain Jaffal [Mon, 26 Jun 2023 12:07:56 +0000 (13:07 +0100)]
[YAMLParser] Support block nodes when parsing YAML strings.
Previously if a string is in the format
```
|
val
val2
val3
```
Yaml parser will error out without parsing the string. The mentioned pattern is a valid yaml str and should be parsed.
Differential Revision: https://reviews.llvm.org/D153760
Nikita Popov [Mon, 26 Jun 2023 13:26:13 +0000 (15:26 +0200)]
[SCEV] Print block dispositions on mismatch (NFC)
Sam McCall [Sat, 24 Jun 2023 00:45:17 +0000 (02:45 +0200)]
[dataflow] Disallow implicit copy of Environment, use fork() instead
Environments are heavyweight, and copies are observably different from the
original: they introduce new SAT variables, which degrade performance &
debugging. Copies should only be done deliberately, where justified.
Empirically there are several places in the framework where we perform dubious
copies, sometimes entirely accidentally. (see e.g. D153491). Making these
explicit makes this mistake harder.
This patch forces copies to go through fork(), the copy-constructor is private.
This requires changes to existing callsites: some are correct and call fork(),
some are incorrect and are fixed, others are difficult and I left a FIXME.
Differential Revision: https://reviews.llvm.org/D153674
Christian Sigg [Mon, 26 Jun 2023 12:55:03 +0000 (14:55 +0200)]
[Bazel][llvm] Fix after 8de9f2b
Nikita Popov [Fri, 16 Jun 2023 15:16:52 +0000 (17:16 +0200)]
[LCSSA] Compute SCEV of LCSSA phi if original instruction had SCEV
The backstory is that the LCSSA invalidation we perform here is not
really necessary from a SCEV perspective. However, other code may
rely on the fact that invalidating only LCSSA phi nodes is sufficient
for transforms like loop peeling
(see https://reviews.llvm.org/D149331#4398582 for more details).
However, performing invalidation during LCSSA construction also
means that SCEV expansion (which may need to construct LCSSA) can
invalidate SCEV, which is somewhat unexpected and code may not be
prepared to deal with it (see the added test case, reported at
https://reviews.llvm.org/D149435#4428219).
Instead of invalidating SCEV, ensure that the LCSSA phi node also
has cached SCEV if the original instruction did. This means that
later invalidation of LCSSA phi nodes will work as expected. This
should avoid both the above issues and be more efficient.
Differential Revision: https://reviews.llvm.org/D153145
Leandro Lupori [Wed, 21 Jun 2023 19:32:48 +0000 (19:32 +0000)]
[NFC][flang] Fix PushSemantics macro
Add and use the CONCAT macro to force the expansion of __LINE__ in
PushSemantics body.
Reviewed By: clementval
Differential Revision: https://reviews.llvm.org/D153460
Leandro Lupori [Fri, 16 Jun 2023 15:59:52 +0000 (15:59 +0000)]
[flang] Fix lowering of array paths in elemental calls
Elemental procedures may need their array arguments to be passed by
address. This is done by setting ArrayExprLowering::semant to a
value that corresponds to this semantics. Later, member functions
such as applyPathToArrayLoad() read this variable to generate FIR
instructions that match the needed behavior. The problem is that
the semant variable also affects how array paths are lowered. Thus,
if an index of the path is an array element, this will cause its
address to be used instead of its value, which usually results in a
segmentation fault at runtime.
Example: b(i:i) = elem_func(a(v(i):v(i)))
To fix this, ArrayExprLowering::nextPathSemant was added. When it's
set, the next array path is handled with the semantics specified by
it, while the elemental argument retains its original semantics.
Fixes https://github.com/llvm/llvm-project/issues/62981
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D153454
Aaron Ballman [Mon, 26 Jun 2023 12:04:20 +0000 (08:04 -0400)]
Diagnose incorrect syntax for #pragma clang diagnostic
We would previously fail to diagnose unexpected tokens after a 'push'
or 'pop' directive.
Fixes https://github.com/llvm/llvm-project/issues/13920
serge-sans-paille [Mon, 26 Jun 2023 07:52:59 +0000 (09:52 +0200)]
[Remarks] Make sure -fdiagnostics-hotness-threshold implies -fdiagnostics-show-hotness
When asking for -fdiagnostics-hotness-threshold, we currently require
-fdiagnostics-show-hotness otherwise we silently display nothing.
I don't see a scenario where that makes sense, so have one option impy
the other.
Differential Revision: https://reviews.llvm.org/D153746
Simon Pilgrim [Mon, 26 Jun 2023 11:39:43 +0000 (12:39 +0100)]
[X86] Generalize combineVectorTruncationWithPACKUS/combineVectorTruncationWithPACKSS and reuse in LowerTRUNCATE
Rename combineVectorTruncationWithPACK* to truncateVectorWithPACK* and split the operands so LowerTRUNCATE can more easily use them.
Noticed while investigating some regressions in D152928 due to us trying to truncate to PACKUS/PACKSS instructions too early
Jean Perier [Mon, 26 Jun 2023 11:23:12 +0000 (13:23 +0200)]
[flang][hlfir] user defined assignment codegen
Add codegen support for hlfir.region_assign with user defined
assignment.
It is currently a bit pessimistic, because outside of forall, it
does not use the PURE aspect, if any, of the assignment routine to
rule out that the routine can write to something else than the LHS that
could overlap with the RHS.
However, the current lowering is anyway adding parenthesis around the
RHS, so this should not cause performance regressions.
Differential Revision: https://reviews.llvm.org/D153516
Jean Perier [Mon, 26 Jun 2023 11:06:43 +0000 (13:06 +0200)]
[flang][hlfir] Lower user defined assignment
Lower user defined assignment inside the hlfir.region_assign
"userDefinedAssignment" mlir region.
This is done by adding an entry point to ConvertCall.h in order
to call genUserCall with the region block arguments as arguments.
The codegen for hlfir.region_assign with user defined assignment
will be added in a later patch.
Differential Revision: https://reviews.llvm.org/D153404
Théo Degioanni [Mon, 26 Jun 2023 10:49:54 +0000 (12:49 +0200)]
[mlir][llvm] Introduce some constant folding.
This revision introduces some constant folding features to the LLVM
dialect. This specific choice of operations to cover is intended to
allow the elimination of logic generated by mem2reg with memset in the
common case of memsets of constant values.
This also introduces new verifiers for integer extension operations.
This lead to a fix in SPIRV to LLVM conversion, as it would sometimes
generate invalid ZExt and SExt operations.
Reviewed By: gysit
Differential Revision: https://reviews.llvm.org/D153135
Nikita Popov [Thu, 22 Jun 2023 07:14:08 +0000 (09:14 +0200)]
[BasicAA] Don't short-circuit non-capturing arguments
This is an alternative to D153464. BasicAA currently assumes that
an unescaped alloca cannot be read through non-nocapture arguments
of a call, based on the argument that if the argument were based on
the alloca, it would not be unescaped.
This currently fails in the case where the call is an ephemeral value
and as such does not count as a capture. It also happens for calls
that are readonly+nounwind+void, though that case tends to not matter
in practice, because such calls will get DCEd anyway.
Differential Revision: https://reviews.llvm.org/D153511
Florian Hahn [Mon, 26 Jun 2023 10:14:33 +0000 (11:14 +0100)]
[ConstraintElim] Add extra phi use tests.
Add additional tests for D153660.
Benjamin Kramer [Mon, 26 Jun 2023 10:04:24 +0000 (12:04 +0200)]
[bazel] Add TargetParser dep to tblgen after
8de9f2b558a046da15cf73191da627bdd83676ca
Quentin Colombet [Mon, 26 Jun 2023 09:42:55 +0000 (11:42 +0200)]
[Reassociation] Only form CSE expressions for local operands
# TL;DR #
This patch constrains how much freedom the heuristic that tries to from CSE
expressions has. The added constrain is that the CSE-able expressions must be
within the same basic block as the expressions they get moved before.
# Details #
The reassociation pass currently tweaks the rewrite of the final expression
towards surfacing pairs of operands that would be CSE-able.
This heuristic applies after the regular ordering of the expression.
The regular ordering uses the program structure to choose in which order each
subexpression is materialized. That order follows the topological order.
Now, to expose more CSE opportunities, this heurisitc effectively bypasses the
previous ordering normally defined by the program and pushes up sub-expressions
that are arbitrary deep in the CFG.
E.g., let's say the program order (top to bottom) gives `((a*b)*c)*d)*e` and
`b*e` appears the most in the program. The expression will be reordered in
`(((b*e)*a)*c)*d`
This reordering implies that all the sub expressions (in this example `xx*a`,
then `yy*c`, etc.) will need to appear after the CSE-able expression.
This may over-constrain where the (sub) expressions may live and in particular
it may create loop-dependent expressions.
This patch only allows to move expressions up the expression chain when the
related values are definied in the same basic block as the ones they
"push-down".
This constrain is far for being perfect but at least it avoids accidentally
creating loop dependent variables.
If we really want to expose CSE-able expressions in a proper way, we would need
a profitability metric and also make the decision globally as opposed to one
chain at a time.
I've put the new constrain behind an option to make comparing the old and new
versions easy. However, I believe that even if we find cases where the old
version performs better it is probably by accident. What I am aiming for with
this change is more predictability, then we can improve if need be.
This fixes www.llvm.org/PR61458
Differential Revision: https://reviews.llvm.org/D147457
Lorenzo Chelini [Wed, 21 Jun 2023 08:53:43 +0000 (10:53 +0200)]
[MLIR][Linalg] Avoid generalizing `linalg.map`
We cannot trivially generalize `linalg.map`, as it does not use the
output as a region argument in the block, while `linalg.generic` expects
many region arguments as the input/output operands.
Reviewed By: nicolasvasilache
Differential Revision: https://reviews.llvm.org/D153442
Piotr Zegar [Mon, 26 Jun 2023 09:19:01 +0000 (09:19 +0000)]
Revert "[clang-tidy] Add modernize-printf-to-std-print check"
This reverts commit
ec89cb9a81529fd41fb37b8e62203a2e9f23bd54.
Emilia Kond [Mon, 26 Jun 2023 09:35:47 +0000 (12:35 +0300)]
[clang-format] Preserve AmpAmpTokenType in nested parentheses
When parsing a requires clause, the UnwrappedLineParser would delegate to
parseParens with an AmpAmpTokenType set to BinaryOperator. However,
parseParens would not carry this over into any nested parens, meaning it
could assign a different token type to an && in a requires clause.
This patch makes sure parseParens inherits its parameter when performing
a recursive call.
Fixes https://github.com/llvm/llvm-project/issues/63251
Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D153641
Jens Massberg [Tue, 20 Jun 2023 11:25:56 +0000 (13:25 +0200)]
[clangd][c++20]Consider rewritten binary operators in TargetFinder
In C++20 some binary operations can be rewritten, e.g. `a != b`
can be rewritten to `!(a == b)` if `!=` is not explicitly defined.
The `TargetFinder` hasn't considered the corresponding `CXXRewrittenBinaryOperator` yet. This resulted that the definition of such operators couldn't be found
when navigating to such a `!=` operator, see https://github.com/clangd/clangd/issues/1476.
In this patch we add support of `CXXRewrittenBinaryOperator` in `FindTarget`.
In such a case we redirect to the inner binary operator of the decomposed form.
E.g. in case that `a != b` has been rewritten to `!(a == b)` we go to the
`==` operator. The `==` operator might be implicitly defined (e.g. by a `<=>`
operator), but this case is already handled, see the new test.
I'm not sure if I the hover test which is added in this patch is the right one,
but at least is passed with this patch and fails without it :)
Note, that it might be a bit missleading that hovering over a `!=` refers to
"instance method operator==".
Differential Revision: https://reviews.llvm.org/D153331
Job Noorman [Mon, 26 Jun 2023 08:26:56 +0000 (10:26 +0200)]
Move SubtargetFeature.h from MC to TargetParser
SubtargetFeature.h is currently part of MC while it doesn't depend on
anything in MC. Since some LLVM components might have the need to work
with target features without necessarily needing MC, it might be
worthwhile to move SubtargetFeature.h to a different location. This will
reduce the dependencies of said components.
Note that I choose TargetParser as the destination because that's where
Triple lives and SubtargetFeatures feels related to that.
This issues came up during a JITLink review (D149522). JITLink would
like to avoid a dependency on MC while still needing to store target
features.
Reviewed By: MaskRay, arsenm
Differential Revision: https://reviews.llvm.org/D150549
Emilia Kond [Mon, 26 Jun 2023 09:26:03 +0000 (12:26 +0300)]
[clang-format][NFC] Use correct test method for new tests
7a38b3bfeb56 landed after
20b4df1ed611, which refactored how tests are
structured in FormatTest. This quick fix-up unifies the tests added in
7a38b3bfeb56 to comply with this new format.
Mike Crowe [Mon, 26 Jun 2023 05:44:14 +0000 (05:44 +0000)]
[clang-tidy] Add modernize-printf-to-std-print check
Add FormatStringConverter utility class that is capable of converting
printf-style format strings into std::print-style format strings along
with recording a set of casts to wrap the arguments as required and
removing now-unnecessary calls to std::string::c_str() and
std::string::data()
Use FormatStringConverter to implement a new clang-tidy check that is
capable of converting calls to printf, fprintf, absl::PrintF,
absl::FPrintF, or any functions configured by an option to calls to
std::print and std::println, or other functions configured by options.
In other words, the check turns:
fprintf(stderr, "The %s is %3d\n", description.c_str(), value);
into:
std::println(stderr, "The {} is {:3}", description, value);
if it can.
std::print and std::println can do almost anything that standard printf
can, but the conversion has some some limitations that are described in
the documentation. If conversion is not possible then the call remains
unchanged.
Depends on D153716
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D149280
eopXD [Thu, 22 Jun 2023 08:35:34 +0000 (01:35 -0700)]
[Clang][RISCV] Check type support for local variable declaration of RVV type
Guard local variable declaration for RVV intrinsic types.
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D153510
Ingo Müller [Mon, 26 Jun 2023 08:22:22 +0000 (08:22 +0000)]
[mlir][LLVMIR] Allow !llvm.ptr<ptr> operands in atomicrmw xchg op.
Previously, llvm.atomicrmw only allowed operands that are pointers to
LLVM floats or integers. However, according to the LLVM IR Language
Reference, that op allows pointer to pointer operands in its `xchg`
mode. This patch allows those operands also in MLIR's LLVM dialect and
adapts the tests accordingly.
Reviewed By: gysit
Differential Revision: https://reviews.llvm.org/D153747
Luke Lau [Fri, 23 Jun 2023 13:56:56 +0000 (14:56 +0100)]
[RISCV] Teach doPeepholeMaskedRVV to handle vslide{up,down}
We already handle vslide1{up,down}, so this extends it to vslide{up,down}.
This was unintentionally added in https://reviews.llvm.org/D150463 and
then removed in
37cfcfcef76bb615b941d7077ca81168bd7ad080, but unless I'm
missing something this should still be ok as the mask only controls what
destination elements are written to.
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D153631
Luke Lau [Fri, 23 Jun 2023 13:31:45 +0000 (14:31 +0100)]
[RISCV] Add test cases for vmerge peephole with vslides
Currently vslide1{up,down}s can have vmerges folded into them, but not
vslide{up,down}s.
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D153630
Ingo Müller [Sun, 25 Jun 2023 09:04:49 +0000 (09:04 +0000)]
[mlir][affine][doc] Fix example snippet for AffineParallelOp. (NFC)
There were various syntax errors; all have pretty trivial fixes but
might distract novice users (like me).
Reviewed By: ingomueller-net
Differential Revision: https://reviews.llvm.org/D153720
Haohai Wen [Mon, 26 Jun 2023 07:27:06 +0000 (15:27 +0800)]
Reland [COFF] Support -gsplit-dwarf for COFF on Windows
This relands
3eee5aa528abd67bb6d057e25ce1980d0d38c445 with fixes.
Job Noorman [Mon, 26 Jun 2023 07:09:36 +0000 (09:09 +0200)]
[JITLink][RISCV] Adjust offsets of non-relaxable edges
The relaxation algorithm used to only update offsets of relaxable edges.
This caused non-relaxable edges that appear after a relaxed instruction
to have an incorrect offset and be applied at the wrong location. This
patch fixes this by updating the offsets of all edges.
Note that this bug was caused by an incorrect translation of LLD's
relaxation algorithm. LLD always uses all edges during relaxation while
I decided to filter-out relaxable edges to prevent having to iterate
non-relaxable edges at each step. However, this had the side-effect of
only updating offsets of relaxable edges. This patch leaves the
filtering of relaxable edges as-is but iterates all edges when updating
offsets.
Reviewed By: StephenFan
Differential Revision: https://reviews.llvm.org/D153515
Job Noorman [Mon, 26 Jun 2023 07:09:29 +0000 (09:09 +0200)]
[JITLink][RISCV] Expose relaxation pass publicly
This is useful for contexts where shouldAddDefaultTargetPasses returns
false but that still want to perform relaxation.
Reviewed By: StephenFan
Differential Revision: https://reviews.llvm.org/D153538
Job Noorman [Mon, 26 Jun 2023 07:09:19 +0000 (09:09 +0200)]
[JITLink][RISCV] Support relaxable edges without relaxation pass
Relaxable edges are created unconditionally, even when the relaxation
pass will not run. However, they were not recognized by applyFixup
causing them to not be applied.
To support configurations without the relaxation pass, this patch adds
these relaxable edges to applyFixup:
- CallRelaxable: Can be treated as R_RISCV_CALL
- AlignRelaxable: Can simply be ignored
An alternative could be to unconditionally run the relaxation pass, even
in contexts where shouldAddDefaultTargetPasses returns false. However, I
could imagine there being use cases for disabling relaxation which
wouldn't be possible anymore then.
Reviewed By: StephenFan
Differential Revision: https://reviews.llvm.org/D153541
pvanhout [Fri, 23 Jun 2023 10:26:57 +0000 (12:26 +0200)]
[NFC][GlobalISel] Don't return `bool` from apply functions
There is no case where those functions return false. It's always return true.
Even if they were to return false, it's not really something we should rely on I think.
With the current combiner implementation, it would just make `tryCombineAll` return false without retrying anymore rules.
I also believe that if an applyer were to return false, it would mean that the match function is not good enough. Asserting on failure in an apply function is a better idea, IMO.
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D153619
WANG Xuerui [Mon, 26 Jun 2023 07:07:21 +0000 (15:07 +0800)]
[Clang][LoongArch] Consume and check -mabi and -mfpu even if -m*-float is present
This kind of CLI flags duplication can sometimes be convenient for build
systems that may have to tinker with these.
For example, in the Linux kernel we almost always want to ensure no FP
instruction is emitted, so `-msoft-float` is present by default; but
sometimes we do want to allow FPU usage (e.g. certain parts of amdgpu DC
code), in which case we want the `-msoft-float` stripped and `-mfpu=64`
added. Here we face a dilemma without this change:
* Either `-mabi` is not supplied by `arch/loongarch` Makefile, in which
case the correct ABI has to be supplied by the driver Makefile
(otherwise the ABI will become double-float due to `-mfpu`), which is
arguably not appropriate for a driver;
* Or `-mabi` is still supplied by `arch/loongarch` Makefile, and the
build immediately errors out because
`-Werror=unused-command-line-argument` is unconditionally set for
Clang builds.
To solve this, simply make sure to check `-mabi` and `-mfpu` (and gain
some useful diagnostics in case of conflicting settings) when
`-m*-float` is successfully parsed.
Reviewed By: SixWeining, MaskRay
Differential Revision: https://reviews.llvm.org/D153707
David CARLIER [Sun, 25 Jun 2023 15:21:15 +0000 (16:21 +0100)]
sanitizer: enable getentropy interception on Linux/GLIBC 2.25 and onwards
https://man7.org/linux/man-pages/man3/getentropy.3.html
Reviewers: melver
Reviewed-By: melver
Differential Revision: https://reviews.llvm.org/D153723
Tobias Gysi [Mon, 26 Jun 2023 06:40:02 +0000 (06:40 +0000)]
[mlir] Avoid expensive LLVM IR import warnings
The revision adds a flag to the LLVM IR import
that avoids emitting expensive warnings about
unsupported debug intrinsics and unhandled
metadata.
Reviewed By: Dinistro
Differential Revision: https://reviews.llvm.org/D153625
Chuanqi Xu [Mon, 26 Jun 2023 06:27:05 +0000 (14:27 +0800)]
[C++] [Coroutines] Assume the allocation doesn't return nullptr
In case of 'get_return_object_on_allocation_failure' get declared, the
compiler is required to call 'operator new(size_t, nothrow_t)' and the
handle the failure case by calling
'get_return_object_on_allocation_failure()'. But the failure case should
be rare and we can assume the allocation is successful and pass the
information to the optimizer.
Craig Topper [Mon, 26 Jun 2023 05:58:33 +0000 (22:58 -0700)]
[RISCV] Properly handle partial writes in isConvertibleToVMV_V_V.
We were only checking for the previous insructions to write exactly
the register or a super register. We ignored writes to a subregister
and continued searching for the producing instruction. We need to
abort instead.
There's another check inside the if body to abort if the registers
don't match exactly. So we just need to check for overlap so we
enter the if body.
Reviewed By: fakepaper56
Differential Revision: https://reviews.llvm.org/D153490
Craig Topper [Mon, 26 Jun 2023 05:58:18 +0000 (22:58 -0700)]
[RISCV] Add test case for D153490. NFC
Craig Topper [Mon, 26 Jun 2023 05:53:58 +0000 (22:53 -0700)]
[RISCV] Use unsigned types for orc_b builtins.
Inspired by D153235, I think bit manipulation makes more
sense on unsigned types.
Reviewed By: Jim
Differential Revision: https://reviews.llvm.org/D153403
Jim Lin [Mon, 26 Jun 2023 02:27:55 +0000 (10:27 +0800)]
[RISCV] Change the type of argument to clz and ctz from ZiZi/WiWi to iUZi/iUWi
Input argument of clz and ctz should be unsigned type and return value
should be integer like `builtin_clz` and `builtin_ctz` defined in clang/include/clang/Basic/Builtins.def.
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D153235
Craig Topper [Mon, 26 Jun 2023 04:59:27 +0000 (21:59 -0700)]
[RISCV] Remove WriteJmpReg. Use WriteJalr in its place.
It was only used for the compressed instruction c.jr which expands
to jalr with rd=x0. Use WriteJalr instead to match jalr.
Aiden Grossman [Mon, 26 Jun 2023 03:15:43 +0000 (03:15 +0000)]
Revert "[llvm-exegesis] Introduce SubprocessMemory Utility Class"
This reverts commit
0b6b400b98b921279fc08c63a2a68ebfcb12a3e2.
The sporadic test failures were fixed during this land, but I forgot to
fix the build failures on certain platforms (seems to mostly be
AArch64/PPC) that result from them not being able to find the symbols
for shm_open and shm_unlink.
WANG Xuerui [Mon, 26 Jun 2023 01:55:13 +0000 (09:55 +0800)]
[llvm-objcopy] Add LoongArch support
Apart from general feature parity, this is also necessary for enabling
ClangBuiltLinux that defaults to using LLVM tools.
While at it, add a missing comment for the Hexagon definition directly
above, so it doesn't get confused with the SPARC definitions.
Reviewed By: SixWeining, MaskRay, jhenderson
Differential Revision: https://reviews.llvm.org/D153609
Weining Lu [Mon, 26 Jun 2023 01:26:15 +0000 (09:26 +0800)]
[LoongArch] Remove AssemblerPredicate for features: f/d/lsx/lasx/lvz/lbt
Linux LoongArch port [1] uses `-msoft-float` (implies no FPU) in its
`cflags` while it also uses floating-point insns in asm sources [2].
GAS allows this usage while IAS currently does not.
This patch removes `AssemblerPredicate`s for floating-point insns so
that to make IAS compitable with GAS. Similarly, also remove
`AssemblerPredicate`s for other ISA extensions, i.e. lsx/las/lvz/lbt.
[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/loongarch/Makefile?h=v6.4-rc1#n49
[2]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/loongarch/kernel/fpu.S?h=v6.4-rc1#n29
Reviewed By: xen0n, hev
Differential Revision: https://reviews.llvm.org/D150196
Weining Lu [Mon, 26 Jun 2023 01:50:36 +0000 (09:50 +0800)]
[doc][LoongArch] Add missed release note about `ual` feature addition
I meant to fold this into
47601815ec3a4f31c797c75748af08acfabc46dc
but failed to do so.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D152671
Aiden Grossman [Sat, 20 May 2023 09:50:43 +0000 (09:50 +0000)]
[llvm-exegesis] Introduce SubprocessMemory Utility Class
This patch introduces the SubprocessMemory class to llvm-exegesis. This
class contains several utilities that are needed for managing memory to
set up an execution environment for memory annotations.
Reviewed By: courbet
Differential Revision: https://reviews.llvm.org/D151022
Wang Rui [Mon, 26 Jun 2023 02:32:24 +0000 (10:32 +0800)]
[LoongArch] Optimize conditional selection of integer
This patch optimizes code generation by leveraging the zeroing behavior of the `maskeqz`/`masknez` instructions.
```
int sel(int a, int b)
{
return (a < b) ? a : 0;
}
```
```
slt $a1,$a0,$a1
masknez $a2,$r0,$a1
maskeqz $a0,$a0,$a1
or $a0,$a0,$a2
```
=>
```
slt $a1,$a0,$a1
maskeqz $a0,$a0,$a1
```
Reviewed By: SixWeining
Differential Revision: https://reviews.llvm.org/D153193
Weining Lu [Mon, 26 Jun 2023 02:30:42 +0000 (10:30 +0800)]
Revert "[LoongArch] Optimize conditional selection of integer"
This reverts commit
3dd319ecf3be64598ea84d1730033854cade7123.
Sorry, I forgot to amend the author name and email when merging this
patch.
Aiden Grossman [Sat, 20 May 2023 09:23:27 +0000 (09:23 +0000)]
[llvm-exegesis] Introduce Subprocess Executor Mode
This patch introduces the subprocess executor mode. Currently, this new
mode doesn't do anything fancy, just executing the same code that the
inprocess executor would do, but within a subprocess. This sets up the
ability to add in many more memory-related features in the future.
Reviewed By: courbet
Differential Revision: https://reviews.llvm.org/D151021
Younan Zhang [Sun, 25 Jun 2023 16:33:16 +0000 (00:33 +0800)]
[clang] Fix a crash on invalid destructor
This is a follow-up patch to D126194 in order to
fix https://github.com/llvm/llvm-project/issues/63503.
Reviewed By: shafik
Differential Revision: https://reviews.llvm.org/D153724
Jie Fu [Mon, 26 Jun 2023 00:59:37 +0000 (08:59 +0800)]
[SimplifyCFG] Remove unused variable 'Inc' (NFC)
/data/llvm-project/llvm/lib/Transforms/Utils/SimplifyCFG.cpp:6051:10: error: unused variable 'Inc' [-Werror,-Wunused-variable]
bool Inc, Wrapped = false;
^
1 error generated.
Aiden Grossman [Sun, 25 Jun 2023 23:46:22 +0000 (23:46 +0000)]
[llvm-exegesis] Add ability to assign perf counters to specific PID
This patch gives the ability to assign performance counters within
llvm-exegesis to a specific process by passing its PID. This is needed
later on for implementing a subprocess executor. Defaults to zero, the
current process, for the InProcessFunctionExecutorImpl.
Reviewed By: courbet
Differential Revision: https://reviews.llvm.org/D151020
khei4 [Mon, 19 Jun 2023 03:57:29 +0000 (12:57 +0900)]
[SimplifyCFG] add nsw on BuildLookuptable LinearMap calculation
Differential Revision: https://reviews.llvm.org/D150943
khei4 [Mon, 19 Jun 2023 03:57:07 +0000 (12:57 +0900)]
[SimplifyCFG] precommit test for LinearMap nsw (NFC)
Differential Revision: https://reviews.llvm.org/D153238
Matt Arsenault [Sun, 25 Jun 2023 15:23:15 +0000 (11:23 -0400)]
RegAllocGreedy: Fix assert with remarks on unassigned subregisters
This tried to query the physical subregister on virtual registers
if they were left unassigned.
Matt Arsenault [Sun, 25 Jun 2023 21:16:10 +0000 (17:16 -0400)]
AMDGPU: Handle the easy parts of strict fptrunc
f64->f16 is hard. The expansion is all integer but we need
to raise exceptions. Also doesn't handle the illegal f16 targets.
Matt Arsenault [Sun, 25 Jun 2023 20:39:15 +0000 (16:39 -0400)]
AMDGPU: Handle constrained fpext
Amaury Séchet [Sun, 25 Jun 2023 22:56:42 +0000 (22:56 +0000)]
[NFC] Autogenerate CodeGen/AMDGPU/combine-reg-or-const.ll
Amaury Séchet [Sun, 25 Jun 2023 21:19:27 +0000 (21:19 +0000)]
[NFC] Autogenerate CodeGen/PowerPC/tail-dup-break-cfg.ll
Niwin Anto [Sun, 25 Jun 2023 21:39:56 +0000 (14:39 -0700)]
[AArch64][GlobalISel] IR translate support for a return instruction of type <1 x i8> or <1 x i16> when using GlobalISel.
Code generation for return instruction of type <1 x i8> or <1 x i16> when using GlobalISel causes internal compiler crash Could not handle ret ty.
Fixes: https://github.com/llvm/llvm-project/issues/58211
Differential Revision: https://reviews.llvm.org/D153300
Tobias Stadler [Sun, 25 Jun 2023 05:08:50 +0000 (22:08 -0700)]
[AArch64][GlobalISel] Select G_UADDE/G_SADDE/G_USUBE/G_SSUBE
This implements the remaining overflow generating instructions in the AArch64
GlobalISel selector. Now wide add/sub operations do not fallback to SelectionDAG
anymore. We make use of PostSelectOptimize to cleanup the hereby generated
flag-setting operations when the carry-out is unused. Since we do not fallback
anymore when selecting add/sub atomics on O0 some test changes were required
there.
Fixes: https://github.com/llvm/llvm-project/issues/59407
Differential Revision: https://reviews.llvm.org/D153164
Amaury Séchet [Sun, 25 Jun 2023 21:05:06 +0000 (21:05 +0000)]
[NFC] Autogenerate CodeGen/PowerPC/pr40922.ll
Piotr Zegar [Sun, 25 Jun 2023 19:40:52 +0000 (19:40 +0000)]
Revert "[clang-tidy] Add modernize-printf-to-std-print check"
This reverts commit
81418ada06abbeba9fd0ea17282cce542cd07706.
Mike Crowe [Sun, 25 Jun 2023 17:38:09 +0000 (17:38 +0000)]
[clang-tidy] Add modernize-printf-to-std-print check
Add FormatStringConverter utility class that is capable of converting
printf-style format strings into std::print-style format strings along
with recording a set of casts to wrap the arguments as required and
removing now-unnecessary calls to std::string::c_str() and
std::string::data()
Use FormatStringConverter to implement a new clang-tidy check that is
capable of converting calls to printf, fprintf, absl::PrintF,
absl::FPrintF, or any functions configured by an option to calls to
std::print and std::println, or other functions configured by options.
In other words, the check turns:
fprintf(stderr, "The %s is %3d\n", description.c_str(), value);
into:
std::println(stderr, "The {} is {:3}", description, value);
if it can.
std::print and std::println can do almost anything that standard printf
can, but the conversion has some some limitations that are described in
the documentation. If conversion is not possible then the call remains
unchanged.
Depends on D153716
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D149280
Mike Crowe [Sun, 25 Jun 2023 16:41:48 +0000 (16:41 +0000)]
[ASTMatchers] Add argumentCountAtLeast narrowing matcher
This will be used by the modernize-use-std-print clang-tidy check and
related checks later.
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D153716
Nico Weber [Sun, 25 Jun 2023 18:32:36 +0000 (14:32 -0400)]
Revert "[COFF] Support -gsplit-dwarf for COFF on Windows"
This reverts commit
3eee5aa528abd67bb6d057e25ce1980d0d38c445.
Breaks tests on mac, see https://reviews.llvm.org/D152785#4447118
Florian Hahn [Sun, 25 Jun 2023 16:07:21 +0000 (17:07 +0100)]
[ConstraintElim] Add tests with condition used in phi.
Add extra tests where conditions are used in phis for D153660.
Florian Hahn [Sun, 25 Jun 2023 15:58:44 +0000 (16:58 +0100)]
[ConstraintElim] Add uses to remark tests to make it more robust.
Add uses of conditions, so the test keeps testing what it is meant to
test after D153660.
Takuya Shimizu [Sun, 25 Jun 2023 15:27:15 +0000 (00:27 +0900)]
[clang][Diagnostics] Provide parameter source range to arity-mismatch notes
Consider the following piece of code:
```
void func( int aa,
int bb,
int cc) {}
void arity_mismatch() {
func(2, 4);
}
```
BEFORE:
```
source.cpp:6:3: error: no matching function for call to 'func'
6 | func(2, 4);
| ^~~~
source.cpp:1:6: note: candidate function not viable: requires 3 arguments, but 2 were provided
1 | void func( int aa,
| ^
```
AFTER:
```
source.cpp:6:3: error: no matching function for call to 'func'
6 | func(2, 4);
| ^~~~
source.cpp:1:6: note: candidate function not viable: requires 3 arguments, but 2 were provided
1 | void func( int aa,
| ^ ~~~~~~~
2 | int bb,
| ~~~~~~~
3 | int cc) {}
| ~~~~~~
```
Reviewed By: cjdb, aaron.ballman
Differential Revision: https://reviews.llvm.org/D153267
Elliot Goodrich [Sun, 25 Jun 2023 15:09:36 +0000 (16:09 +0100)]
Revert "[llvm] Move StringExtras.h include from Error.h to Error.cpp"
This reverts commit
2fa0dbd7bf353db98b27b56137cced0a67de2748.
Elliot Goodrich [Sat, 17 Jun 2023 12:18:23 +0000 (13:18 +0100)]
[llvm] Move StringExtras.h include from Error.h to Error.cpp
Move the implementation of the `toString` function from
`llvm/Support/Error.h` to the source file, which allows us to move
`#include "llvm/ADT/StringExtras.h"` to the source file as well.
As `Error.h` is present in a large number of translation units this
means we are unnecessarily bringing in the contents of
`StringExtras.h` - itself a large file with lots of includes - and
slowing down compilation.
Also move the `#include "llvm/ADT/SmallVector.h"` directive to the
source file as it's no longer needed, but this does not give as much of
a benefit.
This reduces the total number of preprocessing tokens across the LLVM
source files in lib from (roughly) 1,920,413,050 to 1,903,629,230 - a
reduction of ~0.87%. This should result in a small improvement in
compilation time.
Differential Revision: https://reviews.llvm.org/D153229
Elliot Goodrich [Sat, 17 Jun 2023 12:18:23 +0000 (13:18 +0100)]
[llvm] Add missing StringExtras.h includes
In preparation for removing the `#include "llvm/ADT/StringExtras.h"`
from the header to source file of `llvm/Support/Error.h`, first add in
all the missing includes that were previously included transitively
through this header.
Corentin Jabot [Sun, 25 Jun 2023 08:26:30 +0000 (10:26 +0200)]
[Clang][NFC] Add feature test macro checks for C++2c
Craig Topper [Sun, 25 Jun 2023 07:48:26 +0000 (00:48 -0700)]
[RISCV] Add missing Read classes to some compressed instructions.
Reviewed By: wangpc
Differential Revision: https://reviews.llvm.org/D153669
Craig Topper [Sun, 25 Jun 2023 07:47:56 +0000 (00:47 -0700)]
[RISCV] Add GPR bypasses for most scalar integer instructions to the SiFive7 scheduler model.
SiFive7's scalar execution consists of 4 stages AG, M1, M2, WB.
Most simple arithmetic and branch instructions can execute in
either AG or M2.
If the operands are ready, the instruction will execute in the AG
stage. Otherwise, it executes in the M2 stage. Everything is fully
bypassed, so dependent instructions should only see 1 cycle latency.
This patch adds ReadAdvances to pretend that these instructions
execute in the M2 ALU and reads their operands then. This allows
the scheduler to schedule dependent instructions back to back.
I've increased branch latency to 3 since they are also executed in both
stages. Still need to fix JALR, but I want to cleanup some scheduler
classes first.
Multiply, cpop and division instructions can only start in the AG stage.
Still need to do some work for FP instructions that produce integer results.
I've added an llvm-mca test that creates a long dependency chain.
The timeline view can show that things are bypassed. I
didn't check all permutations, but we have some variety.
Reviewed By: wangpc
Differential Revision: https://reviews.llvm.org/D153666
David Green [Sun, 25 Jun 2023 07:44:43 +0000 (08:44 +0100)]
[AArch64] Add SVE tests for double reducts of vector.reduce.fmaximum/fminimum. NFC
Now that the SVE parts are in, we can fill in the double reduction tests
without them causing problems.
Iain Sandoe [Mon, 12 Jun 2023 19:38:02 +0000 (20:38 +0100)]
[C++20][Modules] Complete implementation of module.import p7.
The following test fails to compile TU b.cpp because we are not making the transitively imported modules visible (per [module.import]/p7)
```
a.cppm:
export module a;
export int foo() {
return 42;
}
b.cppm:
export module b;
import a;
export int bar();
b.cpp:
module b;
int bar() {
return foo();
}
clang++ -c -std=c++2b -fmodule-output a.cppm
clang++ -c -std=c++2b -fmodule-output -fprebuilt-module-path=. b.cppm
clang++ -c -std=c++2b -fprebuilt-module-path=. b.cpp
b.cpp:4:12: error: declaration of 'foo' must be imported from module 'a' before it is required
return foo();
```
This is fixed by the following patch (which also addresses a FIXME in basic.def.odr/p6.cppm).
Differential Revision: https://reviews.llvm.org/D152746
Fangrui Song [Sun, 25 Jun 2023 05:44:06 +0000 (22:44 -0700)]
[BPF] Remove unused legacy passes after TargetMachine::adjustPassManager removal
D137796 made these passes unused.
`opt --bpf-ir-peephole` is specified in one test. Add a `registerPipelineParsingCallback`
so that we can use change the test to use `opt --passes=bpf-ir-peephole` instead.
Haohai Wen [Sun, 25 Jun 2023 03:54:23 +0000 (11:54 +0800)]
[COFF] Support -gsplit-dwarf for COFF on Windows
D152340 has split WinCOFFObjectWriter to WinCOFFWriter. This patch adds
another WinCOFFWriter as DwoWriter to write Dwo sections to dwo file.
Driver options are also updated accordingly to support -gsplit-dwarf in
CL mode.
e.g. $ clang-cl -c -gdwarf -gsplit-dwarf foo.c
Like what -gsplit-dwarf did in ELF, using this option will create DWARF object
(.dwo) file. DWARF debug info is split between COFF object and DWARF object
file. It can reduce the executable file size especially for large project.
Reviewed By: skan, MaskRay
Differential Revision: https://reviews.llvm.org/D152785
Vaibhav Thakkar [Sun, 25 Jun 2023 02:27:10 +0000 (19:27 -0700)]
[clang] Fix pretty-printing for variables declared in a for-loop condition
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D153699
Shao-Ce SUN [Sat, 24 Jun 2023 15:04:49 +0000 (23:04 +0800)]
[flang] Rename remaining `__Fortran_PPC_intrinsics` to `__ppc_intrinsics`
Reviewed By: kkwli0
Differential Revision: https://reviews.llvm.org/D153703
Amaury Séchet [Sun, 25 Jun 2023 01:27:29 +0000 (01:27 +0000)]
[NFC] Autogenerate CodeGen/PowerPC/select-i1-vs-i1.ll
Amaury Séchet [Sun, 25 Jun 2023 01:05:21 +0000 (01:05 +0000)]
[NFC] Autogenerate CodeGen/ARM/2013-07-29-vector-or-combine.ll
Amaury Séchet [Sun, 25 Jun 2023 01:02:49 +0000 (01:02 +0000)]
[NFC] Autogenerate CodeGen/ARM/2011-03-15-LdStMultipleBug.ll
Amaury Séchet [Sun, 25 Jun 2023 00:55:03 +0000 (00:55 +0000)]
[NFC] Autogenerate CodeGen/ARM/and-sext-combine.ll
Amaury Séchet [Sun, 25 Jun 2023 00:44:30 +0000 (00:44 +0000)]
[NFC] Autogenerate CodeGen/ARM/machine-cse-cmp.ll
Amaury Séchet [Sun, 25 Jun 2023 00:14:07 +0000 (00:14 +0000)]
[NFC] Autogenerate CodeGen/ARM/pr35103.ll
yronglin [Sun, 25 Jun 2023 00:14:55 +0000 (08:14 +0800)]
[libc++][ranges] Implement P2494R2 (Relaxing range adaptors to allow for move only types)
Implement P2494R2 `Relaxing range adaptors to allow for move only types`
https://open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2494r2.html#wording-ftm
According to the words in P2494R2, I haven't add new test for `drop_while_view`, `take_while_view` and `filter_view`, because these views has the requirement that the predicate is an `indirect_unary_predicate`, which requires that the predicate is `copy_constructible`, so they still can't accept move only types as predicate.
```
[P2483R0] also suggests future work to relax the requirements on the predicate types stored by standard views. This paper does not perform this relaxation, as the copy constructibility requirement is enshrined in the indirect callable concepts ([indirectcallable.indirectinvocable]). Thus, while this paper modifies the views that currently use copyable-box for user provided predicates, it only does so to apply the rename of the exposition-only type to movable-box; it does not change any of the constraints on those views. It does, however, relax the requirements on invocables accepted by the transform family of views, because those are not constrained using the indirect callable concepts.
```
Reviewed By: #libc, var-const
Differential Revision: https://reviews.llvm.org/D151629
Jacques Pienaar [Sun, 25 Jun 2023 00:03:37 +0000 (17:03 -0700)]
[mlir][polyapprox] Use llvm::numbers for constants.
Fixes windows build.
Dave Lee [Sat, 24 Jun 2023 22:00:38 +0000 (15:00 -0700)]
[lldb] Use LLDB_LOGF for printf format strings in AppleObjCDeclVendor.cpp
Fangrui Song [Sat, 24 Jun 2023 18:07:12 +0000 (11:07 -0700)]
[DWARF] Remove remnant .zdebug section recognition
There is a minor behavior difference that is not worth testing for the obsoleted
format. Previously, llvm-dwarfdump considers .zdebug_info as a debug section but
does not decompress it, leading to a warning when the content cannot be parsed.
Now llvm-dwarfdump just ignores the section without a warning.
Ian Anderson [Mon, 5 Jun 2023 22:08:54 +0000 (15:08 -0700)]
[libc++] Remove the type_traits includes from limits and new
type_traits is currently unable to include __type_traits/noexcept_move_assign_container.h, because it would cause several include cycles.
type_traits -> __type_traits/noexcept_move_assign_container.h -> __memory/allocator_traits.h -> __memory/construct_at.h -> new -> exception -> type_traits
type_traits -> __type_traits/noexcept_move_assign_container.h -> __memory/allocator_traits.h -> __memory/construct_at.h -> new -> type_traits
type_traits -> __type_traits/noexcept_move_assign_container.h -> __memory/allocator_traits.h -> limits -> type_traits
This is a problem for clang modules after the std mega module is broken up (D144322), because it becomes a module cycle which is a hard error.
Unconditionally remove the type_traits includes from limits and new in all versions, and also remove the exception include from new. (These are already removed in C++23.)
Reviewed By: ldionne, Mordante, #libc
Differential Revision: https://reviews.llvm.org/D153214
Fangrui Song [Sat, 24 Jun 2023 17:06:17 +0000 (10:06 -0700)]
[DWARF] Adjust warning condition for .dwo sections with relocations
D106624 added a .dwo warning (when there are relocations) that may fire for
non-debug sections, e.g. `.rodata.dwo` when there is a data symbol foo in
-fdata-sections mode. Adjust it to only warn for .debug sections.
While here, change the diagnostic to be more conventional
https://llvm.org/docs/CodingStandards.html#error-and-warning-messages and use
the relocated section name instead of the relocation section name.
This change does not handle `.zdebug` (support was mostly removed from LLVM) or
`__debug` (Mach-O, no DWO support).
Reviewed By: ayermolo, HaohaiWen
Differential Revision: https://reviews.llvm.org/D153602
Shao-Ce SUN [Sat, 24 Jun 2023 16:32:42 +0000 (00:32 +0800)]
[openmp] remove initializeRewriteSymbolsLegacyPassPass
Fix build error caused by D153679
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D153704