diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -1178,9 +1178,11 @@ 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->addAttribute(AttributeList::FirstArgIndex, Attribute::ZExt); + CB->addAttribute(AttributeList::FirstArgIndex + 2, Attribute::ZExt); } else { Value *Cmp = convertToBool(ConvertedShadow, IRB, "_mscmp"); Instruction *CheckTerm = SplitBlockAndInsertIfThen( @@ -1250,9 +1252,11 @@ 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->addAttribute(AttributeList::FirstArgIndex, Attribute::ZExt); + CB->addAttribute(AttributeList::FirstArgIndex + 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 --- a/llvm/test/Instrumentation/MemorySanitizer/instrumentation-with-call-threshold.ll +++ b/llvm/test/Instrumentation/MemorySanitizer/instrumentation-with-call-threshold.ll @@ -40,7 +40,7 @@ ; 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 @@ ; 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 --- a/llvm/test/Instrumentation/MemorySanitizer/with-call-type-size.ll +++ b/llvm/test/Instrumentation/MemorySanitizer/with-call-type-size.ll @@ -11,7 +11,7 @@ } ; 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 @@ } ; 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 @@ } ; 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 @@ } ; 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 @@ 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 @@ } ; 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 @@ } ; 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 @@ 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.