compiler: emit correct alignment in debug info for global variables
Previously we were using a really weird calculation to determine the alignment in bits - written by me (no idea what I was thinking at the time, it's obviously incorrect). Just replace it with the much more obviously correct multiplication by 8 to get bits from bytes. Found while working on properly dealing with alignment in `-size=full`.
Этот коммит содержится в:
родитель
0b47b99448
коммит
0463d34887
1 изменённых файлов: 1 добавлений и 3 удалений
|
@ -433,7 +433,6 @@ func (c *compilerContext) getGlobal(g *ssa.Global) llvm.Value {
|
|||
llvmGlobal = llvm.AddGlobal(c.mod, llvmType, info.linkName)
|
||||
|
||||
// Set alignment from the //go:align comment.
|
||||
var alignInBits uint32
|
||||
alignment := c.targetData.ABITypeAlignment(llvmType)
|
||||
if info.align > alignment {
|
||||
alignment = info.align
|
||||
|
@ -444,7 +443,6 @@ func (c *compilerContext) getGlobal(g *ssa.Global) llvm.Value {
|
|||
c.addError(g.Pos(), "global variable alignment must be a positive power of two")
|
||||
} else {
|
||||
// Set the alignment only when it is a power of two.
|
||||
alignInBits = uint32(alignment) ^ uint32(alignment-1)
|
||||
llvmGlobal.SetAlignment(alignment)
|
||||
}
|
||||
|
||||
|
@ -459,7 +457,7 @@ func (c *compilerContext) getGlobal(g *ssa.Global) llvm.Value {
|
|||
Type: c.getDIType(typ),
|
||||
LocalToUnit: false,
|
||||
Expr: c.dibuilder.CreateExpression(nil),
|
||||
AlignInBits: alignInBits,
|
||||
AlignInBits: uint32(alignment) * 8,
|
||||
})
|
||||
llvmGlobal.AddMetadata(0, diglobal)
|
||||
}
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче