@@ -518,13 +518,11 @@ class SrcSafetyAnalysis {
518518public:
519519 std::vector<MCInstReference>
520520 getLastClobberingInsts (const MCInst &Inst, BinaryFunction &BF,
521- std::optional<MCPhysReg> ClobberedReg) const {
522- if (!ClobberedReg || RegsToTrackInstsFor.empty ())
523- return {};
521+ MCPhysReg ClobberedReg) const {
524522 const SrcState &S = getStateBefore (Inst);
525523
526524 std::vector<MCInstReference> Result;
527- for (const MCInst *Inst : lastWritingInsts (S, * ClobberedReg)) {
525+ for (const MCInst *Inst : lastWritingInsts (S, ClobberedReg)) {
528526 MCInstReference Ref = MCInstReference::get (Inst, BF);
529527 assert (Ref && " Expected Inst to be found" );
530528 Result.push_back (Ref);
@@ -868,16 +866,29 @@ void FunctionAnalysis::augmentUnsafeUseReports(
868866 });
869867
870868 // Augment gadget reports.
871- for (auto Report : Reports) {
869+ for (auto & Report : Reports) {
872870 MCInstReference Location = Report.Issue ->Location ;
873871 LLVM_DEBUG ({ traceInst (BC, " Attaching clobbering info to" , Location); });
872+ assert (Report.RequestedDetails &&
873+ " Should be removed by handleSimpleReports" );
874874 auto DetailedInfo =
875875 std::make_shared<ClobberingInfo>(Analysis->getLastClobberingInsts (
876- Location, BF, Report.RequestedDetails ));
876+ Location, BF, * Report.RequestedDetails ));
877877 Result.Diagnostics .emplace_back (Report.Issue , DetailedInfo);
878878 }
879879}
880880
881+ void FunctionAnalysis::handleSimpleReports (
882+ SmallVector<BriefReport<MCPhysReg>> &Reports) {
883+ // Before re-running the detailed analysis, process the reports which do not
884+ // need any additional details to be attached.
885+ for (auto &Report : Reports) {
886+ if (!Report.RequestedDetails )
887+ Result.Diagnostics .emplace_back (Report.Issue , nullptr );
888+ }
889+ llvm::erase_if (Reports, [](const auto &R) { return !R.RequestedDetails ; });
890+ }
891+
881892void FunctionAnalysis::run () {
882893 LLVM_DEBUG ({
883894 dbgs () << " Analyzing function " << BF.getPrintName ()
@@ -887,6 +898,7 @@ void FunctionAnalysis::run() {
887898
888899 SmallVector<BriefReport<MCPhysReg>> UnsafeUses;
889900 findUnsafeUses (UnsafeUses);
901+ handleSimpleReports (UnsafeUses);
890902 if (!UnsafeUses.empty ())
891903 augmentUnsafeUseReports (UnsafeUses);
892904}
0 commit comments