3 ms·
The generated function also has a subtract zero from rsp which could just be plain eliminated. Though it's probably rarer to have this in general code, it means
by baruch 5y ago
The generated function also has a subtract zero from rsp which could just be plain eliminated. Though it's probably rarer to have this in general code, it means there are no local variables. Looks like there are still some low hanging fruits in there :-)
- FPGAhacker 5y agoI thought maybe it was there to set or clear flags.
- mmastrac 5y agoIt 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/e2e5377e7b68d57def00acda17ffcfca6dce8b84/x86_64-gen.c#L1615 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.