Quantcast
Channel: Active questions tagged kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 6333

clang eager to inline at cost of stack

$
0
0

Apple clang version 11.0.0 (clang-1100.0.33.17)

The project has recently moved to mark all functions "static" that are not prototyped in headers, and only used in the specific source file.llvm appears to be quite eager to inline functions, which is often desirable, especially in userland.

However, the part of the project that is in kernel, has a fixed stack on 16KB.Take a function recurse() which will call itself, in my specific example, 11 times. It calls a logging function 5 times.

If I stick __attribute__(noinline) on the log function, the frame-size of recurse() is 88 bytes. (As reported by --Wframe-larger-than=1). If log() is just static it gets inlined, and recurse() grows to 540 bytes.

Now;

11 * 88 (+ 1x sizeof log usage)

vs

11 * 540

is quite the difference.

It would be nice to be able to tell llvm to favour "smaller stack" during the kernel compile.

Manually figuring out what to "noline" is time-consuming (for the human), and a global -fno-inline-functions would remove improvements that does not affect the stack.

Are there any way to ask clang to limit stack usage as a compile option for some source files?


Viewing all articles
Browse latest Browse all 6333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>