Commit Graph

455335 Commits

Author SHA1 Message Date
Philip Reames
53e9a5ddc0 [LSR] Fix "new use of poison" problem in lsr-term-fold
This models the approach used in LFTR. The short summary is that we need to prove the IV is not dead first, and then we have to either prove the poison flag is valid after the new user or delete it.

There are two key differences between this and LFTR.

First, I allow a non-concrete start to the IV. The goal of LFTR is to canonicalize and IVs with constant starts are canonical, so the very restrictive definition there is mostly okay. Here on the other hand, we're explicitly moving *away* from the canonical form, and thus need to handle non-constant starts.

Second, LFTR bails out instead of removing inbounds on a GEP. This is a pragmatic tradeoff since inbounds is hard to infer and assists aliasing. This pass runs very late, and I think the tradeoff runs the other way.

A different approach we could take for the post-inc check would be to perform a pre-inc check instead of a post-inc check. We would still have to check the pre-inc IV, but that would avoid the need to drop inbounds. Doing the pre-inc check would basically trade killing a whole IV for an extra register move in the loop. I'm open to suggestions on the right approach here.

Note that this analysis is quite expensive compile time wise. I have made no effort to optimize (yet).

Differential Revision: https://reviews.llvm.org/D146464
2023-03-21 08:23:40 -07:00
Nikita Popov
b4307437e5 [ModuleUtils] Handle globals_ctors/dtors with non-literal type (PR56809)
If the global already exists, use its existing type, so we don't
try to mix literal and non-literal structs among the elements.

Fixes https://github.com/llvm/llvm-project/issues/56809.
2023-03-21 16:19:05 +01:00
Erich Keane
514e4359a5 inline stmt attribute diagnosing in templates
D146089's author discovered that our diagnostics for always/no inline
would null-dereference when used in a template. He fixed that by
skipping in the dependent case.

This patch makes sure we diagnose these after a template instantiation.
It also adds infrastructure for other statement attributes to add
checking/transformation.

Differential Revision: https://reviews.llvm.org/D146323
2023-03-21 08:16:52 -07:00
Philip Reames
b33f5e7ed3 [LSR] Use evaluateAtIteration in lsr-term-fold
This is a follow up to one of the side discussions on D146429.  There are two semantic changes contained here.

The motivation for the change to the legality condition introduced in D146429 comes from the fact that we only check the post-inc form. As such, as long as the values of the post-inc variable don't self wrap, it's actually okay if we wrap past the starting value of the pre-inc IV.

Second, Nikic noticed during review that the test changes changed behavior for TC=0 (i.e. N=0 in the tests).  On more careful inspection, it became apparent that the previous manual expansion code was incorrect in the case where the primary IV could wrap without poison, and started with the limit value (i.e. i8 post-inc starts at 255 for 0 exit test, implying pre-inc starts with 0).  See @wrap_around test for an example of the (previous) miscompile.

Differential Revision: https://reviews.llvm.org/D146457
2023-03-21 08:11:36 -07:00
Philip Reames
b7af34c303 [LSR] Add a test case for (another) miscompile in lsr-term-fold
Derived from an observation by @nikic on D146457.
2023-03-21 08:11:36 -07:00
Valentin Clement
faa1043144
[flang] Carry over dynamic type information when creating an unlimited polymorphic temp
The dyanmic type must be carried over in a PolymorphicValue when the address is
loaded from an unlimited polymorphic allocatable.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D146525
2023-03-21 16:08:07 +01:00
Maya Amrami
fd004a4986 [mlir] tosa.concat - Add InferTensorType interface
When this interface is used, a call to inferReturnTypeComponents()
is generated on creation and verification of the op.
A few changes were required in inferReturnTypeComponents():
- Emit error when it fails.
  The verifier calls this method now, and it is preferable to
  indicate what caused the failure.
- Fix the inferred return shapes so they have a type too.

Reviewed By: rsuderman

Differential Revision: https://reviews.llvm.org/D146132
2023-03-21 17:01:08 +02:00
Alex Zinenko
fb409a2822 [mlir] Transform dialect: add named sequences
Named sequences introduce an additional abstraction and reuse capability
to the transform dialect. They can be though of as macros parameterized
with handles that can be invoked in places where a transform dialect
operation is expected. Such reuse was previously not possible in the
dialect and required dynamic construction of the transform IR from the
client language. Named sequences are intentionally restricted to
disallow recursion, as it could make the dialect accidentally
Turing-complete, which isn't desired at this point.

Reviewed By: springerm

Differential Revision: https://reviews.llvm.org/D146433
2023-03-21 14:53:54 +00:00
Aaron Ballman
270a6a2824 No longer issue pedantic warning about pre-c++2b compat
We were accidentally issuing "overloaded 'operator[]' with more than
one parameter is a C++2b extension" with -pedantic because it was an
ExtWarn diagnostic rather than a Warning. This corrects the diagnostic
category and adds some test coverage.

Fixes #61582
2023-03-21 10:51:53 -04:00
Daniel Kiss
83dc4734ba Fix -fsplit-lto-unit with ifuncs
ifuncs can't take part of the whole-program devirtualization so no need them to be copied to the merged module.
The corresponding resolver function also kept out which caused the crash.

Fixes #60962 #57870

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D144982
2023-03-21 15:36:13 +01:00
Philip Reames
042783f556 [LFTR] Assert and simplify under assumption exit counts are integers [nfc]
This invariant was introduced in 8f3d16905d.

Differential Revision: https://reviews.llvm.org/D146470
2023-03-21 07:35:05 -07:00
David Spickett
392d9eb03a [lldb] For native compiles, check signal numbers are correct when adding codes
Reviewed By: arichardson, emaste

Differential Revision: https://reviews.llvm.org/D146285
2023-03-21 14:31:21 +00:00
Pavel Kosov
88e5206f2c Reland [clang][ASTImport] Add support for import of empty records
Patch represents the clang part of changes in D143347

Reviewed By: balazske

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

~~

Huawei RRI, OS Lab
2023-03-21 17:26:36 +03:00
Adrian Kuegel
dc9d2e588d [mlir] Add missing registrations to runners. 2023-03-21 15:17:21 +01:00
Adrian Kuegel
16b192f497 [mlir][Bazel] Adjust BUILD files to 0e9523efda 2023-03-21 15:00:23 +01:00
Maryam Moghadas
155abd0678 [PowerPC] Emit warn_deprecated_lax_vec_conv_all warning only for PPC
This patch is to isolate the lax vector conversions warning only for PPC,
the reason is that SystemZ wants different logic in terms of
vector bool compatibility.

Reviewed By: lei

Differential Revision: https://reviews.llvm.org/D145506
2023-03-21 08:51:25 -05:00
Jan Sjodin
382eb7c2c7 [mlir] Add alloca address space handling to the data layout subsystem
This patch adds alloca address space information to the data layout interface
and implementation in the DLTI dialect. This is needed for targets that use
separate address spaces for local/stack data.

Reviewed By: ftynse, krzysz00

Differential Revision: https://reviews.llvm.org/D144657
2023-03-21 09:37:08 -04:00
Simon Pilgrim
8022ff5f19 [X86] Add verify-machineinstrs checks to baseptr tests
Help catch regressions from D145650 that were only noticed on EXPENSIVE_CHECKS builds
2023-03-21 13:24:47 +00:00
Nicolas Vasilache
20294bf6c1 [mlir][Transform] NFC - Add more advanced debug spew to help hunt down potential misuses
Differential Revision: https://reviews.llvm.org/D146509
2023-03-21 06:12:07 -07:00
Ilya Biryukov
282cae0b9a [Sema] Fix crash on __fp16 parameters in template instantiations
Fixes #61441.

Currently, Clang stores `nullptr` in the parameter lists inside
`FunctionProtoTypeLoc` if `__fp16` is used without pointer qualifiers.

Any code path that calls `Declarator::setInvalidType()` before
`GetFullTypeForDeclarator` will lead to the same problem downstream.

The relevant code is:
```cpp
if (D.isInvalidType())
  return Context.getTrivialTypeSourceInfo(T);

return GetTypeSourceInfoForDeclarator(state, T, TInfo);
```

`GetTypeSourceInfoForDeclarator` sets the parameter `Decl`, but we can't
call it when `isInvalidType() == true` as this causes other assertion
failures that seem harder to fix.

Reviewed By: kadircet

Differential Revision: https://reviews.llvm.org/D146426
2023-03-21 14:06:46 +01:00
Simon Pilgrim
a6a788bdfb [DAG] foldBinOpIntoSelect - use FoldConstantArithmetic instead of getNode() + constant check.
This prevents unused nodes from being created if the constant check fails.

Noticed while triaging D127115 regressions
2023-03-21 12:59:16 +00:00
Sergio Afonso
0e9523efda [mlir] Support lowering of dialect attributes attached to top-level modules
This patch supports the processing of dialect attributes attached to top-level
module-type operations during MLIR-to-LLVMIR lowering.

This approach modifies the `mlir::translateModuleToLLVMIR()` function to call
`ModuleTranslation::convertOperation()` on the top-level operation, after its
body has been lowered. This, in turn, will get the
`LLVMTranslationDialectInterface` object associated to that operation's dialect
before trying to use it for lowering prior to processing dialect attributes
attached to the operation.

Since there are no `LLVMTranslationDialectInterface`s for the builtin and GPU
dialects, which define their own module-type operations, this patch also adds
and registers them. The requirement for always calling
`mlir::registerBuiltinDialectTranslation()` before any translation of MLIR to
LLVM IR where builtin module operations are present is introduced. The purpose
of these new translation interfaces is to succeed when processing module-type
operations, allowing the lowering process to continue and to prevent the
introduction of failures related to not finding such interfaces.

Differential Revision: https://reviews.llvm.org/D145932
2023-03-21 12:54:26 +00:00
LLVM GN Syncbot
cdccea8eb3 [gn build] Port da8260a9b1 2023-03-21 12:38:15 +00:00
Ilyas Mustafazade
64276eec7e [clang][NFC] Fix typo in comment
Differential Revision: https://reviews.llvm.org/D146422
2023-03-21 13:32:05 +01:00
Luo, Yuanke
da8260a9b1 Revert "[X86] Create extra prolog/epilog for stack realignment"
This reverts commit e4c1dfed38.
2023-03-21 20:30:29 +08:00
Uday Bondhugula
8f072bbd74 [MLIR] Fix warnings in AttrTypeSubElements.h
Fix warnings in AttrTypeSubElements.h (below) with GCC 9.4.0.

```
mlir/lib/IR/ExtensibleDialect.cpp:443:62:   required from here
mlir/include/mlir/IR/AttrTypeSubElements.h:412:37: warning: parameter ‘derived’ set but not used [-Wunused-but-set-parameter]
  412 | void walkImmediateSubElementsImpl(T derived,
      |                                   ~~^~~
```

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D146107
2023-03-21 17:48:51 +05:30
Nikita Popov
35130e4d6e [AArch64] Add tests for bitcast to and mask reduction (NFC)
This is a copy of the vecreduce_or tests but with comparison
to -1 rather than 0.
2023-03-21 13:18:25 +01:00
Luo, Yuanke
3e2d4e85d3 Revert "[X86] Create extra prolog/epilog for stack realignment [part 2]"
This reverts commit 614c63bec6.
2023-03-21 20:12:35 +08:00
David Spickett
c8af0d3cea [lldb] Add compile time checks for signal codes when on the matching platform
This adds a new macro to the UnixSignals subclasses, ADD_SIGCODE.

ADD_SIGCODE(4, ILL_ILLOPC, 1, "illegal opcode");

Adds a sigcode to signal 4. That code is ILL_ILLOPC and we expect
its value to be 1. When compiling on a system that matches the class
e.g. FreeBSD for FreeBSDSignals, the macro will check that that is true.

When you're not on FreeBSD we just use the number 1, and ILL_ILLOPC
won't be defined to anything because we don't include csignal.

Example error:
LinuxSignals.cpp:52:3: error: static_assert failed due to requirement
'ILL_COPROC == 9' "Value mismatch for signal code ILL_COPROC"

Reviewed By: arichardson

Differential Revision: https://reviews.llvm.org/D146222
2023-03-21 11:45:13 +00:00
Florian Hahn
af99aa0ff7
[LV] Set imbounds flag using CreateGEP in VPWidenMemInst (NFC).
This avoids having to cast the result of the builder to
GetElementPtrInst.
2023-03-21 11:44:21 +00:00
Alexander Belyaev
3a8f161a34 [mlir] Add a pattern to fold single- and zero-iteration scf.forall ops.
Differential Revision: https://reviews.llvm.org/D145368
2023-03-21 11:59:25 +01:00
Pavel Labath
0165b73be3 [lldb] Relax expectation on TestMainThreadExit
The exit code of the (funky) test inferior depends on the linux kernel
version (changed some time between 5.15 and 6.1).
2023-03-21 11:26:32 +01:00
Max Kazantsev
c270aafb18 Mark widenable condition as noundef
This corresponds to its description in LangRef:
The intrinsic @llvm.experimental.widenable.condition() returns either true or false.

Differential Revision: https://reviews.llvm.org/D146508
Reviewed By: skatkov, nikic
2023-03-21 17:11:58 +07:00
Jay Foad
25ca26e0da [AMDGPU] Make use of GCNSubtarget::hasNSAEncoding. NFC. 2023-03-21 10:00:56 +00:00
Job Noorman
54ab954149 [BOLT] Reject symbols pointing to section end
Sometimes, symbols are present that point to the end of a section (i.e.,
one-past the highest valid address). Currently, BOLT either rejects
those symbols when they don't point to another existing section, or errs
when they do and the other section is not executable. I suppose BOLT
would accept the symbol when it points to an executable section.

In any case, these symbols should not be considered while discovering
functions and should not result in an error. This patch implements that.

Note that this patch checks explicitly for symbols whose value equals
the end of their section. It might make more sense to verify that the
symbol's value is within [section start, section end). However, I'm not
sure if this could every happen *and* its value does not equal the end.

Another way to implement this is to verify that the BinarySection we
find at the symbol's address actually corresponds to the symbol's
section. I'm not sure what the best approach is so feedback is welcome.

Reviewed By: yota9, rafauler

Differential Revision: https://reviews.llvm.org/D146215
2023-03-21 13:59:39 +04:00
Nikita Popov
289542b1e7 [InstCombine] Fold icmp eq of non-inbounds geps
We can fold equality comparisons of non-inbounds geps to offset
comparison (https://alive2.llvm.org/ce/z/x2Zp8b). The inbounds
requirement is only necessary for relational comparisons.
2023-03-21 10:51:37 +01:00
OCHyams
5d17ae2d5d [Assignment Tracking] Downgrade dbg.assigns to dbg.values in mem2reg
For fully promoted variables dbg.assigns and dbg.values convey the same
information and can be used interchangeably. This patch converts dbg.assigns to
dbg.values for variables promoted by mem2reg. This reduces resource usage by
reducing the amount of unnecessary function local metadata. The compile time
tracker reports that CTMark projects build with LTO-O3-g with 0.4% fewer
instructions retired and peak memory usage is reduced by 2.2%.

Reviewed By: jryans

Differential Revision: https://reviews.llvm.org/D145511
2023-03-21 09:50:36 +00:00
Pavel Labath
090205fb57 [lldb] Fix TestStepOverWatchpoint 2023-03-21 10:45:12 +01:00
Nikita Popov
3cfb081c19 [InstCombine] Add icmp gep tests without inbounds (NFC) 2023-03-21 10:41:15 +01:00
Nikita Popov
e8ec42b80b [InstCombine] Fold icmp eq of non-inbounds gep with base pointer
For equality comparisons, we don't need the gep to be inbounds:
https://alive2.llvm.org/ce/z/Fe_kn2
2023-03-21 10:20:11 +01:00
Nicolas Vasilache
9437bf418a [mlir][Linalg][Transform] Fix effect on RewriteInDestinationPassingStyleOp that did not consume its operand 2023-03-21 02:17:45 -07:00
OCHyams
d5b2c8e56d [Assignment Tracking][NFC] Use BitVectors as masks for SmallVectors
...rather than using DenseMaps to track per-variable information.

Rather than tracking 3 maps of {VariableID: SomeInfo} per block, use a
BitVector indexed by VariableID to mask 3 vectors of SomeInfo.

BlockInfos now need to be initialised with a call to init which sets the
BitVector width to the number of partially promoted variables in the function
and fills the vectors with Top values.

Prior to this patch, in joinBlockInfo, it was necessary to insert Top values
into the Join result for variables in A XOR B after joining the variables in A
AND B. Now, because the vectors are pre-filled with Top values we need only
join the variables A AND B and set the BitVector of tracked variables to A OR
B.

The patch achieves an average of 0.25% reduction in instructions retired and a
1.1% max-rss for the CTMark suite in LTO-O3-g builds.

Reviewed By: scott.linder

Differential Revision: https://reviews.llvm.org/D145558
2023-03-21 09:11:54 +00:00
OCHyams
ee928e3228 [NFC] Add iterator traits to BitVector set_bits_iterator
Reviewed By: scott.linder

Differential Revision: https://reviews.llvm.org/D146232
2023-03-21 09:11:54 +00:00
David Spickett
85bc498826 [LLDB] Show sub type of signals when debugging a core file
Previously we only looked at the si_signo field, so you got:
```
(lldb) bt
* thread #1, name = 'a.out.mte', stop reason = signal SIGSEGV
  * frame #0: 0x00000000004007f4
```
This patch adds si_code so we can show:
```
(lldb) bt
* thread #1, name = 'a.out.mte', stop reason = signal SIGSEGV: sync tag check fault
  * frame #0: 0x00000000004007f4
```

The order of errno and code was incorrect in ElfLinuxSigInfo::Parse.
It was the order that a "swapped" siginfo arch would use, which for Linux,
is only MIPS. We removed MIPS Linux support some time ago.

See:
fe15c26ee2/include/uapi/asm-generic/siginfo.h (L121)

A test is added using memory tagging faults. Which were the original
motivation for the changes.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D146045
2023-03-21 09:10:09 +00:00
Nikita Popov
d0de2c51c9 [InstCombine] Simplify foldOperationIntoSelectOperand() (NFCI)
Rather than handling all instruction types separately, clone the
original instruction and replace the select operand.
2023-03-21 10:02:29 +01:00
Max Kazantsev
9f48562ebf [Test] Add test on freezing of widenable condition 2023-03-21 15:59:00 +07:00
Valentin Clement
658595d031
[flang] Handle polymorphic entities with rank > 0 in entry statement
Correctly create the temporary for argument absent in the entry statement.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D146447
2023-03-21 09:50:57 +01:00
Ding Xiang Fei
8325d46a4a [MergeFuncs] Compare load instruction metadata
MergeFuncs currently merges load instructions with differing
semantically-relevant metadata, e.g. a load that has !nonnull
with one that does not.

Update FunctionComparator to make sure that metadata of both
loads is the same. Alternatively, it would be possilbe to ignore
the metadata during comparison, and then drop it during merging.

Differential Revision: https://reviews.llvm.org/D144682
2023-03-21 09:45:51 +01:00
Ilyas Mustafazade
d9b3a94425 [NFC] Change strcpy to std::copy
Differential Revision: https://reviews.llvm.org/D146382
2023-03-21 09:44:23 +01:00
Bing1 Yu
db8c0b295d [X86][MemFold] Stop emitting Header for X86 fold tables
Reviewed By: skan

Differential Revision: https://reviews.llvm.org/D146502
2023-03-21 16:38:42 +08:00