Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Time to Test Your Compiler

Name: Anonymous 2014-04-30 9:59

void foo() {}
void bar() {}
void main() {
if ((void*)foo < (void*)bar) {
printf("sound compiler! preserves ordering.\n");
} else {
printf("your gaypiler sucks balls and doesn't respect memory layout\n");
}
}

Name: Anonymous 2014-05-01 6:06

>>1,4,5
I cannot think of any situation where it would strongly benefit you to do this sort of ordering by hand. If it really matters, most compilers will allow you to declare an output section for each function so you can set the ordering at link time. You'd probably be better of just using assembly for the entire hot path though.

IHBT

>>2
Profile guided optimizers do exactly this.

>>14
You can't rely on this behavior if your toolchain re-orders functions based on input from a profile guided optimizer, or if it generates a separate segment for each function (for link time dead code elimination, etc). If your compiler doesn't support either of these, it's crap.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List