[llvm-dev] Getting stack size of compiled functions from LLVM

Nicholas Chapman via llvm-dev llvm-dev at lists.llvm.org
Mon May 28 23:34:07 PDT 2018


Hi all,
I'm trying to get the amount of stack memory used by the functions I am 
JIT compiling with LLVM.
I have a host C++ program, and I want to be able to access the stack 
size from the host C++ program.

I see in PrologEpilogInserter.cpp that the computed stack size is read 
from the MachineFunction corresponding to a Function, in order to issue 
a warning if the stack size is too large.
However I don't see a way to access this information from my host C++ 
program.

One approach I have investigated is writing a MachineFunctionPass that 
could access the MachineFunctions and hence the stack size. However I 
have not been able to get my MachineFunctionPass to run
without hitting assert failures.

Is it possible to add/schedule a MachineFunctionPass to run without 
modifying the LLVM libraries themselves?  I would prefer not to have to 
modify LLVM.
If it is the case that the code to schedule the MachineFunctionPass must 
be added to LLVM, then it's not clear to me how to return the stack size 
information to the host C++ program either.

Any help would be appreciated.
Thanks,
     Nick C.


More information about the llvm-dev mailing list