Skip to content

Commit 3656c51

Browse files
committed
[msan] Handle Intrinsic::vector_reduce_f{add,mul}
This adds handleVectorReduceWithStarterIntrinsic() (similar to handleVectorReduceIntrinsic but for intrinsics with an additional starting parameter) and uses it to handle Intrinsic::vector_reduce_f{add,mul}. Updates the tests from llvm#125597
1 parent 2a84e1e commit 3656c51

File tree

3 files changed

+116
-302
lines changed

3 files changed

+116
-302
lines changed

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3500,6 +3500,18 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
35003500
setOrigin(&I, getOrigin(&I, 0));
35013501
}
35023502

3503+
// Similar to handleVectorReduceIntrinsic but with an initial starting value.
3504+
// e.g., call float @llvm.vector.reduce.fadd.f32.v2f32(float %a0, <2 x float> %a1)
3505+
// shadow = shadow[a0] | shadow[a1.0] | shadow[a1.1]
3506+
void handleVectorReduceWithStarterIntrinsic(IntrinsicInst &I) {
3507+
IRBuilder<> IRB(&I);
3508+
Value *Shadow0 = getShadow(&I, 0);
3509+
Value *Shadow1 = IRB.CreateOrReduce(getShadow(&I, 1));
3510+
Value *S = IRB.CreateOr(Shadow0, Shadow1);
3511+
setShadow(&I, S);
3512+
setOriginForNaryOp(I);
3513+
}
3514+
35033515
// Instrument vector.reduce.or intrinsic.
35043516
// Valid (non-poisoned) set bits in the operand pull low the
35053517
// corresponding shadow bits.
@@ -4344,6 +4356,11 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
43444356
case Intrinsic::vector_reduce_mul:
43454357
handleVectorReduceIntrinsic(I);
43464358
break;
4359+
case Intrinsic::vector_reduce_fadd:
4360+
case Intrinsic::vector_reduce_fmul:
4361+
handleVectorReduceWithStarterIntrinsic(I);
4362+
break;
4363+
43474364
case Intrinsic::x86_sse_stmxcsr:
43484365
handleStmxcsr(I);
43494366
break;

0 commit comments

Comments
 (0)