Skip to content

Commit d885fc7

Browse files
authored
Fix GC assertion on array of derived pointers (#47299)
* Fix GC assertion on array of derived pointers * Add test
1 parent 1a7a131 commit d885fc7

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
@@ -426,7 +426,7 @@ unsigned getCompositeNumElements(Type *T) {
426426
// Walk through a Type, and record the element path to every tracked value inside
427427
void TrackCompositeType(Type *T, std::vector<unsigned> &Idxs, std::vector<std::vector<unsigned>> &Numberings) {
428428
if (isa<PointerType>(T)) {
429-
if (T->getPointerAddressSpace() == AddressSpace::Tracked)
429+
if (isSpecialPtr(T))
430430
Numberings.push_back(Idxs);
431431
}
432432
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
@@ -148,6 +148,25 @@ define {} addrspace(10)* @gclift_switch({} addrspace(13)* addrspace(10)* %input,
148148
ret {} addrspace(10)* %ret
149149
}
150150

151+
define void @decayar([2 x {} addrspace(10)* addrspace(11)*] %ar) {
152+
%v2 = call {}*** @julia.get_pgcstack()
153+
%e0 = extractvalue [2 x {} addrspace(10)* addrspace(11)*] %ar, 0
154+
%l0 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %e0
155+
%e1 = extractvalue [2 x {} addrspace(10)* addrspace(11)*] %ar, 1
156+
%l1 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %e1
157+
%r = call i32 @callee_root({} addrspace(10)* %l0, {} addrspace(10)* %l1)
158+
ret void
159+
}
160+
161+
; CHECK-LABEL: @decayar
162+
; CHECK: %gcframe = call {} addrspace(10)** @julia.new_gc_frame(i32 2)
163+
; CHECK: %1 = call {} addrspace(10)** @julia.get_gc_frame_slot({} addrspace(10)** %gcframe, i32 1)
164+
; CHECK: store {} addrspace(10)* %l0, {} addrspace(10)** %1, align 8
165+
; CHECK: %2 = call {} addrspace(10)** @julia.get_gc_frame_slot({} addrspace(10)** %gcframe, i32 0)
166+
; CHECK: store {} addrspace(10)* %l1, {} addrspace(10)** %2, align 8
167+
; CHECK: %r = call i32 @callee_root({} addrspace(10)* %l0, {} addrspace(10)* %l1)
168+
; CHECK: call void @julia.pop_gc_frame({} addrspace(10)** %gcframe)
169+
151170
!0 = !{i64 0, i64 23}
152171
!1 = !{!1}
153172
!2 = !{!7} ; scope list

0 commit comments

Comments
 (0)