Skip to content

Commit d1d5ec4

Browse files
thomasfaingnaertJeffBezanson
authored andcommitted
Fix incorrect caching of Julia-LLVM type mapping with llvmcall (#34109)
1 parent 257907d commit d1d5ec4

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/cgutils.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,9 @@ static Type *julia_struct_to_llvm(jl_value_t *jt, jl_unionall_t *ua, bool *isbox
693693
#endif
694694
decl = StructType::get(jl_LLVMContext, latypes);
695695
}
696-
jst->struct_decl = decl;
696+
// don't use struct_decl cache for llvmcall
697+
if (!llvmcall)
698+
jst->struct_decl = decl;
697699
return decl;
698700
}
699701
}

test/llvmpasses/llvmcall.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
include(joinpath("..", "testhelpers", "llvmpasses.jl"))
77

88
@generated foo(x)=:(ccall("extern foo", llvmcall, $x, ($x,), x))
9+
bar(x) = ntuple(i -> VecElement{Float16}(x[i]), 2)
910

1011
# CHECK: call half @foo(half zeroext %{{[0-9]+}})
1112
emit(foo, Float16)
@@ -15,3 +16,6 @@ emit(foo, NTuple{2, Float16})
1516

1617
# CHECK: call <2 x half> @foo(<2 x half> %{{[0-9]+}})
1718
emit(foo, NTuple{2, VecElement{Float16}})
19+
20+
# CHECK: define <2 x i16> @julia_bar_{{[0-9]+}}([2 x i16]
21+
emit(bar, NTuple{2, Float16})

0 commit comments

Comments
 (0)