-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[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
atrosinenko
merged 1 commit into
main
from
users/atrosinenko/bolt-make-getstatebefore-const
Apr 7, 2025
Merged
[BOLT] Make DataflowAnalysis::getStateBefore() const (NFC) #133308
atrosinenko
merged 1 commit into
main
from
users/atrosinenko/bolt-make-getstatebefore-const
Apr 7, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Mar 27, 2025
@llvm/pr-subscribers-bolt Author: Anatoly Trosinenko (atrosinenko) ChangesFull diff: https://github.com/llvm/llvm-project/pull/133308.diff 2 Files Affected:
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);
|
maksfb
approved these changes
Mar 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
kbeyls
approved these changes
Mar 28, 2025
e611f6c
to
eebc0ca
Compare
12d4a20
to
33c6052
Compare
eebc0ca
to
a5d8504
Compare
498e9a6
to
4f662e3
Compare
9ddb906
to
2bf9f89
Compare
46d771d
to
05852d6
Compare
Base automatically changed from
users/atrosinenko/bolt-gs-address-materialization
to
main
April 7, 2025 10:13
05852d6
to
79b70c1
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.