Commit Graph

474307 Commits

Author SHA1 Message Date
Vitaly Buka
2344a72dd6 [test][sanitizer] Check LINKER_IS_LLD to detect LLD
This enables some tests requiring LLD when we test
compiler-rt activated with LLVM_ENABLE_RUNTIMES.
2023-09-11 11:02:01 -07:00
Jeremy Morse
1ce1732f82 [DebugInfo] Use getStableDebugLoc to pick IRBuilder DebugLocs
When IRBuilder is given an insertion position and there is debug-info, it
sets the DebugLoc of newly inserted instructions to the DebugLoc of the
insertion position. Unfortunately, that means if you insert in front of a
debug intrinsics, your "real" instructions get potentially-misleading
source locations from the debug intrinsics. Worse, if you compile -gmlt to
get source locations but no variable locations, you'll get different source
locations to a normal -g build, which is silly.

Rectify this with the getStableDebugLoc method, which skips over any debug
intrinsics to find the next "real" instruction. This is the source location
that you would get if you compile with -gmlt, and it remains stable in the
presence of debug intrinsics. The changed tests show a few locations where
this has been happening, for example selecting line-zero locations for
instrumentation on a perfectly valid call site.

Differential Revision: https://reviews.llvm.org/D159485
2023-09-11 19:00:44 +01:00
Lang Hames
5293109774 Re-apply 75c487602a "[ORC] Add a MachOBuilder utility, use it to..." with fixes.
This re-applies 75c487602a ([ORC] Add a MachOBuilder utility, use it to build
MachO debug objects), which was reverted in 99e70cc3a5 due to build
failures. The MachoBuilder class has been refactored to fix the errors.
2023-09-11 10:56:54 -07:00
Fangrui Song
65a15a56d5 [ELF] Respect orders of symbol assignments and DEFINED (#65866)
Fix #64600: the currently implementation is minimal (see
https://reviews.llvm.org/D83758), and an assignment like
`__TEXT_REGION_ORIGIN__ = DEFINED(__TEXT_REGION_ORIGIN__) ? __TEXT_REGION_ORIGIN__ : 0;`
(used by avr-ld[1]) leads to a value of zero (default value in `declareSymbol`),
which is unexpected.

Assign orders to symbol assignments and references so that
for a script-defined symbol, the `DEFINED` results match users'
expectation. I am unclear about GNU ld's exact behavior, but this hopefully
matches its behavior in the majority of cases.

[1]: https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=ld/scripttempl/avr.sc
2023-09-11 10:54:49 -07:00
Philip Reames
299d710e3d [RISCV] Lower fixed vectors extract_vector_elt through stack at high LMUL
This is the extract side of D159332. The goal is to avoid non-linear costing on patterns where an entire vector is split back into scalars. This is an idiomatic pattern for SLP.

Each vslide operation is linear in LMUL on common hardware. (For instance, the sifive-x280 cost model models slides this way.) If we do a VL unique extracts, each with a cost linear in LMUL, the overall cost is O(LMUL2) * VLEN/ETYPE. To avoid the degenerate case, fallback to the stack if we're beyond LMUL2.

There's a subtly here. For this to work, we're *relying* on an optimization in LegalizeDAG which tries to reuse the stack slot from a previous extract. In practice, this appear to trigger for patterns within a block, but if we ended up with an explode idiom split across multiple blocks, we'd still be in quadratic territory. I don't think that variant is fixable within SDAG.

It's tempting to think we can do better than going through the stack, but well, I haven't found it yet if it exists. Here's the results for sifive-s280 on all the variants I wrote (all 16 x i64 with V):

output/sifive-x280/linear_decomp_with_slidedown.mca:Total Cycles:      20703
output/sifive-x280/linear_decomp_with_vrgather.mca:Total Cycles:      23903
output/sifive-x280/naive_linear_with_slidedown.mca:Total Cycles:      21604
output/sifive-x280/naive_linear_with_vrgather.mca:Total Cycles:      22804
output/sifive-x280/recursive_decomp_with_slidedown.mca:Total Cycles:      15204
output/sifive-x280/recursive_decomp_with_vrgather.mca:Total Cycles:      18404
output/sifive-x280/stack_by_vreg.mca:Total Cycles:      12104
output/sifive-x280/stack_element_by_element.mca:Total Cycles:      4304

I am deliberately excluding scalable vectors. It functionally works, but frankly, the code quality for an idiomatic explode loop is so terrible either way that it felt better to leave that for future work.

Differential Revision: https://reviews.llvm.org/D159375
2023-09-11 10:49:17 -07:00
Stanislav Mekhanoshin
070c2570ad
[AMDGPU] Global ISel for packed fp32 instructions (#65803) 2023-09-11 10:48:37 -07:00
Lorenzo Chelini
33deb28006 [MLIR][Linalg] Improve documentation in LinalgInterfaces.td (NFC)
ShapeType::kDynamic -> ShapedType::kDynamic
2023-09-11 19:46:20 +02:00
Matthias Braun
5d7f84ee17 LoopRotate: Add code to update branch weights
This adds code to the loop rotation transformation to ensure that the
computed block execution counts for the loop bodies are the same before
and after the transformation. This isn't always true in practice, but I
believe this is because of numeric inaccuracies in the BlockFrequency
computation.

The invariants this is modeled on and heuristic choice of 0-trip loop
amount is explained in a lenghty comment in the new
`updateBranchWeights()` function.

Differential Revision: https://reviews.llvm.org/D157462
2023-09-11 10:38:06 -07:00
Matthias Braun
285e0235f5 ProfDataUtils: Add extractFromBranchWeightMD function; NFC
Expose internal helper function as new `extractFromBranchWeightMD` API.

Differential revision: https://reviews.llvm.org/D157937
2023-09-11 10:38:06 -07:00
Matthias Braun
f8431a0e40 Avoid running optimization passes in frontend test
Differential Revision: https://reviews.llvm.org/D157518
2023-09-11 10:38:06 -07:00
Alex Brachet
779a7b7fd7
[Fuchsia] Re-enable libcxx timezone database (#65981) 2023-09-11 13:37:38 -04:00
David Spickett
8012518f60 Revert "[lldb] Improve completion tests (#65973)"
This reverts commit 2378ba632e.

I need to fix the x86 specific register tests.
2023-09-11 17:35:27 +00:00
kazutakahirata
5378117327
[ADT] Remove any_isa (NFC) (#65636)
any_isa has been deprecated since:

  commit bb7940e25f
  Author: Sebastian Neubauer <Sebastian.Neubauer@amd.com>
  Date:   Tue Dec 20 13:28:30 2022 +0100
2023-09-11 10:33:14 -07:00
Scott Linder
4333146195 [NFC][AsmPrinter] Use std::visit in constructVariableDIEImpl
This potentially has a slightly positive performance impact, as
std::visit can be implemented as a `switch`-like jump rather than
a series of `if`s.

More importantly, the reader can be confident is no overlap between the
cases.

Differential Revision: https://reviews.llvm.org/D158678
2023-09-11 17:32:00 +00:00
Scott Linder
35e621f9ae [NFC][AsmPrinter] Expose std::variant-ness of DbgVariable
Differential Revision: https://reviews.llvm.org/D158677
2023-09-11 17:31:59 +00:00
Scott Linder
414ceffc9e [NFC][AsmPrinter] Remove dead multi-MMI handling from DwarfFile::addScopeVariable
Differential Revision: https://reviews.llvm.org/D158676
2023-09-11 17:31:59 +00:00
Scott Linder
58c108cde7 [NFC][AsmPrinter] Refactor DbgVariable as a std::variant
Only a subset of the fields of DbgVariable are meaningful at any time,
and some fields are re-used for multiple purposes (for example
FrameIndexExprs is used with a throw-away frame-index of 0 to hold a
single DIExpression without needing to add another member). The exact
invariants must be reverse-engineered by inspecting the actual use of
the class, its imprecise/outdated doc-comment, and some asserts.

Refactor DbgVariable into a sum type by inheriting from std::variant.
This makes the active fields for any given state explicit and removes
the need to re-use fields in disparate contexts. As a bonus, it seems to
reduce the size on my x86_64 linux box from 144 bytes to 96 bytes.

There is some potential cost to `std::get` as it must check the active
alternative even when context or an assert obviates it. To try to help
ensure the compiler can optimize out the checks the patch also adds a
helper `get` method which uses the noexcept `std::get_if`.

Some of the extra cost would also be avoided more cleanly with a
refactor that exposes the alternative types in the public interface,
which will come in another patch.

Differential Revision: https://reviews.llvm.org/D158675
2023-09-11 17:31:59 +00:00
Stanislav Mekhanoshin
093aa37744
[AMDGPU] Autogenerate min.ll/max.ll tests. NFC. (#65786) 2023-09-11 10:29:53 -07:00
David Spickett
2378ba632e
[lldb] Improve completion tests (#65973)
* Assert no completions for tests that should not find completions.
* Remove regex mode from complete_from_to, which was unused.

This exposed bugs in 2 of the tests, target stop-hook and
process unload. These were fixed in previous commits but
couldn't be tested properly until this patch.
2023-09-11 18:26:51 +01:00
kadir çetinkaya
a4d14011e5
[include-cleaner] Fix handling of enums in presence of qualifiers (#65952) 2023-09-11 19:21:02 +02:00
Fangrui Song
b40a5bead2 [Driver][test] Don't check the version in the triple
On a macOS host the version may be different.

Fix: 9f77facfce
2023-09-11 10:17:08 -07:00
Matt Arsenault
1b235b087b ValueTracking: Add baseline tests for fcmp with non-0/inf constants
Currently assumes only do anything for fcmps that perform an exact
class test.
2023-09-11 20:03:03 +03:00
Jeremy Morse
1d82c765ef [NFC][RemoveDIs] Provide an iterator-taking split-block method
As per the stack of patches this is attached to, allow users of
BasicBlock::splitBasicBlock to provide an iterator for a position, instead
of just an instruction pointer. This is to fit with my proposal for how to
get rid of debug intrinsics [0]. There are other call-sites that would need
to change, but this is sufficient for a stage2clang self host and some
other C++ projects to build identical binaries, in the context of the whole
remove-DIs project.

[0] https://discourse.llvm.org/t/rfc-instruction-api-changes-needed-to-eliminate-debug-intrinsics-from-ir/68939

Differential Revision: https://reviews.llvm.org/D152545
2023-09-11 17:50:47 +01:00
Benjamin Maxwell
ccef726d09 [mlir][VectorOps] Don't drop scalable dims when lowering transfer_reads/writes (in VectorToLLVM)
This is a follow-on to D158753, and allows the lowering of a
transfer read/write of n-D vectors with a single trailing scalable dimension
to primitive vector ops.

The final conversion to LLVM depends on D158517 and D158752, without
these patches type conversion will fail (or an assert is hit in the LLVM
backend) if the final IR contains an array of scalable vectors.

This patch adds `transform.apply_patterns.vector.lower_create_mask`
which allows the lowering of vector.create_mask/constant_mask to be
tested independently of --convert-vector-to-llvm.

Reviewed By: c-rhodes, awarzynski, dcaballe

Differential Revision: https://reviews.llvm.org/D159482
2023-09-11 16:47:51 +00:00
David Spickett
6bf923d5c3 [lldb][Tests] Reformat API tests with black
These are all recent additions I think, including a few of mine
for AArch64.

Going forward the CI checks should help us fix these earlier.
2023-09-11 16:44:12 +00:00
Alex Brachet
62bec3de12
[libcxx] Fix include directory order (#65859)
It's important that the arch directory be included first so that
its header files which interpose on the default include dir
be included instead of the default ones. The clang driver [1] does
this when not building with -nostdinc, the libcxx build should
do the same.

We found this after https://reviews.llvm.org/D154282 when cross
compiling from non Linux to Linux. If the host machine was not
Linux, _LIBCPP_HAS_NO_TIME_ZONE_DATABASE would be defined in
the default include dir __config_site, while it was undefined
in the arch specific one causing build failures.
2023-09-11 12:36:06 -04:00
bipmis
74e4e9e6f2 Fold or-phi test 2023-09-11 17:33:36 +01:00
Nick Desaulniers
93bd428742
[InlineAsm] refactor InlineAsm class NFC (#65649)
I would like to steal one of these bits to denote whether a kind may be
spilled by the register allocator or not, but I'm afraid to touch of any
this code using bitwise operands.

Make flags a first class type using bitfields, rather than launder data
around via `unsigned`.
2023-09-11 09:27:37 -07:00
Luke Lau
e33f3f09b8
[RISCV] Shrink vslidedown when lowering fixed extract_subvector (#65598)
As noted in
https://github.com/llvm/llvm-project/pull/65392#discussion_r1316259471,
when lowering an extract of a fixed length vector from another vector,
we don't need to perform the vslidedown on the full vector type. Instead
we can extract the smallest subregister that contains the subvector to
be extracted and perform the vslidedown with a smaller LMUL. E.g, with
+Zvl128b:

v2i64 = extract_subvector nxv4i64, 2

is currently lowered as

vsetivli zero, 2, e64, m4, ta, ma
vslidedown.vi v8, v8, 2

This patch shrinks the vslidedown to LMUL=2:

vsetivli zero, 2, e64, m2, ta, ma
vslidedown.vi v8, v8, 2

Because we know that there's at least 128*2=256 bits in v8 at LMUL=2,
and we only need the first 256 bits to extract a v2i64 at index 2.

lowerEXTRACT_VECTOR_ELT already has this logic, so this extracts it out
and reuses it.

I've split this out into a separate PR rather than include it in #65392,
with the hope that we'll be able to generalize it later.

This patch refactors extract_subvector lowering to lower to
extract_subreg directly, and to shortcut whenever the index is 0 when
extracting a scalable vector. This doesn't change any of the existing
behaviour, but makes an upcoming patch that extends the scalable path
slightly easier to read.
2023-09-11 17:25:12 +01:00
Ellis Hoag
4a46fd5439 [GlobPattern][docs] Fix poorly rendered docs
In #65397 I attempted to fix these docs by adding a "." but that didn't
seem to work. This tries to use two newlines to divide paragraphs.
2023-09-11 09:23:49 -07:00
Jakub Kuderski
1258c3f214
[mlir][spirv] Support spirv.coopmatrix type (de-)serialization (#65831)
Extend SPIR-V target serialization and deserialization to handle coop
matrix types. Add a roundtrip test. In addition to `FileCheck` checks,
the resulting spirv binary also passes `spir-val` (external tool).

Also fix a type attribute bug surfaced by the `CooperativeMatrixLength`
op.

Multiple matrix operand attributes will be handled in a future patch to
reduce the scope.
2023-09-11 12:23:18 -04:00
Ellis Hoag
30e688e6d0
[lld][MachO] Add option to suppress mismatch profile errors (#65551)
Both ELF and COFF support `--no-lto-pgo-warn-mismatch` in
https://reviews.llvm.org/D104431 to suppress warnings due to mismatching
profile hashes. As profiles go stale, it becomes likely that some
function's CFGs will change so that their profiles can no longer be
used. This commit adds the linker option `--no-pgo-warn-mismatch` to
suppress these warnings.

Note that we do have the LLVM backend flag `no-pgo-warn-mismatch`
3df1a64eba/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp (L210)

but that is set to true by default during LTO
3df1a64eba/llvm/include/llvm/LTO/Config.h (L76-L77)
2023-09-11 09:13:55 -07:00
David Spickett
3125bd4bc7
[lldb] Correctly invalidate unloaded image tokens (#65945)
Some functions in Process were using LLDB_INVALID_ADDRESS instead of
LLDB_INVALID_TOKEN.

The only visible effect of this appears to be that "process unload
<tab>" would complete to 0 even after the image was unloaded. Since the
command is checking for LLDB_INVALID_TOKEN.

Everything else worked somehow. I've added a check to the existing load
unload tests anyway.

The tab completion cannot be checked as is, but when I make them more
strict in a later patch it will be tested.
2023-09-11 17:12:09 +01:00
Luke Lau
b46d7011f2
[RISCV] Refactor extract_subvector lowering slightly. NFC (#65391)
This patch refactors extract_subvector lowering to lower to
extract_subreg directly, and to shortcut whenever the index is 0 when
extracting a scalable vector. This doesn't change any of the existing
behaviour, but makes an upcoming patch that extends the scalable path
slightly easier to read.
2023-09-11 16:48:35 +01:00
Nick Desaulniers
26181544f7
[clang][VarDecl] Reset un-evaluated constant for all C++ modes (#65818)
After commit 610ec954e1 ("[clang] allow const structs/unions/arrays to
be constant expressions for C"), attempts to evaluate
structs/unions/arrays as constants are also performed for C++98 and
C++03.

An assertion was getting tripped up since the potentially-partially
evaluated value was not being reset for those 2 language modes.  Make
sure to reset it now for all C++ modes.

Fixes: #65784
2023-09-11 08:37:01 -07:00
Luke Lau
46f3ea5952
[RISCV] Add extract_subvector tests for a statically-known VLEN. NFC (#65389)
This is partly a precommit for an upcoming patch, and partly to remove
the fixed length LMUL restriction similarly to what was done in
https://reviews.llvm.org/D158270, since it's no longer that relevant.
2023-09-11 16:28:53 +01:00
stefankoncarevic
fbf67bfaf0 [mlir][GPU] Handle LLVM pointer attributes on memref arguments.
Handle pointer attributes (noalias, nonnull, readonly, writeonly,
dereferencable, dereferencable_or_null). "noalias" attribute is
ignore for non-bare pointer.

Reviewed By: krzysz00

Differential Revision: https://reviews.llvm.org/D157082
2023-09-11 15:10:55 +00:00
Maciej Gabka
9272aa9d08 [Driver] Do not generate error about unsupported target specific options when there is no compiler jobs
The upstream commit: https://reviews.llvm.org/D151590
added a new flag to mark target specific compiler options.

The side effect of it was that in cases when -### or -v is used without any
input file, clang started emitting an error.
It happened like that becasue there is no compilation actions created
which could consume/verify these target specific options.

This patch changes that error to a warning about unused option in situations
when there is no actions and still generates error when there are actions.

Fix for https://github.com/llvm/llvm-project/issues/64958

Differential Revision: https://reviews.llvm.org/D159361
2023-09-11 14:58:36 +00:00
Simon Pilgrim
f8b04eb6d0 [X86] matchIndexRecursively - add zext(add/addlike(x,c)) -> index: zext(x), disp + zext(c) pattern handling
More restricted alternative to a8cef6b58e
2023-09-11 15:36:13 +01:00
erichkeane
6c0b9e3576 Remove extra switch from 0323938d 2023-09-11 07:16:27 -07:00
Guillaume Chatelet
a1f5a495e0
[libc] Add type_traits tests (#65956)
This is not exhaustive for now but it provides a placeholder for
`invoke_result` test mentioned in #65750.
2023-09-11 14:15:12 +00:00
Guillaume Chatelet
d557e2b076
[libc][NFC] Fix missing header in CMakelists.txt (#65960) 2023-09-11 14:12:58 +00:00
Jeremy Morse
d529943a27 [NFC][RemoveDIs] Prefer iterators over inst-pointers in InstCombine
As per my proposal for how to eliminate debug intrinsics [0], for various
places in InstCombine prefer to insert using an instruction iterator rather
than an instruction pointer. This is so that we can eventually pass more
information in the iterator class. These call-sites where I've changed the
spelling are those that necessary to build a stage2clang to produce an
identical binary in the coming no-debug-intrinsics mode.

[0] https://discourse.llvm.org/t/rfc-instruction-api-changes-needed-to-eliminate-debug-intrinsics-from-ir/68939

Differential Revision: https://reviews.llvm.org/D152543
2023-09-11 15:04:51 +01:00
Sergio Afonso
edc2fb0733
[Flang][OpenMP][Sema] Support propagation of REQUIRES information across program units
Re-land commit 3787fd942f

This patch adds support for storing OpenMP REQUIRES information in the
semantics symbols for programs/subprograms and modules/submodules, and
populates them during directive resolution. A pass is added to name resolution
that makes sure this information is also propagated across top-level programs,
functions and subprograms.

Storing REQUIRES information inside of semantics symbols will also allow
supporting the propagation of this information across Fortran modules. This
will come as a separate patch.

The `bool DirectiveAttributeVisitor::Pre(const parser::SpecificationPart &x)`
method is removed since it resulted in specification parts being visited twice.

This is patch 3/5 of a series splitting D149337 to simplify review.

Differential Revision: https://reviews.llvm.org/D157983
2023-09-11 15:01:57 +01:00
Felipe de Azevedo Piovezan
26ca2f47c1 [DebugInfo] Parse StrOffsets section if needed
Querying the debug_str_offsets section requires parsing the top level DIE of the
CU (as well as the section itself); the current getter, however, assumes this is
done elsewhere. This patch changes the getter behavior to match what is done in
other getter methods (e.g.  `getCompilationDir` or `getVariableForAddress`), in
other words, `extractDIEsIfNeeded` is now called prior to returning the
debug_str_offsets contributions for the Unit.

One way in which this bug manifested is when `dwarfdump --debug-str-offsets` is
invoked: because the DIEs are never parsed, we incorrectly print an empty
section (with no warnings or errors).

Differential Revision: https://reviews.llvm.org/D159484
2023-09-11 09:59:21 -04:00
Ying Chen
d9c9c9f2d9
[NFC][Clang][RISCV] Fix typos of riscv-v-spec doc in riscv_vector.td (#65944)
Fix index typos, s.t. indexes in comments be same with riscv-v-spec v1.0 doc.
2023-09-11 21:58:51 +08:00
Giuliano Belinassi
0323938d3c Fix warning in MSVC
Currently there is no PrintOnLeft attribute set, which results in an
empty switch-case. When compiling this, MSVC issues a warning saying
that the switch-case is empty. Fix this by using a macro and checking
if this macro is defined or not.

Links to D157394
2023-09-11 06:51:11 -07:00
Michael Halkenhäuser
12ac0f6ede
[OpenMP][DeviceRTL][AMDGPU] Add missing libomptarget build targets (#65964)
Extend CMake variable `all_amdgpu_architectures` by `gfx941` and
`gfx942`.
2023-09-11 15:43:51 +02:00
liqin.weng
3723ede3cf [VP] IR expansion for zext/sext/trunc/fptosi/fptosi/sitofp/uitofp/fptrunc/fpext
Add basic handling for VP ops that can expand to Cast intrinsics

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D159491
2023-09-11 21:14:38 +08:00
liqin.weng
28e74e6180 [VP] IR expansion for abs/smax/smin/umax/umin
Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D159495
2023-09-11 21:14:37 +08:00