diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/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(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/llvm/test/Instrumentation/MemorySanitizer/atomics.ll b/llvm/test/Instrumentation/MemorySanitizer/atomics.ll --- a/llvm/test/Instrumentation/MemorySanitizer/atomics.ll +++ b/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