Skip to content

Commit 33c6052

Browse files
committed
[BOLT] Make DataflowAnalysis::getStateBefore() const (NFC)
1 parent a5d8504 commit 33c6052

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

bolt/include/bolt/Passes/DataflowAnalysis.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,17 @@ class DataflowAnalysis {
292292
/// Relies on a ptr map to fetch the previous instruction and then retrieve
293293
/// state. WARNING: Watch out for invalidated pointers. Do not use this
294294
/// function if you invalidated pointers after the analysis has been completed
295-
ErrorOr<const StateTy &> getStateBefore(const MCInst &Point) {
296-
return getStateAt(PrevPoint[&Point]);
295+
ErrorOr<const StateTy &> getStateBefore(const MCInst &Point) const {
296+
auto It = PrevPoint.find(&Point);
297+
if (It == PrevPoint.end())
298+
return make_error_code(std::errc::result_out_of_range);
299+
return getStateAt(It->getSecond());
297300
}
298301

299-
ErrorOr<const StateTy &> getStateBefore(ProgramPoint Point) {
302+
ErrorOr<const StateTy &> getStateBefore(ProgramPoint Point) const {
300303
if (Point.isBB())
301304
return getStateAt(*Point.getBB());
302-
return getStateAt(PrevPoint[Point.getInst()]);
305+
return getStateBefore(*Point.getInst());
303306
}
304307

305308
/// Remove any state annotations left by this analysis

bolt/lib/Passes/PAuthGadgetScanner.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ class PacRetAnalysis
443443
public:
444444
std::vector<MCInstReference>
445445
getLastClobberingInsts(const MCInst &Inst, BinaryFunction &BF,
446-
const ArrayRef<MCPhysReg> UsedDirtyRegs) {
446+
const ArrayRef<MCPhysReg> UsedDirtyRegs) const {
447447
if (RegsToTrackInstsFor.empty())
448448
return {};
449449
auto MaybeState = getStateBefore(Inst);

0 commit comments

Comments
 (0)