diff options
| author | 2026-03-08 18:04:29 +0100 | |
|---|---|---|
| committer | 2026-03-08 18:04:29 +0100 | |
| commit | 18304d695eb69e6e8776e82c305c6798d42ca1f7 (patch) | |
| tree | 7d4f2ed1f066b8c00b8ba68905265251c3bf40e9 /test | |
| parent | 0a9b4736ca028e1637311a6cc0753bbb9351e951 (diff) | |
ir: fix inlining getting stuck on complex recursive call sequences
By maintaining a proper stack of inline expansions and refusing to
expand callers already present in the stack.
Diffstat (limited to 'test')
| -rw-r--r-- | test/16-inline.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/16-inline.c b/test/16-inline.c index 983d9b2..f66b2cb 100644 --- a/test/16-inline.c +++ b/test/16-inline.c @@ -2,6 +2,7 @@ /* CFLAGS: -O1 */ /* EXPECT: 25;0 +-3,-6,-9,-12,-15, */ static inline int sqr(int x) {return x*x;} @@ -11,9 +12,21 @@ static inline int ind(int (*f)(int), int arg) { } #include <stdio.h> + +static inline void each(int *xs, size_t n, void (*f)(void *, int *), void *u) { + for (; n > 0; --n, ++xs) f(u, xs); +} +static inline void multp(void *u, int *x) { *x *= *(int *)u; } +static inline void printi(void *_, int *x) { printf("%d,", *x); } + int main() { int q = ind(sqr, 5); printf("%d;%d\n", q, ind(foo,-2)); + int xs[5] = {1,2,3,4,5}; + int m = -3; + each(xs, 5, multp, &m); + each(xs, 5, printi, NULL); + printf("\n"); } static inline int foo(int w) { |