Philip Reames [Fri, 2 Dec 2022 19:45:53 +0000 (11:45 -0800)]
[RISCV] Fold low 12 bits into instruction during frame index elimination
Fold the low 12 bits of an immediate offset into the offset field of the using instruction. That using instruction will be a load, store, or addi which performs an add of a signed 12-bit immediate as part of it's operation. Splitting out the low bits allows the high bits to be generated via a single LUI instead of needing an LUI/ADDI pair.
The codegen effect of this is mostly converting cases where "split addi" kicks in to using LUI + a folded offset. There are a couple of straight dynamic instruction count wins, and using a canonical LUI is probably better than a chain of SP adds if the dynamic instruction count is equal.
Differential Revision: https://reviews.llvm.org/D139037
Krzysztof Parzyszek [Fri, 2 Dec 2022 17:35:05 +0000 (09:35 -0800)]
TargetTransformInfo: convert Optional to std::optional
Recommit: added missing "#include <cstdint>".
Akira Hatanaka [Fri, 2 Dec 2022 19:41:09 +0000 (11:41 -0800)]
Don't revisit the subexpressions of PseudoObjectExpr when building a
ParentMap
The assertion that is removed in this patch was failing when ObjC dot
notation expressions appear in both sides of an assignment (see the test
case in arc-repeated-weak.mm). Visit the PseudoObjectExpr once when the
syntactic expression is visited and return without visiting the
subexpressions when it's visited again when the semantic expressions are
visited.
Differential Revision: https://reviews.llvm.org/D139171
Krzysztof Parzyszek [Fri, 2 Dec 2022 19:33:24 +0000 (11:33 -0800)]
Revert "TargetTransformInfo: convert Optional to std::optional"
This reverts commit
b83711248cb12639e7ef7303cfbb4452b4067e85.
Some buildbots are failing.
Mitch Phillips [Thu, 1 Dec 2022 23:35:04 +0000 (15:35 -0800)]
Make -fsanitize=scudo use scudo_standalone. Delete check-scudo.
Leaves the implementation and tests files in-place for right now, but
deletes the ability to build the old sanitizer-common based scudo. This
has been on life-support for a long time, and the newer scudo_standalone
is much better supported and maintained.
Also patches up some GWP-ASan wording, primarily related to the fact
that -fsanitize=scudo now is scudo_standalone, and therefore the way to
reference the GWP-ASan options through the environment variable has
changed.
Future follow-up patches will delete the original scudo, and migrate all
its tests over to be part of the scudo_standalone test suite.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D138157
Krzysztof Parzyszek [Fri, 2 Dec 2022 17:35:05 +0000 (09:35 -0800)]
TargetTransformInfo: convert Optional to std::optional
wren romano [Fri, 2 Dec 2022 02:29:22 +0000 (18:29 -0800)]
[mlir][sparse] LICM for SparseTensorReader::readCOO
This commit performs two related changes. First we adjust `readCOOValue` to take the `IsPattern` bool as a template parameter rather than a function argument. Second we factor `readCOOLoop` out from `readCOO`, and template it on `IsPattern` and `IsSymmetric`. Together this moves all the assertions and header-dependent conditionals out of the main for-loop of `readCOO`. The only remaining conditional is in the `IsSymmetric=true` variant: checking whether the element is on the diagonal or not (which cannot be lifted out of the loop).
Depends On D138363
Reviewed By: aartbik
Differential Revision: https://reviews.llvm.org/D138365
Peter Klausler [Thu, 1 Dec 2022 00:11:20 +0000 (16:11 -0800)]
[flang] Check discrepancies between local & available global subprograms
When a scope declares the name and perhaps some characteristics of
an external subprogram using any of the many means that Fortran supplies
for doing such a thing, and that external subprogram's definition is
available, check the local declaration against the external definition.
In particular, if the global definition's interface cannot be called
by means of an implicit interface, ensure that references are via an
explicit and compatible interface.
Further, extend call site checking so that when a local declaration
exists for a known global symbol and the arguments are valid for that
local declaration, the arguments are checked against the global's
interface, just are is already done when no local declaration exists.
Differential Revision: https://reviews.llvm.org/D139042
wren romano [Fri, 2 Dec 2022 02:18:33 +0000 (18:18 -0800)]
[mlir][sparse] Breaking up openSparseTensor to better support non-permutations
This commit updates how the `SparseTensorConversion` pass handles `NewOp`. It breaks up the underlying `openSparseTensor` function into two parts (`SparseTensorReader::create` and `SparseTensorReader::readSparseTensor`) so that the pass can inject code for constructing `lvlSizes` between those two parts. Migrating the construction of `lvlSizes` out of the runtime and into the pass is a necessary first step toward fully supporting non-permutations. (The alternative would be for the pass to generate a `FuncOp` for performing the construction and then passing that to the runtime; which doesn't seem to have any benefits over the design of this commit.) And since the pass now generates the code to call these two functions, this change also removes the `Action::kFromFile` value from the enum used by `_mlir_ciface_newSparseTensor`.
Reviewed By: aartbik
Differential Revision: https://reviews.llvm.org/D138363
Fangrui Song [Fri, 2 Dec 2022 19:05:43 +0000 (19:05 +0000)]
[AsmPrinter] .addrsig_sym: remove isTransitiveUsedByMetadataOnly
With D135642 ignoring unregistered symbols, isTransitiveUsedByMetadataOnly added
by D101512 is no longer needed (the operation is potentially slow). There is a
`.addrsig_sym` directive for an only-used-by-metadata symbol but it does not
emit an entry.
Reviewed By: rnk
Differential Revision: https://reviews.llvm.org/D138362
Fangrui Song [Fri, 2 Dec 2022 18:57:48 +0000 (18:57 +0000)]
[Driver] -p: change from unused warning to error for most targets
AIX and OpenBSD seem to use -p. For most targets (at least FreeBSD and Linux),
-p is legacy (GCC freebsd has a warning). We don't want the uses to grow, so
making -p an alias for -pg is not recommended. I think the uses are small.
Reviewed By: mgorny
Differential Revision: https://reviews.llvm.org/D138255
Rong Xu [Fri, 2 Dec 2022 18:22:07 +0000 (10:22 -0800)]
[PGO][indirect-call-promotion] Add extra parameter check for musttail callsite
Indirect-call-promtion for musttail callsite needs stricter type check
with parameter. This patch adds the needed extra parameter type check.
Differential Revision: https://reviews.llvm.org/D139051
Jan Svoboda [Fri, 2 Dec 2022 18:45:20 +0000 (10:45 -0800)]
Reapply "[clang][modules][deps] Including module maps are affecting"
This reverts commit
f0ce827c6972009c5052f8447c6aadf4e4be6113.
This reapplies commit
83973cf157f7850eb133a4bbfa0f8b7958bad215.
The new test now should pass on Windows thanks to commit
4d6483e91bb8f4147ff4001e6a11e373d5198e1c.
Argyrios Kyrtzidis [Thu, 1 Dec 2022 00:12:35 +0000 (16:12 -0800)]
[lldb/unittests/CMakeLists.txt] Remove extra compiler flag `-include gtest_common.h`, NFC
This doesn't seem to be necessary anymore so remove it to be more consistent with rest of the LLVM projects
that don't use prefix headers.
Differential Revision: https://reviews.llvm.org/D139058
Peter Klausler [Mon, 24 Oct 2022 17:14:03 +0000 (10:14 -0700)]
[flang] Accommodate unknowable CHARACTER length in evaluate::ArrayConstructor<>
The internal representation for array constructors in expressions during semantic
analysis needs to be able to accommodate circumstances (e.g. TRIM(), substrings)
in which the length of the elements in the array is either unknown or cannot be
represented as a context-free integer expression.
Differential Revision: https://reviews.llvm.org/D139041
Jan Svoboda [Fri, 2 Dec 2022 18:26:23 +0000 (10:26 -0800)]
Reapply "[clang][modules][deps] Parent module maps are affecting"
This reverts commit
67f34054d6ea8e40fd10cb74441d5ccab004c75b.
This reapplies commit
f99e5a9106f08ad92a22c3b114d2052e5c502924.
This improves commit
8ab388e158528d9af5eb0376ef698b243d946f19 that unsucessfully attempted to forward-fix Windows test failure.
Argyrios Kyrtzidis [Thu, 1 Dec 2022 00:36:00 +0000 (16:36 -0800)]
[lldb] Fix the `dwarf` log descriptions
Differential Revision: https://reviews.llvm.org/D139061
chenglin.bi [Fri, 2 Dec 2022 18:01:47 +0000 (02:01 +0800)]
[InstCombine] Precommit tests for D139076; NFC
Peter Klausler [Fri, 11 Nov 2022 01:29:29 +0000 (17:29 -0800)]
[flang] Restore ENUM_CLASS() to be compilation-time code
Rework some recent changes to the ENUM_CLASS() macro so that
all of the construction of enumerator-to-name string mapping
data structures is again performed at compilation time.
Differential Revision: https://reviews.llvm.org/D137859
Paul Robinson [Fri, 4 Nov 2022 15:36:00 +0000 (08:36 -0700)]
[lit][AIX] Convert clang tests to use 'target={{.*}}-aix{{.*}}'
Part of the project to eliminate special handling for triples in lit
expressions.
Differential Revision: https://reviews.llvm.org/D137437
Paul Robinson [Fri, 4 Nov 2022 15:35:11 +0000 (08:35 -0700)]
[lit][AIX] Convert llvm tests to use 'target={{.*}}-aix{{.*}}'
Part of the project to eliminate special handling for triples in lit
expressions.
Differential Revision: https://reviews.llvm.org/D137436
Usman Nadeem [Wed, 30 Nov 2022 21:15:43 +0000 (13:15 -0800)]
[Flang][Driver] Handle target CPU and features
This patch:
- Adds target-feature and target-cpu to FC1Options.
- Moves getTargetFeatures() from Clang.cpp to CommonArgs.cpp.
- Processes target cpu and features in the flang driver. Right now
features are only added for AArch64/x86 because I only did basic
testing on them but it should generally work for others as well.
Option handling is similar to clang.
- Adds appropriate structures in TargetOptions and passes them to
the target machine.
What's missing:
- Adding the CPU info and the features as attributes in the LLVM IR
module.
- Processing target specific flags, e.g. SVE vector bits for AArch64,
ABI etc.
Differential Revision: https://reviews.llvm.org/D137995
Change-Id: Ib081a74ea98617674845518a5d2754edba596418
Jun Zhang [Fri, 2 Dec 2022 17:10:13 +0000 (01:10 +0800)]
Link with missing libs to fix broken shared unittest build
Oops, I think we should link with this as well.
Signed-off-by: Jun Zhang <jun@junz.org>
Jean Perier [Fri, 2 Dec 2022 16:57:01 +0000 (17:57 +0100)]
[flang] fix unused-but-set-parameter warning in ConvertExprToHLFIR.cpp
Some named value operands are not used yet (TODOs). Some compilers
complain about it. Remove names of unused parameters.
Differential Revision: https://reviews.llvm.org/D139207
Nicolas Vasilache [Sun, 13 Nov 2022 23:20:44 +0000 (15:20 -0800)]
[mlir][Linalg] NFC - Purge OpBuilder uses in favor of RewriterBase in places unrelated to op definitions
RewriterBase is the proper builder to use so one can listen to IR modifications (i.e. not just creation).
Differential Revision: https://reviews.llvm.org/D137922
Jun Zhang [Fri, 2 Dec 2022 15:34:59 +0000 (23:34 +0800)]
Link with missing libs to fix broken shared build
Signed-off-by: Jun Zhang <jun@junz.org>
Differential Revision: https://reviews.llvm.org/D139202
Pietro Albini [Thu, 17 Nov 2022 14:32:38 +0000 (15:32 +0100)]
[lldb] fix license header in TraceHTR.h
It seems like the license header got mangled somehow, joining multiple
lines together and splitting some lines across multiple ones. That is
causing errors in a license checker I'm using (called REUSE).
This commit restores the license header to the format used by the rest
of the files in the project.
Differential Revision: https://reviews.llvm.org/D138271
Benjamin Kramer [Fri, 2 Dec 2022 15:56:05 +0000 (16:56 +0100)]
[bazel] Add a missing dependency after
786cbb09ed
Quentin Colombet [Fri, 2 Dec 2022 14:41:29 +0000 (14:41 +0000)]
Re-apply "[mlir][MemRefToLLVM] Remove the code for lowering subview"
This reverts commit
d0650d108929985760d536d59e9927838dccc9b8.
Original commit message:
Subviews are supposed to be expanded before we hit the lowering
code.
The expansion is done with the pass called
expand-strided-metadata.
Add a test that demonstrate how these passes can be linked up to achieve
the desired lowering.
This patch is NFC in spirit but not in practice because `subview` gets
lowered into `reinterpret_cast(extract_strided_metadata, <some math>)`
which lowers in two memref descriptors (one for `reinterpert_cast` and
one for `extract_strided_metadata`), which creates some noise of the
form: `extractvalue(unrealized_cast(extractvalue[0]))[0]` that is
currently not simplified within MLIR but that is really just noop in
that case.
Differential Revision: https://reviews.llvm.org/D136377
Jean Perier [Fri, 2 Dec 2022 15:19:30 +0000 (16:19 +0100)]
[flang] Lower conversions to HLFIR
Differential Revision: https://reviews.llvm.org/D139196
Sanjay Patel [Fri, 2 Dec 2022 14:18:11 +0000 (09:18 -0500)]
[SDAG] bail out of mergeTruncStores() if there's any other use in the chain
This fixes the miscompile in issue #58883.
The test demonstrates that we gave up on store merging in that example.
This change should be strictly safe (just adds another clause
to avoid the transform), and it does not prohibit any existing
valid optimizations based on regression tests. I want to believe
that it's also a sufficient fix (possibly overkill), but I'm not
sure how to prove that.
Differential Revision: https://reviews.llvm.org/D137791
Valery Pykhtin [Mon, 17 Oct 2022 11:30:45 +0000 (13:30 +0200)]
[AMDGPU] Scheduler: Don't revert the schedule if the register pressure isn't changed for a region
This one-linear fix improves compilation time for about ~40% on ASAN enabled code.
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D136069
Valentin Clement [Fri, 2 Dec 2022 14:51:01 +0000 (15:51 +0100)]
[flang] Perform assignment to polymorphic allocatable with runtime call
Lower assignment to polymorphic allocatable to the `Assign` runtime
call.
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D139192
Matthias Springer [Fri, 2 Dec 2022 10:46:14 +0000 (11:46 +0100)]
[mlir][bufferization] Make `TensorCopyInsertionPass` a test pass
TensorCopyInsertion should not have been exposed as a pass. This was a flaw in the original design. It is a preparation step for bufferization and certain transforms (that would otherwise be legal) are illegal between TensorCopyInsertion and actual rewrite to MemRef ops. Therefore, even if broken down as two separate steps internally, they should be exposed as a single pass.
This change affects the sparse compiler, which uses `TensorCopyInsertionPass`. A new `SparsificationAndBufferizationPass` is added to replace all passes in the sparse tensor pipeline from `TensorCopyInsertionPass` until the actual bufferization (rewrite to memref/non-tensor). It is generally unsafe to run arbitrary passes in-between, in particular passes that hoist tensor ops out of loops or change SSA use-def chains along tensor ops.
Differential Revision: https://reviews.llvm.org/D138915
Florian Hahn [Fri, 2 Dec 2022 14:34:34 +0000 (14:34 +0000)]
[DSE] Use precise loc for memcpy_chk during overwrite checks.
Extends the logic from D115167 to memcpy_chk.
Depends on D115167
Reviewed By: asbirlea
Differential Revision: https://reviews.llvm.org/D139096
chenglin.bi [Fri, 2 Dec 2022 14:26:20 +0000 (22:26 +0800)]
[Instcombine] Code refactors for foldSelectOpOp; NFC
Reuse the code about find common operator.
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D139075
Quentin Colombet [Fri, 2 Dec 2022 14:19:37 +0000 (14:19 +0000)]
Revert "[mlir][MemRefToLLVM] Remove the code for lowering subview"
This reverts commit
c8e15afa4caf74f0d8281ca3e44674f1f6c1bc52.
This breaks some integration tests, see
https://lab.llvm.org/buildbot/#/builders/220/builds/10446
I have to update a bunch of RUN lines in the tests to use the new
lowering scheme. Nothing complicated but let's keep the build clean
while I'm fixing that.
Jay Foad [Fri, 2 Dec 2022 14:07:11 +0000 (14:07 +0000)]
Revert "[AMDGPU] Speedup GCNDownwardRPTracker::advanceBeforeNext"
This reverts commit
2d09bec169277fb5a341249afacff532c7511756.
It was causing assertion failures in some out-of-tree tests.
Krzysztof Parzyszek [Fri, 2 Dec 2022 03:50:39 +0000 (21:50 -0600)]
Attributes: convert Optional to std::optional
Michael Buch [Fri, 2 Dec 2022 14:12:41 +0000 (14:12 +0000)]
Revert "[lldb][Target] Flush the scratch TypeSystem when owning lldb_private::Module gets unloaded"
This reverts commit
4df11394a10b3b15d2fb9bde8b831cf68785aa45.
Lorenzo Chelini [Fri, 2 Dec 2022 13:50:23 +0000 (14:50 +0100)]
Revert "Revert "[MLIR] Introduce constraint attributes for DenseArrayAttr""
This reverts commit
4e6dab98e0cb60c635656a818062887d97c3ef5f.
Re-apply: D138988 after fixing error on windows. Remove test for boolean
attributes as it does not make sense to apply these constraints on
boolean array.
Jean Perier [Fri, 2 Dec 2022 13:46:22 +0000 (05:46 -0800)]
[flang] add missing unreachable in D139179
Fix bot failure https://lab.llvm.org/buildbot/#/builders/160/builds/13647
caused by https://reviews.llvm.org/D139179.
Even if the switch is fully covering, adding an unreachable after is
required to cover all path since the switch argument could be a broken
value that does not belong to the enum.
Jean Perier [Fri, 2 Dec 2022 13:22:25 +0000 (14:22 +0100)]
[flang] Lower unary operation to HLFIR
Lower not, negate, and complex component to HLFIR.
Parentheses is the only remaining operation, but needs some
care/thinking to properly deal with character/derived variables.
Differential Revision: https://reviews.llvm.org/D139186
Jean Perier [Fri, 2 Dec 2022 13:21:06 +0000 (14:21 +0100)]
[flang] Make SetLength TODO explicit in HLFIR
evaluate::SetLength is the last intrinsic binary operation
that needs to be lowered to HLFIR. It will require an hlfir.set_length
op or hlfir.as_expr to convert the result to an expression. Add a TODO
for now.
Differential Revision: https://reviews.llvm.org/D139183
Jean Perier [Fri, 2 Dec 2022 13:20:06 +0000 (14:20 +0100)]
[flang] Lower complex constructor to HLFIR
Differential Revision: https://reviews.llvm.org/D139180
Jean Perier [Fri, 2 Dec 2022 13:19:05 +0000 (14:19 +0100)]
[flang] Lower logical operations to HLFIR
Differential Revision: https://reviews.llvm.org/D139179
Jean Perier [Fri, 2 Dec 2022 13:17:55 +0000 (14:17 +0100)]
[flang] Lower relational to HLFIR
Differential Revision: https://reviews.llvm.org/D139176
Florian Hahn [Fri, 2 Dec 2022 12:58:46 +0000 (12:58 +0000)]
Revert "Enhance stack protector for calling no return function"
This reverts commit
416e8c6ad529c57f21f46c6f52ded96d3ed239fb.
This commit causes a test failure with expensive checks due to a DT
verification failure. Revert to bring bot back to green:
https://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-expensive/24249/testReport/junit/LLVM/CodeGen_X86/stack_protector_no_return_ll/
+ /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-expensive/clang-build/bin/llc /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-expensive/llvm-project/llvm/test/CodeGen/X86/stack-protector-no-return.ll -mtriple=x86_64-unknown-linux-gnu -o -
+ /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-expensive/clang-build/bin/FileCheck /Users/buildslave/jenkins/workspace/clang-stage1-cmake-RA-expensive/llvm-project/llvm/test/CodeGen/X86/stack-protector-no-return.ll
DominatorTree is different than a freshly computed one!
Current:
=============================--------------------------------
Inorder Dominator Tree: DFSNumbers invalid: 0 slow queries.
[1] %entry {
4294967295,
4294967295} [0]
[2] %unreachable {
4294967295,
4294967295} [1]
[2] %lpad {
4294967295,
4294967295} [1]
[3] %invoke.cont {
4294967295,
4294967295} [2]
[4] %invoke.cont2 {
4294967295,
4294967295} [3]
[4] %SP_return3 {
4294967295,
4294967295} [3]
[4] %CallStackCheckFailBlk2 {
4294967295,
4294967295} [3]
[3] %lpad1 {
4294967295,
4294967295} [2]
[4] %eh.resume {
4294967295,
4294967295} [3]
[5] %SP_return6 {
4294967295,
4294967295} [4]
[5] %CallStackCheckFailBlk5 {
4294967295,
4294967295} [4]
[4] %terminate.lpad {
4294967295,
4294967295} [3]
[5] %SP_return9 {
4294967295,
4294967295} [4]
[5] %CallStackCheckFailBlk8 {
4294967295,
4294967295} [4]
[2] %SP_return {
4294967295,
4294967295} [1]
[2] %CallStackCheckFailBlk {
4294967295,
4294967295} [1]
Roots: %entry
Guillaume Chatelet [Fri, 2 Dec 2022 10:08:08 +0000 (10:08 +0000)]
[lld][Alignment][NFC] Use Align instead of log2 of alignment in Wasm Sections
I intend to slowly upgrade all alignments to the Align type in lld as well.
Some places talk about alignment in Bytes while other specify them as Log2(Bytes).
Let's make sure all of this is coherent.
Differential Revision: https://reviews.llvm.org/D139181
Guillaume Chatelet [Fri, 2 Dec 2022 12:42:43 +0000 (12:42 +0000)]
[Alignment][NFC] Use Align in StringTableBuilder ctor
Sam McCall [Wed, 30 Nov 2022 14:59:23 +0000 (15:59 +0100)]
[include-cleaner] clang-include-cleaner can print/apply edits
This adds command-line flags to the tool:
+ -print: prints changed source code
+ -print=changes: prints headers added/removed
+ -edit: rewrites code in place
+ -insert=0/-remove=0: disables additions/deletions for the above
These are supported by a couple of new functions dumped into Analysis:
analyze() sits on top of walkUsed and makes used/unused decisions for
Includes. fixIncludes() applies those results to source code.
Differential Revision: https://reviews.llvm.org/D139013
Guillaume Chatelet [Fri, 2 Dec 2022 12:10:06 +0000 (12:10 +0000)]
[Alignment][NFC] Use Align within StringTableBuilder
Florian Hahn [Fri, 2 Dec 2022 11:28:22 +0000 (11:28 +0000)]
[DSE] Use precise loc for memset_chk during overwrite checks
memset_chk may not write the number of bytes specified by the third
argument, if it is larger than the destination size (specified as 4th
argument).
Reviewed By: asbirlea
Differential Revision: https://reviews.llvm.org/D115167
Ties Stuij [Thu, 1 Dec 2022 16:37:50 +0000 (16:37 +0000)]
[AArch64] use CNT for ISD::popcnt and ISD::parity if available
These are the two places where we explicitly want to use cnt in
SelectionDAG when feature CSSC is available: ISD::popcnt and ISD::parity
For both, we need to make sure we're emitting optimized code for i32 (and
lower), i64 and i128. The most optimal way is of course using the GPR CNT
instruction. If we don't have CSSC, but we do have neon, we'll use floating
point CNT. If all fails, we'll fall back on the general GPR popcnt and parity
implementations.
spec:
https://developer.arm.com/documentation/ddi0602/2022-09/Base-Instructions/CNT--Count-bits-
Reviewed By: lenary
Differential Revision: https://reviews.llvm.org/D138808
Tomas Matheson [Fri, 2 Dec 2022 10:56:34 +0000 (10:56 +0000)]
[NFC] clang-format AArch64TargetParser
Michael Buch [Fri, 25 Nov 2022 14:45:09 +0000 (14:45 +0000)]
[lldb][Target] Flush the scratch TypeSystem when owning lldb_private::Module gets unloaded
**Summary**
This patch addresses #59128, where LLDB would crash when evaluating
importing a type that has been imported before into the same target.
The proposed solution is to clear the scratch AST (and associated
persistent variables, `ClangASTImporter`, etc.) whenever a module that
could've owned one of the stale `TypeSystem`s gets unloaded/destroyed.
Details:
1. The first time we evaluate the expression we import the decl for Foo into the Targets scratch AST
context (lives in m_scratch_type_system_map). During this process we also create a ClangASTImporter
that lives in the ClangPersistentVariables::m_ast_importer_sp. This importer has decl tracking
structures which reference the source AST that the decl got imported from. This importer also gets
re-used for all calls to DeportType (which we use to copy the final decl into the Targets scratch AST).
2. Rebuilding the executable triggers a tear-down of the Module that was backing the ASTContext that
we originally got the Foo decl from (which lived in the Module::m_type_system_map). However, the Target’s scratch AST lives on.
3. Re-running the same expression will now create a new ASTImporterDelegate where the destination TranslationUnitDecl is
the same as the one from step (1).
4. When importing the new Foo decl we first try to find it in the destination DeclContext, which happens to be
the scratch destination TranslationUnitDecl. The `Foo` decl exists in this context since we copied it into
the scratch AST in the first run. The ASTImporter then queries LLDB for the origin of that decl. Using the
same persistent variable ClangASTImporter we claim the decl has an origin in the AST context that got torn
down with the Module. This faulty origin leads to a use-after-free.
**Testing**
- Added API test
Differential Revision: https://reviews.llvm.org/D138724
Michael Buch [Thu, 1 Dec 2022 09:24:32 +0000 (09:24 +0000)]
[lldb][Module][NFC] Add ModuleList::AnyOf
Differential Revision: https://reviews.llvm.org/D139083
Michael Buch [Thu, 1 Dec 2022 08:59:03 +0000 (08:59 +0000)]
[lldb][Module] Document ModuleList::ForEach and assert nullness
Currently all callsites already assume the pointer is non-null.
This patch just asserts this assumption.
This is practically enforced by `ModuleList::Append`
which won't add `nullptr`s to `m_modules`.
Differential Revision: https://reviews.llvm.org/D139082
Konstantin Vladimirov [Fri, 2 Dec 2022 07:49:45 +0000 (10:49 +0300)]
[RISCV] Add correct predicate over FMV instructions
Restricts FMV usage for subtargets without 'f' extension.
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D139105
tentzen [Fri, 2 Dec 2022 10:42:43 +0000 (02:42 -0800)]
Revert "[Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 2"
This reverts commit
1a949c871ab4a6b6d792849d3e8c0fa6958d27f5.
Quentin Colombet [Sat, 15 Oct 2022 00:25:56 +0000 (00:25 +0000)]
[mlir][MemRefToLLVM] Remove the code for lowering subview
Subviews are supposed to be expanded before we hit the lowering
code.
The expansion is done with the pass called
expand-strided-metadata.
Add a test that demonstrate how these passes can be linked up to achieve
the desired lowering.
This patch is NFC in spirit but not in practice because `subview` gets
lowered into `reinterpret_cast(extract_strided_metadata, <some math>)`
which lowers in two memref descriptors (one for `reinterpert_cast` and
one for `extract_strided_metadata`), which creates some noise of the
form: `extractvalue(unrealized_cast(extractvalue[0]))[0]` that is
currently not simplified within MLIR but that is really just noop in
that case.
Differential Revision: https://reviews.llvm.org/D136377
Matthias Springer [Fri, 2 Dec 2022 09:40:29 +0000 (10:40 +0100)]
[mlir][tensor] Fold rank-reducing insert_slice with inverse collapse_shape
Differential Revision: https://reviews.llvm.org/D139104
Matthias Springer [Fri, 2 Dec 2022 09:40:03 +0000 (10:40 +0100)]
[mlir][tensor] Fold rank-reducing extract_slice with inverse expand_shape
Differential Revision: https://reviews.llvm.org/D139103
River Riddle [Fri, 2 Dec 2022 08:22:10 +0000 (00:22 -0800)]
[mlir][Index] Add pretty result names for ConstantOp and BoolConstantOp
ConstantOp uses `%idx<value>` and BoolConstantOp uses true/false, which
is similar to the printing for arith::ConstantOp.
Differential Revision: https://reviews.llvm.org/D139175
Mel Chen [Fri, 2 Dec 2022 08:03:42 +0000 (00:03 -0800)]
[NFC] Update Transforms/LoopVectorize/RISCV/select-cmp-reduction.ll.
Valentin Clement [Fri, 2 Dec 2022 08:52:06 +0000 (09:52 +0100)]
[flang] Enable character type guard in select type
SELECT TYPE lower and conversion was not handling
`character` type guard. This add support for it.
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D139106
Vlad Serebrennikov [Fri, 2 Dec 2022 08:52:19 +0000 (11:52 +0300)]
[clang] Remove unused bookmark in CWG360 test (NFC)
KAWASHIMA Takahiro [Wed, 16 Nov 2022 10:54:32 +0000 (19:54 +0900)]
[clang][docs] Correct floating point option explanations
Explanations for options of floating point are updated to match
the `RenderFloatingPointOptions` function in
`clang/lib/Driver/ToolChains/Clang.cpp`.
Missing explanations are also added.
Differential Revision: https://reviews.llvm.org/D138117
River Riddle [Fri, 2 Dec 2022 08:19:28 +0000 (00:19 -0800)]
[TypeSwitch] Use perfect forwarding in the cast functions
This allows for properly supporting TypeSwitch on reference
types which do not support copying/do not want copying.
River Riddle [Fri, 2 Dec 2022 07:22:22 +0000 (23:22 -0800)]
[mlir] Allow access to the underlying diagnostic
This allows for more interesting manipulation of an
inflight diagnostic.
Guillaume Chatelet [Wed, 30 Nov 2022 11:42:47 +0000 (11:42 +0000)]
[libc] Make libc memory functions weak by default for bazel
This helps override llvm libc functions for experiment purposes.
Differential Revision: https://reviews.llvm.org/D138999
gonglingqin [Fri, 2 Dec 2022 08:30:56 +0000 (16:30 +0800)]
[LoongArch] Extract out and reuse getValueType(). NFC.
Jean Perier [Fri, 2 Dec 2022 08:28:15 +0000 (09:28 +0100)]
[flang] Lower evaluate::Extremum
Update BinaryOp<T>::gen so that const T& is threaded and some
operation knowledge that is not encoded by the type T or the arguments
can be used. For Extremum, it is the order (Greater or Lesser) that is
required, but this will also be required for evaluate::Relational.
Differential Revision: https://reviews.llvm.org/D139124
Valery Pykhtin [Wed, 19 Oct 2022 16:07:19 +0000 (18:07 +0200)]
[AMDGPU] Speedup GCNDownwardRPTracker::advanceBeforeNext
The function makes liveness tests for the entire live register set for every instruction it passes by.
This becomes very slow on high RP regions such as ASAN enabled code.
Instead only uses of last tracked instruction should be tested and this greatly improves compilation time.
This patch revealed few bugs in SIFormMemoryClauses and PreRARematStage::sinkTriviallyRematInsts which should
be fixed first.
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D136267
Fangrui Song [Fri, 2 Dec 2022 08:02:19 +0000 (08:02 +0000)]
Support: Convert some Optional to std::optional
tentzen [Fri, 2 Dec 2022 06:45:46 +0000 (22:45 -0800)]
[Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 2
This patch is the Part-2 (BE LLVM) implementation of HW Exception handling.
Part-1 (FE Clang) was committed in
797ad701522988e212495285dade8efac41a24d4.
This new feature adds the support of Hardware Exception for Microsoft Windows
SEH (Structured Exception Handling).
Compiler options:
For clang-cl.exe, the option is -EHa, the same as MSVC.
For clang.exe, the extra option is -fasync-exceptions,
plus -triple x86_64-windows -fexceptions and -fcxx-exceptions as usual.
NOTE:: Without the -EHa or -fasync-exceptions, this patch is a NO-DIFF change.
The rules for C code:
For C-code, one way (MSVC approach) to achieve SEH -EHa semantic is to follow three rules:
First, no exception can move in or out of _try region., i.e., no "potential faulty
instruction can be moved across _try boundary.
Second, the order of exceptions for instructions 'directly' under a _try must be preserved
(not applied to those in callees).
Finally, global states (local/global/heap variables) that can be read outside of _try region
must be updated in memory (not just in register) before the subsequent exception occurs.
The impact to C++ code:
Although SEH is a feature for C code, -EHa does have a profound effect on C++
side. When a C++ function (in the same compilation unit with option -EHa ) is
called by a SEH C function, a hardware exception occurs in C++ code can also
be handled properly by an upstream SEH _try-handler or a C++ catch(...).
As such, when that happens in the middle of an object's life scope, the dtor
must be invoked the same way as C++ Synchronous Exception during unwinding process.
Design:
A natural way to achieve the rules above in LLVM today is to allow an EH edge
added on memory/computation instruction (previous iload/istore idea) so that
exception path is modeled in Flow graph preciously. However, tracking every
single memory instruction and potential faulty instruction can create many
Invokes, complicate flow graph and possibly result in negative performance
impact for downstream optimization and code generation. Making all
optimizations be aware of the new semantic is also substantial.
This design does not intend to model exception path at instruction level.
Instead, the proposed design tracks and reports EH state at BLOCK-level to
reduce the complexity of flow graph and minimize the performance-impact on CPP
code under -EHa option.
One key element of this design is the ability to compute State number at
block-level. Our algorithm is based on the following rationales:
A _try scope is always a SEME (Single Entry Multiple Exits) region as jumping
into a _try is not allowed. The single entry must start with a seh_try_begin()
invoke with a correct State number that is the initial state of the SEME.
Through control-flow, state number is propagated into all blocks. Side exits
marked by seh_try_end() will unwind to parent state based on existing SEHUnwindMap[].
Note side exits can ONLY jump into parent scopes (lower state number).
Thus, when a block succeeds various states from its predecessors, the lowest
State triumphs others. If some exits flow to unreachable, propagation on those
paths terminate, not affecting remaining blocks.
For CPP code, object lifetime region is usually a SEME as SEH _try.
However there is one rare exception: jumping into a lifetime that has Dtor but
has no Ctor is warned, but allowed:
Warning: jump bypasses variable with a non-trivial destructor
In that case, the region is actually a MEME (multiple entry multiple exits).
Our solution is to inject a eha_scope_begin() invoke in the side entry block to
ensure a correct State.
Implementation:
Part-1: Clang implementation (already in):
Please see commit
797ad701522988e212495285dade8efac41a24d4).
Part-2 : LLVM implementation described below.
For both C++ & C-code, the state of each block is computed at the same place in
BE (WinEHPreparing pass) where all other EH tables/maps are calculated.
In addition to _scope_begin & _scope_end, the computation of block state also
rely on the existing State tracking code (UnwindMap and InvokeStateMap).
For both C++ & C-code, the state of each block with potential trap instruction
is marked and reported in DAG Instruction Selection pass, the same place where
the state for -EHsc (synchronous exceptions) is done.
If the first instruction in a reported block scope can trap, a Nop is injected
before this instruction. This nop is needed to accommodate LLVM Windows EH
implementation, in which the address in IPToState table is offset by +1.
(note the purpose of that is to ensure the return address of a call is in the
same scope as the call address.
The handler for catch(...) for -EHa must handle HW exception. So it is
'adjective' flag is reset (it cannot be IsStdDotDot (0x40) that only catches
C++ exceptions).
Suppress push/popTerminate() scope (from noexcept/noTHrow) so that HW
exceptions can be passed through.
Original llvm-dev [RFC] discussions can be found in these two threads below:
https://lists.llvm.org/pipermail/llvm-dev/2020-March/140541.html
https://lists.llvm.org/pipermail/llvm-dev/2020-April/141338.html
Differential Revision: https://reviews.llvm.org/D102817/new/
Fangrui Song [Fri, 2 Dec 2022 07:43:18 +0000 (07:43 +0000)]
AttributeParser: Convert Optional to std::optional
Dhruva Chakrabarti [Fri, 2 Dec 2022 06:01:54 +0000 (22:01 -0800)]
Revert "[OpenMP] [OMPT] [3/8] Implemented callback registration in libomptarget"
This reverts commit
2b234ce3f07caea605df730ca0b33f22c419582f.
wanglei [Fri, 2 Dec 2022 05:48:02 +0000 (13:48 +0800)]
[LoongArch] Remove dead code. NFC
Jan Svoboda [Fri, 2 Dec 2022 05:31:30 +0000 (21:31 -0800)]
Revert "[clang][modules][deps] Parent module maps are affecting"
This reverts commit
f99e5a9106f08ad92a22c3b114d2052e5c502924.
Jan Svoboda [Fri, 2 Dec 2022 05:31:29 +0000 (21:31 -0800)]
Revert "[clang][modules][deps] Including module maps are affecting"
This reverts commit
83973cf157f7850eb133a4bbfa0f8b7958bad215.
Chen Zheng [Fri, 2 Dec 2022 03:58:03 +0000 (22:58 -0500)]
[PowerPC] move ctrloop pass before tail duplication
Tail duplication may modify the loop to a "non-canonical" form
that CTR Loop pass can not recognize. We fixed one issue in D135846.
And we found in some other case, the loop is changed to irreducible form.
It is hard to fix this case in CTR loop pass, instead we reorder the
CTR loop pass before tail duplication pass and just after finalize-isel
pass to avoid any unexpected change to the loop form.
Reviewed By: lkail
Differential Revision: https://reviews.llvm.org/D138265
Chen Zheng [Fri, 2 Dec 2022 03:51:24 +0000 (22:51 -0500)]
Revert "[PowerPC] handle more than two predecessors loop header in ctrloop pass"
This reverts commit
df9d60af1f9fa44f411b656bbc691d950c6fc087.
The CTRLoops pass is reordered to front of tail duplication pass in D138265.
Jan Svoboda [Fri, 2 Dec 2022 05:07:56 +0000 (21:07 -0800)]
[clang][deps] Convert file dependency paths to the native style
This is an attempt to fix a Windows bot failure. In the test introduced in
83973cf1, file dependencies were printed out-of-order (after replacing backslashes with slashes). This might've been caused by styles of some paths being different.
Jan Svoboda [Fri, 2 Dec 2022 04:09:03 +0000 (20:09 -0800)]
[clang][modules][deps] Including module maps are affecting
With this patch, we mark module maps that include an affecting `extern` module map as also affecting. This is a generalization of D137197: now we don't require the importing module map to describe parent of the extern module.
Depends on D137198.
Reviewed By: Bigcheese
Differential Revision: https://reviews.llvm.org/D137206
Jan Svoboda [Fri, 2 Dec 2022 04:08:51 +0000 (20:08 -0800)]
[clang][modules][deps] Parent module maps are affecting
Currently, the algorithm for gathering affecting module maps includes only those defining modules that include some headers. This is not entirely correct, though. Some module maps might be "importing" module maps for `extern` submodules. Such parent module maps are affecting - they do change semantics of the compilation. This patch adds parent module maps into the set of affecting module maps.
Depends on D137197.
Reviewed By: Bigcheese
Differential Revision: https://reviews.llvm.org/D137198
Jan Svoboda [Fri, 2 Dec 2022 04:08:30 +0000 (20:08 -0800)]
[clang][modules][deps] Transitive module maps are not affecting
Currently, the algorithm for gathering affecting module maps includes those defining transitive dependencies. This seems like an over-approximation, since those don't change the semantics of current module build.
(With this patch, `ModulesToProcess` only ever holds modules whose headers will be serialized into the current PCM.)
Reviewed By: Bigcheese
Differential Revision: https://reviews.llvm.org/D137197
Matt Arsenault [Fri, 2 Dec 2022 02:59:52 +0000 (21:59 -0500)]
InstCombine: Convert some tests to opaque pointers
Needed manual fixes:
2008-01-06-VoidCast.ll
alias.ll @0 type lost
pr27703.ll totally confused
pr44242.ll phi and update_test_checks
pr44245.ll phi and update_test_checks
Needed re-running update_test_checks:
2009-01-08-AlignAlloca.ll
2009-02-20-InstCombine-SROA.ll
addrspacecast.ll
alloca-cast-debuginfo.ll
alloca-in-non-alloca-as.ll
alloca.ll
icmp-gep.ll
icmp-custom-dl.ll
lifetime-no-null-opt.ll
non-integral-pointers.ll
pr33689_same_bitwidth.ll
pr39908.ll
scalable-cast-of-alloc.ll
select-cmp-br.ll
unpack-fca.ll
Converted to generated checks:
2012-6-7-vselect-bitcast.ll
Matt Arsenault [Fri, 2 Dec 2022 03:26:30 +0000 (22:26 -0500)]
InstCombine: Don't use anonymous values in tests
These interfered with opaquification
Matt Arsenault [Fri, 2 Dec 2022 03:12:28 +0000 (22:12 -0500)]
InstCombine: Stop using grep in some tests
Switch to FileCheck and generated checks.
Jan Svoboda [Fri, 2 Dec 2022 04:00:56 +0000 (20:00 -0800)]
[clang][serialization] NFCI: Avoid re-reading input file info
This patch resolves a FIXME that points out an inefficiency in first deserializing the input file info and the whole input file, which redundantly deserializes the input file info again.
Reviewed By: Bigcheese
Differential Revision: https://reviews.llvm.org/D137192
Jan Svoboda [Fri, 2 Dec 2022 03:09:09 +0000 (19:09 -0800)]
[clang][deps][lex] Avoid canonicalization of remapped framework directories
In D134923, the scanner introduced canonicalization of framework directories when reporting module map paths in order to increase module sharing. However, if we canonicalize framework directory that plays a role in a VFS remapping, and later try to use that module map to build the module, header lookup can fail. This happens when the module headers are remapped using the original framework path.
This patch fixes that. The implementation relies on the fact that the chain of directories in VFS remapping are assigned `DirectoryEntry` objects distinct from their on-disk counterparts. If we detect that case, we avoid the canonicalization.
Reviewed By: benlangmuir
Differential Revision: https://reviews.llvm.org/D135841
Louis Dionne [Fri, 2 Dec 2022 03:26:01 +0000 (19:26 -0800)]
[libc++][NFC] Avoid most-vexing parse
Chen Zheng [Fri, 2 Dec 2022 01:52:14 +0000 (20:52 -0500)]
[PowerPC] [NFC] add test for O0 pipeline
This is to address comments https://reviews.llvm.org/D138265#3950197
This should be helpful for detecting optimization passes added to O0
pipeline by mistake.
Reviewed By: lkail
Differential Revision: https://reviews.llvm.org/D138973
chenglin.bi [Fri, 2 Dec 2022 02:58:44 +0000 (10:58 +0800)]
[AArch64] Precommit test for D138904; NFC
shift + and -> shift + shift to select more shfited registers.
Matt Arsenault [Fri, 2 Dec 2022 02:46:59 +0000 (21:46 -0500)]
InstCombine: Convert target tests to opaque pointers
The opaquify script deleted a few declarations for some reason which
were manually deleted.
Matt Arsenault [Fri, 2 Dec 2022 02:51:13 +0000 (21:51 -0500)]
InstCombine: Don't use anonymous values in test
Also don't use grep because it's not 2002.
Matt Arsenault [Fri, 2 Dec 2022 02:33:26 +0000 (21:33 -0500)]
AMDGPU: Convert some assorted tests to opaque pointers
Prashant Kumar [Thu, 1 Dec 2022 16:27:33 +0000 (16:27 +0000)]
Replacing `is` with `==` for the dtype check.
>>> a = np.ndarray([1,1]).astype(np.half)
>>> a
array([[0.007812]], dtype=float16)
>>> a.dtype
dtype('float16')
>>> a.dtype == np.half
True
>>> a.dtype == np.float16
True
>>> a.dtype is np.float16
False
Checking with `is` leads to inconsistency in checking.
Reviewed By: silvas
Differential Revision: https://reviews.llvm.org/D139121
Matt Arsenault [Thu, 1 Dec 2022 23:07:47 +0000 (18:07 -0500)]
AMDGPU: Fix broken attribute usage in test