Skip to content
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
Closed

optimize #include files with macro guards #4

mycoboco opened this issue Nov 6, 2014 · 4 comments
Assignees
Labels

Comments

@mycoboco
Copy link
Owner

@mycoboco mycoboco commented Nov 6, 2014

No description provided.

@mycoboco mycoboco self-assigned this Nov 20, 2014
@mycoboco
Copy link
Owner Author

@mycoboco 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
Copy link
Owner Author

@mycoboco mycoboco commented Mar 6, 2015

Those bugs described above have been fixed by 2187744.

@mycoboco
Copy link
Owner Author

@mycoboco 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
Copy link
Owner Author

@mycoboco 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.