From 861551b2ba73955bec4eccced0a2e70feb32b8d1 Mon Sep 17 00:00:00 2001 From: luoliwoshang <2643523683@qq.com> Date: Thu, 11 Jul 2024 21:16:50 +0800 Subject: [PATCH] update:extra alignment for structs only --- ssa/type.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ssa/type.go b/ssa/type.go index 67c0ca17..af48f47c 100644 --- a/ssa/type.go +++ b/ssa/type.go @@ -114,7 +114,11 @@ func (p *goProgram) Offsetsof(fields []*types.Var) (ret []int64) { func (p *goProgram) Sizeof(T types.Type) int64 { prog := Program(p) ptrSize := int64(prog.PointerSize()) - return align((prog.sizes.Sizeof(T) + extraSize(T, ptrSize)), prog.sizes.Alignof(T)) + baseSize := prog.sizes.Sizeof(T) + extraSize(T, ptrSize) + if _, ok := T.Underlying().(*types.Struct); ok { + return align(baseSize, prog.sizes.Alignof(T)) + } + return baseSize } func extraSize(t types.Type, ptrSize int64) (ret int64) {