Skip to content

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

Closed
@newling

Description

@newling

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions