http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54553
Bug #: 54553
Summary: atribute optimize on function affects optimization for
other functions
Classification: Unclassified
Product: gcc
Version: 4.7.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: [email protected]
ReportedBy: [email protected]
Created attachment 28175
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28175
tar.gz of files described in the case including sources
We tried to use __attribute__((optimize(0))) on specific function for debug
purposes while compiling code with -O2 and we encountered a strange behaviour.
The function with attribute was not optimised, as expected but in addition all
other functions in the c file that includes h file with that attribute were not
optimised. My guess is that when compiler meets __attribute__ optimize - it
just treats it as if it was #pragma thus not restoring the previous
optimization state.
Where are several files attached:
1) test1.i
file with no __attribute__((optimize(0)))
2) test2.i
file with __attribute__((optimize(0)))
3) test1.s
assembly produced by test1 (f1, f2 and f3 are inlined)
4) test2.s
assembly produced by test1 (none of the functions are inlined)
5) complier.out
compiler output produced by
x86_64-apple-darwin12-gcc-4.7.1 -v test2.c -o test2 -O2 --save
P.S.: This dow not seems to be architecture dependent as we had a similar
problem with mips cross-compiler on windows platform.