There was already some form of this, but it wasn't working. I moved the depth tracking from InterpState to InterpFrame so remove some of the magic from the Ret instructions.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Move things around a bit and add some + 1s to get matching diagnostic output with the current interpreter.
The changes make sense, I am sure about any trade-offs of doing the checking during the call Vs doing at return.
clang/lib/AST/Interp/Interp.cpp | ||
---|---|---|
345–352 | -fconstexpr-depth sets the number of *recursive* constexpr calls, but this looks like it's measuring the depth of the call stack regardless of whether there's recursion or not. Can you add a test where you set this value to something low and make nested calls that exceed that depth? (Also, there's -fconstexpr-steps https://clang.llvm.org/docs/UsersManual.html#cmdoption-fconstexpr-steps we'll need to support at some point, in case you weren't aware of the option.) |
LGTM, though I would appreciate adding the other test case from my comments since it's interesting behavior.
clang/lib/AST/Interp/Interp.cpp | ||
---|---|---|
345–352 | Whelp, TIL that our docs are wrong and should be updated (I'll take care of that): https://godbolt.org/z/ahPjPnhGr It has nothing to do with recursion, that's just the way in which you'd typically run into it. |
clang/lib/AST/Interp/Interp.cpp | ||
---|---|---|
345–352 | I know about -fconstexpr-steps, but the notion of "steps" is implementation dependent, isn't it? I.e. I could just cal a "step" the execution of one opcode? |
-fconstexpr-depth sets the number of *recursive* constexpr calls, but this looks like it's measuring the depth of the call stack regardless of whether there's recursion or not. Can you add a test where you set this value to something low and make nested calls that exceed that depth?
(Also, there's -fconstexpr-steps https://clang.llvm.org/docs/UsersManual.html#cmdoption-fconstexpr-steps we'll need to support at some point, in case you weren't aware of the option.)