[PATCH] D19997: [MSan] [X86] Fix vararg helper for fixed arguments in overflow area.

Marcin Koƛcielnicki via llvm-commits llvm-commits at lists.llvm.org
Fri May 6 12:43:04 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL268783: [MSan] [X86] Fix vararg helper for fixed arguments in overflow area. (authored by koriakin).

Changed prior to commit:
  http://reviews.llvm.org/D19997?vs=56354&id=56449#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19997

Files:
  llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/trunk/test/Instrumentation/MemorySanitizer/msan_basic.ll

Index: llvm/trunk/test/Instrumentation/MemorySanitizer/msan_basic.ll
===================================================================
--- llvm/trunk/test/Instrumentation/MemorySanitizer/msan_basic.ll
+++ llvm/trunk/test/Instrumentation/MemorySanitizer/msan_basic.ll
@@ -914,8 +914,7 @@
 ; the third struct goes to the overflow area byval
 
 ; CHECK-LABEL: @VAArgStruct
-; undef
-; CHECK: store i32 -1, i32* {{.*}}@__msan_va_arg_tls {{.*}}, align 8
+; undef not stored to __msan_va_arg_tls - it's a fixed argument
 ; first struct through general purpose registers
 ; CHECK: store i64 {{.*}}, i64* {{.*}}@__msan_va_arg_tls{{.*}}, i64 8){{.*}}, align 8
 ; CHECK: store i64 {{.*}}, i64* {{.*}}@__msan_va_arg_tls{{.*}}, i64 16){{.*}}, align 8
Index: llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -2891,9 +2891,14 @@
          ArgIt != End; ++ArgIt) {
       Value *A = *ArgIt;
       unsigned ArgNo = CS.getArgumentNo(ArgIt);
+      bool IsFixed = ArgNo < CS.getFunctionType()->getNumParams();
       bool IsByVal = CS.paramHasAttr(ArgNo + 1, Attribute::ByVal);
       if (IsByVal) {
         // ByVal arguments always go to the overflow area.
+        // Fixed arguments passed through the overflow area will be stepped
+        // over by va_start, so don't count them towards the offset.
+        if (IsFixed)
+          continue;
         assert(A->getType()->isPointerTy());
         Type *RealTy = A->getType()->getPointerElementType();
         uint64_t ArgSize = DL.getTypeAllocSize(RealTy);
@@ -2918,10 +2923,16 @@
             FpOffset += 16;
             break;
           case AK_Memory:
+            if (IsFixed)
+              continue;
             uint64_t ArgSize = DL.getTypeAllocSize(A->getType());
             Base = getShadowPtrForVAArgument(A->getType(), IRB, OverflowOffset);
             OverflowOffset += alignTo(ArgSize, 8);
         }
+        // Take fixed arguments into account for GpOffset and FpOffset,
+        // but don't actually store shadows for them.
+        if (IsFixed)
+          continue;
         IRB.CreateAlignedStore(MSV.getShadow(A), Base, kShadowTLSAlignment);
       }
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19997.56449.patch
Type: text/x-patch
Size: 2345 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160506/c739032b/attachment-0001.bin>


More information about the llvm-commits mailing list