[llvm-dev] Dumping the static stack reservation sizes for functions

Ben Craig via llvm-dev llvm-dev at lists.llvm.org
Mon Feb 5 14:42:00 PST 2018


Alternatively, you can parse the assembly...

https://github.com/spotify/linux/blob/master/scripts/checkstack.pl


I've used something like this in the past on x86 and ARM.  I also parsed the output of objdump enough so that I could connect callers and callees (static dispatch only), so that I could analyze stack depths.

________________________________
From: llvm-dev <llvm-dev-bounces at lists.llvm.org> on behalf of Martin J. O'Riordan via llvm-dev <llvm-dev at lists.llvm.org>
Sent: Monday, February 5, 2018 4:22:58 PM
To: 'Francis Visoiu Mistrih'
Cc: 'LLVM Developers'
Subject: Re: [llvm-dev] Dumping the static stack reservation sizes for functions

Cool this is better than I expected - I never thought about the YAML support.  And the document reference is really very good.

Thanks Francis,

        MartinO

-----Original Message-----
From: Francis Visoiu Mistrih [mailto:francisvm at yahoo.com]
Sent: 05 February 2018 21:43
To: Martin J. O'Riordan <MartinO at theheart.ie>
Cc: LLVM Developers <llvm-dev at lists.llvm.org>; Adam Nemet <anemet at apple.com>
Subject: Re: [llvm-dev] Dumping the static stack reservation sizes for functions

Hi Martin,

> On Feb 5, 2018, at 11:46 AM, Martin J. O'Riordan via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>
> I would like to be able to emit a list of functions by name and their fixed stack reservation size information, so that a programmer can gauge how much stack they are likely to need in tightly constrained embedded systems.  Despite the rich number of options, the only option I can find that is even relatively close is:
>
> -warn-stack-size=<uint>
>
> Is there some existing way of getting this information emitted in an easily parsable way (e.g. in CSV form) , or will I need to add the capability?

There is an optimization remark emitted (in YAML) for the stack size:

$ clang -fsave-optimization-record foo.c $ cat foo.opt.yaml […]
--- !Analysis
Pass:            prologepilog
Name:            StackSize
DebugLoc:        { File: foo.c, Line: 3, Column: 0 }
Function:        main
Args:
  - NumStackBytes:   '24'
  - String:          ' stack bytes in function'
...
[…]

For more information about optimization remarks I suggest Adam’s talk: https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_devmtg_2016-2D11_Slides_Nemet-2DCompiler-2DassistedPerformanceAnalysis.pdf&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=y8mub81SfUi-UCZRX0Vl1g&m=91ISonwGFC-5PXicMmU7hKU05JDu3cO9Xj1OSyr8fQo&s=O5WFJ5ZuPJlCKra2PNkkyQbSS7Qmy1y-1mQtRqj0yE8&e=

Cheers,

—
Francis

>
> Thanks,
>
>             MartinO
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Ddev&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=y8mub81SfUi-UCZRX0Vl1g&m=91ISonwGFC-5PXicMmU7hKU05JDu3cO9Xj1OSyr8fQo&s=O4d7UXtJcj-2MZnKbdq-U7N5z1d1l1302PuDIAlj4h8&e=

_______________________________________________
LLVM Developers mailing list
llvm-dev at lists.llvm.org
https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Ddev&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=y8mub81SfUi-UCZRX0Vl1g&m=91ISonwGFC-5PXicMmU7hKU05JDu3cO9Xj1OSyr8fQo&s=O4d7UXtJcj-2MZnKbdq-U7N5z1d1l1302PuDIAlj4h8&e=
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180205/3f664aba/attachment.html>


More information about the llvm-dev mailing list