Commit efc43cb
authored
[late-gc-lowering] null-out GC frame slots for dead objects (JuliaLang#52935)
Should fix JuliaLang#51818.
MWE:
```julia
function testme()
X = @noinline rand(1_000_000_00)
Y = @noinline sum(X)
X = nothing
GC.gc()
return Y
end
```
Note that it now stores a `NULL` in the GC frame before calling
`jl_gc_collect`.
Before:
```llvm
; Function Signature: testme()
; @ /Users/dnetto/Personal/test.jl:3 within `testme`
define double @julia_testme_535() #0 {
top:
%gcframe1 = alloca [3 x ptr], align 16
call void @llvm.memset.p0.i64(ptr align 16 %gcframe1, i8 0, i64 24, i1 true)
%pgcstack = call ptr inttoptr (i64 6595051180 to ptr)(i64 262) #10
store i64 4, ptr %gcframe1, align 16
%task.gcstack = load ptr, ptr %pgcstack, align 8
%frame.prev = getelementptr inbounds ptr, ptr %gcframe1, i64 1
store ptr %task.gcstack, ptr %frame.prev, align 8
store ptr %gcframe1, ptr %pgcstack, align 8
; @ /Users/dnetto/Personal/test.jl:4 within `testme`
%0 = call nonnull ptr @j_rand_539(i64 signext 100000000)
%gc_slot_addr_0 = getelementptr inbounds ptr, ptr %gcframe1, i64 2
store ptr %0, ptr %gc_slot_addr_0, align 16
; @ /Users/dnetto/Personal/test.jl:5 within `testme`
%1 = call double @j_sum_541(ptr nonnull %0)
; @ /Users/dnetto/Personal/test.jl:7 within `testme`
; ┌ @ gcutils.jl:132 within `gc` @ gcutils.jl:132
call void @jlplt_ijl_gc_collect_543_got.jit(i32 1)
%frame.prev4 = load ptr, ptr %frame.prev, align 8
store ptr %frame.prev4, ptr %pgcstack, align 8
; └
; @ /Users/dnetto/Personal/test.jl:8 within `testme`
ret double %1
}
```
After:
```llvm
; Function Signature: testme()
; @ /Users/dnetto/Personal/test.jl:3 within `testme`
define double @julia_testme_752() #0 {
top:
%gcframe1 = alloca [3 x ptr], align 16
call void @llvm.memset.p0.i64(ptr align 16 %gcframe1, i8 0, i64 24, i1 true)
%pgcstack = call ptr inttoptr (i64 6595051180 to ptr)(i64 262) #10
store i64 4, ptr %gcframe1, align 16
%task.gcstack = load ptr, ptr %pgcstack, align 8
%frame.prev = getelementptr inbounds ptr, ptr %gcframe1, i64 1
store ptr %task.gcstack, ptr %frame.prev, align 8
store ptr %gcframe1, ptr %pgcstack, align 8
; @ /Users/dnetto/Personal/test.jl:4 within `testme`
%0 = call nonnull ptr @j_rand_756(i64 signext 100000000)
%gc_slot_addr_0 = getelementptr inbounds ptr, ptr %gcframe1, i64 2
store ptr %0, ptr %gc_slot_addr_0, align 16
; @ /Users/dnetto/Personal/test.jl:5 within `testme`
%1 = call double @j_sum_758(ptr nonnull %0)
store ptr null, ptr %gc_slot_addr_0, align 16
; @ /Users/dnetto/Personal/test.jl:7 within `testme`
; ┌ @ gcutils.jl:132 within `gc` @ gcutils.jl:132
call void @jlplt_ijl_gc_collect_760_got.jit(i32 1)
%frame.prev6 = load ptr, ptr %frame.prev, align 8
store ptr %frame.prev6, ptr %pgcstack, align 8
; └
; @ /Users/dnetto/Personal/test.jl:8 within `testme`
ret double %1
}
```1 parent bce3d4d commit efc43cb
File tree
4 files changed
+62
-12
lines changed- src
- test
- compiler
- llvmpasses
4 files changed
+62
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
356 | | - | |
| 356 | + | |
357 | 357 | | |
358 | | - | |
359 | | - | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
360 | 361 | | |
361 | 362 | | |
362 | 363 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1820 | 1820 | | |
1821 | 1821 | | |
1822 | 1822 | | |
1823 | | - | |
| 1823 | + | |
1824 | 1824 | | |
1825 | 1825 | | |
1826 | 1826 | | |
| |||
1862 | 1862 | | |
1863 | 1863 | | |
1864 | 1864 | | |
1865 | | - | |
| 1865 | + | |
1866 | 1866 | | |
1867 | 1867 | | |
1868 | 1868 | | |
| |||
2292 | 2292 | | |
2293 | 2293 | | |
2294 | 2294 | | |
| 2295 | + | |
| 2296 | + | |
| 2297 | + | |
| 2298 | + | |
| 2299 | + | |
| 2300 | + | |
| 2301 | + | |
| 2302 | + | |
| 2303 | + | |
| 2304 | + | |
| 2305 | + | |
| 2306 | + | |
| 2307 | + | |
2295 | 2308 | | |
2296 | | - | |
| 2309 | + | |
2297 | 2310 | | |
2298 | 2311 | | |
2299 | 2312 | | |
| |||
2306 | 2319 | | |
2307 | 2320 | | |
2308 | 2321 | | |
| 2322 | + | |
| 2323 | + | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
2309 | 2331 | | |
2310 | 2332 | | |
2311 | 2333 | | |
| |||
2317 | 2339 | | |
2318 | 2340 | | |
2319 | 2341 | | |
2320 | | - | |
| 2342 | + | |
2321 | 2343 | | |
2322 | 2344 | | |
2323 | 2345 | | |
| |||
2439 | 2461 | | |
2440 | 2462 | | |
2441 | 2463 | | |
2442 | | - | |
| 2464 | + | |
2443 | 2465 | | |
2444 | 2466 | | |
2445 | 2467 | | |
| |||
2464 | 2486 | | |
2465 | 2487 | | |
2466 | 2488 | | |
2467 | | - | |
| 2489 | + | |
2468 | 2490 | | |
2469 | | - | |
| 2491 | + | |
2470 | 2492 | | |
2471 | 2493 | | |
2472 | 2494 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1003 | 1003 | | |
1004 | 1004 | | |
1005 | 1005 | | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
17 | 22 | | |
18 | 23 | | |
19 | 24 | | |
| |||
0 commit comments