Skip to content

Commit b9671b0

Browse files
committed
fix julia_alignment
Make julia_alignment actually return the jl_datatype_align if `alignment == 0` and check that the requested alignment is coherent with the heap alignment.
1 parent ed286e4 commit b9671b0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/cgutils.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,9 +1169,10 @@ static Value *emit_bounds_check(const jl_cgval_t &ainfo, jl_value_t *ty, Value *
11691169
// It is currently unused, but might be used in the future for a more precise answer.
11701170
static unsigned julia_alignment(Value* /*ptr*/, jl_value_t *jltype, unsigned alignment)
11711171
{
1172-
if (!alignment && jl_datatype_align(jltype) > JL_HEAP_ALIGNMENT) {
1173-
// Type's natural alignment exceeds strictest alignment promised in heap, so return the heap alignment.
1174-
return JL_HEAP_ALIGNMENT;
1172+
if (!alignment) {
1173+
alignment = jl_datatype_align(jltype);
1174+
assert(alignment <= JL_HEAP_ALIGNMENT);
1175+
assert(JL_HEAP_ALIGNMENT % alignment == 0);
11751176
}
11761177
return alignment;
11771178
}

0 commit comments

Comments
 (0)