[llvm] 35d00fd - [msan] Reset shadow of byval before call
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 14 22:35:54 PST 2022
Author: Vitaly Buka
Date: 2022-01-14T22:35:43-08:00
New Revision: 35d00fdc109f407af42746b141d1a1a182a5f686
URL: https://github.com/llvm/llvm-project/commit/35d00fdc109f407af42746b141d1a1a182a5f686
DIFF: https://github.com/llvm/llvm-project/commit/35d00fdc109f407af42746b141d1a1a182a5f686.diff
LOG: [msan] Reset shadow of byval before call
If function is not sanitized we must reset shadow, not copy.
Depends on D117285
Reviewed By: kda, eugenis
Differential Revision: https://reviews.llvm.org/D117286
Added:
Modified:
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
llvm/test/Instrumentation/MemorySanitizer/byval.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index 9896a1a7bedc..cfe993dedbc2 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -3726,10 +3726,14 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
getShadowOriginPtr(A, IRB, IRB.getInt8Ty(), Alignment,
/*isStore*/ false)
.first;
-
- Store = IRB.CreateMemCpy(ArgShadowBase, Alignment, AShadowPtr,
- Alignment, Size);
- // TODO(glider): need to copy origins.
+ if (!PropagateShadow) {
+ Store = IRB.CreateMemSet(ArgShadowBase,
+ Constant::getNullValue(IRB.getInt8Ty()),
+ Size, Alignment);
+ } else {
+ Store = IRB.CreateMemCpy(ArgShadowBase, Alignment, AShadowPtr,
+ Alignment, Size);
+ }
} else {
// Any other parameters mean we need bit-grained tracking of uninit
// data
diff --git a/llvm/test/Instrumentation/MemorySanitizer/byval.ll b/llvm/test/Instrumentation/MemorySanitizer/byval.ll
index bded2ad1cff9..a636847229be 100644
--- a/llvm/test/Instrumentation/MemorySanitizer/byval.ll
+++ b/llvm/test/Instrumentation/MemorySanitizer/byval.ll
@@ -79,12 +79,11 @@ entry:
ret void
}
-; FIXME: Shadow for byval should be reset not copied before the call.
define void @ByValForwardByValNoSanitize(i32, i128* byval(i128) %p) {
; CHECK-LABEL: @ByValForwardByValNoSanitize(
; CHECK-NEXT: entry:
; CHECK: call void @llvm.memset.p0i8.i64(i8* align 8 {{.*}}, i8 0, i64 16, i1 false)
-; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* bitcast ([100 x i64]* @__msan_param_tls to i8*), i8* {{.*}}, i64 16, i1 false)
+; CHECK: call void @llvm.memset.p0i8.i64(i8* bitcast ([100 x i64]* @__msan_param_tls to i8*), i8 0, i64 16, i1 false)
; CHECK: store i32 0, i32* getelementptr inbounds ([200 x i32], [200 x i32]* @__msan_param_origin_tls, i32 0, i32 0)
; CHECK-NEXT: call void @FnByVal(
; CHECK-NEXT: ret void
More information about the llvm-commits
mailing list