<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/134785>134785</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Bytecode interpreter: Optimization opportunities
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:frontend,
clang:bytecode
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
tbaederr
</td>
</tr>
</table>
<pre>
- When allocating a new `InterpFrame`, we do that as a `unique_ptr`, which causes a heap allocation. In the constructor, we immediately do another heap allocation for `Locals`. Can we do this in one allocation? Does it make sense to add an allocator for this to `InterpState`? Does the fact that we have a stack based allocation scheme (LIFO basically) help us at all here?
- We currently create `Function` instances for all builtin functions. However, we rarely use them later, since the classified argument calls, etc. don't always match what we actually have on the stack and we instead _need to_ look at their `CallExpr`. Can we do without the `Function` instance for builtins?
- `OffsetHelper` in `Interp.h` currently pushes the new value to the stack, but some callers pop it immediately again to use the new pointer (e.g. in `ArrayElemPtr`, we call `NarrowPtr`). Stop doing that and instead return the new value.
- In `Block::invokeCtor`, we call `memset()` on the entire data of the block, and then follow it by calling the ctor function, which will overwrite the entire data again (hopefully). Remove that memset call. Simply doing that caused some problems for me in the past, so there's more to it than just that.
- We do create full `Block`s for dummy pointers these days, even though we can never actually access their data. We only ever look at the `InlineDescriptors` we set via their `CtorFn`. Does it improve performance if we don't initialize the data fields of dummy blocks?
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx0lcuO27gShp-G3hQiyPJ94UWnO0YaCE4OJotZBiWqZDFNkRqyaI_z9IMifelJMCsDIlmX76-_jDGaoyPaq9VHtXqZYeLBhz23SB2FMGt9d9nDB_hzIAdordfIxh0BwdEZ1Lp-dUxhOgQcSa1r1TzDmaDzwAMyYASUS8mZvxJ9nzjc7gxGD6AxRZIrA-F0j-5dBa8OeCDQ3kUOSbMP18hmHKkzyGQvkgWd54HCrwGg90HyfvEabVTruoJndP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