@@ -22,6 +22,7 @@ type ExprTypeInfo struct {
2222
2323type LLVMTypeMap struct {
2424 TypeStringer
25+ types.StdSizes
2526 target llvm.TargetData
2627 inttype llvm.Type
2728
@@ -80,7 +81,11 @@ func NewLLVMTypeMap(target llvm.TargetData) *LLVMTypeMap {
8081 inttype = llvm .Int32Type ()
8182 }
8283 return & LLVMTypeMap {
83- target : target ,
84+ target : target ,
85+ StdSizes : types.StdSizes {
86+ WordSize : int64 (target .PointerSize ()),
87+ MaxAlign : 8 ,
88+ },
8489 types : make (map [string ]llvm.Type ),
8590 inttype : inttype ,
8691 }
@@ -399,7 +404,7 @@ func (tm *LLVMTypeMap) Alignof(typ types.Type) int64 {
399404 case types .Uintptr , types .UnsafePointer , types .String :
400405 return int64 (tm .target .PointerSize ())
401406 }
402- return types . DefaultAlignof (typ )
407+ return tm . StdSizes . Alignof (typ )
403408 case * types.Struct :
404409 max := int64 (1 )
405410 for i := 0 ; i < typ .NumFields (); i ++ {
@@ -422,10 +427,8 @@ func (tm *LLVMTypeMap) Sizeof(typ types.Type) int64 {
422427 return int64 (tm .target .TypeAllocSize (tm .inttype ))
423428 case types .Uintptr , types .UnsafePointer :
424429 return int64 (tm .target .PointerSize ())
425- case types .String :
426- return 2 * int64 (tm .target .PointerSize ())
427430 }
428- return types . DefaultSizeof (typ )
431+ return tm . StdSizes . Sizeof (typ )
429432 case * types.Array :
430433 eltsize := tm .Sizeof (typ .Elem ())
431434 eltalign := tm .Alignof (typ .Elem ())
0 commit comments