llvm.org GIT mirror llvm / e1287f5
[msan] Avoid redundant origin stores. Origin is meaningless for fully initialized values. Avoid storing origin for function arguments that are known to be always initialized (i.e. shadow is a compile-time null constant). This is not about correctness, but purely an optimization. Seems to affect compilation time of blacklisted functions significantly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213239 91177308-0d34-0410-b5e6-96231b3b80d8 Evgeniy Stepanov 6 years ago
2 changed file(s) with 22 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
23122312 Value *ArgShadowBase = getShadowPtrForArgument(A, IRB, ArgOffset);
23132313 DEBUG(dbgs() << " Arg#" << i << ": " << *A <<
23142314 " Shadow: " << *ArgShadow << "\n");
2315 bool ArgIsInitialized = false;
23152316 if (CS.paramHasAttr(i + 1, Attribute::ByVal)) {
23162317 assert(A->getType()->isPointerTy() &&
23172318 "ByVal argument is not a pointer!");
23242325 Size = MS.DL->getTypeAllocSize(A->getType());
23252326 Store = IRB.CreateAlignedStore(ArgShadow, ArgShadowBase,
23262327 kShadowTLSAlignment);
2328 Constant *Cst = dyn_cast(ArgShadow);
2329 if (Cst && Cst->isNullValue()) ArgIsInitialized = true;
23272330 }
2328 if (MS.TrackOrigins)
2331 if (MS.TrackOrigins && !ArgIsInitialized)
23292332 IRB.CreateStore(getOrigin(A),
23302333 getOriginPtrForArgument(A, IRB, ArgOffset));
23312334 (void)Store;
763763 ; CHECK: [[A:%.*]] = phi i32 [ undef, %cond.true ], [ undef, %cond.false ]
764764 ; CHECK: store i32 0, i32* bitcast {{.*}} @__msan_retval_tls
765765 ; CHECK: ret i32 [[A]]
766
767
768 ; Test that there are no __msan_param_origin_tls stores when
769 ; argument shadow is a compile-time zero constant (which is always the case
770 ; in functions missing sanitize_memory attribute).
771
772 define i32 @NoSanitizeMemoryParamTLS(i32* nocapture readonly %x) {
773 entry:
774 %0 = load i32* %x, align 4
775 %call = tail call i32 @NoSanitizeMemoryParamTLSHelper(i32 %0)
776 ret i32 %call
777 }
778
779 declare i32 @NoSanitizeMemoryParamTLSHelper(i32 %x)
780
781 ; CHECK-LABEL: define i32 @NoSanitizeMemoryParamTLS(
782 ; CHECK-NOT: __msan_param_origin_tls
783 ; CHECK: ret i32
766784
767785
768786 ; Test argument shadow alignment