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 @@ -1949,7 +1949,7 @@ IRBuilder<> IRB(&I); Value *Addr = I.getOperand(0); Value *Val = I.getOperand(1); - Value *ShadowPtr = getShadowOriginPtr(Addr, IRB, Val->getType(), Align(1), + Value *ShadowPtr = getShadowOriginPtr(Addr, IRB, getShadowTy(Val), Align(1), /*isStore*/ true) .first; 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 @@ -22,6 +22,20 @@ ; CHECK: store i32 0, {{.*}} @__msan_retval_tls ; CHECK: ret i32 +; atomicrmw xchg ptr: exactly the same as above + +define i32* @AtomicRmwXchgPtr(i32** %p, i32* %x) sanitize_memory { +entry: + %0 = atomicrmw xchg i32** %p, i32* %x seq_cst + ret i32* %0 +} + +; CHECK-LABEL: @AtomicRmwXchgPtr +; CHECK: store i64 0, +; CHECK: atomicrmw xchg {{.*}} seq_cst +; CHECK: store i64 0, {{.*}} @__msan_retval_tls +; CHECK: ret i32* + ; atomicrmw max: exactly the same as above