Dear All,
Does anyone have good ideas to dynamically measure the stack size of a program by using LLVM.
I am trying to add some new intrinsic functions after each “alloca” in bitcode. Is it a good way to do it?
Any existing tools can help me to do so?
Any help will be deeply appreciated.
Thank you,
GUanhua
Depending on how much precision you need, you could use the llvm.frameaddress intrinsic.
-Chris
Chris:
This prompts me to a related question. For procedures that do not call
alloca() at run time, is there a way to learn the stack frame size in
bytes for each procedure at static compile time?
shap
The GC infrastructure exposes this information in a framework suitable for emitting metadata tables from a compiler plugin, if your interest lies in that direction.
— Gordon
That too, but my immediate interest was computing an upper bound on
stack size for the Coyotos kernel.
shap
I think it is dumped if you pass -print-machineinstrs to llc.
-Chris
This prompts me to a related question. For procedures that do not call
alloca() at run time, is there a way to learn the stack frame size in
bytes for each procedure at static compile time?
The linux kernel uses the attached script to check the stack usage of
functions.
Ciao,
Duncan.
checkstack.pl (4.25 KB)