Skip to content

Commit 702784c

Browse files
authored
[msan] Check mask and rounding mode in handleAVX512VectorConvertFPToInt (#147782)
The checks were missing in "Add handler for llvm.x86.avx512.mask.cvtps2dq.512 (#147377)
1 parent 8b9bbd9 commit 702784c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4407,7 +4407,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
44074407
Value *A = I.getOperand(0);
44084408
Value *WriteThrough = I.getOperand(1);
44094409
Value *Mask = I.getOperand(2);
4410-
[[maybe_unused]] Value *RoundingMode = I.getOperand(3);
4410+
Value *RoundingMode = I.getOperand(3);
44114411

44124412
assert(isFixedFPVector(A));
44134413
assert(isFixedIntVector(WriteThrough));
@@ -4419,8 +4419,13 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
44194419

44204420
assert(Mask->getType()->isIntegerTy());
44214421
assert(Mask->getType()->getScalarSizeInBits() == ANumElements);
4422+
insertCheckShadowOf(Mask, &I);
44224423

44234424
assert(RoundingMode->getType()->isIntegerTy());
4425+
// Only four bits of the rounding mode are used, though it's very
4426+
// unusual to have uninitialized bits there (more commonly, it's a
4427+
// constant).
4428+
insertCheckShadowOf(RoundingMode, &I);
44244429

44254430
assert(I.getType() == WriteThrough->getType());
44264431

llvm/test/Instrumentation/MemorySanitizer/X86/avx512-intrinsics.ll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7941,13 +7941,20 @@ declare <16 x i32> @llvm.x86.avx512.mask.cvtps2dq.512(<16 x float>, <16 x i32>,
79417941

79427942
define <16 x i32>@test_int_x86_avx512_mask_cvt_ps2dq_512(<16 x float> %x0, <16 x i32> %x1, i16 %x2) #0 {
79437943
; CHECK-LABEL: @test_int_x86_avx512_mask_cvt_ps2dq_512(
7944+
; CHECK-NEXT: [[TMP10:%.*]] = load i16, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__msan_param_tls to i64), i64 128) to ptr), align 8
79447945
; CHECK-NEXT: [[TMP1:%.*]] = load <16 x i32>, ptr @__msan_param_tls, align 8
79457946
; CHECK-NEXT: [[TMP2:%.*]] = load <16 x i32>, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__msan_param_tls to i64), i64 64) to ptr), align 8
79467947
; CHECK-NEXT: call void @llvm.donothing()
79477948
; CHECK-NEXT: [[TMP3:%.*]] = bitcast i16 [[X2:%.*]] to <16 x i1>
79487949
; CHECK-NEXT: [[TMP4:%.*]] = icmp ne <16 x i32> [[TMP1]], zeroinitializer
79497950
; CHECK-NEXT: [[TMP5:%.*]] = sext <16 x i1> [[TMP4]] to <16 x i32>
79507951
; CHECK-NEXT: [[TMP6:%.*]] = select <16 x i1> [[TMP3]], <16 x i32> [[TMP5]], <16 x i32> [[TMP2]]
7952+
; CHECK-NEXT: [[_MSCMP:%.*]] = icmp ne i16 [[TMP10]], 0
7953+
; CHECK-NEXT: br i1 [[_MSCMP]], label [[TMP11:%.*]], label [[TMP12:%.*]], !prof [[PROF1]]
7954+
; CHECK: 8:
7955+
; CHECK-NEXT: call void @__msan_warning_noreturn() #[[ATTR10]]
7956+
; CHECK-NEXT: unreachable
7957+
; CHECK: 9:
79517958
; CHECK-NEXT: [[RES:%.*]] = call <16 x i32> @llvm.x86.avx512.mask.cvtps2dq.512(<16 x float> [[X0:%.*]], <16 x i32> [[X1:%.*]], i16 [[X2]], i32 10)
79527959
; CHECK-NEXT: [[TMP7:%.*]] = icmp ne <16 x i32> [[TMP1]], zeroinitializer
79537960
; CHECK-NEXT: [[TMP8:%.*]] = sext <16 x i1> [[TMP7]] to <16 x i32>

0 commit comments

Comments
 (0)