Commit Graph

34901 Commits

Author SHA1 Message Date
Felipe de Azevedo Piovezan
a195d1fc6c [DebugInfo] Implement TAG_label entries for debug_names (#71724)
The DWARF 5 specification says that:

> The name index must contain an entry for each debugging information
entry that
> defines a named [...] label [...].

The verifier currently verifies this, but the AsmPrinter does not add
entries for TAG_labels in debug_names. This patch addresses the issue by
ensuring we add labels in the accelerator tables once we have a fully
completed DIE for the TAG_label entry.

We also respect the spec as follows:
> DW_TAG_label debugging information entries without an address
attribute
> (DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, or DW_AT_entry_pc) are
excluded.

The effect of this on the size of accelerator tables is minimal, as
TAG_labels are usually created by C/C++ labels (see example in test),
which are typically paired with "goto" statements.
2023-11-13 11:02:58 -08:00
Felipe de Azevedo Piovezan
83729e6716 [SelectionDAG] Disable FastISel for swiftasync functions (#70741)
Most (x86) swiftasync functions tend to use both SelectionDAGISel and
FastISel lowering:
* FastISel argument lowering can only handle C calling convention.
* FastISel fails mid-BB in a number of ways, including in simple `ret
void` instructions under certain circumstances.

This dance of SelectionDAG (argument) -> FastISel (some instructions) ->
SelectionDAG(remaining instructions) is lossy; in particular, Argument
information lowering is cleared after that first SelectionDAG run.

Since swiftasync functions rely heavily on proper Argument lowering for
debug information, this patch disables the use of FastISel in such
functions.
2023-11-13 08:27:29 -08:00
Kazu Hirata
055f377349 [llvm] Stop including llvm/ADT/SparseBitVector.h (NFC)
Identified with clangd.
2023-11-13 07:30:48 -08:00
Craig Topper
44e8bea400 [GISel][AArch64] Notify the Observer when CTTZ lowering changes the opcode to CTPOP. (#72008) 2023-11-12 19:36:24 -08:00
Carl Ritson
52b247b1d3 [PHIElimination] Handle subranges in LiveInterval updates (#69429)
Add subrange tracking and handling for LiveIntervals during PHI
elimination.
This requires extending MachineBasicBlock::SplitCriticalEdge to also
update subrange intervals.
2023-11-13 12:16:26 +09:00
Kazu Hirata
01702c3f7f [llvm] Stop including llvm/ADT/SmallSet.h (NFC)
Identified with clangd.
2023-11-11 12:32:15 -08:00
Momchil Velikov
e8209b2486 [MachineSink] Drop debug info for instructions deleted by sink-and-fold (#71443)
After performing sink-and-fold over a COPY, the original instruction is
replaced with one that produces its output in the destination of the
copy. Its value is still available (in a hard register), so if there are
debug instructions which refer to the (now deleted) virtual register
they could be updated to refer to the hard register, in principle.
However, it's not clear how to do that, moreover in some cases the debug
instructions may need to be replicated proportionally to the number of
the COPY instructions replaced and in some extreme cases we can end up
with quadratic increase in the number of debug instructions, e.g:

        int f(int);
    
        void g(int x) {
          int y = x + 1;
    
          int t0 = y;
          f(t0);
    
          int t1 = y;
          f(t1);
        }
2023-11-11 19:43:14 +00:00
Kazu Hirata
d4360e428f [llvm] Stop including llvm/ADT/DenseMap.h (NFC)
Ientified with clangd.
2023-11-11 10:07:19 -08:00
Kazu Hirata
bafd35ca04 [llvm] Stop including llvm/ADT/SmallPtrSet.h (NFC)
Identified with clangd.
2023-11-11 00:35:14 -08:00
Kazu Hirata
0d55ea25a6 [llvm] Stop including llvm/ADT/DenseMapInfo.h (NFC)
Identified with clangd.
2023-11-11 00:13:29 -08:00
David Green
10ce319320 [AArch64][GlobalISel] Expand handling for sitofp and uitofp (#71282)
Similar to #70635, this expands the handling of integer to fp
conversions. The code is very similar to the float->integer conversions
with types handled oppositely. There are some extra unhandled cases
which require more handling for ASR operations.
2023-11-10 13:41:13 +00:00
Yingwei Zheng
650026897c [RISCV][SDAG] Prefer ShortForwardBranch to lower sdiv by pow2 (#67364)
This patch lowers `sdiv x, +/-2**k` to `add + select + shift` when the
short forward branch optimization is enabled. The latter inst seq
performs faster than the seq generated by target-independent
DAGCombiner. This algorithm is described in ***Hacker's Delight***.

This patch also removes duplicate logic in the X86 and AArch64 backend.
But we cannot do this for the PowerPC backend since it generates a
special instruction `addze`.
2023-11-10 21:38:47 +08:00
Jeremy Morse
10a9e7442c [DebugInfo][RemoveDIs] Add conversion utilities for new-debug-info format
This patch plumbs the command line --experimental-debuginfo-iterators flag
in to the pass managers, so that modules can be converted to the new
format, passes run, then converted back to the old format. That allows
developers to test-out the new debuginfo representation across some part of
LLVM with no further work, and from the command line. It also installs
flag-catchers at the various points that bitcode and textual IR can egress
from a process, and temporarily convert the module to dbg.value format when
doing so.

No tests alas as it's designed to be transparent.

Differential Revision: https://reviews.llvm.org/D154372
2023-11-09 22:30:49 +00:00
stephenpeckham
1d1fede493 [XCOFF] Ensure .file is emitted before any .info pseudo-ops (#71577)
When generating the assembly code for AIX/XCOFF, the .file pseudo-op
needs to be emitted first, before any csects are generated. Otherwise,
information such as the embedded command line will be associated with
part of the object file rather than the entire object file.
2023-11-09 16:03:45 -06:00
Nikita Popov
f67158422c [CFIInstrInserter] Use number of supported registers (NFC) (#71797)
This makes use of the more accurate register number introduced in PR
#70222 to avoid CFI calculations for unsupported registers.

This has basically no impact right now, but results in a 0.2% compile-time
improvement at O0 when applied on top of #70958.

The reason is that the extra registers that PR adds push the `BitVector`
out of the `SmallVector` space, which results in an outsized impact.
(This does make me wonder whether `BitVector` should accept an `N`
template parameter to allow using a larger `SmallVector`...)
2023-11-09 14:43:45 +01:00
Igor Kirillov
59a063d5c6 [ExpandMemCmp] Improve memcmp optimisation for boolean results (#71221)
This patch enhances the optimization of memcmp calls when only two
outcomes
are needed and comparison fits into one block, for example:

	bool result = memcmp(a, b, 6) > 0;

Previously, LLVM would generate unnecessary operations even when the
user of
memcmp was only interested in a binary outcome.
2023-11-09 11:52:04 +00:00
Nikita Popov
74a76a2885 [BranchFolding] Remove dubious assert from operator< (#71639)
`MergePotentialElts::operator<` asserts that the two elements being
compared are not equal. However, sorting functions are allowed to invoke
the comparison function with equal arguments (though they usually don't
for efficiency reasons).

There is an existing special-case that disables the assert if
_GLIBCXX_DEBUG is used, which may invoke the comparator with equal args
to verify strict weak ordering. I believe libc++ also has strict weak
ordering checks under some options nowadays.

Recently, #71312 was reported, where a change to glibc's qsort_r
implementation can also result in comparison between equal elements.
From what I understood, this is an inefficiency that will be fixed on
the glibc side as well, but I think at this point we should just remove
this assertion.

Fixes https://github.com/llvm/llvm-project/issues/71312.
2023-11-09 10:23:10 +01:00
Jianjian Guan
d36eb79ccc [RISCV] Support Strict FP arithmetic Op when only have Zvfhmin (#68867)
Include: STRICT_FADD, STRICT_FSUB, STRICT_FMUL, STRICT_FDIV,
STRICT_FSQRT and STRICT_FMA.
2023-11-09 09:55:48 +08:00
Alex Langford
d42b2ceb6c Revert "[Pass][CodeGen] Add some necessary passes for codegen (#70903)"
This change broke building LLVM with Module support enabled, i.e.
`LLVM_ENABLE_MODULES=ON`.
This reverts commit f40da072ed.
2023-11-08 15:59:44 -08:00
alexfh
067632e141 Revert "[DAGCombiner] Transform (icmp eq/ne (and X,C0),(shift X,C1)) to use rotate or to getter constants." due to a miscompile (#71598)
- Revert "[DAGCombiner] Transform `(icmp eq/ne (and X,C0),(shift X,C1))`
to use rotate or to getter constants." - causes a miscompile, see
112e49b381 (commitcomment-131943923)
- Revert "[X86] Fix gcc warning about mix of enumeral and non-enumeral
types. NFC", which fixes a compiler warning in the commit above
2023-11-08 15:07:12 +01:00
Jay Foad
d5f3b3b3b1 [RegScavenger] Simplify state tracking for backwards scavenging (#71202)
Track the live register state immediately before, instead of after,
MBBI. This makes it simple to track the state at the start or end of a
basic block without a separate (and poorly named) Tracking flag.

This changes the API of the backward(MachineBasicBlock::iterator I)
method, which now recedes to the state just before, instead of just
after, *I. Some clients are simplified by this change.

There is one small functional change shown in the lit tests where
multiple spilled registers all need to be reloaded before the same
instruction. The reloads will now be inserted in the opposite order.
This should not affect correctness.
2023-11-08 09:49:07 +00:00
paperchalice
f40da072ed [Pass][CodeGen] Add some necessary passes for codegen (#70903)
These passes are used in `TargetPassConfig.cpp`, so add them here. Part
of #69879.
@arsenm Thanks for reviwing.
2023-11-08 16:24:39 +09:00
Vladislav Dzhidzhoev
6beddd668a Revert "[DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (4/7)"
This caused assert:
llvm/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp:110:
void llvm::DwarfFile::addScopeVariable(LexicalScope *, DbgVariable *):
Assertion `Ret.second' failed.

See comments https://reviews.llvm.org/D144006#4656350.

This reverts commit 3b449bd46a.
2023-11-08 00:29:24 +01:00
Michael Maitland
4832c88e49 [MachineVerifier] Fix COPY check in MachineVerifier for scalable vectors
This change fixes #71518, which compared the KnownMinValue of the
scalable virtual register with the FixedSize of the physical register in
the wrong direction. It turns out that we cannot include this check at all since
it will lead to a false failures. Test cases are added to show that
the false failures no longer occur after this fix.
2023-11-07 14:49:38 -08:00
Michael Maitland
ac4ff6168a [CodeGen][MachineVerifier] Use TypeSize instead of unsigned for getRe… (#70881)
…gSizeInBits

This patch changes getRegSizeInBits to return a TypeSize instead of an
unsigned in the case that a virtual register has a scalable LLT. In the
case that register is physical, a Fixed TypeSize is returned.

The MachineVerifier pass is updated to allow copies between fixed and
scalable operands as long as the Src size will fit into the Dest size.

This is a precommit which will be stacked on by a change to GISel to
generate COPYs with a scalable destination but a fixed size source.

This patch is stacked on https://github.com/llvm/llvm-project/pull/70893
for the ability to use scalable vector types in MIR tests.
2023-11-07 14:38:46 -05:00
Paulo Matos
7b9d73c2f9 [NFC] Remove Type::getInt8PtrTy (#71029)
Replace this with PointerType::getUnqual().
Followup to the opaque pointer transition. Fixes an in-code TODO item.
2023-11-07 17:26:26 +01:00
Mitch Phillips
9e50c6e6b5 Revert "Reapply "RegisterCoalescer: Add implicit-def of super register when coalescing SUBREG_TO_REG""
This reverts commit ba385ae210.

Reason: Broke the MSan buildbot. See comments on
ba385ae210
for more information.
2023-11-07 15:08:45 +01:00
Matt Arsenault
013d1ca9b5 RegisterCoalescer: Clear isSSA property
Fix some expensive checks verifier errors on MIR tests.
2023-11-07 22:43:46 +09:00
Graham Hunter
a850dbcc5c [AArch64] Sink vscale calls into loops for better isel (#70304)
For more recent sve capable CPUs it is beneficial to use the inc*
instruction
to increment a value by vscale (potentially shifted or multiplied) even
in
short loops.

This patch tells codegenprepare to sink appropriate vscale calls into
blocks where they are used so that isel can match them.
2023-11-07 10:29:42 +00:00
Skwoogey
a700a520f8 [InterleavedAccessPass] Avoid optimizing load instructions if it has dead binop users (#71339)
If a load instruction qualifies to be optimized by InterleavedAccess
Pass, but also has a dead binop instruction, this will lead to a crash.

Binop instruction will not be deleted, because normally it would be
deleted through its' users, but it has none. Later on deleting a load
instruction will fail because it still has uses.
2023-11-07 08:08:49 +00:00
Matt Arsenault
ba385ae210 Reapply "RegisterCoalescer: Add implicit-def of super register when coalescing SUBREG_TO_REG"
This reverts commit e0f86ca200.

This was hitting some assertions which have since been relaxed.
2023-11-07 16:57:02 +09:00
Amara Emerson
6b69584660 [GlobalISel] Fall back for bf16 conversions. (#71470)
We don't support these correctly since we don't yet have FP types.
AMDGPU tests were silently miscompiling bf16 as if they were fp16.
2023-11-06 21:18:57 -08:00
Jon Roelofs
fa71f9e87a Reland "[Intrinsics][ObjC] Mark objc_retain and friends as thisreturn."
This reverts commit cb62f67088.

Fixes: https://github.com/llvm/llvm-project/issues/69658
2023-11-06 11:10:59 -08:00
Jon Roelofs
d9ccacee13 Revert "Reland "[Intrinsics][ObjC] Mark objc_retain and friends as thisreturn.""
This reverts commit 30414fc614.

Broke some buildbots.
2023-11-06 10:04:22 -08:00
Stefan Pintilie
423ad04c67 [PowerPC] Add an alias for -mregnames so that full register names used in assembly. (#70255)
This option already exists on GCC and so it is being added to LLVM so
that we use the same option as them.
2023-11-06 12:30:19 -05:00
Jon Roelofs
30414fc614 Reland "[Intrinsics][ObjC] Mark objc_retain and friends as thisreturn."
This reverts commit cb62f67088.

Fixes: https://github.com/llvm/llvm-project/issues/69658
2023-11-06 08:47:05 -08:00
Nikita Popov
1a1a5ec756 [SDAG] Avoid use of ConstantExpr::getFPTrunc() (NFC)
Use the constant folding API instead. As we're working on
ConstantFP, it is guaranteed to succeed.
2023-11-06 15:55:23 +01:00
Simon Pilgrim
b65da9848b [AsmPrinter] Use StringRef::starts_with/ends_with instead of startswith/endswith. NFC.
startswith/endswith wrap starts_with/ends_with and will eventually go away (to more closely match string_view)
2023-11-06 13:27:37 +00:00
Diana
7f5d59b38d [AMDGPU] ISel for @llvm.amdgcn.cs.chain intrinsic (#68186)
The @llvm.amdgcn.cs.chain intrinsic is essentially a call. The call
parameters are bundled up into 2 intrinsic arguments, one for those that
should go in the SGPRs (the 3rd intrinsic argument), and one for those
that should go in the VGPRs (the 4th intrinsic argument). Both will
often be some kind of aggregate.

Both instruction selection frameworks have some internal representation
for intrinsics (G_INTRINSIC[_WITH_SIDE_EFFECTS] for GlobalISel,
ISD::INTRINSIC_[VOID|WITH_CHAIN] for DAGISel), but we can't use those
because aggregates are dissolved very early on during ISel and we'd lose
the inreg information. Therefore, this patch shortcircuits both the
IRTranslator and SelectionDAGBuilder to lower this intrinsic as a call
from the very start. It tries to use the existing infrastructure as much
as possible, by calling into the code for lowering tail calls.

This has already gone through a few rounds of review in Phab:

Differential Revision: https://reviews.llvm.org/D153761
2023-11-06 12:30:07 +01:00
Craig Topper
90f768440d [VP][RISCV] Add llvm.experimental.vp.reverse. (#70405)
This is similar to vector.reverse, but only reverses the first EVL
elements.

I extracted this code from our downstream. Some of it may have come from
https://repo.hca.bsc.es/gitlab/rferrer/llvm-epi/ originally.
2023-11-05 22:39:27 -08:00
Craig Topper
16ddd25b69 Revert "[GISel] Add LookThroughInstrs for getIConstantVRegVal and getIConstan… (#68327)"
This reverts commit 28ae42e662.

The assert in getIConstantVRegVal was not updated for this change.
The ValAndVReg->VReg == VReg check fails if any look through happens.

RISC-V was the only target using the lookthrough functionality, but I'm
not sure it was needed so I'm removing that too.
2023-11-04 12:21:06 -07:00
Simon Pilgrim
1085b70a94 [DAG] Don't fold (zext (bitop (load x), cst)) -> (bitop (zextload x), (zext cst)) if the zext is free
Prevents an infinite loop if we've been trying to narrow the bitop to a more preferable type
2023-11-04 15:32:13 +00:00
David Green
54574d3272 [AArch64][GlobalISel] Expand handling for fptosi and fptoui (#70635)
Now that we have more types handled for zext/sext and trunc, it is
possible to get more types working for the vector float to integer
conversions. This patch adds fp16, widening and narrowing vector support
to handle more types. The smaller types wil be expanded to the size of
the larger element type. A couple of case require more awkward truncates
to get working as they go from illegal to illegal types.
2023-11-04 11:47:05 +00:00
Ramkumar Ramachandra
fd887a3633 LegalizeVectorTypes: fix bug in widening of vec result in xrint (#71198)
Fix a bug introduced in 98c90a1 (ISel: introduce vector ISD::LRINT,
ISD::LLRINT; custom RISCV lowering), where ISD::LRINT and ISD::LLRINT
used WidenVecRes_Unary to widen the vector result. This leads to
incorrect CodeGen for RISC-V fixed-vectors of length 3, and a crash in
SelectionDAG when we try to lower llvm.lrint.vxi32.vxf64 on i686. Fix
the bug by implementing a correct WidenVecRes_XRINT.

Fixes #71187.
2023-11-03 21:04:09 +00:00
Nick Desaulniers
284c6990c1 [CalcSpillWeights] don't mark live intervals with spillable inlineasm ops as having infinite spill weight (#70747)
This is necessary for RegAllocGreedy support for memory folding inline
asm that uses "rm" constraints.

Thanks to @qcolombet for the suggestion.

Link: https://github.com/llvm/llvm-project/issues/20571
2023-11-03 12:49:07 -07:00
Craig Topper
70b35ec0a8 [SelectionDAG] Add initial support for nneg flag on ISD::ZERO_EXTEND. (#70872)
This adds the nneg flag to SDNodeFlags and the node printing code.
SelectionDAGBuilder will add this flag to the node if the target doesn't
prefer sign extend.

A future RISC-V patch can remove the sign extend preference from
SelectionDAGBuilder.

I've also added the flag to the DAG combine that converts
ISD::SIGN_EXTEND to ISD::ZERO_EXTEND.
2023-11-03 11:15:08 -07:00
Nick Desaulniers
778a48468b [InlineAsm] Steal a bit to denote a register is foldable (#70738)
When using the inline asm constraint string "rm" (or "g"), we generally
would like the compiler to choose "r", but it is permitted to choose "m"
if there's register pressure. This is distinct from "r" in which the
register is not permitted to be spilled to the stack.

The decision of which to use must be made at some point.  Currently, the
instruction selection frameworks (ISELs) make the choice, and the
register allocators had better be able to handle the result.

Steal a bit from Storage when using register operands to disambiguate
between the two cases.  Add helpers/getters/setters, and print in MIR
when such a register is foldable.

The getter will later be used by the register allocation frameworks (and
asserted by the ISELs) while the setters will be used by the instruction
selection frameworks.

Link: https://github.com/llvm/llvm-project/issues/20571
2023-11-03 09:37:07 -07:00
Matt Arsenault
3cef582ae4 CodeGen: Port ExpandLargeFpConvert to new PM (#71027) 2023-11-03 14:23:30 +09:00
Michael Maitland
801a30aa8f [CodeGen][MIR] Support parsing of scalable vectors in MIR (#70893)
This patch builds on the support for vectors by adding ability to parse
scalable vectors in MIR and updates error messages to reflect that ability.
2023-11-02 21:49:18 -04:00
Craig Topper
46732e2abb [GISel] Remove BitVector from RegBank. Use tablegen CoverageData tables directly. NFC (#71105)
RegBanks are allocated as global variables. The use of BitVector causes
a static global constructor to be used. The BitVector is initialized
from a table of bits that is created by tablegen. We can keep a pointer
to that data and use it as the bit vector instead.

This does require a little bit of manual indexing and reimplementation
of BitVector::count.
2023-11-02 17:54:11 -07:00