Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix LLVM byte alignment for real #803

Merged
merged 2 commits into from
Jan 27, 2025
Merged

Conversation

marvinborner
Copy link
Member

Closes #794.

I've also added a test but it's a bit useless since the buggy parts all get optimized away and we currently only run tests with optimizations.

@marvinborner marvinborner requested a review from phischu January 26, 2025 17:15
@@ -580,19 +580,22 @@ object Transformer {
}

def pushFrameOnto(stack: Operand, environment: machine.Environment, returnAddressName: String, sharer: Operand, eraser: Operand)(using ModuleContext, FunctionContext, BlockContext) = {
if (!environment.isEmpty) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Should we create an additional function for this? (like in popEnvironmentFrom)

@marvinborner
Copy link
Member Author

After some more thought I'm not sure how my initial change would fix all of the alignment problems.

Would my second solution in which we use packed structural types, also be okay (2-byte change)? In general not packing structs has all kinds of potential benefits for performance but they don't apply to us anyway, since such optimizations would segfault right now(?). Because our stack allocation is fundamentally based on knowing the exact allocation size, I believe this to be the only correct choice.

@marvinborner marvinborner changed the title Fix LLVM byte alignment by pushing separately Fix LLVM byte alignment for real Jan 26, 2025
@@ -428,7 +428,7 @@ object Transformer {
case machine.Type.Prompt() => 8 // TODO Make fat?
case machine.Type.Stack() => 8 // TODO Make fat?
case machine.Type.Int() => 8 // TODO Make fat?
case machine.Type.Byte() => 8
case machine.Type.Byte() => 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Didn't @phischu just change this from 1 to 8 to fix something else?

Copy link
Member Author

Choose a reason for hiding this comment

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

This was an insufficient fix as described in #785 (comment)

@b-studios
Copy link
Collaborator

I'll interpret the thumbs up by @phischu as an approve and merge this :)

@b-studios b-studios merged commit acb9c98 into master Jan 27, 2025
2 checks passed
@b-studios b-studios deleted the fix/unpredictable-byte-alignment branch January 27, 2025 13:54
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.

Properly fix alignment of bytes on stack
2 participants