You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[globalopt] Propagate values of global let variables and global variables assigned only once into their uses.
Values of global let variables and global variables assigned only once are propagated into their uses and thus enable further optimizations like constant propagation, simplifications, etc.
The optimization is applied if the initializer is simple enough, i.e. it should be a constant expression, containing literals and other let variables or global variables which are assigned only once.
This is the final patch covering the remaining case where sources are compiled in a script mode.
The case of global let variables is easy. We just find all loads from the corresponding global_addresses and replace them with the known values assigned during their initialization.
The case of global variables, which are not "let", is more interesting. Only values of the following global variables are propagated:
- "private" variables with exactly one assignment
- "internal" variables with exactly one assignment, but only in the WMO compilation mode.
- address of variable should not be taken anywhere in the program, because if this happens, the value could be changed elsewhere indirectly.
rdar://19883795
Swift SVN r30157
0 commit comments