mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-04 22:07:27 +00:00
more notes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34204 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
08ba1de2d2
commit
48d3c108b6
@ -874,15 +874,15 @@ void test(int X) {
|
||||
if (X) abort();
|
||||
}
|
||||
|
||||
is currently compiled to (with -static):
|
||||
is currently compiled to:
|
||||
|
||||
_test:
|
||||
subl $12, %esp
|
||||
cmpl $0, 16(%esp)
|
||||
jne LBB1_1 #cond_true
|
||||
jne LBB1_1
|
||||
addl $12, %esp
|
||||
ret
|
||||
LBB1_1: #cond_true
|
||||
LBB1_1:
|
||||
call L_abort$stub
|
||||
|
||||
It would be better to produce:
|
||||
@ -895,5 +895,28 @@ _test:
|
||||
ret
|
||||
|
||||
This can be applied to any no-return function call that takes no arguments etc.
|
||||
Alternatively, the stack save/restore logic could be shrink-wrapped, producing
|
||||
something like this:
|
||||
|
||||
_test:
|
||||
cmpl $0, 4(%esp)
|
||||
jne LBB1_1
|
||||
ret
|
||||
LBB1_1:
|
||||
subl $12, %esp
|
||||
call L_abort$stub
|
||||
|
||||
Both are useful in different situations. Finally, it could be shrink-wrapped
|
||||
and tail called, like this:
|
||||
|
||||
_test:
|
||||
cmpl $0, 4(%esp)
|
||||
jne LBB1_1
|
||||
ret
|
||||
LBB1_1:
|
||||
pop %eax # realign stack.
|
||||
call L_abort$stub
|
||||
|
||||
Though this probably isn't worth it.
|
||||
|
||||
//===---------------------------------------------------------------------===//
|
||||
|
Loading…
Reference in New Issue
Block a user