Hello, somehow gcc removes my puts function from my code when optimizing, anyone knows why?
main.c: https://github.com/cheyao/AsmOS/blob/master/lib/main.c
You can also see from the elf file disasembly that the third call (puts) is gone
With -O0 https://github.com/cheyao/AsmOS/blob/master/O0.dis
With -O1 https://github.com/cheyao/AsmOS/blob/master/O1.dis
The only thing i changed that may effect this is changed "" to <> include brackets (and changed the file's directories but that shouldn't effect it)
GCC optimization removing my function call
-
- Member
- Posts: 5562
- Joined: Mon Mar 25, 2013 7:01 pm
Re: GCC optimization removing my function call
GCC is performing tail call optimization. Notice how the optimized main function ends with a JMP instead of a RET.
If your code isn't working, the problem is unrelated to this optimization.
If your code isn't working, the problem is unrelated to this optimization.
-
- Member
- Posts: 78
- Joined: Tue Jun 07, 2022 11:23 am
- Libera.chat IRC: Cyao
- Location: France
- Contact:
Re: GCC optimization removing my function call
Ahhh ok, I thought the jump stuff had to do with other stuffOctocontrabass wrote:GCC is performing tail call optimization. Notice how the optimized main function ends with a JMP instead of a RET.
If your code isn't working, the problem is unrelated to this optimization.