summaryrefslogtreecommitdiff
path: root/bolt
diff options
context:
space:
mode:
authorSlava Gurevich <sgurevich@gmail.com>2025-10-14 02:00:35 -0700
committerGitHub <noreply@github.com>2025-10-14 02:00:35 -0700
commit4a8dd4998dae8b7d67e416d20a1fa8a9451c64f5 (patch)
tree64f503802d56d11e1ae21c73e1048a6b15df8954 /bolt
parentee6c92f8d7acdd633f5fd9a2d92c6e4861148604 (diff)
[BOLT][NFC] Fix for a dangling reference UB (#163344)
Fix UB caused by accessing the top element of the stack via a dangling reference after a call to .pop() This is tripping static analysis. No functional changes. Performance impact is negligible, but alt. implementation of the fix is possible if needed. Testing: Both functional and unit tests are passing.
Diffstat (limited to 'bolt')
-rw-r--r--bolt/lib/Passes/FrameAnalysis.cpp2
-rw-r--r--bolt/lib/Passes/ShrinkWrapping.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/bolt/lib/Passes/FrameAnalysis.cpp b/bolt/lib/Passes/FrameAnalysis.cpp
index f568039bbf16..0b26da337123 100644
--- a/bolt/lib/Passes/FrameAnalysis.cpp
+++ b/bolt/lib/Passes/FrameAnalysis.cpp
@@ -198,7 +198,7 @@ public:
if (CFIStack.empty())
dbgs() << "Assertion is about to fail: " << BF.getPrintName() << "\n";
assert(!CFIStack.empty() && "Corrupt CFI stack");
- std::pair<int64_t, uint16_t> &Elem = CFIStack.top();
+ std::pair<int64_t, uint16_t> Elem = CFIStack.top();
CFIStack.pop();
CfaOffset = Elem.first;
CfaReg = Elem.second;
diff --git a/bolt/lib/Passes/ShrinkWrapping.cpp b/bolt/lib/Passes/ShrinkWrapping.cpp
index 4ea60f388e2f..fe342ccd38a6 100644
--- a/bolt/lib/Passes/ShrinkWrapping.cpp
+++ b/bolt/lib/Passes/ShrinkWrapping.cpp
@@ -402,7 +402,7 @@ void StackLayoutModifier::classifyCFIs() {
break;
case MCCFIInstruction::OpRestoreState: {
assert(!CFIStack.empty() && "Corrupt CFI stack");
- std::pair<int64_t, uint16_t> &Elem = CFIStack.top();
+ std::pair<int64_t, uint16_t> Elem = CFIStack.top();
CFIStack.pop();
CfaOffset = Elem.first;
CfaReg = Elem.second;