@@ -274,11 +274,12 @@ static cl::opt<bool>
274
274
cl::desc (" propagate shadow through ICmpEQ and ICmpNE" ),
275
275
cl::Hidden, cl::init(true ));
276
276
277
- static cl::opt<uint> ClPrintFaultingInst (
278
- " msan-print -faulting-instruction" ,
279
- cl::desc (" If set to 1, print the name of the LLVM IR instruction that "
277
+ static cl::opt<uint> ClEmbedFaultingInst (
278
+ " msan-embed -faulting-instruction" ,
279
+ cl::desc (" If set to 1, embed the name of the LLVM IR instruction that "
280
280
" failed the shadow check."
281
- " If set to 2, print the full LLVM IR instruction." ),
281
+ " If set to 2, embed the full LLVM IR instruction. "
282
+ " The runtime can print the embedded instruction." ),
282
283
cl::Hidden, cl::init(0 ));
283
284
284
285
static cl::opt<bool >
@@ -823,7 +824,7 @@ void MemorySanitizer::createKernelApi(Module &M, const TargetLibraryInfo &TLI) {
823
824
VAArgOriginTLS = nullptr ;
824
825
VAArgOverflowSizeTLS = nullptr ;
825
826
826
- if (ClPrintFaultingInst )
827
+ if (ClEmbedFaultingInst )
827
828
WarningFn = M.getOrInsertFunction (
828
829
" __msan_warning_instname" , TLI.getAttrList (C, {0 }, /* Signed=*/ false ),
829
830
IRB.getVoidTy (), IRB.getInt32Ty (), IRB.getPtrTy ());
@@ -888,7 +889,7 @@ void MemorySanitizer::createUserspaceApi(Module &M,
888
889
// FIXME: this function should have "Cold" calling conv,
889
890
// which is not yet implemented.
890
891
if (TrackOrigins) {
891
- if (ClPrintFaultingInst ) {
892
+ if (ClEmbedFaultingInst ) {
892
893
StringRef WarningFnName =
893
894
Recover ? " __msan_warning_with_origin_instname"
894
895
: " __msan_warning_with_origin_noreturn_instname" ;
@@ -903,7 +904,7 @@ void MemorySanitizer::createUserspaceApi(Module &M,
903
904
IRB.getVoidTy (), IRB.getInt32Ty ());
904
905
}
905
906
} else {
906
- if (ClPrintFaultingInst ) {
907
+ if (ClEmbedFaultingInst ) {
907
908
StringRef WarningFnName = Recover ? " __msan_warning_instname"
908
909
: " __msan_warning_noreturn_instname" ;
909
910
WarningFn =
@@ -945,7 +946,7 @@ void MemorySanitizer::createUserspaceApi(Module &M,
945
946
AccessSizeIndex++) {
946
947
unsigned AccessSize = 1 << AccessSizeIndex;
947
948
std::string FunctionName;
948
- if (ClPrintFaultingInst ) {
949
+ if (ClEmbedFaultingInst ) {
949
950
FunctionName = " __msan_maybe_warning_instname_" + itostr (AccessSize);
950
951
MaybeWarningFn[AccessSizeIndex] = M.getOrInsertFunction (
951
952
FunctionName, TLI.getAttrList (C, {0 , 1 }, /* Signed=*/ false ),
@@ -1449,7 +1450,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
1449
1450
}
1450
1451
}
1451
1452
1452
- if (ClPrintFaultingInst ) {
1453
+ if (ClEmbedFaultingInst ) {
1453
1454
if (MS.CompileKernel || MS.TrackOrigins )
1454
1455
IRB.CreateCall (MS.WarningFn , {Origin, InstName})->setCannotMerge ();
1455
1456
else
@@ -1478,7 +1479,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
1478
1479
Value *ConvertedShadow2 =
1479
1480
IRB.CreateZExt (ConvertedShadow, IRB.getIntNTy (8 * (1 << SizeIndex)));
1480
1481
CallBase *CB;
1481
- if (ClPrintFaultingInst )
1482
+ if (ClEmbedFaultingInst )
1482
1483
CB = IRB.CreateCall (
1483
1484
Fn, {ConvertedShadow2,
1484
1485
MS.TrackOrigins && Origin ? Origin : (Value *)IRB.getInt32 (0 ),
@@ -1498,7 +1499,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
1498
1499
/* Unreachable */ !MS.Recover , MS.ColdCallWeights );
1499
1500
1500
1501
IRB.SetInsertPoint (CheckTerm);
1501
- // InstName will be ignored by insertWarningFn if ClPrintFaultingInst is
1502
+ // InstName will be ignored by insertWarningFn if ClEmbedFaultingInst is
1502
1503
// false
1503
1504
insertWarningFn (IRB, Origin, InstName);
1504
1505
LLVM_DEBUG (dbgs () << " CHECK: " << *Cmp << " \n " );
@@ -1514,19 +1515,19 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
1514
1515
Instruction *Instruction = InstructionChecks.front ().OrigIns ;
1515
1516
1516
1517
Value *InstName = nullptr ;
1517
- if (ClPrintFaultingInst >= 1 ) {
1518
+ if (ClEmbedFaultingInst >= 1 ) {
1518
1519
IRBuilder<> IRB0 (Instruction);
1519
1520
std::string str;
1520
1521
StringRef InstNameStrRef;
1521
1522
1522
1523
// Dumping the full instruction is expensive because the operands etc.
1523
1524
// likely make the string unique per instruction instance, hence we
1524
1525
// offer a choice whether to only print the instruction name.
1525
- if (ClPrintFaultingInst >= 2 ) {
1526
+ if (ClEmbedFaultingInst >= 2 ) {
1526
1527
llvm::raw_string_ostream buf (str);
1527
1528
Instruction->print (buf);
1528
1529
InstNameStrRef = StringRef (str);
1529
- } else if (ClPrintFaultingInst >= 1 ) {
1530
+ } else if (ClEmbedFaultingInst >= 1 ) {
1530
1531
if (CallInst *CI = dyn_cast<CallInst>(Instruction)) {
1531
1532
if (CI->getCalledFunction ()) {
1532
1533
Twine description = " call " + CI->getCalledFunction ()->getName ();
0 commit comments