Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It looks like a generic prologue. Ideally the code generator would detect that no stack frame is required whatsoever and just emit the barebones return. It's possible that the prologue is generated ahead of time and then patched as the codegen determines how many locals it needs.

You could do a second pass if you detect no locals (you'd need to as you'll be computing new offsets for relative branches/loads/etc), or potentially generate two versions of each function as you compile and only commit the one that is smaller but those are some pretty big tradeoffs.

I don't have any idea how TCC is organized internally but my money would be on a generic prologue getting fixed up after-the-fact.

EDIT: I think that it might generate the prolog by rewinding to the beginning of the function here: https://github.com/TinyCC/tinycc/blob/e2e5377e7b68d57def00ac...

I'm not sure if sub rsp, 0 is faster than just filling w/a NOP but that could always be someone's future experiment.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: