diff --git a/Compiler/test/codegen.jl b/Compiler/test/codegen.jl index 9ba268fe95be8..9b92f560c64fc 100644 --- a/Compiler/test/codegen.jl +++ b/Compiler/test/codegen.jl @@ -1036,3 +1036,8 @@ f56739(a) where {T} = a @test f56739(1) == 1 g56739(x) = @noinline f56739(x) @test g56739(1) == 1 + +struct Vec56937 x::NTuple{8, VecElement{Int}} end + +x56937 = Ref(Vec56937(ntuple(_->VecElement(1),8))) +@test x56937[].x[1] == VecElement{Int}(1) # shouldn't crash diff --git a/src/codegen.cpp b/src/codegen.cpp index 5bf7c74deedcb..714b8e930dd51 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -8916,6 +8916,8 @@ static jl_llvm_functions_t Type *RT = Arg->getParamStructRetType(); TypeSize sz = DL.getTypeAllocSize(RT); Align al = DL.getPrefTypeAlign(RT); + if (al > MAX_ALIGN) + al = Align(MAX_ALIGN); param.addAttribute(Attribute::NonNull); // The `dereferenceable` below does not imply `nonnull` for non addrspace(0) pointers. param.addDereferenceableAttr(sz); diff --git a/src/datatype.c b/src/datatype.c index c78b00fdd2245..fd25cca503676 100644 --- a/src/datatype.c +++ b/src/datatype.c @@ -769,6 +769,8 @@ void jl_compute_field_offsets(jl_datatype_t *st) if (al > alignm) alignm = al; } + if (alignm > MAX_ALIGN) + alignm = MAX_ALIGN; // We cannot guarantee alignments over 16 bytes because that's what our heap is aligned as if (LLT_ALIGN(sz, alignm) > sz) { haspadding = 1; sz = LLT_ALIGN(sz, alignm);