Inline Return Statement
- You have an unconditional jump to a set of consecutive statements ending with a return statement.
Inline those statements.
void function() {
/* frame setup code */
...
if(cond) {
...
goto leave;
}
...
leave:
/* frame clean-up code */
...
return;
}
⇓
void function() {
/* frame setup code */
...
if(cond) {
...
/* frame clean-up code */
...
return;
}
...
/* frame clean-up code */
...
return;
}
Motivation
When a function has multiple return statements the compiler unifies these statements in a single return statement, to avoid unnecessary duplication of the clean-up code. A jump, however, does not have the same semantic meaning of a return statement, being sometimes preferable the latter for better code comprehension.
Mechanics
- Inline the statements between the label and the return statement instead of the jump.
- Remove the label, if no longer used.