Commit 325ae8e
authored
Fixed a crash when linker erases functions that still have users. (#5437)
When linking to library with a list of `-exports`, the linker erases
functions that are not exported assuming they are no longer used. This
assumption is not correct when the function is a constructor for a
global variable. This change fixes the crash by first checking whether
the function still has uses before erasing.
This change adds a regression test with a non-trivially removable global
variable constructor that would crash without this change.1 parent cdee446 commit 325ae8e
2 files changed
Lines changed: 30 additions & 1 deletion
File tree
- lib/HLSL
- tools/clang/test/HLSLFileCheck/shader_targets/library
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
959 | 959 | | |
960 | 960 | | |
961 | 961 | | |
962 | | - | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
963 | 967 | | |
964 | 968 | | |
965 | 969 | | |
| |||
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
0 commit comments