Consider Calloc and Realloc for autotuners#2038
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates Goblint’s autotuning heuristics so they treat calloc and realloc similarly to malloc, aligning the autotuners with existing allocation-kind handling in the malloc-wrapper analysis.
Changes:
- Extend the “allocations-in-loops” autotuner to also detect
calloc/realloccalls inside loops. - Extend the malloc-wrapper autotuner to recognize wrappers around
calloc/reallocin addition tomalloc(by reusing wrapper-function classification logic). - Add a clarifying TODO comment in
c2poAnalysisabout missingreallochandling.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/autoTune.ml | Autotuners now consider Calloc/Realloc for loop allocation detection and malloc-wrapper detection. |
| src/analyses/wrapperFunctionAnalysis.ml | Exposes wrapper-classification plumbing to enable reuse by autotuners. |
| src/analyses/c2poAnalysis.ml | Comment-only change noting a potential missing Realloc case. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
On sv-benchmarks with level01, 60s and 1GB this already has interesting effects: https://goblint.cs.ut.ee/results/340-all-level01-pr-2038-after/table-generator-cmp.diff.html#/table?filter=0(0*status*(status(notIn(FAILED)),category(notIn()))).
|
I looked into it and according to manual inspection the branches that became dead due to this change seemed to actually be dead. I then looked at SV-COMP 2026 results and found out that the task was invalidated. Turns out Mopsa already had an issue with this: |
While debugging #2030 (comment) I noticed that the mallocWrappers autotuner doesn't pick up on the wrapper of
calloc. Despite the name, it makes sense to do so (and withrealloc). The mallocWrapper analysis also already considers them.After reviewing all pattern matchings for these allocation kinds, I also found the same being missing from the allocation loop unrolling autotuner.
TODO