diff --git a/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/lib/Transforms/Instrumentation/MemorySanitizer.cpp index f484ff0a98c..64574a6aa23 100644 --- a/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -1948,7 +1948,8 @@ struct MemorySanitizerVisitor : public InstVisitor { 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 { // The other argument can potentially be uninitialized, but we can not // detect this situation reliably without possible false positives. if (isa(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()); diff --git a/test/Instrumentation/MemorySanitizer/atomics.ll b/test/Instrumentation/MemorySanitizer/atomics.ll index 36afb91a40b..f6d326e52ea 100644 --- a/test/Instrumentation/MemorySanitizer/atomics.ll +++ b/test/Instrumentation/MemorySanitizer/atomics.ll @@ -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