[PATCH] D97029: [msan] Set cmpxchg shadow precisely
stephan.yichao.zhao via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 18 20:41:20 PST 2021
stephan.yichao.zhao created this revision.
stephan.yichao.zhao added a reviewer: eugenis.
Herald added subscribers: jfb, hiraditya.
stephan.yichao.zhao requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D97029
Files:
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
llvm/test/Instrumentation/MemorySanitizer/atomics.ll
Index: llvm/test/Instrumentation/MemorySanitizer/atomics.ll
===================================================================
--- llvm/test/Instrumentation/MemorySanitizer/atomics.ll
+++ llvm/test/Instrumentation/MemorySanitizer/atomics.ll
@@ -51,7 +51,7 @@
}
; 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 @@
}
; CHECK-LABEL: @CmpxchgMonotonic
-; CHECK: store { i32, i1 } zeroinitializer,
+; CHECK: store i32 0,
; CHECK: icmp
; CHECK: br
; CHECK: @__msan_warning_with_origin
Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -1948,7 +1948,8 @@
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 @@
// 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());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97029.324870.patch
Type: text/x-patch
Size: 1721 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210219/d467cc4a/attachment.bin>
More information about the llvm-commits
mailing list