Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2525,11 +2525,10 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {

Value *S = IRB.CreateOr({S1S2, V1S2, S1V2});
if (ClPreciseDisjointOr && cast<PossiblyDisjointInst>(&I)->isDisjoint()) {
// "V1" and "V2" were NOT'ed above, but we still want to reuse them
// because they were IntCast'ed to the same type as the shadows.
//
// (V1 & V2) == ~(~V1 | ~V2) (de Morgan)
Value *V1V2 = IRB.CreateNot(IRB.CreateOr(V1, V2));
// "V1" and "V2" were NOT'ed above
V1 = IRB.CreateIntCast(I.getOperand(0), S1->getType(), false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't reuse the variable name :(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed the earlier variables NotV1 / NotV2

V2 = IRB.CreateIntCast(I.getOperand(1), S2->getType(), false);
Value *V1V2 = IRB.CreateAnd(V1, V2);
S = IRB.CreateOr({S, V1V2});
}

Expand Down
7 changes: 3 additions & 4 deletions llvm/test/Instrumentation/MemorySanitizer/or.ll
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ define i8 @test_disjoint_or(i8 %a, i8 %b) sanitize_memory {
; CHECK-IMPRECISE: [[C:%.*]] = or disjoint i8 [[A]], [[B]]
; CHECK-IMPRECISE-NEXT: store i8 [[TMP11]], ptr @__msan_retval_tls, align 8
;
; CHECK-PRECISE: [[TMP10:%.*]] = or i8 [[TMP3]], [[TMP4]]
; CHECK-PRECISE-NEXT: [[TMP11:%.*]] = xor i8 [[TMP10]], -1
; CHECK-PRECISE-NEXT: [[TMP12:%.*]] = or i8 [[TMP9]], [[TMP11]]
; CHECK-PRECISE: [[TMP10:%.*]] = and i8 [[A]], [[B]]
; CHECK-PRECISE-NEXT: [[TMP11:%.*]] = or i8 [[TMP9]], [[TMP10]]
; CHECK-PRECISE-NEXT: [[C:%.*]] = or disjoint i8 [[A]], [[B]]
; CHECK-PRECISE-NEXT: store i8 [[TMP12]], ptr @__msan_retval_tls, align 8
; CHECK-PRECISE-NEXT: store i8 [[TMP11]], ptr @__msan_retval_tls, align 8
;
; CHECK-NEXT: ret i8 [[C]]
;
Expand Down
Loading