[PATCH] D49473: [MSan] pull insertShadowCheck() into getShadowOriginPtr(). NFC

Alexander Potapenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 19 07:41:29 PDT 2018


glider added a comment.

I've also noticed that currently MSan instruments loads by placing the checks _after_ them, which is also incorrect.
E.g. for the following function:

  int foo(int *v) {
    return *v;
  }

the following IR is generated by the trunk compiler with -O2:

  define dso_local i32 @foo(i32* nocapture readonly %v) local_unnamed_addr #0 {
  entry:
    %0 = load i64, i64* getelementptr inbounds ([100 x i64], [100 x i64]* @__msan_param_tls, i64 0, i64 0), align 8
    %1 = load i32, i32* %v, align 4, !tbaa !2
    %2 = ptrtoint i32* %v to i64
    %3 = xor i64 %2, 87960930222080
    %4 = inttoptr i64 %3 to i32*
    %_msld = load i32, i32* %4, align 4
    store i32 %_msld, i32* bitcast ([100 x i64]* @__msan_retval_tls to i32*), align 8
    %_mscmp = icmp eq i64 %0, 0
    br i1 %_mscmp, label %6, label %5, !prof !6
  
  ; <label>:5:                                      ; preds = %entry
    call void @__msan_warning_noreturn() #1
    call void asm sideeffect "", ""() #1
    unreachable
  
  ; <label>:6:                                      ; preds = %entry
    ret i32 %1
  }


https://reviews.llvm.org/D49473





More information about the llvm-commits mailing list