[PATCH] D85040: [MSAN] Instrument freeze instruction by clearing shadow
Gui Andrade via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 31 15:37:13 PDT 2020
guiand updated this revision to Diff 282337.
guiand added a comment.
Fixed to actually set the shadow and origin. Sorry for the mix-up!
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85040/new/
https://reviews.llvm.org/D85040
Files:
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
llvm/test/Instrumentation/MemorySanitizer/freeze.ll
Index: llvm/test/Instrumentation/MemorySanitizer/freeze.ll
===================================================================
--- /dev/null
+++ llvm/test/Instrumentation/MemorySanitizer/freeze.ll
@@ -0,0 +1,20 @@
+; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck %s
+; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=2 -S -passes=msan 2>&1 | FileCheck %s -check-prefixes=CHECK,CHECK-ORIGIN
+; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @nofreeze(i32* %ptr) sanitize_memory {
+ %val = load i32, i32* %ptr
+ ; CHECK: [[SHADOW_PTR:%.*]] = inttoptr
+ ; CHECK: [[SHADOW:%.*]] = load i32, i32* [[SHADOW_PTR]]
+ ; CHECK: store i32 [[SHADOW]], {{.*}} @__msan_retval_tls
+ ret i32 %val
+}
+
+define i32 @freeze_inst(i32* %ptr) sanitize_memory {
+ %val = load i32, i32* %ptr
+ %freeze_val = freeze i32 %val
+ ; CHECK: store i32 0, {{.*}} @__msan_retval_tls
+ ret i32 %freeze_val
+}
Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -4220,6 +4220,11 @@
setOrigin(&I, getCleanOrigin());
}
+ void visitFreezeInstruction(FreezeInst &I) {
+ // Freeze always returns a fully defined value.
+ setShadow(&I, getCleanShadow(&I));
+ }
+
void visitInstruction(Instruction &I) {
// Everything else: stop propagating and check for poisoned shadow.
if (ClDumpStrictInstructions)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85040.282337.patch
Type: text/x-patch
Size: 1813 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200731/670d0b96/attachment.bin>
More information about the llvm-commits
mailing list