Skip to content

Commit

Permalink
Fix GC assertion on array of derived pointers (JuliaLang#47299)
Browse files Browse the repository at this point in the history
* Fix GC assertion on array of derived pointers

* Add test
  • Loading branch information
wsmoses committed Oct 25, 2022
1 parent 1a7a131 commit d885fc7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/llvm-late-gc-lowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ unsigned getCompositeNumElements(Type *T) {
// Walk through a Type, and record the element path to every tracked value inside
void TrackCompositeType(Type *T, std::vector<unsigned> &Idxs, std::vector<std::vector<unsigned>> &Numberings) {
if (isa<PointerType>(T)) {
if (T->getPointerAddressSpace() == AddressSpace::Tracked)
if (isSpecialPtr(T))
Numberings.push_back(Idxs);
}
else if (isa<StructType>(T) || isa<ArrayType>(T) || isa<VectorType>(T)) {
Expand Down
19 changes: 19 additions & 0 deletions test/llvmpasses/late-lower-gc.ll
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,25 @@ define {} addrspace(10)* @gclift_switch({} addrspace(13)* addrspace(10)* %input,
ret {} addrspace(10)* %ret
}

define void @decayar([2 x {} addrspace(10)* addrspace(11)*] %ar) {
%v2 = call {}*** @julia.get_pgcstack()
%e0 = extractvalue [2 x {} addrspace(10)* addrspace(11)*] %ar, 0
%l0 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %e0
%e1 = extractvalue [2 x {} addrspace(10)* addrspace(11)*] %ar, 1
%l1 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %e1
%r = call i32 @callee_root({} addrspace(10)* %l0, {} addrspace(10)* %l1)
ret void
}

; CHECK-LABEL: @decayar
; CHECK: %gcframe = call {} addrspace(10)** @julia.new_gc_frame(i32 2)
; CHECK: %1 = call {} addrspace(10)** @julia.get_gc_frame_slot({} addrspace(10)** %gcframe, i32 1)
; CHECK: store {} addrspace(10)* %l0, {} addrspace(10)** %1, align 8
; CHECK: %2 = call {} addrspace(10)** @julia.get_gc_frame_slot({} addrspace(10)** %gcframe, i32 0)
; CHECK: store {} addrspace(10)* %l1, {} addrspace(10)** %2, align 8
; CHECK: %r = call i32 @callee_root({} addrspace(10)* %l0, {} addrspace(10)* %l1)
; CHECK: call void @julia.pop_gc_frame({} addrspace(10)** %gcframe)

!0 = !{i64 0, i64 23}
!1 = !{!1}
!2 = !{!7} ; scope list
Expand Down

0 comments on commit d885fc7

Please sign in to comment.