Skip to content

[BOLT] Make DataflowAnalysis::getStateBefore() const (NFC) #133308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions bolt/include/bolt/Passes/DataflowAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bolt/lib/Passes/PAuthGadgetScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down