[llvm] b86302e - [MSan] Set zeroext on call arguments to msan functions with zeroext parameter attribute
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Tue May 18 14:08:18 PDT 2021
Author: Arthur Eubanks
Date: 2021-05-18T14:07:39-07:00
New Revision: b86302e500791481da5f446c700a63693b355024
URL: https://github.com/llvm/llvm-project/commit/b86302e500791481da5f446c700a63693b355024
DIFF: https://github.com/llvm/llvm-project/commit/b86302e500791481da5f446c700a63693b355024.diff
LOG: [MSan] Set zeroext on call arguments to msan functions with zeroext parameter attribute
ABI attributes need to match between the caller and callee.
Reviewed By: rnk
Differential Revision: https://reviews.llvm.org/D102667
Added:
Modified:
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
llvm/test/Instrumentation/MemorySanitizer/instrumentation-with-call-threshold.ll
llvm/test/Instrumentation/MemorySanitizer/with-call-type-size.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index 3e4fae586aae..fb779e8c5559 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -1178,9 +1178,11 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
FunctionCallee Fn = MS.MaybeStoreOriginFn[SizeIndex];
Value *ConvertedShadow2 =
IRB.CreateZExt(ConvertedShadow, IRB.getIntNTy(8 * (1 << SizeIndex)));
- IRB.CreateCall(Fn,
- {ConvertedShadow2,
- IRB.CreatePointerCast(Addr, IRB.getInt8PtrTy()), Origin});
+ CallBase *CB = IRB.CreateCall(
+ Fn, {ConvertedShadow2,
+ IRB.CreatePointerCast(Addr, IRB.getInt8PtrTy()), Origin});
+ CB->addParamAttr(0, Attribute::ZExt);
+ CB->addParamAttr(2, Attribute::ZExt);
} else {
Value *Cmp = convertToBool(ConvertedShadow, IRB, "_mscmp");
Instruction *CheckTerm = SplitBlockAndInsertIfThen(
@@ -1250,9 +1252,11 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
FunctionCallee Fn = MS.MaybeWarningFn[SizeIndex];
Value *ConvertedShadow2 =
IRB.CreateZExt(ConvertedShadow, IRB.getIntNTy(8 * (1 << SizeIndex)));
- IRB.CreateCall(Fn, {ConvertedShadow2, MS.TrackOrigins && Origin
- ? Origin
- : (Value *)IRB.getInt32(0)});
+ CallBase *CB = IRB.CreateCall(
+ Fn, {ConvertedShadow2,
+ MS.TrackOrigins && Origin ? Origin : (Value *)IRB.getInt32(0)});
+ CB->addParamAttr(0, Attribute::ZExt);
+ CB->addParamAttr(1, Attribute::ZExt);
} else {
Value *Cmp = convertToBool(ConvertedShadow, IRB, "_mscmp");
Instruction *CheckTerm = SplitBlockAndInsertIfThen(
diff --git a/llvm/test/Instrumentation/MemorySanitizer/instrumentation-with-call-threshold.ll b/llvm/test/Instrumentation/MemorySanitizer/instrumentation-with-call-threshold.ll
index 424a5e05ffef..b66a3a2fef6c 100644
--- a/llvm/test/Instrumentation/MemorySanitizer/instrumentation-with-call-threshold.ll
+++ b/llvm/test/Instrumentation/MemorySanitizer/instrumentation-with-call-threshold.ll
@@ -40,7 +40,7 @@ declare void @foo(...)
; CHECK: = load
; CHECK: = load
; CHECK: = zext i1 {{.*}} to i8
-; CHECK: call void @__msan_maybe_warning_1(
+; CHECK: call void @__msan_maybe_warning_1(i8 zeroext {{.*}}, i32 zeroext {{.*}})
; CHECK-NOT: unreachable
; CHECK: ret void
@@ -58,7 +58,7 @@ entry:
; CHECK-ORIGINS-NOT: __msan_chain_origin
; CHECK-ORIGINS: bitcast i64* {{.*}} to i8*
; CHECK-ORIGINS-NOT: __msan_chain_origin
-; CHECK-ORIGINS: call void @__msan_maybe_store_origin_8(
+; CHECK-ORIGINS: call void @__msan_maybe_store_origin_8(i64 zeroext {{.*}}, i8* {{.*}}, i32 zeroext {{.*}})
; CHECK-ORIGINS-NOT: __msan_chain_origin
; CHECK: store i64
; CHECK: ret void
diff --git a/llvm/test/Instrumentation/MemorySanitizer/with-call-type-size.ll b/llvm/test/Instrumentation/MemorySanitizer/with-call-type-size.ll
index da5e75b9d2bf..03fd03ef009b 100644
--- a/llvm/test/Instrumentation/MemorySanitizer/with-call-type-size.ll
+++ b/llvm/test/Instrumentation/MemorySanitizer/with-call-type-size.ll
@@ -11,7 +11,7 @@ define <4 x i32> @test1(<4 x i32> %vec, i1 %idx, i32 %x) sanitize_memory {
}
; CHECK-LABEL: @test1(
; CHECK: %[[A:.*]] = zext i1 {{.*}} to i8
-; CHECK: call void @__msan_maybe_warning_1(i8 %[[A]], i32 0)
+; CHECK: call void @__msan_maybe_warning_1(i8 zeroext %[[A]], i32 zeroext 0)
; CHECK: ret <4 x i32>
define <4 x i32> @test2(<4 x i32> %vec, i2 %idx, i32 %x) sanitize_memory {
@@ -20,7 +20,7 @@ define <4 x i32> @test2(<4 x i32> %vec, i2 %idx, i32 %x) sanitize_memory {
}
; CHECK-LABEL: @test2(
; CHECK: %[[A:.*]] = zext i2 {{.*}} to i8
-; CHECK: call void @__msan_maybe_warning_1(i8 %[[A]], i32 0)
+; CHECK: call void @__msan_maybe_warning_1(i8 zeroext %[[A]], i32 zeroext 0)
; CHECK: ret <4 x i32>
define <4 x i32> @test8(<4 x i32> %vec, i8 %idx, i32 %x) sanitize_memory {
@@ -29,7 +29,7 @@ define <4 x i32> @test8(<4 x i32> %vec, i8 %idx, i32 %x) sanitize_memory {
}
; CHECK-LABEL: @test8(
; zext i8 -> i8 unnecessary.
-; CHECK: call void @__msan_maybe_warning_1(i8 %{{.*}}, i32 0)
+; CHECK: call void @__msan_maybe_warning_1(i8 zeroext %{{.*}}, i32 zeroext 0)
; CHECK: ret <4 x i32>
define <4 x i32> @test9(<4 x i32> %vec, i9 %idx, i32 %x) sanitize_memory {
@@ -38,7 +38,7 @@ define <4 x i32> @test9(<4 x i32> %vec, i9 %idx, i32 %x) sanitize_memory {
}
; CHECK-LABEL: @test9(
; CHECK: %[[A:.*]] = zext i9 {{.*}} to i16
-; CHECK: call void @__msan_maybe_warning_2(i16 %[[A]], i32 0)
+; CHECK: call void @__msan_maybe_warning_2(i16 zeroext %[[A]], i32 zeroext 0)
; CHECK: ret <4 x i32>
define <4 x i32> @test16(<4 x i32> %vec, i16 %idx, i32 %x) sanitize_memory {
@@ -46,7 +46,7 @@ define <4 x i32> @test16(<4 x i32> %vec, i16 %idx, i32 %x) sanitize_memory {
ret <4 x i32> %vec1
}
; CHECK-LABEL: @test16(
-; CHECK: call void @__msan_maybe_warning_2(i16 %{{.*}}, i32 0)
+; CHECK: call void @__msan_maybe_warning_2(i16 zeroext %{{.*}}, i32 zeroext 0)
; CHECK: ret <4 x i32>
define <4 x i32> @test17(<4 x i32> %vec, i17 %idx, i32 %x) sanitize_memory {
@@ -55,7 +55,7 @@ define <4 x i32> @test17(<4 x i32> %vec, i17 %idx, i32 %x) sanitize_memory {
}
; CHECK-LABEL: @test17(
; CHECK: %[[A:.*]] = zext i17 {{.*}} to i32
-; CHECK: call void @__msan_maybe_warning_4(i32 %[[A]], i32 0)
+; CHECK: call void @__msan_maybe_warning_4(i32 zeroext %[[A]], i32 zeroext 0)
; CHECK: ret <4 x i32>
define <4 x i32> @test42(<4 x i32> %vec, i42 %idx, i32 %x) sanitize_memory {
@@ -64,7 +64,7 @@ define <4 x i32> @test42(<4 x i32> %vec, i42 %idx, i32 %x) sanitize_memory {
}
; CHECK-LABEL: @test42(
; CHECK: %[[A:.*]] = zext i42 {{.*}} to i64
-; CHECK: call void @__msan_maybe_warning_8(i64 %[[A]], i32 0)
+; CHECK: call void @__msan_maybe_warning_8(i64 zeroext %[[A]], i32 zeroext 0)
; CHECK: ret <4 x i32>
define <4 x i32> @test64(<4 x i32> %vec, i64 %idx, i32 %x) sanitize_memory {
@@ -72,7 +72,7 @@ define <4 x i32> @test64(<4 x i32> %vec, i64 %idx, i32 %x) sanitize_memory {
ret <4 x i32> %vec1
}
; CHECK-LABEL: @test64(
-; CHECK: call void @__msan_maybe_warning_8(i64 %{{.*}}, i32 0)
+; CHECK: call void @__msan_maybe_warning_8(i64 zeroext %{{.*}}, i32 zeroext 0)
; CHECK: ret <4 x i32>
; Type size too large => inline check.
More information about the llvm-commits
mailing list