@@ -2512,24 +2512,25 @@ 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
2516- Value *V1 = IRB.CreateNot (I.getOperand (0 ));
2517- Value *V2 = IRB.CreateNot (I.getOperand (1 ));
2515+ Value *V1 = I.getOperand (0 );
2516+ Value *V2 = I.getOperand (1 );
25182517 if (V1->getType () != S1->getType ()) {
25192518 V1 = IRB.CreateIntCast (V1, S1->getType (), false );
25202519 V2 = IRB.CreateIntCast (V2, S2->getType (), false );
25212520 }
2521+
2522+ Value *NotV1 = IRB.CreateNot (V1);
2523+ Value *NotV2 = IRB.CreateNot (V2);
2524+
25222525 Value *S1S2 = IRB.CreateAnd (S1, S2);
2523- Value *V1S2 = IRB.CreateAnd (V1, S2);
2524- Value *S1V2 = IRB.CreateAnd (S1, V2);
2526+ Value *S2NotV1 = IRB.CreateAnd (NotV1, S2);
2527+ Value *S1NotV2 = IRB.CreateAnd (S1, NotV2);
2528+
2529+ Value *S = IRB.CreateOr ({S1S2, S2NotV1, S1NotV2});
25252530
2526- Value *S = IRB.CreateOr ({S1S2, V1S2, S1V2});
25272531 if (ClPreciseDisjointOr && cast<PossiblyDisjointInst>(&I)->isDisjoint ()) {
2528- // "V1" and "V2" were NOT'ed above
2529- V1 = IRB.CreateIntCast (I.getOperand (0 ), S1->getType (), false );
2530- V2 = IRB.CreateIntCast (I.getOperand (1 ), S2->getType (), false );
25312532 Value *V1V2 = IRB.CreateAnd (V1, V2);
2532- S = IRB.CreateOr ({ S, V1V2} );
2533+ S = IRB.CreateOr (S, V1V2, " _ms_disjoint " );
25332534 }
25342535
25352536 setShadow (&I, S);
0 commit comments