aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineModuleInfo.cpp
diff options
context:
space:
mode:
authorThurston Dang <thurston@google.com>2025-01-23 22:53:56 -0800
committerGitHub <noreply@github.com>2025-01-23 22:53:56 -0800
commit8ef171ee831ff030e5aa81a74d68edc133d0cb4f (patch)
tree06d40d98898dc13e24fe72197c0e06d33b3db29b /llvm/lib/CodeGen/MachineModuleInfo.cpp
parent45d83ae7df65a3c9843270d970119bc97957d830 (diff)
downloadllvm-8ef171ee831ff030e5aa81a74d68edc133d0cb4f.zip
llvm-8ef171ee831ff030e5aa81a74d68edc133d0cb4f.tar.gz
llvm-8ef171ee831ff030e5aa81a74d68edc133d0cb4f.tar.bz2
[msan] Handle horizontal add/subtract intrinsic by applying to shadow (#124159)
Horizontal add (hadd) and subtract (hsub) are currently heuristically handled by `maybeHandleSimpleNomemIntrinsic()` (via `handleUnknownIntrinsic()`), which computes the shadow by bitwise OR'ing the two operands. This has false positives for hadd/hsub shadows. For example, suppose the shadows for the two operands are 00000000 and 11111111 respectively. The expected shadow for the result is 00001111, but `maybeHandleSimpleNomemIntrinsic` would compute it as 11111111. This patch handles horizontal add using `handleIntrinsicByApplyingToShadow` (from https://github.com/llvm/llvm-project/pull/114490), which has no false positives for hadd/hsub: if each pair of adjacent shadow values is zero (fully initialized), the result will be zero (fully initialized). More generally, it is precise for hadd/hsub if at least one of the two adjacent shadow values in each pair is zero. It does have some false negatives for hadd/hsub: if we add/subtract two adjacent non-zero shadow values, some bits of the result may incorrectly be zero. We consider this an acceptable tradeoff for performance. To make shadow propagation precise, we want the equivalent of "horizontal OR", but this is not available. Reducing horizontal OR to (permutation plus bitwise OR) is left as an exercise for the reader.
Diffstat (limited to 'llvm/lib/CodeGen/MachineModuleInfo.cpp')
0 files changed, 0 insertions, 0 deletions