<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 9/3/13 1:27 PM, Snehasish Kumar
wrote:<br>
</div>
<blockquote
cite="mid:CAMoUCJhCg+X0LpzKWO3XKLVy-isNEhqDymu8cOVaeP9KS-kd-w@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<div dir="ltr">Hi
<div><br>
</div>
<div>I was wondering if someone knows about any effort within
the LLVM community to perform stack usage analysis per
function similar to GCC's "<a moz-do-not-send="true"
href="http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/Static-Stack-Usage-Analysis.html">-fstack-usage</a>"
option?</div>
</div>
</blockquote>
<br>
I am not familiar with the -fstack-usage option in GCC, but as far
as I know, LLVM does not have a FunctionPass or MachineFunctionPass
which performs the calculations described below. You could, of
course, quickly test this by running the clang -fstack-usage and see
what happens. LLVM and the DragonEgg plugin for GCC is more likely
to support the feature.<br>
<br>
That said, writing such as pass would be very easy to do. If you're
only concerned about the size of stack-allocated objects, you can
write an LLVM pass that looks for alloca instructions, determine
that they are not in loops, and then sums up the sizes of the
allocatoed memory using the DataLayout pass.<br>
<br>
If you want something that includes stack-spill slots and the like,
then you'd need to write a MachineFunction Pass and examine the
generated machine instructions. Alternatively, there might be a way
in a MachineFunctionPass to get a pointer to a MachineFrame object
and to query its size.<br>
<br>
-- John T.<br>
<br>
<blockquote
cite="mid:CAMoUCJhCg+X0LpzKWO3XKLVy-isNEhqDymu8cOVaeP9KS-kd-w@mail.gmail.com"
type="cite">
<div dir="ltr">
<div><br>
</div>
<div>In short, with fstack-usage, gcc prints out the maximum
stack usage per function (in bytes) which it can determine as
a) static (no calls to alloca in source) b) bounded (calls to
alloca with constants) c) unbounded (calls to alloca with
variables). A more detailed description can be found in this <a
moz-do-not-send="true"
href="http://ols.fedoraproject.org/GCC/Reprints-2005/hainque-Reprint.pdf">pdf</a>.</div>
<div><br>
</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Snehasish Kumar</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
</blockquote>
<br>
</body>
</html>