New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize #include files with macro guards #4

Closed
mycoboco opened this Issue Nov 6, 2014 · 4 comments

Comments

Projects
None yet
1 participant
@mycoboco
Owner

mycoboco commented Nov 6, 2014

No description provided.

@mycoboco mycoboco self-assigned this Nov 20, 2014

@mycoboco

This comment has been minimized.

Show comment
Hide comment
@mycoboco

mycoboco Mar 6, 2015

Owner

a35a585 has a bug - it cannot properly handle if a pp-directive follows a macro guard, e.g.,

#ifndef FOO
#define FOO
BODY1
#endif

#ifndef BAR
#define BAR
BODY2
#endif

sc incorrectly thinks this optimizable when BAR #defined, thus #undefining FOO does not bring the BODY1 part.

Similar examples include:

#ifndef FOO                                                                                           
#define FOO                                                                                           
BODY                                                                                                  
#endif                                                                                                

#pragma nothing 

and

#pragma nothing                                                                                       

#ifndef FOO                                                                                           
#define FOO                                                                                           
#endif

sc optimizes both even if it should not.

Owner

mycoboco commented Mar 6, 2015

a35a585 has a bug - it cannot properly handle if a pp-directive follows a macro guard, e.g.,

#ifndef FOO
#define FOO
BODY1
#endif

#ifndef BAR
#define BAR
BODY2
#endif

sc incorrectly thinks this optimizable when BAR #defined, thus #undefining FOO does not bring the BODY1 part.

Similar examples include:

#ifndef FOO                                                                                           
#define FOO                                                                                           
BODY                                                                                                  
#endif                                                                                                

#pragma nothing 

and

#pragma nothing                                                                                       

#ifndef FOO                                                                                           
#define FOO                                                                                           
#endif

sc optimizes both even if it should not.

@mycoboco

This comment has been minimized.

Show comment
Hide comment
@mycoboco

mycoboco Mar 6, 2015

Owner

Those bugs described above have been fixed by 2187744.

Owner

mycoboco commented Mar 6, 2015

Those bugs described above have been fixed by 2187744.

@mycoboco

This comment has been minimized.

Show comment
Hide comment
@mycoboco

mycoboco Mar 6, 2015

Owner

Performance improvement by macro guard optimization:

time for i in {1..100}; do sc decl.c > /dev/null 2>&1; done
gcc without opt with opt
6.3s 12.0s 9.3s
Owner

mycoboco commented Mar 6, 2015

Performance improvement by macro guard optimization:

time for i in {1..100}; do sc decl.c > /dev/null 2>&1; done
gcc without opt with opt
6.3s 12.0s 9.3s

@mycoboco mycoboco closed this Mar 6, 2015

@mycoboco

This comment has been minimized.

Show comment
Hide comment
@mycoboco

mycoboco Mar 7, 2015

Owner

State transition of mg_state and state for macro guard:

state transition for macro guard

Owner

mycoboco commented Mar 7, 2015

State transition of mg_state and state for macro guard:

state transition for macro guard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment