@@ -713,21 +713,23 @@ SrcSafetyAnalysis::create(BinaryFunction &BF,
713713 RegsToTrackInstsFor);
714714}
715715
716- static BriefReport<MCPhysReg> make_generic_report (MCInstReference Location,
717- StringRef Text) {
716+ // This function could return PartialReport<T>, but currently T is always
717+ // MCPhysReg, even though it is an implementation detail.
718+ static PartialReport<MCPhysReg> make_generic_report (MCInstReference Location,
719+ StringRef Text) {
718720 auto Report = std::make_shared<GenericDiagnostic>(Location, Text);
719- return BriefReport <MCPhysReg>(Report, std::nullopt );
721+ return PartialReport <MCPhysReg>(Report, std::nullopt );
720722}
721723
722724template <typename T>
723- static BriefReport <T> make_report (const GadgetKind &Kind,
724- MCInstReference Location,
725- T RequestedDetails) {
725+ static PartialReport <T> make_gadget_report (const GadgetKind &Kind,
726+ MCInstReference Location,
727+ T RequestedDetails) {
726728 auto Report = std::make_shared<GadgetDiagnostic>(Kind, Location);
727- return BriefReport <T>(Report, RequestedDetails);
729+ return PartialReport <T>(Report, RequestedDetails);
728730}
729731
730- static std::optional<BriefReport <MCPhysReg>>
732+ static std::optional<PartialReport <MCPhysReg>>
731733shouldReportReturnGadget (const BinaryContext &BC, const MCInstReference &Inst,
732734 const SrcState &S) {
733735 static const GadgetKind RetKind (" non-protected ret found" );
@@ -752,10 +754,10 @@ shouldReportReturnGadget(const BinaryContext &BC, const MCInstReference &Inst,
752754 if (S.SafeToDerefRegs [RetReg])
753755 return std::nullopt ;
754756
755- return make_report (RetKind, Inst, RetReg);
757+ return make_gadget_report (RetKind, Inst, RetReg);
756758}
757759
758- static std::optional<BriefReport <MCPhysReg>>
760+ static std::optional<PartialReport <MCPhysReg>>
759761shouldReportCallGadget (const BinaryContext &BC, const MCInstReference &Inst,
760762 const SrcState &S) {
761763 static const GadgetKind CallKind (" non-protected call found" );
@@ -777,10 +779,10 @@ shouldReportCallGadget(const BinaryContext &BC, const MCInstReference &Inst,
777779 if (S.SafeToDerefRegs [DestReg])
778780 return std::nullopt ;
779781
780- return make_report (CallKind, Inst, DestReg);
782+ return make_gadget_report (CallKind, Inst, DestReg);
781783}
782784
783- static std::optional<BriefReport <MCPhysReg>>
785+ static std::optional<PartialReport <MCPhysReg>>
784786shouldReportSigningOracle (const BinaryContext &BC, const MCInstReference &Inst,
785787 const SrcState &S) {
786788 static const GadgetKind SigningOracleKind (" signing oracle found" );
@@ -797,7 +799,7 @@ shouldReportSigningOracle(const BinaryContext &BC, const MCInstReference &Inst,
797799 if (S.TrustedRegs [SignedReg])
798800 return std::nullopt ;
799801
800- return make_report (SigningOracleKind, Inst, SignedReg);
802+ return make_gadget_report (SigningOracleKind, Inst, SignedReg);
801803}
802804
803805template <typename T> static void iterateOverInstrs (BinaryFunction &BF, T Fn) {
@@ -812,7 +814,7 @@ template <typename T> static void iterateOverInstrs(BinaryFunction &BF, T Fn) {
812814}
813815
814816static SmallVector<MCPhysReg>
815- collectRegsToTrack (ArrayRef<BriefReport <MCPhysReg>> Reports) {
817+ collectRegsToTrack (ArrayRef<PartialReport <MCPhysReg>> Reports) {
816818 SmallSet<MCPhysReg, 4 > RegsToTrack;
817819 for (auto Report : Reports)
818820 if (Report.RequestedDetails )
@@ -822,7 +824,7 @@ collectRegsToTrack(ArrayRef<BriefReport<MCPhysReg>> Reports) {
822824}
823825
824826void FunctionAnalysisContext::findUnsafeUses (
825- SmallVector<BriefReport <MCPhysReg>> &Reports) {
827+ SmallVector<PartialReport <MCPhysReg>> &Reports) {
826828 auto Analysis = SrcSafetyAnalysis::create (BF, AllocatorId, {});
827829 LLVM_DEBUG ({ dbgs () << " Running src register safety analysis...\n " ; });
828830 Analysis->run ();
@@ -856,7 +858,7 @@ void FunctionAnalysisContext::findUnsafeUses(
856858}
857859
858860void FunctionAnalysisContext::augmentUnsafeUseReports (
859- ArrayRef<BriefReport <MCPhysReg>> Reports) {
861+ ArrayRef<PartialReport <MCPhysReg>> Reports) {
860862 SmallVector<MCPhysReg> RegsToTrack = collectRegsToTrack (Reports);
861863 // Re-compute the analysis with register tracking.
862864 auto Analysis = SrcSafetyAnalysis::create (BF, AllocatorId, RegsToTrack);
@@ -882,7 +884,7 @@ void FunctionAnalysisContext::augmentUnsafeUseReports(
882884}
883885
884886void FunctionAnalysisContext::handleSimpleReports (
885- SmallVector<BriefReport <MCPhysReg>> &Reports) {
887+ SmallVector<PartialReport <MCPhysReg>> &Reports) {
886888 // Before re-running the detailed analysis, process the reports which do not
887889 // need any additional details to be attached.
888890 for (auto &Report : Reports) {
@@ -899,7 +901,7 @@ void FunctionAnalysisContext::run() {
899901 BF.dump ();
900902 });
901903
902- SmallVector<BriefReport <MCPhysReg>> UnsafeUses;
904+ SmallVector<PartialReport <MCPhysReg>> UnsafeUses;
903905 findUnsafeUses (UnsafeUses);
904906 handleSimpleReports (UnsafeUses);
905907 if (!UnsafeUses.empty ())
0 commit comments