Skip to content

Commit a1be1cb

Browse files
committed
[cc] key aarch64 frame fix
1 parent 881a5c7 commit a1be1cb

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

cc/arch/aarch64/codegen.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,9 +619,12 @@ impl RegAlloc {
619619
}
620620
PseudoKind::Sym(name) => {
621621
// Check if this is a local variable or a global symbol
622-
if func.locals.contains_key(name) {
623-
// Local variable - allocate stack space
624-
self.stack_offset += 8;
622+
if let Some(local) = func.locals.get(name) {
623+
// Local variable - allocate stack space based on actual type size
624+
let size = local.typ.size_bytes().max(8) as i32;
625+
// Align to 8 bytes
626+
let aligned_size = (size + 7) & !7;
627+
self.stack_offset += aligned_size;
625628
self.locations
626629
.insert(interval.pseudo, Loc::Stack(-self.stack_offset));
627630
} else {

0 commit comments

Comments
 (0)