[llvm] [msan] Generalize handlePairwiseShadowOrIntrinsic, and handle x86 pairwise add/sub (PR #127567)
Thurston Dang via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 19 16:51:47 PST 2025
================
@@ -2618,28 +2625,56 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
FixedVectorType *ParamType =
cast<FixedVectorType>(I.getArgOperand(0)->getType());
if (I.arg_size() == 2)
- assert(ParamType == cast<FixedVectorType>(I.getArgOperand(1)->getType()));
+ assert(I.getArgOperand(0)->getType() == I.getArgOperand(1)->getType());
+
[[maybe_unused]] FixedVectorType *ReturnType =
cast<FixedVectorType>(I.getType());
assert(ParamType->getNumElements() * I.arg_size() ==
2 * ReturnType->getNumElements());
IRBuilder<> IRB(&I);
- unsigned Width = ParamType->getNumElements() * I.arg_size();
+
+ unsigned TotalNumElems = ParamType->getNumElements() * I.arg_size();
+ FixedVectorType *ReinterpretShadowTy = nullptr;
+ if (ReinterpretElemWidth.has_value()) {
+ assert(ParamType->getPrimitiveSizeInBits() %
+ ReinterpretElemWidth.value() ==
+ 0);
+ ReinterpretShadowTy = FixedVectorType::get(
+ IRB.getIntNTy(ReinterpretElemWidth.value()),
+ ParamType->getPrimitiveSizeInBits() / ReinterpretElemWidth.value());
+ TotalNumElems = ReinterpretShadowTy->getNumElements() * I.arg_size();
+ }
// Horizontal OR of shadow
SmallVector<int, 8> EvenMask;
SmallVector<int, 8> OddMask;
- for (unsigned X = 0; X < Width; X += 2) {
+ for (unsigned X = 0; X + 1 < TotalNumElems; X += 2) {
----------------
thurstond wrote:
Done
https://github.com/llvm/llvm-project/pull/127567
More information about the llvm-commits
mailing list