File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
lib/Transforms/Instrumentation
test/Instrumentation/MemorySanitizer Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -2512,6 +2512,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
2512
2512
// S = S | (V1 & V2)
2513
2513
Value *S1 = getShadow (&I, 0 );
2514
2514
Value *S2 = getShadow (&I, 1 );
2515
+ // Gotcha: V1 and V2 are NOT'ed here
2515
2516
Value *V1 = IRB.CreateNot (I.getOperand (0 ));
2516
2517
Value *V2 = IRB.CreateNot (I.getOperand (1 ));
2517
2518
if (V1->getType () != S1->getType ()) {
@@ -2524,7 +2525,11 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
2524
2525
2525
2526
Value *S = IRB.CreateOr ({S1S2, V1S2, S1V2});
2526
2527
if (ClPreciseDisjointOr && cast<PossiblyDisjointInst>(&I)->isDisjoint ()) {
2527
- Value *V1V2 = IRB.CreateAnd (V1, V2);
2528
+ // "V1" and "V2" were NOT'ed above, but we still want to reuse them
2529
+ // because they were IntCast'ed to the same type as the shadows.
2530
+ //
2531
+ // (V1 & V2) == ~(~V1 | ~V2) (de Morgan)
2532
+ Value *V1V2 = IRB.CreateNot (IRB.CreateOr (V1, V2));
2528
2533
S = IRB.CreateOr ({S, V1V2});
2529
2534
}
2530
2535
Original file line number Diff line number Diff line change @@ -45,8 +45,9 @@ define i8 @test_disjoint_or(i8 %a, i8 %b) sanitize_memory {
45
45
; CHECK-IMPRECISE: [[C:%.*]] = or disjoint i8 [[A]], [[B]]
46
46
; CHECK-IMPRECISE-NEXT: store i8 [[TMP11]], ptr @__msan_retval_tls, align 8
47
47
;
48
- ; CHECK-PRECISE: [[TMP10:%.*]] = and i8 [[TMP3]], [[TMP4]]
49
- ; CHECK-PRECISE-NEXT: [[TMP12:%.*]] = or i8 [[TMP11]], [[TMP10]]
48
+ ; CHECK-PRECISE: [[TMP10:%.*]] = or i8 [[TMP3]], [[TMP4]]
49
+ ; CHECK-PRECISE-NEXT: [[TMP11:%.*]] = xor i8 [[TMP10]], -1
50
+ ; CHECK-PRECISE-NEXT: [[TMP12:%.*]] = or i8 [[TMP9]], [[TMP11]]
50
51
; CHECK-PRECISE-NEXT: [[C:%.*]] = or disjoint i8 [[A]], [[B]]
51
52
; CHECK-PRECISE-NEXT: store i8 [[TMP12]], ptr @__msan_retval_tls, align 8
52
53
;
You can’t perform that action at this time.
0 commit comments