Skip to content

Commit 17afb84

Browse files
wsmosesstaticfloat
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 43a4e2a commit 17afb84

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
@@ -420,7 +420,7 @@ unsigned getCompositeNumElements(Type *T) {
420420
// Walk through a Type, and record the element path to every tracked value inside
421421
void TrackCompositeType(Type *T, std::vector<unsigned> &Idxs, std::vector<std::vector<unsigned>> &Numberings) {
422422
if (isa<PointerType>(T)) {
423-
if (T->getPointerAddressSpace() == AddressSpace::Tracked)
423+
if (isSpecialPtr(T))
424424
Numberings.push_back(Idxs);
425425
}
426426
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
@@ -93,6 +93,25 @@ top:
9393
; CHECK: ret i32
9494
}
9595

96+
define void @decayar([2 x {} addrspace(10)* addrspace(11)*] %ar) {
97+
%v2 = call {}*** @julia.get_pgcstack()
98+
%e0 = extractvalue [2 x {} addrspace(10)* addrspace(11)*] %ar, 0
99+
%l0 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %e0
100+
%e1 = extractvalue [2 x {} addrspace(10)* addrspace(11)*] %ar, 1
101+
%l1 = load {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %e1
102+
%r = call i32 @callee_root({} addrspace(10)* %l0, {} addrspace(10)* %l1)
103+
ret void
104+
}
105+
106+
; CHECK-LABEL: @decayar
107+
; CHECK: %gcframe = call {} addrspace(10)** @julia.new_gc_frame(i32 2)
108+
; CHECK: %1 = call {} addrspace(10)** @julia.get_gc_frame_slot({} addrspace(10)** %gcframe, i32 1)
109+
; CHECK: store {} addrspace(10)* %l0, {} addrspace(10)** %1, align 8
110+
; CHECK: %2 = call {} addrspace(10)** @julia.get_gc_frame_slot({} addrspace(10)** %gcframe, i32 0)
111+
; CHECK: store {} addrspace(10)* %l1, {} addrspace(10)** %2, align 8
112+
; CHECK: %r = call i32 @callee_root({} addrspace(10)* %l0, {} addrspace(10)* %l1)
113+
; CHECK: call void @julia.pop_gc_frame({} addrspace(10)** %gcframe)
114+
96115
!0 = !{i64 0, i64 23}
97116
!1 = !{}
98117
!2 = distinct !{!2}

0 commit comments

Comments
 (0)