@@ -713,21 +713,23 @@ SrcSafetyAnalysis::create(BinaryFunction &BF,
713
713
RegsToTrackInstsFor);
714
714
}
715
715
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) {
718
720
auto Report = std::make_shared<GenericDiagnostic>(Location, Text);
719
- return BriefReport <MCPhysReg>(Report, std::nullopt);
721
+ return PartialReport <MCPhysReg>(Report, std::nullopt);
720
722
}
721
723
722
724
template <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) {
726
728
auto Report = std::make_shared<GadgetDiagnostic>(Kind, Location);
727
- return BriefReport <T>(Report, RequestedDetails);
729
+ return PartialReport <T>(Report, RequestedDetails);
728
730
}
729
731
730
- static std::optional<BriefReport <MCPhysReg>>
732
+ static std::optional<PartialReport <MCPhysReg>>
731
733
shouldReportReturnGadget (const BinaryContext &BC, const MCInstReference &Inst,
732
734
const SrcState &S) {
733
735
static const GadgetKind RetKind (" non-protected ret found" );
@@ -752,10 +754,10 @@ shouldReportReturnGadget(const BinaryContext &BC, const MCInstReference &Inst,
752
754
if (S.SafeToDerefRegs [RetReg])
753
755
return std::nullopt;
754
756
755
- return make_report (RetKind, Inst, RetReg);
757
+ return make_gadget_report (RetKind, Inst, RetReg);
756
758
}
757
759
758
- static std::optional<BriefReport <MCPhysReg>>
760
+ static std::optional<PartialReport <MCPhysReg>>
759
761
shouldReportCallGadget (const BinaryContext &BC, const MCInstReference &Inst,
760
762
const SrcState &S) {
761
763
static const GadgetKind CallKind (" non-protected call found" );
@@ -777,10 +779,10 @@ shouldReportCallGadget(const BinaryContext &BC, const MCInstReference &Inst,
777
779
if (S.SafeToDerefRegs [DestReg])
778
780
return std::nullopt;
779
781
780
- return make_report (CallKind, Inst, DestReg);
782
+ return make_gadget_report (CallKind, Inst, DestReg);
781
783
}
782
784
783
- static std::optional<BriefReport <MCPhysReg>>
785
+ static std::optional<PartialReport <MCPhysReg>>
784
786
shouldReportSigningOracle (const BinaryContext &BC, const MCInstReference &Inst,
785
787
const SrcState &S) {
786
788
static const GadgetKind SigningOracleKind (" signing oracle found" );
@@ -797,7 +799,7 @@ shouldReportSigningOracle(const BinaryContext &BC, const MCInstReference &Inst,
797
799
if (S.TrustedRegs [SignedReg])
798
800
return std::nullopt;
799
801
800
- return make_report (SigningOracleKind, Inst, SignedReg);
802
+ return make_gadget_report (SigningOracleKind, Inst, SignedReg);
801
803
}
802
804
803
805
template <typename T> static void iterateOverInstrs (BinaryFunction &BF, T Fn) {
@@ -812,7 +814,7 @@ template <typename T> static void iterateOverInstrs(BinaryFunction &BF, T Fn) {
812
814
}
813
815
814
816
static SmallVector<MCPhysReg>
815
- collectRegsToTrack (ArrayRef<BriefReport <MCPhysReg>> Reports) {
817
+ collectRegsToTrack (ArrayRef<PartialReport <MCPhysReg>> Reports) {
816
818
SmallSet<MCPhysReg, 4 > RegsToTrack;
817
819
for (auto Report : Reports)
818
820
if (Report.RequestedDetails )
@@ -822,7 +824,7 @@ collectRegsToTrack(ArrayRef<BriefReport<MCPhysReg>> Reports) {
822
824
}
823
825
824
826
void FunctionAnalysisContext::findUnsafeUses (
825
- SmallVector<BriefReport <MCPhysReg>> &Reports) {
827
+ SmallVector<PartialReport <MCPhysReg>> &Reports) {
826
828
auto Analysis = SrcSafetyAnalysis::create (BF, AllocatorId, {});
827
829
LLVM_DEBUG ({ dbgs () << " Running src register safety analysis...\n " ; });
828
830
Analysis->run ();
@@ -856,7 +858,7 @@ void FunctionAnalysisContext::findUnsafeUses(
856
858
}
857
859
858
860
void FunctionAnalysisContext::augmentUnsafeUseReports (
859
- ArrayRef<BriefReport <MCPhysReg>> Reports) {
861
+ ArrayRef<PartialReport <MCPhysReg>> Reports) {
860
862
SmallVector<MCPhysReg> RegsToTrack = collectRegsToTrack (Reports);
861
863
// Re-compute the analysis with register tracking.
862
864
auto Analysis = SrcSafetyAnalysis::create (BF, AllocatorId, RegsToTrack);
@@ -882,7 +884,7 @@ void FunctionAnalysisContext::augmentUnsafeUseReports(
882
884
}
883
885
884
886
void FunctionAnalysisContext::handleSimpleReports (
885
- SmallVector<BriefReport <MCPhysReg>> &Reports) {
887
+ SmallVector<PartialReport <MCPhysReg>> &Reports) {
886
888
// Before re-running the detailed analysis, process the reports which do not
887
889
// need any additional details to be attached.
888
890
for (auto &Report : Reports) {
@@ -899,7 +901,7 @@ void FunctionAnalysisContext::run() {
899
901
BF.dump ();
900
902
});
901
903
902
- SmallVector<BriefReport <MCPhysReg>> UnsafeUses;
904
+ SmallVector<PartialReport <MCPhysReg>> UnsafeUses;
903
905
findUnsafeUses (UnsafeUses);
904
906
handleSimpleReports (UnsafeUses);
905
907
if (!UnsafeUses.empty ())
0 commit comments