[llvm-branch-commits] [llvm] [BOLT] Make DataflowAnalysis::getStateBefore() const (NFC) (PR #133308)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Mar 27 13:03:48 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-bolt
Author: Anatoly Trosinenko (atrosinenko)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/133308.diff
2 Files Affected:
- (modified) bolt/include/bolt/Passes/DataflowAnalysis.h (+7-4)
- (modified) bolt/lib/Passes/PAuthGadgetScanner.cpp (+1-1)
``````````diff
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 16da08551a34d..86897937c95fe 100644
--- a/bolt/lib/Passes/PAuthGadgetScanner.cpp
+++ b/bolt/lib/Passes/PAuthGadgetScanner.cpp
@@ -448,7 +448,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);
``````````
</details>
https://github.com/llvm/llvm-project/pull/133308
More information about the llvm-branch-commits
mailing list