Skip to content

Commit d89cdec

Browse files
maleadtKristofferC
authored andcommitted
Fix alloc opt pass on LLVM 11+. (#39119)
(cherry picked from commit f5c8e67)
1 parent 336c71b commit d89cdec

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/llvm-alloc-opt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static bool hasObjref(Type *ty)
6666
return ptrty->getAddressSpace() == AddressSpace::Tracked;
6767
#if JL_LLVM_VERSION >= 110000
6868
if (isa<ArrayType>(ty) || isa<VectorType>(ty))
69-
return GetElementPtrInst::getTypeAtIndex(ty, (uint64_t)0);
69+
return hasObjref(GetElementPtrInst::getTypeAtIndex(ty, (uint64_t)0));
7070
#else
7171
if (auto seqty = dyn_cast<SequentialType>(ty))
7272
return hasObjref(seqty->getElementType());

test/llvmpasses/alloc-opt3.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This file is a part of Julia. License is MIT: https://julialang.org/license
2+
3+
# RUN: julia --startup-file=no %s %t -O
4+
# RUN: cat %t/* | FileCheck %s
5+
6+
include(joinpath("..", "testhelpers", "llvmpasses.jl"))
7+
8+
# JuliaLang/julia#38922
9+
function haszerolayout(x::NTuple{32, VecElement{UInt8}})
10+
rx = Ref(x)
11+
GC.@preserve rx begin
12+
lower = iszero(unsafe_load(Ptr{UInt128}(pointer_from_objref(rx)), 1))
13+
upper = iszero(unsafe_load(Ptr{UInt128}(pointer_from_objref(rx)), 2))
14+
lower & upper
15+
end
16+
end
17+
18+
# CHECK-LABEL: @julia_haszerolayout
19+
# CHECK: top:
20+
# CHECK-NOT: @jl_gc_pool_alloc
21+
# CHECK: extractelement
22+
# CHECK: ret i8
23+
emit(haszerolayout, NTuple{32,VecElement{UInt8}})

0 commit comments

Comments
 (0)