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> {
25122512 // S = S | (V1 & V2)
25132513 Value *S1 = getShadow (&I, 0 );
25142514 Value *S2 = getShadow (&I, 1 );
2515+ // Gotcha: V1 and V2 are NOT'ed here
25152516 Value *V1 = IRB.CreateNot (I.getOperand (0 ));
25162517 Value *V2 = IRB.CreateNot (I.getOperand (1 ));
25172518 if (V1->getType () != S1->getType ()) {
@@ -2524,7 +2525,11 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
25242525
25252526 Value *S = IRB.CreateOr ({S1S2, V1S2, S1V2});
25262527 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));
25282533 S = IRB.CreateOr ({S, V1V2});
25292534 }
25302535
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 {
4545; CHECK-IMPRECISE: [[C:%.*]] = or disjoint i8 [[A]], [[B]]
4646; CHECK-IMPRECISE-NEXT: store i8 [[TMP11]], ptr @__msan_retval_tls, align 8
4747;
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]]
5051; CHECK-PRECISE-NEXT: [[C:%.*]] = or disjoint i8 [[A]], [[B]]
5152; CHECK-PRECISE-NEXT: store i8 [[TMP12]], ptr @__msan_retval_tls, align 8
5253;
You can’t perform that action at this time.
0 commit comments