Skip to content

compiler: consistently pass layout and alignment to createAlloc#5509

Open
niaow wants to merge 1 commit into
tinygo-org:devfrom
niaow:consistent-create-alloc
Open

compiler: consistently pass layout and alignment to createAlloc#5509
niaow wants to merge 1 commit into
tinygo-org:devfrom
niaow:consistent-create-alloc

Conversation

@niaow

@niaow niaow commented Jul 8, 2026

Copy link
Copy Markdown
Member

This resolves the // TODO: make sure all callsites set the correct alignment. from #5420 as well as some places where we did not pass the object layout.

@niaow
niaow requested a review from aykevl July 8, 2026 18:02
Comment thread compiler/gc.go

// Make the runtime call.
call := b.createRuntimeCall(allocFunc, []llvm.Value{sizeValue, layoutValue}, comment)
if align != 0 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this change, passing align=0 to createAlloc would produce an align 0 LLVM attribute, which is invalid in LLVM IR (alignment must be a power of 2 or omitted). The PR assumes all callsites are fixed, but if any future callsite passes 0, it would produce broken IR silently. Consider adding an assertion/panic if align == 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants