20098 Commits

Author SHA1 Message Date
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
Simon Pilgrim
f1200ca7ac
[DAG] visitEXTRACT_VECTOR_ELT - constant fold legal fp imm values (#74304)
If we're extracting a constant floating point value, and the constant is a legal fp imm value, then replace the extraction with a fp constant.
2023-12-07 14:56:12 +00:00
Simon Pilgrim
5384fb3d40 [X86] gep-expanded-vector.ll - regenerate checks 2023-12-07 14:07:10 +00:00
Harald van Dijk
03edfe6148
Implement SoftPromoteHalf for FFREXP. (#74076)
`llvm/test/CodeGen/RISCV/llvm.frexp.ll` and
`llvm/test/CodeGen/X86/llvm.frexp.ll` contain a number of disabled tests
for unimplemented functionality. This implements one missing part of it.
2023-12-07 11:10:17 +00:00
Simon Pilgrim
22df0886a1
[DAG] Don't split f64 constant stores if the fp imm is legal (#74622)
If the target can generate a specific fp immediate constant, then don't split the store into 2 x i32 stores

Another cleanup step for #74304
2023-12-07 10:33:03 +00:00
Thurston Dang
69c4930aad Revert "Reapply "RegisterCoalescer: Add implicit-def of super register when coalescing SUBREG_TO_REG""
This reverts commit 1f283a60a4bb896fa2d37ce00a3018924be82b9f.
Reason: breaks MSan buildbot
(https://lab.llvm.org/buildbot/#/builders/74/builds/24077)
2023-12-06 19:27:21 +00:00
Matt Arsenault
1f283a60a4 Reapply "RegisterCoalescer: Add implicit-def of super register when coalescing SUBREG_TO_REG"
This reverts commit 9e50c6e6b5741895f58f3e530004052844b6af9f. A few assertion and verifier
errors have been fixed in the coalescer and allocator, so hopefully this sticks this time.
2023-12-06 23:07:22 +07:00
Shengchen Kan
b8bc2351b8
[X86][test] Simplify test avx512-broadcast-unfold.ll (#74593)
The test was updated by

opt -passes=early-cse -S
llvm/test/CodeGen/X86/avx512-broadcast-unfold.ll
2023-12-06 22:38:32 +08:00
Simon Pilgrim
56eb3e738a
[X86] Set x87 fld1/fldz pseudo instructions as rematerializable (#74592)
No need to generate/spill/restore to cpu stack

Cleanup work to allow us to properly use isFPImmLegal and fix some regressions encountered while looking at #74304
2023-12-06 14:36:42 +00:00
Simon Pilgrim
bf454839a1 [X86] vec_zero_cse.ll - replace X32 check prefix with X86
We use X32 for gnux32 triples - X86 should be used for 32-bit triples
2023-12-06 14:06:37 +00:00
Shengchen Kan
50c66600b8 [X86][test] Migrate test avx512-broadcast-unfold.ll for opaque pointers 2023-12-06 21:24:30 +08:00
Simon Pilgrim
f12a0ba53e [X86] zero-remat.ll - regenerate checks 2023-12-06 11:15:55 +00:00
Simon Pilgrim
322c7c717b [X86] slow-unaligned-mem.ll - improve checks
We can't easily convert this to use the update scripts, but we can manually improve the checks so we check for the right number of stores
2023-12-06 10:50:57 +00:00
Arthur Eubanks
ddebce7021
[X86] Respect code_model when determining if a global is small/large (#74498)
Using the GlobalVariable code_model property added in #72077.

code_model = "small" means the global should be treated as small
regardless of the TargetMachine code model.
code_model = "large" means the global should be treated as large
regardless of the TargetMachine code model.

Inferring small/large based on a known section name still takes
precedence for correctness.

The intention is to use this for globals that are accessed very
infrequently but also take up a lot of space in the binary to mitigate
relocation overflows. Prime examples are globals that go in
"__llvm_prf_names" for coverage/PGO instrumented builds and
"asan_globals" for ASan builds.
2023-12-05 10:38:02 -08:00