Register R0 is not used sometimes
Bug #1790343 reported by
Harjit Singh
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GNU Arm Embedded Toolchain |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Please refer to https:/
The second column - the ARM version - is the one with the issue.
The function test() is compiled to "_Z4testv:" and it doesn't use R0. Instead, it uses R4 which results in R4 being saved and restored.
Using option -O3 doesn't change this.
Interestingly, main() which has essentially the same code does use R0 as expected.
Thanks for looking into this.
To post a comment you must log in.
Test is missing a return statement. I think main is compiled more efficiently because it can see that the value in the ptr field is the same as the value being returned so it's happy to put ptr into r0. For test the return is missing so the compiler might be assuming that r0 should not be reused.
Best regards.