Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 03de2a6

Browse files
committed
[msan] Change va_start/va_copy shadow memset alignment to 8.
This fixes va_start/va_copy of a va_list field which happens to not be laid out at a 16-byte boundary. Differential Revision: http://llvm-reviews.chandlerc.com/D276 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172128 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 893a234 commit 03de2a6

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/Transforms/Instrumentation/MemorySanitizer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,7 +1774,7 @@ struct VarArgAMD64Helper : public VarArgHelper {
17741774
// Unpoison the whole __va_list_tag.
17751775
// FIXME: magic ABI constants.
17761776
IRB.CreateMemSet(ShadowPtr, Constant::getNullValue(IRB.getInt8Ty()),
1777-
/* size */24, /* alignment */16, false);
1777+
/* size */24, /* alignment */8, false);
17781778
}
17791779

17801780
void visitVACopyInst(VACopyInst &I) {
@@ -1785,7 +1785,7 @@ struct VarArgAMD64Helper : public VarArgHelper {
17851785
// Unpoison the whole __va_list_tag.
17861786
// FIXME: magic ABI constants.
17871787
IRB.CreateMemSet(ShadowPtr, Constant::getNullValue(IRB.getInt8Ty()),
1788-
/* size */ 24, /* alignment */ 16, false);
1788+
/* size */24, /* alignment */8, false);
17891789
}
17901790

17911791
void finalizeInstrumentation() {

test/Instrumentation/MemorySanitizer/msan_basic.ll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,3 +534,16 @@ define <8 x i8*> @VectorOfPointers(<8 x i8*>* %p) nounwind uwtable {
534534
; CHECK: load <8 x i8*>*
535535
; CHECK: store <8 x i64> {{.*}} @__msan_retval_tls
536536
; CHECK: ret <8 x i8*>
537+
538+
; Test handling of va_copy.
539+
540+
declare void @llvm.va_copy(i8*, i8*) nounwind
541+
542+
define void @VACopy(i8* %p1, i8* %p2) nounwind uwtable {
543+
call void @llvm.va_copy(i8* %p1, i8* %p2) nounwind
544+
ret void
545+
}
546+
547+
; CHECK: @VACopy
548+
; CHECK: call void @llvm.memset.p0i8.i64({{.*}}, i8 0, i64 24, i32 8, i1 false)
549+
; CHECK: ret void

0 commit comments

Comments
 (0)