Skip to content

Commit 3415aa5

Browse files
committed
Revert "[msan] Remove unnecacary zero increment"
This reverts commit 4ad58c8.
1 parent 4ad58c8 commit 3415aa5

File tree

14 files changed

+136
-86
lines changed

14 files changed

+136
-86
lines changed

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5685,7 +5685,8 @@ struct VarArgPowerPCHelper : public VarArgHelperBase {
56855685
"finalizeInstrumentation called twice");
56865686
IRBuilder<> IRB(MSV.FnPrologueEnd);
56875687
VAArgSize = IRB.CreateLoad(IRB.getInt64Ty(), MS.VAArgOverflowSizeTLS);
5688-
Value *CopySize = VAArgSize;
5688+
Value *CopySize =
5689+
IRB.CreateAdd(ConstantInt::get(MS.IntptrTy, 0), VAArgSize);
56895690

56905691
if (!VAStartInstrumentationList.empty()) {
56915692
// If there is a va_start in this function, make a backup copy of
@@ -5698,7 +5699,7 @@ struct VarArgPowerPCHelper : public VarArgHelperBase {
56985699

56995700
Value *SrcSize = IRB.CreateBinaryIntrinsic(
57005701
Intrinsic::umin, CopySize,
5701-
ConstantInt::get(IRB.getInt64Ty(), kParamTLSSize));
5702+
ConstantInt::get(MS.IntptrTy, kParamTLSSize));
57025703
IRB.CreateMemCpy(VAArgTLSCopy, kShadowTLSAlignment, MS.VAArgTLS,
57035704
kShadowTLSAlignment, SrcSize);
57045705
}
@@ -6044,7 +6045,8 @@ struct VarArgGenericHelper : public VarArgHelperBase {
60446045
"finalizeInstrumentation called twice");
60456046
IRBuilder<> IRB(MSV.FnPrologueEnd);
60466047
VAArgSize = IRB.CreateLoad(IRB.getInt64Ty(), MS.VAArgOverflowSizeTLS);
6047-
Value *CopySize = VAArgSize;
6048+
Value *CopySize =
6049+
IRB.CreateAdd(ConstantInt::get(MS.IntptrTy, 0), VAArgSize);
60486050

60496051
if (!VAStartInstrumentationList.empty()) {
60506052
// If there is a va_start in this function, make a backup copy of
@@ -6056,7 +6058,7 @@ struct VarArgGenericHelper : public VarArgHelperBase {
60566058

60576059
Value *SrcSize = IRB.CreateBinaryIntrinsic(
60586060
Intrinsic::umin, CopySize,
6059-
ConstantInt::get(IRB.getInt64Ty(), kParamTLSSize));
6061+
ConstantInt::get(MS.IntptrTy, kParamTLSSize));
60606062
IRB.CreateMemCpy(VAArgTLSCopy, kShadowTLSAlignment, MS.VAArgTLS,
60616063
kShadowTLSAlignment, SrcSize);
60626064
}

llvm/test/Instrumentation/MemorySanitizer/ARM32/vararg-arm32.ll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ target triple = "mips64--linux"
77
define i32 @foo(i32 %guard, ...) {
88
; CHECK-LABEL: define i32 @foo(
99
; CHECK-SAME: i32 [[GUARD:%.*]], ...) {
10-
; CHECK-NEXT: [[TMP2:%.*]] = load i64, ptr @__msan_va_arg_overflow_size_tls, align 8
10+
; CHECK-NEXT: [[TMP1:%.*]] = load i64, ptr @__msan_va_arg_overflow_size_tls, align 8
11+
; CHECK-NEXT: [[TMP2:%.*]] = add i64 0, [[TMP1]]
1112
; CHECK-NEXT: [[TMP3:%.*]] = alloca i8, i64 [[TMP2]], align 8
1213
; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 8 [[TMP3]], i8 0, i64 [[TMP2]], i1 false)
1314
; CHECK-NEXT: [[TMP4:%.*]] = call i64 @llvm.umin.i64(i64 [[TMP2]], i64 800)
@@ -57,6 +58,7 @@ declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #1
5758
define i32 @bar() {
5859
; CHECK-LABEL: define i32 @bar() {
5960
; CHECK-NEXT: [[TMP1:%.*]] = load i64, ptr @__msan_va_arg_overflow_size_tls, align 8
61+
; CHECK-NEXT: [[TMP2:%.*]] = add i64 0, [[TMP1]]
6062
; CHECK-NEXT: call void @llvm.donothing()
6163
; CHECK-NEXT: store i32 0, ptr @__msan_param_tls, align 8
6264
; CHECK-NEXT: store i32 0, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__msan_param_tls to i64), i64 8) to ptr), align 8
@@ -85,6 +87,7 @@ declare i32 @foo2(i32 %g1, i32 %g2, ...)
8587
define i32 @bar2() {
8688
; CHECK-LABEL: define i32 @bar2() {
8789
; CHECK-NEXT: [[TMP1:%.*]] = load i64, ptr @__msan_va_arg_overflow_size_tls, align 8
90+
; CHECK-NEXT: [[TMP2:%.*]] = add i64 0, [[TMP1]]
8891
; CHECK-NEXT: call void @llvm.donothing()
8992
; CHECK-NEXT: store i32 0, ptr @__msan_param_tls, align 8
9093
; CHECK-NEXT: store i32 0, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__msan_param_tls to i64), i64 8) to ptr), align 8
@@ -110,6 +113,7 @@ define dso_local i64 @many_args() {
110113
; CHECK-LABEL: define dso_local i64 @many_args() {
111114
; CHECK-NEXT: [[ENTRY:.*:]]
112115
; CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr @__msan_va_arg_overflow_size_tls, align 8
116+
; CHECK-NEXT: [[TMP1:%.*]] = add i64 0, [[TMP0]]
113117
; CHECK-NEXT: call void @llvm.donothing()
114118
; CHECK-NEXT: store i64 0, ptr @__msan_param_tls, align 8
115119
; CHECK-NEXT: store i64 0, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__msan_param_tls to i64), i64 8) to ptr), align 8

llvm/test/Instrumentation/MemorySanitizer/LoongArch/vararg-loongarch64.ll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #1
1111
define i32 @foo(i32 %guard, ...) {
1212
; CHECK-LABEL: @foo
1313
; CHECK: [[TMP1:%.*]] = load {{.*}} @__msan_va_arg_overflow_size_tls
14-
; CHECK: [[TMP3:%.*]] = alloca {{.*}} [[TMP1]]
15-
; CHECK: call void @llvm.memset.p0.i64(ptr align 8 [[TMP3]], i8 0, i64 [[TMP1]], i1 false)
16-
; CHECK: [[TMP4:%.*]] = call i64 @llvm.umin.i64(i64 [[TMP1]], i64 800)
14+
; CHECK: [[TMP2:%.*]] = add i64 0, [[TMP1]]
15+
; CHECK: [[TMP3:%.*]] = alloca {{.*}} [[TMP2]]
16+
; CHECK: call void @llvm.memset.p0.i64(ptr align 8 [[TMP3]], i8 0, i64 [[TMP2]], i1 false)
17+
; CHECK: [[TMP4:%.*]] = call i64 @llvm.umin.i64(i64 [[TMP2]], i64 800)
1718
; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[TMP3]], ptr align 8 @__msan_va_arg_tls, i64 [[TMP4]], i1 false)
1819
;
1920
%vl = alloca ptr, align 8

llvm/test/Instrumentation/MemorySanitizer/LoongArch/vararg.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ define void @VaStart(ptr %s, ...) {
99
; CHECK-LABEL: define void @VaStart(
1010
; CHECK-SAME: ptr [[S:%.*]], ...) {
1111
; CHECK-NEXT: [[ENTRY:.*:]]
12-
; CHECK-NEXT: [[TMP1:%.*]] = load i64, ptr @__msan_va_arg_overflow_size_tls, align 8
12+
; CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr @__msan_va_arg_overflow_size_tls, align 8
13+
; CHECK-NEXT: [[TMP1:%.*]] = add i64 0, [[TMP0]]
1314
; CHECK-NEXT: [[TMP2:%.*]] = alloca i8, i64 [[TMP1]], align 8
1415
; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 8 [[TMP2]], i8 0, i64 [[TMP1]], i1 false)
1516
; CHECK-NEXT: [[TMP3:%.*]] = call i64 @llvm.umin.i64(i64 [[TMP1]], i64 800)

llvm/test/Instrumentation/MemorySanitizer/Mips/vararg-mips64.ll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ define i32 @foo(i32 %guard, ...) {
1616

1717
; CHECK-LABEL: @foo
1818
; CHECK: [[A:%.*]] = load {{.*}} @__msan_va_arg_overflow_size_tls
19-
; CHECK: [[C:%.*]] = alloca {{.*}} [[A]]
19+
; CHECK: [[B:%.*]] = add i64 0, [[A]]
20+
; CHECK: [[C:%.*]] = alloca {{.*}} [[B]]
2021

21-
; CHECK: call void @llvm.memset.p0.i64(ptr align 8 [[C]], i8 0, i64 [[A]], i1 false)
22+
; CHECK: call void @llvm.memset.p0.i64(ptr align 8 [[C]], i8 0, i64 [[B]], i1 false)
2223

23-
; CHECK: [[D:%.*]] = call i64 @llvm.umin.i64(i64 [[A]], i64 800)
24+
; CHECK: [[D:%.*]] = call i64 @llvm.umin.i64(i64 [[B]], i64 800)
2425
; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[C]], ptr align 8 @__msan_va_arg_tls, i64 [[D]], i1 false)
2526

2627
declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #1

llvm/test/Instrumentation/MemorySanitizer/Mips/vararg-mips64el.ll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ define i32 @foo(i32 %guard, ...) {
1616

1717
; CHECK-LABEL: @foo
1818
; CHECK: [[A:%.*]] = load {{.*}} @__msan_va_arg_overflow_size_tls
19-
; CHECK: [[C:%.*]] = alloca {{.*}} [[A]]
19+
; CHECK: [[B:%.*]] = add i64 0, [[A]]
20+
; CHECK: [[C:%.*]] = alloca {{.*}} [[B]]
2021

21-
; CHECK: call void @llvm.memset.p0.i64(ptr align 8 [[C]], i8 0, i64 [[A]], i1 false)
22+
; CHECK: call void @llvm.memset.p0.i64(ptr align 8 [[C]], i8 0, i64 [[B]], i1 false)
2223

23-
; CHECK: [[D:%.*]] = call i64 @llvm.umin.i64(i64 [[A]], i64 800)
24+
; CHECK: [[D:%.*]] = call i64 @llvm.umin.i64(i64 [[B]], i64 800)
2425
; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[C]], ptr align 8 @__msan_va_arg_tls, i64 [[D]], i1 false)
2526

2627
declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #1

llvm/test/Instrumentation/MemorySanitizer/Mips32/vararg-mips.ll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ target triple = "mips64--linux"
77
define i32 @foo(i32 %guard, ...) {
88
; CHECK-LABEL: define i32 @foo(
99
; CHECK-SAME: i32 [[GUARD:%.*]], ...) {
10-
; CHECK-NEXT: [[TMP2:%.*]] = load i64, ptr @__msan_va_arg_overflow_size_tls, align 8
10+
; CHECK-NEXT: [[TMP1:%.*]] = load i64, ptr @__msan_va_arg_overflow_size_tls, align 8
11+
; CHECK-NEXT: [[TMP2:%.*]] = add i64 0, [[TMP1]]
1112
; CHECK-NEXT: [[TMP3:%.*]] = alloca i8, i64 [[TMP2]], align 8
1213
; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 8 [[TMP3]], i8 0, i64 [[TMP2]], i1 false)
1314
; CHECK-NEXT: [[TMP4:%.*]] = call i64 @llvm.umin.i64(i64 [[TMP2]], i64 800)
@@ -57,6 +58,7 @@ declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #1
5758
define i32 @bar() {
5859
; CHECK-LABEL: define i32 @bar() {
5960
; CHECK-NEXT: [[TMP1:%.*]] = load i64, ptr @__msan_va_arg_overflow_size_tls, align 8
61+
; CHECK-NEXT: [[TMP2:%.*]] = add i64 0, [[TMP1]]
6062
; CHECK-NEXT: call void @llvm.donothing()
6163
; CHECK-NEXT: store i32 0, ptr @__msan_param_tls, align 8
6264
; CHECK-NEXT: store i32 0, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__msan_param_tls to i64), i64 8) to ptr), align 8
@@ -85,6 +87,7 @@ declare i32 @foo2(i32 %g1, i32 %g2, ...)
8587
define i32 @bar2() {
8688
; CHECK-LABEL: define i32 @bar2() {
8789
; CHECK-NEXT: [[TMP1:%.*]] = load i64, ptr @__msan_va_arg_overflow_size_tls, align 8
90+
; CHECK-NEXT: [[TMP2:%.*]] = add i64 0, [[TMP1]]
8891
; CHECK-NEXT: call void @llvm.donothing()
8992
; CHECK-NEXT: store i32 0, ptr @__msan_param_tls, align 8
9093
; CHECK-NEXT: store i32 0, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__msan_param_tls to i64), i64 8) to ptr), align 8
@@ -110,6 +113,7 @@ define dso_local i64 @many_args() {
110113
; CHECK-LABEL: define dso_local i64 @many_args() {
111114
; CHECK-NEXT: [[ENTRY:.*:]]
112115
; CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr @__msan_va_arg_overflow_size_tls, align 8
116+
; CHECK-NEXT: [[TMP1:%.*]] = add i64 0, [[TMP0]]
113117
; CHECK-NEXT: call void @llvm.donothing()
114118
; CHECK-NEXT: store i64 0, ptr @__msan_param_tls, align 8
115119
; CHECK-NEXT: store i64 0, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__msan_param_tls to i64), i64 8) to ptr), align 8

llvm/test/Instrumentation/MemorySanitizer/Mips32/vararg-mipsel.ll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ target triple = "mips64el--linux"
77
define i32 @foo(i32 %guard, ...) {
88
; CHECK-LABEL: define i32 @foo(
99
; CHECK-SAME: i32 [[GUARD:%.*]], ...) {
10-
; CHECK-NEXT: [[TMP2:%.*]] = load i64, ptr @__msan_va_arg_overflow_size_tls, align 8
10+
; CHECK-NEXT: [[TMP1:%.*]] = load i64, ptr @__msan_va_arg_overflow_size_tls, align 8
11+
; CHECK-NEXT: [[TMP2:%.*]] = add i64 0, [[TMP1]]
1112
; CHECK-NEXT: [[TMP3:%.*]] = alloca i8, i64 [[TMP2]], align 8
1213
; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 8 [[TMP3]], i8 0, i64 [[TMP2]], i1 false)
1314
; CHECK-NEXT: [[TMP4:%.*]] = call i64 @llvm.umin.i64(i64 [[TMP2]], i64 800)
@@ -57,6 +58,7 @@ declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #1
5758
define i32 @bar() {
5859
; CHECK-LABEL: define i32 @bar() {
5960
; CHECK-NEXT: [[TMP1:%.*]] = load i64, ptr @__msan_va_arg_overflow_size_tls, align 8
61+
; CHECK-NEXT: [[TMP2:%.*]] = add i64 0, [[TMP1]]
6062
; CHECK-NEXT: call void @llvm.donothing()
6163
; CHECK-NEXT: store i32 0, ptr @__msan_param_tls, align 8
6264
; CHECK-NEXT: store i32 0, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__msan_param_tls to i64), i64 8) to ptr), align 8
@@ -84,6 +86,7 @@ declare i32 @foo2(i32 %g1, i32 %g2, ...)
8486
define i32 @bar2() {
8587
; CHECK-LABEL: define i32 @bar2() {
8688
; CHECK-NEXT: [[TMP1:%.*]] = load i64, ptr @__msan_va_arg_overflow_size_tls, align 8
89+
; CHECK-NEXT: [[TMP2:%.*]] = add i64 0, [[TMP1]]
8790
; CHECK-NEXT: call void @llvm.donothing()
8891
; CHECK-NEXT: store i32 0, ptr @__msan_param_tls, align 8
8992
; CHECK-NEXT: store i32 0, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__msan_param_tls to i64), i64 8) to ptr), align 8
@@ -109,6 +112,7 @@ define dso_local i64 @many_args() {
109112
; CHECK-LABEL: define dso_local i64 @many_args() {
110113
; CHECK-NEXT: [[ENTRY:.*:]]
111114
; CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr @__msan_va_arg_overflow_size_tls, align 8
115+
; CHECK-NEXT: [[TMP1:%.*]] = add i64 0, [[TMP0]]
112116
; CHECK-NEXT: call void @llvm.donothing()
113117
; CHECK-NEXT: store i64 0, ptr @__msan_param_tls, align 8
114118
; CHECK-NEXT: store i64 0, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__msan_param_tls to i64), i64 8) to ptr), align 8

llvm/test/Instrumentation/MemorySanitizer/PowerPC/vararg-ppc64.ll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ define i32 @foo(i32 %guard, ...) {
1616

1717
; CHECK-LABEL: @foo
1818
; CHECK: [[A:%.*]] = load {{.*}} @__msan_va_arg_overflow_size_tls
19-
; CHECK: [[C:%.*]] = alloca {{.*}} [[A]]
19+
; CHECK: [[B:%.*]] = add i64 0, [[A]]
20+
; CHECK: [[C:%.*]] = alloca {{.*}} [[B]]
2021

21-
; CHECK: call void @llvm.memset.p0.i64(ptr align 8 [[C]], i8 0, i64 [[A]], i1 false)
22+
; CHECK: call void @llvm.memset.p0.i64(ptr align 8 [[C]], i8 0, i64 [[B]], i1 false)
2223

23-
; CHECK: [[D:%.*]] = call i64 @llvm.umin.i64(i64 [[A]], i64 800)
24+
; CHECK: [[D:%.*]] = call i64 @llvm.umin.i64(i64 [[B]], i64 800)
2425
; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[C]], ptr align 8 @__msan_va_arg_tls, i64 [[D]], i1 false)
2526

2627
declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #1

llvm/test/Instrumentation/MemorySanitizer/PowerPC/vararg-ppc64le.ll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ define i32 @foo(i32 %guard, ...) {
1616

1717
; CHECK-LABEL: @foo
1818
; CHECK: [[A:%.*]] = load {{.*}} @__msan_va_arg_overflow_size_tls
19-
; CHECK: [[C:%.*]] = alloca {{.*}} [[A]]
19+
; CHECK: [[B:%.*]] = add i64 0, [[A]]
20+
; CHECK: [[C:%.*]] = alloca {{.*}} [[B]]
2021

21-
; CHECK: call void @llvm.memset.p0.i64(ptr align 8 [[C]], i8 0, i64 [[A]], i1 false)
22+
; CHECK: call void @llvm.memset.p0.i64(ptr align 8 [[C]], i8 0, i64 [[B]], i1 false)
2223

23-
; CHECK: [[D:%.*]] = call i64 @llvm.umin.i64(i64 [[A]], i64 800)
24+
; CHECK: [[D:%.*]] = call i64 @llvm.umin.i64(i64 [[B]], i64 800)
2425
; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[C]], ptr align 8 @__msan_va_arg_tls, i64 [[D]], i1 false)
2526

2627
declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #1

0 commit comments

Comments
 (0)