Skip to content

Commit c72fbe5

Browse files
committed
[MSAN] Add unary FNeg visitor to the MemorySanitizer
Differential Revision: https://reviews.llvm.org/D62909 llvm-svn: 362664
1 parent 6c5d5ce commit c72fbe5

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,6 +2110,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
21102110
SC.Done(&I);
21112111
}
21122112

2113+
void visitFNeg(UnaryOperator &I) { handleShadowOr(I); }
2114+
21132115
// Handle multiplication by constant.
21142116
//
21152117
// Handle a special case of multiplication by constant that may have one or

llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,22 @@ entry:
438438
; CHECK: store i32 %[[SC]], i32* {{.*}}@__msan_retval_tls
439439
; CHECK: ret float
440440

441+
; Check that fneg simply propagates shadow.
442+
443+
define float @FNeg(float %a) nounwind uwtable readnone sanitize_memory {
444+
entry:
445+
%c = fneg float %a
446+
ret float %c
447+
}
448+
449+
; CHECK-LABEL: @FNeg
450+
; CHECK: %[[SA:.*]] = load i32,{{.*}}@__msan_param_tls
451+
; CHECK-ORIGINS: %[[SB:.*]] = load i32,{{.*}}@__msan_param_origin_tls
452+
; CHECK: = fneg float
453+
; CHECK: store i32 %[[SA]], i32* {{.*}}@__msan_retval_tls
454+
; CHECK-ORIGINS: store i32{{.*}}@__msan_retval_origin_tls
455+
; CHECK: ret float
456+
441457
; Check that we propagate shadow for x<0, x>=0, etc (i.e. sign bit tests)
442458

443459
define zeroext i1 @ICmpSLTZero(i32 %x) nounwind uwtable readnone sanitize_memory {

0 commit comments

Comments
 (0)