aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
diff options
context:
space:
mode:
authorPiJoules <6019989+PiJoules@users.noreply.github.com>2025-05-15 11:52:25 -0700
committerGitHub <noreply@github.com>2025-05-15 11:52:25 -0700
commit2661e995ceebd6fd083e5b62aeff21e67b28e9a4 (patch)
treeb7c23ce41e45b5fb8686d5cd0c0d9f674bbbef9b /llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
parent5c551cbe462ea1b22bfe7e42e248ca29ea5c334c (diff)
downloadllvm-2661e995ceebd6fd083e5b62aeff21e67b28e9a4.zip
llvm-2661e995ceebd6fd083e5b62aeff21e67b28e9a4.tar.gz
llvm-2661e995ceebd6fd083e5b62aeff21e67b28e9a4.tar.bz2
[llvm] Ensure propagated constants in the vtable are aligned (#136630)
It's possible for virtual constant propagation in whole program devirtualization to create unaligned loads. We originally saw this with 4-byte aligned relative vtables where we could store 8-byte values before/after the vtable. But since the vtable is 4-byte aligned and we unconditionally do an 8-byte load, we can't guarantee that the stored constant will always be aligned to 8 bytes. We can also see this with normal vtables whenever a 1-byte char is stored in the vtable because the offset calculation for the GEP doesn't take into account the original vtable alignment. This patch introduces two changes to virtual constant propagation: 1. Do not propagate constants whose preferred alignment is larger than the vtable alignment. This is required because if the constants are stored in the vtable, we can only guarantee the constant will be stored at an address at most aligned to the vtable's alignment. 2. Round up the offset used in the GEP before the load to ensure it's at an address suitably aligned such that we can load from it. This patch updates tests to reflect this alignment change and adds some cases for relative vtables.
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp')
0 files changed, 0 insertions, 0 deletions