Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting upper bound on stack size from .o/.asm : possible? #350

Closed
newling opened this issue Feb 12, 2025 · 1 comment
Closed

Getting upper bound on stack size from .o/.asm : possible? #350

newling opened this issue Feb 12, 2025 · 1 comment

Comments

@newling
Copy link

newling commented Feb 12, 2025

Is there a way to get a (useful) upper-bound on the stack size from an object/asm file? Related to the comment here: #342 (comment)

I can see what appears to be stack pointer manipulation in the object dump:

2c: 3b 10 a0 72 02 00 00 c0 17 00	paddb	[sp], #0x5c0;		movxm	dj3, #0x540
36: 3b 11 c0 52 02 00 00 00 9c e9	st	r16, [sp, #-1436];		movxm	dj2, #0x580
40: 3b 11 e0 32 02 00 00 40 8c e9	st	r17, [sp, #-1440];		movxm	dj1, #0x5c0
4a: 3b 11 00 f3 01 00 00 80 7c e9	st	r18, [sp, #-1444];		movxm	dn7, #0x600
...
d0: 35 40 50 0f 00 01    	mova	r0, #0x8;		st	r0, [sp, #-1408]
d6: 99 05 00 12  	or	r0, r8, r0
da: 35 40 58 0f 80 01    	mova	r0, #0xc;		st	r0, [sp, #-1344]
e0: 9d 05 00 2a 0c ea    	lda	dj0, [sp, #-1408];		or	r0, r8, r0
...
968: d9 7e 48 07  	lda	p7, [sp, #-1472]
96c: d9 f6 48 07  	lda	p6, [sp, #-1468]
970: 59 6e 49 07  	lda	r23, [sp, #-1464]
974: 59 ec 49 07  	lda	r22, [sp, #-1460]

but I'm not sure how to interpret it or extract the info I want.

Motivation: I'd like to set the stack address in iree-amd-aie only after full compilation of the core code (currently it happens before). I think it's possible, for example I think we can set the addresses of the buffers after the core code is generated. So if there's a way we can get a tight upper bound on stack size, it should be possible to avoid these hard-to-diagnose issues where the stack is too small, by allocation the correct amount of memory for the stack

@newling
Copy link
Author

newling commented Feb 21, 2025

It is possible using --stack-size-section, this was our solution in iree-amd-aie: nod-ai/iree-amd-aie#1121

@newling newling closed this as completed Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant