Skip to content

Commit

Permalink
conv:abi: Include abi alignment when reconstructing aggregates.
Browse files Browse the repository at this point in the history
  • Loading branch information
lkorenc authored and xlauko committed Nov 20, 2023
1 parent 277105d commit 408c661
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/vast/Conversion/ABI/AggregateTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ namespace vast::conv::abi
++arg_idx;
offset = 0;
}

void adjust_by_align(mlir_type type)
{
auto align = parent.dl.getTypeABIAlignment(type) * 8;
if (offset % align != 0)
offset += align - (offset % align);
}
};

// TODO(conv:abi): Issue #423 - figure out how to make this not adhoc.
Expand Down Expand Up @@ -113,6 +120,8 @@ namespace vast::conv::abi
if (needs_nesting(field_type))
return self_t(state, mod).run_on(field_type, rewriter);

state.adjust_by_align(field_type);

if (!state.fits(field_type))
state.advance();
return state.allocate(field_type, rewriter);
Expand Down

0 comments on commit 408c661

Please sign in to comment.