OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 11:16 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: GCC optimization removing my function call
PostPosted: Fri Nov 18, 2022 3:20 pm 
Offline
Member
Member

Joined: Tue Jun 07, 2022 11:23 am
Posts: 78
Location: France
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)

_________________
https://github.com/cheyao/Achieve-Core


Top
 Profile  
 
 Post subject: Re: GCC optimization removing my function call
PostPosted: Fri Nov 18, 2022 3:35 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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.


Top
 Profile  
 
 Post subject: Re: GCC optimization removing my function call
PostPosted: Sat Nov 19, 2022 1:13 am 
Offline
Member
Member

Joined: Tue Jun 07, 2022 11:23 am
Posts: 78
Location: France
Octocontrabass 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.

Ahhh ok, I thought the jump stuff had to do with other stuff

_________________
https://github.com/cheyao/Achieve-Core


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 71 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group