compiler: Set actual initializer for global variables
In the Go SSA, global variables are initialized in the init() function instead of declaring them in the global itself. Work around this oddity by simply setting the correct initializer when we find this global. This should produce more efficient code, both in RAM and code size. Apparently LLVM didn't optimize it away on it's own.
Этот коммит содержится в:
родитель
c5a82bb916
коммит
b11a618d99
1 изменённых файлов: 5 добавлений и 1 удалений
6
tgo.go
6
tgo.go
|
@ -583,7 +583,11 @@ func (c *Compiler) parseInstr(frame *Frame, instr ssa.Instruction) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c.builder.CreateStore(val, addr)
|
||||
if instr.Parent().Synthetic == "package initializer" {
|
||||
addr.SetInitializer(val)
|
||||
} else {
|
||||
c.builder.CreateStore(val, addr)
|
||||
}
|
||||
return nil
|
||||
default:
|
||||
return errors.New("unknown instruction: " + fmt.Sprintf("%#v", instr))
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче