compiler: do not remove dead globals
These were not removed when they contain data, and will be removed by LLVM anyway.
Этот коммит содержится в:
родитель
b0aeaed635
коммит
1f2af7d848
2 изменённых файлов: 1 добавлений и 20 удалений
1
ir.go
1
ir.go
|
@ -50,7 +50,6 @@ type Function struct {
|
|||
type Global struct {
|
||||
g *ssa.Global
|
||||
llvmGlobal llvm.Value
|
||||
flag bool // used by dead code elimination
|
||||
initializer Value
|
||||
}
|
||||
|
||||
|
|
20
passes.go
20
passes.go
|
@ -254,13 +254,10 @@ func (p *Program) AnalyseGoCalls() {
|
|||
// Simple pass that removes dead code. This pass makes later analysis passes
|
||||
// more useful.
|
||||
func (p *Program) SimpleDCE() {
|
||||
// Unmark all functions and globals.
|
||||
// Unmark all functions.
|
||||
for _, f := range p.Functions {
|
||||
f.flag = false
|
||||
}
|
||||
for _, f := range p.Globals {
|
||||
f.flag = false
|
||||
}
|
||||
|
||||
// Initial set of live functions. Include main.main, *.init and runtime.*
|
||||
// functions.
|
||||
|
@ -316,10 +313,6 @@ func (p *Program) SimpleDCE() {
|
|||
f.flag = true
|
||||
worklist = append(worklist, operand)
|
||||
}
|
||||
case *ssa.Global:
|
||||
// TODO: globals that reference other globals
|
||||
global := p.GetGlobal(operand)
|
||||
global.flag = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -336,17 +329,6 @@ func (p *Program) SimpleDCE() {
|
|||
}
|
||||
}
|
||||
p.Functions = livefunctions
|
||||
|
||||
// Remove unmarked globals.
|
||||
liveglobals := []*Global{}
|
||||
for _, g := range p.Globals {
|
||||
if g.flag {
|
||||
liveglobals = append(liveglobals, g)
|
||||
} else {
|
||||
delete(p.globalMap, g.g)
|
||||
}
|
||||
}
|
||||
p.Globals = liveglobals
|
||||
}
|
||||
|
||||
// Whether this function needs a scheduler.
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче