Skip to content

Commit 86a1df3

Browse files
committed
Recast operands as ints instead, per Florian2
1 parent 7a7aeb0 commit 86a1df3

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2525,11 +2525,10 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
25252525

25262526
Value *S = IRB.CreateOr({S1S2, V1S2, S1V2});
25272527
if (ClPreciseDisjointOr && cast<PossiblyDisjointInst>(&I)->isDisjoint()) {
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+
// "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);
2531+
Value *V1V2 = IRB.CreateAnd(V1, V2);
25332532
S = IRB.CreateOr({S, V1V2});
25342533
}
25352534

llvm/test/Instrumentation/MemorySanitizer/or.ll

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ 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:%.*]] = or i8 [[TMP3]], [[TMP4]]
49-
; CHECK-PRECISE-NEXT: [[TMP11:%.*]] = xor i8 [[TMP10]], -1
50-
; CHECK-PRECISE-NEXT: [[TMP12:%.*]] = or i8 [[TMP9]], [[TMP11]]
48+
; CHECK-PRECISE: [[TMP10:%.*]] = and i8 [[A]], [[B]]
49+
; CHECK-PRECISE-NEXT: [[TMP11:%.*]] = or i8 [[TMP9]], [[TMP10]]
5150
; CHECK-PRECISE-NEXT: [[C:%.*]] = or disjoint i8 [[A]], [[B]]
52-
; CHECK-PRECISE-NEXT: store i8 [[TMP12]], ptr @__msan_retval_tls, align 8
51+
; CHECK-PRECISE-NEXT: store i8 [[TMP11]], ptr @__msan_retval_tls, align 8
5352
;
5453
; CHECK-NEXT: ret i8 [[C]]
5554
;

0 commit comments

Comments
 (0)