Skip to content

Commit 7ecc6d2

Browse files
committed
[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
1 parent 51ed070 commit 7ecc6d2

File tree

3 files changed

+548
-6
lines changed

3 files changed

+548
-6
lines changed

0 commit comments

Comments
 (0)