1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00
llvm-mirror/test/Instrumentation/MemorySanitizer/msan_llvm_strip_invariant.ll
Evgeniy Stepanov 4c3c83afa7 Handle llvm.launder.invariant.group in msan.
Summary:
[MSan] handle llvm.launder.invariant.group

    Msan used to give false-positives in

    class Foo {
     public:
      virtual ~Foo() {};
    };

    // Return true iff *x is set.
    bool f1(void **x, bool flag);

    Foo* f() {
      void *p;
      bool found;
      found = f1(&p,flag);
      if (found) {
        // p is always set here.
        return static_cast<Foo*>(p); // False positive here.
      }
      return nullptr;
    }

Patch by Ilya Tokar.

Reviewers: #sanitizers, eugenis

Reviewed By: #sanitizers, eugenis

Subscribers: eugenis, Prazek, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D68236

llvm-svn: 373515
2019-10-02 19:53:19 +00:00

22 lines
690 B
LLVM

; Make sure MSan handles llvm.launder.invariant.group correctly.
; RUN: opt < %s -msan -msan-kernel=1 -O1 -S | FileCheck -check-prefixes=CHECK %s
; RUN: opt < %s -msan -O1 -S | FileCheck -check-prefixes=CHECK %s
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@flag = dso_local local_unnamed_addr global i8 0, align 1
define dso_local i8* @f(i8* %x) local_unnamed_addr #0 {
entry:
%0 = call i8* @llvm.strip.invariant.group.p0i8(i8* %x)
ret i8* %0
}
; CHECK-NOT: call void @__msan_warning_noreturn
declare i8* @llvm.strip.invariant.group.p0i8(i8*)
attributes #0 = { sanitize_memory uwtable }