save_reg can't reuse the temporary local variable created before to save register. It may consume a lot of stack memory.
eg.
Disassembly of section .text:
00000000 <test>:
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 81 ec 0c 00 00 00 sub $0xc,%esp
9: 90 nop
a: 8b 05 00 00 00 00 mov 0x0,%eax
10: b9 03 00 00 00 mov $0x3,%ecx
15: 51 push %ecx
16: b9 02 00 00 00 mov $0x2,%ecx
1b: 51 push %ecx
1c: b9 01 00 00 00 mov $0x1,%ecx
21: 51 push %ecx
22: 89 45 fc mov %eax,-0x4(%ebp)
25: 8b 45 fc mov -0x4(%ebp),%eax
28: 8b 00 mov (%eax),%eax
2a: ff d0 call *%eax
2c: 83 c4 0c add $0xc,%esp
2f: 8b 05 00 00 00 00 mov 0x0,%eax
35: b9 06 00 00 00 mov $0x6,%ecx
3a: 51 push %ecx
3b: b9 05 00 00 00 mov $0x5,%ecx
40: 51 push %ecx
41: b9 04 00 00 00 mov $0x4,%ecx
46: 51 push %ecx
47: 89 45 f8 mov %eax,-0x8(%ebp)
4a: 8b 45 f8 mov -0x8(%ebp),%eax
4d: 8b 00 mov (%eax),%eax
4f: ff d0 call *%eax
51: 83 c4 0c add $0xc,%esp
54: 8b 05 00 00 00 00 mov 0x0,%eax
5a: b9 09 00 00 00 mov $0x9,%ecx
5f: 51 push %ecx
60: b9 08 00 00 00 mov $0x8,%ecx
65: 51 push %ecx
66: b9 07 00 00 00 mov $0x7,%ecx
6b: 51 push %ecx
6c: 89 45 f4 mov %eax,-0xc(%ebp)
6f: 8b 45 f4 mov -0xc(%ebp),%eax
72: 8b 00 mov (%eax),%eax
74: ff d0 call *%eax
76: 83 c4 0c add $0xc,%esp
79: c9 leave
7a: c3 ret
Everytime calling the function create a new local variable on stack to save register.
The first patch use a list to save these local variable and reuse them.
Disassembly of section .text:
00000000 <test>:
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 81 ec 00 00 00 00 sub $0x0,%esp
9: 90 nop
a: 8b 05 00 00 00 00 mov 0x0,%eax
10: b9 03 00 00 00 mov $0x3,%ecx
15: 51 push %ecx
16: b9 02 00 00 00 mov $0x2,%ecx
1b: 51 push %ecx
1c: b9 01 00 00 00 mov $0x1,%ecx
21: 51 push %ecx
22: 8b 08 mov (%eax),%ecx
24: ff d1 call *%ecx
26: 83 c4 0c add $0xc,%esp
29: 8b 05 00 00 00 00 mov 0x0,%eax
2f: b9 06 00 00 00 mov $0x6,%ecx
34: 51 push %ecx
35: b9 05 00 00 00 mov $0x5,%ecx
3a: 51 push %ecx
3b: b9 04 00 00 00 mov $0x4,%ecx
40: 51 push %ecx
41: 8b 08 mov (%eax),%ecx
43: ff d1 call *%ecx
45: 83 c4 0c add $0xc,%esp
48: 8b 05 00 00 00 00 mov 0x0,%eax
4e: b9 09 00 00 00 mov $0x9,%ecx
53: 51 push %ecx
54: b9 08 00 00 00 mov $0x8,%ecx
59: 51 push %ecx
5a: b9 07 00 00 00 mov $0x7,%ecx
5f: 51 push %ecx
60: 8b 08 mov (%eax),%ecx
62: ff d1 call *%ecx
64: 83 c4 0c add $0xc,%esp
67: c9 leave
68: c3 ret
I'm unfamiliar with Git and I don't know how to remove the commit message like "Merge git://repo.or.cz/tinycc into mob" ...