@@ -947,19 +947,16 @@ void MemorySanitizer::createUserspaceApi(Module &M,
947
947
for (size_t AccessSizeIndex = 0 ; AccessSizeIndex < kNumberOfAccessSizes ;
948
948
AccessSizeIndex++) {
949
949
unsigned AccessSize = 1 << AccessSizeIndex;
950
- std::string FunctionName;
950
+ std::string FunctionName = " __msan_maybe_warning_" + itostr (AccessSize);
951
+ SmallVector<Type *, 4 > ArgsTy = {IRB.getIntNTy (AccessSize * 8 ),
952
+ IRB.getInt32Ty ()};
951
953
if (ClEmbedFaultingInst != MSanEmbedFaultingInstructionMode::None) {
952
954
FunctionName = " __msan_maybe_warning_instname_" + itostr (AccessSize);
953
- MaybeWarningFn[AccessSizeIndex] = M.getOrInsertFunction (
954
- FunctionName, TLI.getAttrList (C, {0 , 1 }, /* Signed=*/ false ),
955
- IRB.getVoidTy (), IRB.getIntNTy (AccessSize * 8 ), IRB.getInt32Ty (),
956
- IRB.getPtrTy ());
957
- } else {
958
- FunctionName = " __msan_maybe_warning_" + itostr (AccessSize);
959
- MaybeWarningFn[AccessSizeIndex] = M.getOrInsertFunction (
960
- FunctionName, TLI.getAttrList (C, {0 , 1 }, /* Signed=*/ false ),
961
- IRB.getVoidTy (), IRB.getIntNTy (AccessSize * 8 ), IRB.getInt32Ty ());
955
+ ArgsTy.push_back (IRB.getPtrTy ());
962
956
}
957
+ MaybeWarningFn[AccessSizeIndex] = M.getOrInsertFunction (
958
+ FunctionName, FunctionType::get (IRB.getVoidTy (), ArgsTy, false ),
959
+ TLI.getAttrList (C, {0 , 1 }, /* Signed=*/ false ));
963
960
964
961
FunctionName = " __msan_maybe_store_origin_" + itostr (AccessSize);
965
962
MaybeStoreOriginFn[AccessSizeIndex] = M.getOrInsertFunction (
@@ -1452,17 +1449,13 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
1452
1449
}
1453
1450
}
1454
1451
1455
- if (ClEmbedFaultingInst != MSanEmbedFaultingInstructionMode::None) {
1456
- if (MS.CompileKernel || MS.TrackOrigins )
1457
- IRB.CreateCall (MS.WarningFn , {Origin, InstName})->setCannotMerge ();
1458
- else
1459
- IRB.CreateCall (MS.WarningFn , {InstName})->setCannotMerge ();
1460
- } else {
1461
- if (MS.CompileKernel || MS.TrackOrigins )
1462
- IRB.CreateCall (MS.WarningFn , Origin)->setCannotMerge ();
1463
- else
1464
- IRB.CreateCall (MS.WarningFn )->setCannotMerge ();
1465
- }
1452
+ SmallVector<Value *, 4 > Args;
1453
+ if (MS.CompileKernel || MS.TrackOrigins )
1454
+ Args.push_back (Origin);
1455
+ if (ClEmbedFaultingInst != MSanEmbedFaultingInstructionMode::None)
1456
+ Args.push_back (InstName);
1457
+ IRB.CreateCall (MS.WarningFn , Args)->setCannotMerge ();
1458
+
1466
1459
// FIXME: Insert UnreachableInst if !MS.Recover?
1467
1460
// This may invalidate some of the following checks and needs to be done
1468
1461
// at the very end.
@@ -1480,17 +1473,14 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
1480
1473
ConvertedShadow = convertShadowToScalar (ConvertedShadow, IRB);
1481
1474
Value *ConvertedShadow2 =
1482
1475
IRB.CreateZExt (ConvertedShadow, IRB.getIntNTy (8 * (1 << SizeIndex)));
1483
- CallBase *CB;
1476
+
1477
+ SmallVector<Value *, 4 > Args = {
1478
+ ConvertedShadow2,
1479
+ MS.TrackOrigins && Origin ? Origin : (Value *)IRB.getInt32 (0 )};
1484
1480
if (ClEmbedFaultingInst != MSanEmbedFaultingInstructionMode::None)
1485
- CB = IRB.CreateCall (
1486
- Fn, {ConvertedShadow2,
1487
- MS.TrackOrigins && Origin ? Origin : (Value *)IRB.getInt32 (0 ),
1488
- InstName});
1489
- else
1490
- CB = IRB.CreateCall (Fn,
1491
- {ConvertedShadow2, MS.TrackOrigins && Origin
1492
- ? Origin
1493
- : (Value *)IRB.getInt32 (0 )});
1481
+ Args.push_back (InstName);
1482
+
1483
+ CallBase *CB = IRB.CreateCall (Fn, Args);
1494
1484
1495
1485
CB->addParamAttr (0 , Attribute::ZExt);
1496
1486
CB->addParamAttr (1 , Attribute::ZExt);
0 commit comments