1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[msan] Set cmpxchg shadow precisely

In terms of https://llvm.org/docs/LangRef.html#cmpxchg-instruction,
the return type of chmpxchg is a pair {ty, i1}, while I think we
only wanted to set the shadow for the address 0th op, and it has type
ty.

Reviewed-by: eugenis

Differential Revision: https://reviews.llvm.org/D97029
This commit is contained in:
Jianzhou Zhao 2021-02-19 04:37:49 +00:00
parent 4fe33c803d
commit fbcfd3cb70
2 changed files with 6 additions and 5 deletions

View File

@ -1948,7 +1948,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
IRBuilder<> IRB(&I);
Value *Addr = I.getOperand(0);
Value *ShadowPtr = getShadowOriginPtr(Addr, IRB, I.getType(), Align(1),
Value *Val = I.getOperand(1);
Value *ShadowPtr = getShadowOriginPtr(Addr, IRB, Val->getType(), Align(1),
/*isStore*/ true)
.first;
@ -1959,9 +1960,9 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
// The other argument can potentially be uninitialized, but we can not
// detect this situation reliably without possible false positives.
if (isa<AtomicCmpXchgInst>(I))
insertShadowCheck(I.getOperand(1), &I);
insertShadowCheck(Val, &I);
IRB.CreateStore(getCleanShadow(&I), ShadowPtr);
IRB.CreateStore(getCleanShadow(Val), ShadowPtr);
setShadow(&I, getCleanShadow(&I));
setOrigin(&I, getCleanOrigin());

View File

@ -51,7 +51,7 @@ entry:
}
; CHECK-LABEL: @Cmpxchg
; CHECK: store { i32, i1 } zeroinitializer,
; CHECK: store i32 0,
; CHECK: icmp
; CHECK: br
; CHECK: @__msan_warning_with_origin
@ -70,7 +70,7 @@ entry:
}
; CHECK-LABEL: @CmpxchgMonotonic
; CHECK: store { i32, i1 } zeroinitializer,
; CHECK: store i32 0,
; CHECK: icmp
; CHECK: br
; CHECK: @__msan_warning_with_origin