From 2b65b0f314f7ce9bb4b45b8e2386823686814dba Mon Sep 17 00:00:00 2001 From: Cameron McInally Date: Wed, 5 Jun 2019 22:37:05 +0000 Subject: [PATCH] [MSAN] Add unary FNeg visitor to the MemorySanitizer Differential Revision: https://reviews.llvm.org/D62909 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362664 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Instrumentation/MemorySanitizer.cpp | 2 ++ .../MemorySanitizer/msan_basic.ll | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/lib/Transforms/Instrumentation/MemorySanitizer.cpp index 87f73ff24c4..7c261775003 100644 --- a/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -2110,6 +2110,8 @@ struct MemorySanitizerVisitor : public InstVisitor { SC.Done(&I); } + void visitFNeg(UnaryOperator &I) { handleShadowOr(I); } + // Handle multiplication by constant. // // Handle a special case of multiplication by constant that may have one or diff --git a/test/Instrumentation/MemorySanitizer/msan_basic.ll b/test/Instrumentation/MemorySanitizer/msan_basic.ll index a42730de012..499de14aea3 100644 --- a/test/Instrumentation/MemorySanitizer/msan_basic.ll +++ b/test/Instrumentation/MemorySanitizer/msan_basic.ll @@ -438,6 +438,22 @@ entry: ; CHECK: store i32 %[[SC]], i32* {{.*}}@__msan_retval_tls ; CHECK: ret float +; Check that fneg simply propagates shadow. + +define float @FNeg(float %a) nounwind uwtable readnone sanitize_memory { +entry: + %c = fneg float %a + ret float %c +} + +; CHECK-LABEL: @FNeg +; CHECK: %[[SA:.*]] = load i32,{{.*}}@__msan_param_tls +; CHECK-ORIGINS: %[[SB:.*]] = load i32,{{.*}}@__msan_param_origin_tls +; CHECK: = fneg float +; CHECK: store i32 %[[SA]], i32* {{.*}}@__msan_retval_tls +; CHECK-ORIGINS: store i32{{.*}}@__msan_retval_origin_tls +; CHECK: ret float + ; Check that we propagate shadow for x<0, x>=0, etc (i.e. sign bit tests) define zeroext i1 @ICmpSLTZero(i32 %x) nounwind uwtable readnone sanitize_memory { -- 2.50.1