Commit 6b4e685
[Clang][SYCL] Fix dangling pointers and ODR violation in free functions (#20422)
**Problems**
Problem 1: When a library consisting of free function kernels is
registered with SYCL RT, we store pointers (as `string_view`) to free
function names in `m_FreeFunctionKernelGlobalInfo` but we do not remove
them from `m_FreeFunctionKernelGlobalInfo` when the library is unloaded.
Thus, we end up holding dangling pointers and any further operation on
`m_FreeFunctionKernelGlobalInfo` might segfault.
Problem 2: Consider the case when you have multiple TUs with free
functions and they are compiled separately but linked together into a
single shared lib. In that case, we will have multiple definition of
`static GlobalMapUpdater updater` in the shared lib => violating ODR
**Solution**
Discard pointers to free function names when library is unloaded and
have `GlobalMapUpdater` defined in anonymous namespace, instead of
`sycl::v1::detail`
---------
Co-authored-by: premanandrao <premanand.m.rao@intel.com>1 parent faadbce commit 6b4e685
File tree
11 files changed
+65
-32
lines changed- clang
- lib/Sema
- test
- CodeGenSYCL
- SemaSYCL/Inputs/sycl/detail
- sycl
- include/sycl/detail
- source/detail
- program_manager
- test/abi
11 files changed
+65
-32
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7302 | 7302 | | |
7303 | 7303 | | |
7304 | 7304 | | |
| 7305 | + | |
| 7306 | + | |
| 7307 | + | |
| 7308 | + | |
| 7309 | + | |
| 7310 | + | |
| 7311 | + | |
7305 | 7312 | | |
7306 | 7313 | | |
7307 | | - | |
7308 | | - | |
7309 | | - | |
| 7314 | + | |
7310 | 7315 | | |
7311 | 7316 | | |
7312 | 7317 | | |
7313 | 7318 | | |
7314 | 7319 | | |
7315 | 7320 | | |
| 7321 | + | |
| 7322 | + | |
| 7323 | + | |
| 7324 | + | |
| 7325 | + | |
7316 | 7326 | | |
7317 | 7327 | | |
7318 | | - | |
7319 | | - | |
7320 | | - | |
| 7328 | + | |
7321 | 7329 | | |
7322 | 7330 | | |
7323 | 7331 | | |
| |||
Lines changed: 5 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1087 | 1087 | | |
1088 | 1088 | | |
1089 | 1089 | | |
1090 | | - | |
1091 | | - | |
1092 | | - | |
| 1090 | + | |
1093 | 1091 | | |
1094 | 1092 | | |
1095 | 1093 | | |
1096 | 1094 | | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
1097 | 1098 | | |
1098 | 1099 | | |
1099 | | - | |
1100 | | - | |
1101 | | - | |
| 1100 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1567 | 1567 | | |
1568 | 1568 | | |
1569 | 1569 | | |
1570 | | - | |
1571 | | - | |
1572 | | - | |
| 1570 | + | |
1573 | 1571 | | |
1574 | 1572 | | |
1575 | 1573 | | |
1576 | 1574 | | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
1577 | 1578 | | |
1578 | 1579 | | |
1579 | | - | |
1580 | | - | |
1581 | | - | |
| 1580 | + | |
Lines changed: 5 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
79 | | - | |
80 | | - | |
| 78 | + | |
81 | 79 | | |
82 | 80 | | |
83 | 81 | | |
84 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
85 | 86 | | |
86 | 87 | | |
87 | | - | |
88 | | - | |
89 | | - | |
| 88 | + | |
Lines changed: 3 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
| 13 | + | |
16 | 14 | | |
17 | 15 | | |
18 | 16 | | |
| 17 | + | |
19 | 18 | | |
20 | 19 | | |
21 | | - | |
22 | | - | |
23 | | - | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
26 | 37 | | |
27 | 38 | | |
28 | 39 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2418 | 2418 | | |
2419 | 2419 | | |
2420 | 2420 | | |
2421 | | - | |
| 2421 | + | |
2422 | 2422 | | |
2423 | | - | |
2424 | 2423 | | |
2425 | 2424 | | |
2426 | 2425 | | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
| 2430 | + | |
| 2431 | + | |
| 2432 | + | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
2427 | 2437 | | |
2428 | 2438 | | |
2429 | 2439 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
262 | 268 | | |
263 | 269 | | |
264 | 270 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3344 | 3344 | | |
3345 | 3345 | | |
3346 | 3346 | | |
| 3347 | + | |
3347 | 3348 | | |
3348 | 3349 | | |
3349 | 3350 | | |
| |||
0 commit comments