Skip to content

Commit 95f4aa4

Browse files
authored
[clang][bytecode] Add assert to ensure correct state restoration in CallBI function (llvm#115496)
This commit adds an assert statement to the CallBI function to ensure that the interpreter state (S.Current) is correctly reset to the previous frame (FrameBefore) after InterpretBuiltin returns true. This helps catch any potential issues during development and debugging.
1 parent a12e79a commit 95f4aa4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1370,9 +1370,15 @@ bool CallBI(InterpState &S, CodePtr OpPC, const Function *Func,
13701370
S.Current = NewFrame.get();
13711371

13721372
if (InterpretBuiltin(S, OpPC, Func, CE, BuiltinID)) {
1373-
NewFrame.release();
1373+
// Release ownership of NewFrame to prevent it from being deleted.
1374+
NewFrame.release(); // Frame was deleted already.
1375+
// Ensure that S.Current is correctly reset to the previous frame.
1376+
assert(S.Current == FrameBefore);
13741377
return true;
13751378
}
1379+
1380+
// Interpreting the function failed somehow. Reset to
1381+
// previous state.
13761382
S.Current = FrameBefore;
13771383
return false;
13781384
}

0 commit comments

Comments
 (0)