https://github.com/atrosinenko updated https://github.com/llvm/llvm-project/pull/133308
>From c7395a163286ee331fc601b35222f5a3d422d188 Mon Sep 17 00:00:00 2001 From: Anatoly Trosinenko <atrosine...@accesssoftek.com> Date: Thu, 27 Mar 2025 21:06:55 +0300 Subject: [PATCH] [BOLT] Make DataflowAnalysis::getStateBefore() const (NFC) --- bolt/include/bolt/Passes/DataflowAnalysis.h | 11 +++++++---- bolt/lib/Passes/PAuthGadgetScanner.cpp | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bolt/include/bolt/Passes/DataflowAnalysis.h b/bolt/include/bolt/Passes/DataflowAnalysis.h index 2afaa6d3043a6..f6ca39cf6f860 100644 --- a/bolt/include/bolt/Passes/DataflowAnalysis.h +++ b/bolt/include/bolt/Passes/DataflowAnalysis.h @@ -292,14 +292,17 @@ class DataflowAnalysis { /// Relies on a ptr map to fetch the previous instruction and then retrieve /// state. WARNING: Watch out for invalidated pointers. Do not use this /// function if you invalidated pointers after the analysis has been completed - ErrorOr<const StateTy &> getStateBefore(const MCInst &Point) { - return getStateAt(PrevPoint[&Point]); + ErrorOr<const StateTy &> getStateBefore(const MCInst &Point) const { + auto It = PrevPoint.find(&Point); + if (It == PrevPoint.end()) + return make_error_code(std::errc::result_out_of_range); + return getStateAt(It->getSecond()); } - ErrorOr<const StateTy &> getStateBefore(ProgramPoint Point) { + ErrorOr<const StateTy &> getStateBefore(ProgramPoint Point) const { if (Point.isBB()) return getStateAt(*Point.getBB()); - return getStateAt(PrevPoint[Point.getInst()]); + return getStateBefore(*Point.getInst()); } /// Remove any state annotations left by this analysis diff --git a/bolt/lib/Passes/PAuthGadgetScanner.cpp b/bolt/lib/Passes/PAuthGadgetScanner.cpp index 00846247fdc21..df9e87bd4e999 100644 --- a/bolt/lib/Passes/PAuthGadgetScanner.cpp +++ b/bolt/lib/Passes/PAuthGadgetScanner.cpp @@ -443,7 +443,7 @@ class PacRetAnalysis public: std::vector<MCInstReference> getLastClobberingInsts(const MCInst &Inst, BinaryFunction &BF, - const ArrayRef<MCPhysReg> UsedDirtyRegs) { + const ArrayRef<MCPhysReg> UsedDirtyRegs) const { if (RegsToTrackInstsFor.empty()) return {}; auto MaybeState = getStateBefore(Inst); _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits