Skip to content

Commit 7ff3900

Browse files
wsmosesKristofferC
authored andcommitted
Fix GC assertion on array of derived pointers (#47299)
* Fix GC assertion on array of derived pointers * Add test (cherry picked from commit d885fc7)
1 parent 36a17ad commit 7ff3900

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/llvm-late-gc-lowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ unsigned getCompositeNumElements(Type *T) {
419419
// Walk through a Type, and record the element path to every tracked value inside
420420
void TrackCompositeType(Type *T, std::vector<unsigned> &Idxs, std::vector<std::vector<unsigned>> &Numberings) {
421421
if (isa<PointerType>(T)) {
422-
if (T->getPointerAddressSpace() == AddressSpace::Tracked)
422+
if (isSpecialPtr(T))
423423
Numberings.push_back(Idxs);
424424
}
425425
else if (isa<StructType>(T) || isa<ArrayType>(T) || isa<VectorType>(T)) {

test/llvmpasses/late-lower-gc.ll

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,25 @@ top:
124124
; CHECK: ret i32
125125
}
126126

127+
define void @decayar([2 x {} addrspace(10)* addrspace(11)*] %ar) {
128+
%v2 = call {}*** @julia.get_pgcstack()
129+
%e0 = extractvalue [2 x {} addrspace(10)* addrspace(11)*] %ar, 0
130+
%l0 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %e0
131+
%e1 = extractvalue [2 x {} addrspace(10)* addrspace(11)*] %ar, 1
132+
%l1 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %e1
133+
%r = call i32 @callee_root({} addrspace(10)* %l0, {} addrspace(10)* %l1)
134+
ret void
135+
}
136+
137+
; CHECK-LABEL: @decayar
138+
; CHECK: %gcframe = call {} addrspace(10)** @julia.new_gc_frame(i32 2)
139+
; CHECK: %1 = call {} addrspace(10)** @julia.get_gc_frame_slot({} addrspace(10)** %gcframe, i32 1)
140+
; CHECK: store {} addrspace(10)* %l0, {} addrspace(10)** %1, align 8
141+
; CHECK: %2 = call {} addrspace(10)** @julia.get_gc_frame_slot({} addrspace(10)** %gcframe, i32 0)
142+
; CHECK: store {} addrspace(10)* %l1, {} addrspace(10)** %2, align 8
143+
; CHECK: %r = call i32 @callee_root({} addrspace(10)* %l0, {} addrspace(10)* %l1)
144+
; CHECK: call void @julia.pop_gc_frame({} addrspace(10)** %gcframe)
145+
127146
!0 = !{i64 0, i64 23}
128147
!1 = !{}
129148
!2 = distinct !{!2}

0 commit comments

Comments
 (0)