19761 Commits

Author SHA1 Message Date
Matt Arsenault
0e46b49de4 Reapply "RegisterCoalescer: Add implicit-def of super register when coalescing SUBREG_TO_REG"
This reverts commit c398fa009a47eb24f88383d5e911e59e70f8db86.

PPC backend was fixed in 2f82662ce901c6666fceb9c6c5e0de216a1c9667
2023-12-22 16:46:22 +07:00
Arthur Eubanks
7433b1ca3e Reapply "[X86] Set SHF_X86_64_LARGE for globals with explicit well-known large section name (#74381)"
This reverts commit 19fff858931bf575b63a0078cc553f8f93cced20.

Now that explicit large globals are handled properly in the small code model.
2023-12-21 10:51:30 -08:00
Arthur Eubanks
2366d53d8d
[X86] Fix more medium code model addressing modes (#75641)
By looking at whether a global is large instead of looking at the code
model.

This also fixes references to large data in the small code model.

We now always fold any 32-bit offset into the addressing mode with the
large code model since it uses 64-bit relocations.
2023-12-21 10:40:56 -08:00
David Li
f44079db22
[ISel] Add pattern matching for depositing subreg value (#75978)
Depositing value into the lowest byte/word is a common code pattern.
This patch improves the code generation for it to avoid redundant AND
and OR operations.
2023-12-21 10:18:57 -08:00
Simon Pilgrim
6ec350b483 [X86] SimplifyDemandedVectorEltsForTargetShuffle - don't simplify constant mask if it has multiple uses
Avoid generating extra constant vectors
2023-12-20 15:22:48 +00:00
Jonas Paulsson
e32e147d6c
[DAGCombiner] Don't drop alignment info of original load. (#75626)
Pass the original MMO instead of different individual values.

getAlign() was used before where actually getOriginalAlign() would have been
better, and this patch has the same effect.
2023-12-19 16:30:47 +01:00
Arthur Eubanks
68c976bf64 [X86] Fix referencing local tagged globals
We should treat the medium code model like the small code model.
Classifying non-local references already properly handled this.
2023-12-17 13:49:50 -08:00
Stefan Pintilie
c398fa009a Revert "Reapply "RegisterCoalescer: Add implicit-def of super register when coalescing SUBREG_TO_REG""
This reverts commit f4b5be1ecdc85ca4257b739afb8d57e23c7a8030.

The above change was breaking the clang-ppc64le-linux-test-suite bot.
2023-12-16 07:30:53 -06:00
Arthur Eubanks
b3e353d263
[X86] Don't use rip-relative lea to get a function address in medium static mode (#75656)
This essentially reverts https://reviews.llvm.org/D140593. Somewhere
along the line we properly fixed the medium code model to assume
functions are small, so now we get a 32-bit movl as desired.
2023-12-15 15:15:18 -08:00
Paul Kirth
9a578a9f60
Revert "[StackColoring] Delete dead stack slots (#75351)" (#75655)
This reverts commit 08b306dc8e7c0b2498f4f194a3c51686d56dbd20.

it causes the following assertion failure:
llvm/include/llvm/CodeGen/MachineFrameInfo.h:530: int64_t
llvm::MachineFrameInfo::getObjectOffset(int) const: Assertion
`!isDeadObjectIndex(ObjectIdx) && "Getting frame offset for a dead
object?"' failed.
2023-12-15 13:32:39 -08:00
Arthur Eubanks
809ee6cfcf [X86][test] Update tagged-globals*.ll tests
Use update_llc_test_checks.py.

Split out jump table tests into separate file since we don't want to check the exact instruction sequence for it.
2023-12-15 12:54:55 -08:00
mohammed-nurulhoque
08b306dc8e
[StackColoring] Delete dead stack slots (#75351)
deletes slots that have lifetime markers and the lifetime ranges are empty.
2023-12-15 09:58:19 +00:00
Craig Topper
2a21260ea8 [SelectionDAG] Use getVectorElementPointer in DAGCombiner::replaceStoreOfInsertLoad. (#74249)
This ensures we clip the index to be in bounds of the vector we are
inserting into. If the index is out of bounds the results of the insert
element is poison. If we don't clip the index we can write memory that
was not part of the original store.

Fixes #74248 #75557.
2023-12-14 20:25:16 -08:00
Matt Arsenault
f4b5be1ecd Reapply "RegisterCoalescer: Add implicit-def of super register when coalescing SUBREG_TO_REG"
This reverts commit 69c4930aad9659ec6ab846c8e7124d6afe044b1e.

See if this sticks after a few more coalescer assertions are fixed.
2023-12-15 10:51:47 +07:00
Arthur Eubanks
239a41e8f2 Re-Reland [X86] Respect code models more when determining if a global reference can fit in 32 bits (#75386)
For non-GlobalValue references, the small and medium code models can use
32 bit constants.

For GlobalValue references, use TargetMachine::isLargeGlobalObject().
Look through aliases for determining if a GlobalValue is small or large.
Even the large code model can reference small objects with 32 bit
constants as long as we're in no-pic mode, or if the reference is offset
from the GOT.

Original commit broke the build...

First reland broke large PIC builds referencing small data since it was using GOTOFF as a 32-bit constant.
2023-12-14 14:12:37 -08:00
Jon Roelofs
640c1d3dd1
[llvm] Support IFuncs on Darwin platforms (#73686)
... by lowering them as lazy resolve-on-first-use symbol resolvers. Note that this is subtly different timing than on ELF platforms, where ifunc resolution happens at load time.

Since ld64 and ld-prime don't support all the cases we need for these, we lower them manually in the AsmPrinter.
2023-12-14 14:40:52 -07:00
Arthur Eubanks
15617d14f7 Revert "Reland [X86] Respect code models more when determining if a global reference can fit in 32 bits (#75386)"
This reverts commit ec92d74a0ef89b9dd46aee6ec8aca6bfd3c66a54.

Breaks some compiler-rt tests, e.g. https://lab.llvm.org/buildbot/#/builders/37/builds/28834
2023-12-14 12:28:50 -08:00
Arthur Eubanks
ec92d74a0e Reland [X86] Respect code models more when determining if a global reference can fit in 32 bits (#75386)
For non-GlobalValue references, the small and medium code models can use
32 bit constants.

For GlobalValue references, use TargetMachine::isLargeGlobalObject().
Look through aliases for determining if a GlobalValue is small or large.
Even the large code model can reference small objects with 32 bit
constants as long as we're in no-pic mode, or if the reference is offset
from the GOT.

Original commit broke the build...
2023-12-14 09:49:35 -08:00
Arthur Eubanks
f0c03da63c
Revert "[X86] Respect code models more when determining if a global reference can fit in 32 bits" (#75500)
Reverts llvm/llvm-project#75386

Breaks build.
2023-12-14 09:32:55 -08:00
Simon Pilgrim
88f1a2c50d [X86] combineLoad - allow constant loads to share matching 'lower constant bits' with larger VBROADCAST_LOAD/SUBV_BROADCAST_LOAD nodes
We already had separate support for VBROADCAST_LOAD - merge this with the generic load handling and add SUBV_BROADCAST_LOAD support as well.
2023-12-14 17:31:07 +00:00
Arthur Eubanks
5e38ba26d2
[X86] Respect code models more when determining if a global reference can fit in 32 bits (#75386)
For non-GlobalValue references, the small and medium code models can use
32 bit constants.

For GlobalValue references, use TargetMachine::isLargeGlobalObject().
Look through aliases for determining if a GlobalValue is small or large.
Even the large code model can reference small objects with 32 bit
constants as long as we're in no-pic mode, or if the reference is offset
from the GOT.
2023-12-14 09:28:27 -08:00
Simon Pilgrim
3c423722cf [X86] combineLoad - improve constant pool matches by ignoring undef elements
When trying to share constant pool entries, we can ignore the undef elements of the entry that is being removed
2023-12-14 15:13:39 +00:00
Simon Pilgrim
2141a51be1 [X86] broadcast-elm-cross-splat-vec.ll - drop constant pool check
This is handled in the assembly comments.
2023-12-14 12:10:33 +00:00
Arthur Eubanks
c64334fb30
[X86][FastISel] Support medium code model in more places (#75375)
The medium code model is basically identical to the small code model
except that large objects cannot be referenced with 32-bit offsets.
2023-12-13 13:44:37 -08:00
Arthur Eubanks
e8f43883a0 [X86][test] Use separate check prefix in code-model-elf.ll
Since these will produce different results in upcoming changes.
2023-12-13 13:05:59 -08:00
Matt Arsenault
300a55003c
RegisterCoalescer: Fix implicit operand handling during rematerialize (#75271)
If the rematerialize was placing a subregister into a super register,
and implicit operands referenced the original register, we need to add
undef flags to the now-subregister indexed implicit operands.

Depends #75152
2023-12-13 15:15:36 +07:00
Matt Arsenault
538a83e4b9
RegisterCoalescer: Add undef flags in removePartialRedundancy (#75152)
If the copy being hoisted was undef, we have the same problems that
eliminateUndefCopy needs to solve. We would effectively be introducing a
new live out implicit_def. We need to add an undef flag to avoid
artificially introducing a live through undef value. Previously, the
verifier would fail due to the dead def inside the loop providing the
live in value for the %1 use.
2023-12-13 15:02:53 +07:00
Arthur Eubanks
19fff85893 Revert "[X86] Set SHF_X86_64_LARGE for globals with explicit well-known large section name (#74381)"
This reverts commit 323451ab88866c42c87971cbc670771bd0d48692.

Code with these section names in the wild doesn't compile because
support for large globals in the small code model is not complete yet.
2023-12-12 16:31:41 -08:00
Arthur Eubanks
3959231695 [X86][FastISel] Bail out on large objects when materializing a GlobalValue
To avoid crashes with explicitly large objects.

I will clean up fast-isel with large objects/medium code model soon.
2023-12-12 12:45:20 -08:00
Simon Pilgrim
06613095c4 [X86] avx512-vbroadcast.ll - fix orphan check prefixes
The AVX512F/AVX512BW checks had been removed despite still being used
2023-12-12 18:34:53 +00:00
Evgenii Kudriashov
ef35da825f
[X86][GlobalISel] Add instruction selection for G_SELECT (#70753) 2023-12-12 16:08:08 +01:00
Alexander Yermolovich
e8e9a33583
[LLVM][DWARF] Add compilation directory and dwo name to TU in dwo section (#74909)
This adds support to help LLDB when binary is built with split dwarf,
has
.debug_names accelerator table and DWP file.
Final linked binary might have Type Units (TUs) with the same type
signature in multiple
compilation units. Although the signature is the same, TUs are not
guranted to
be bit identical. This is not a problem when they are in .o/.dwo files
as LLDB
can find them by looking at the right one based on
DW_AT_comp_dir/DW_AT_name in
skeleton CU. Once DWP is created, TUs are de-duplicated, and we need to
know
from which CU remaining one came from.

This approach allows LLDB to figure it out, with minimal changes to the
rest of
the tooling. As would have been the case if .debug_tu_index section in
DWP was
modified.
2023-12-12 07:01:20 -08:00
James Y Knight
ed4194bb8d
[X86] Set MaxAtomicSizeInBitsSupported. (#75112)
This will result in larger atomic operations getting expanded to
`__atomic_*` libcalls via AtomicExpandPass, which matches what Clang
already does in the frontend.
2023-12-12 08:16:55 -05:00
Orlando Cazalet-Hyams
5ee088134f
[DebugInfo][RemoveDIs] Handle dbg.declares in SelectionDAGISel (#73496)
This is a boring mechanical update to support DPValues that look like
dbg.declares in SelectionDAG.

The tests will become "live" once #74090 lands (see for more info).
2023-12-12 11:32:19 +00:00
Simon Pilgrim
3be65325f9 [X86] canonicalizeShuffleWithBinOps - generalize to handle some unary ops
Rename to canonicalizeShuffleWithOp and begin adding SHUFFLE(UNARYOP(X),UNARYOP(Y)) -> UNARYOP(SHUFFLE(X,Y)) fold support.

This is only kicking in after legalization, so targets that expand bit counts are still duplicating but it helps with a few initial cases.

I'm investigating adding support for extensions/conversions as well, but this is a first step.
2023-12-12 10:59:38 +00:00
Simon Pilgrim
1d56138d74 [X86] X86FixupVectorConstants - create f32/f64 broadcast constants if the source constant data was f32/f64
This partially reverts 33819f3bfb9c - the asm comments become a lot messier in #73509 - we're better off ensuring the constant data is the correct type in DAG
2023-12-12 10:32:04 +00:00
paperchalice
ce08c7ee1e
[CodeGen] Port SelectOptimize to new pass manager (#74920)
- Use `BlockFrequencyInfoWrapperPass` in legacy pass so member
`std::unique_ptr<BranchProbabilityInfo> BPI` could be removed.
- Member `DominatorTree *DT = nullptr` is unused, remove it.
2023-12-12 12:09:30 +08:00
Arthur Eubanks
f82c85d21f
[X86] Handle unsized types in TargetMachine::isLargeGlobalObject() (#74952)
isLargeGlobalObject() didn't handle opaque types, resulting in crashes.
2023-12-11 19:13:09 -08:00
Arthur Eubanks
3850131197
[X86] Handle ifuncs in TargetMachine::isLargeGlobalObject() (#74911)
isLargeGlobalObject() didn't handle GlobalIFuncs, resulting in crashes.

Treat ifuncs the same as normal Functions.
2023-12-11 19:01:44 -08:00
Arthur Eubanks
843ea98437
[X86] Allow constant pool references under medium code model in X86InstrInfo::foldMemoryOperandImpl() (#75011)
The medium code model assumes that the constant pool is referenceable
with 32-bit relocations.
2023-12-11 19:00:56 -08:00
Simon Pilgrim
33819f3bfb [X86] X86FixupVectorConstants - create f32/f64 broadcast constants if the source constant data was ANY floating point type
We don't need an exact match, this is mainly cleanup for cases where v2f32 style types have been cast to f64 etc.
2023-12-11 16:23:04 +00:00
Simon Pilgrim
a7d8d11a14 [X86] combineConcatVectorOps - constant fold vector load concatenation directly into a new load.
Create a new constant pool entry directly instead of going via a BUILD_VECTOR node, which makes constant pool reuse more difficult.

Helps with some regressions in #73509
2023-12-11 16:23:04 +00:00
Simon Pilgrim
d1deeae094
[X86] Rename VBROADCASTF128/VBROADCASTI128 to VBROADCASTF128rm/VBROADCASTI128rm (#75040)
Add missing rm postfix to show these are load instructions
2023-12-11 11:52:53 +00:00
Simon Pilgrim
21be9114ab [X86] evex-to-vex-compress.mir - strip trailing whitespace 2023-12-11 11:10:03 +00:00
paperchalice
9bd32d78a9
[CodeGen] Update DwarfEHPreparePass references in CodeGenPassBuilder.h (#74068)
Forgot to update the counterpart in `CodeGenPassBuilder.h`. Also Rename `dwarfehprepare` -> `dwarf-eh-prepare`.
2023-12-11 09:26:01 +08:00
James Y Knight
e79ef93c83 [X86] Rearrange a few atomics tests. NFC. 2023-12-09 20:53:29 -05:00
Arthur Eubanks
687e63a2bd
[X86] Allow accessing large globals in small code model (#74785)
This removes some assumptions that the small code model will only
reference "near" globals.

There are still some missing optimizations and wrong code sequences, but
I'd like to address those separately. This will require auditing any
checks of the code model in the X86 backend.
2023-12-08 11:09:54 -08:00
Simon Pilgrim
5f91335a55 [X86] canonicalizeBitSelect - always use VPTERNLOGD for sub-32bit types
We were using VPTERNLOGQ for everything but i32 types, which made broadcasts wider than necessary

Noticed in #73509
2023-12-08 11:38:32 +00:00
Simon Pilgrim
faecc736e2
[DAG] isSplatValue - node is a splat if all demanded elts have the same whole constant value (#74443) 2023-12-08 10:53:51 +00:00
Simon Pilgrim
8859a4f630 [X86] LowerBUILD_VECTOR - don't use insert_element(constant, elt, idx) if we have a freeze(undef) element
Fixes #74736
2023-12-08 10:28:56 +00:00