compiler: try harder to find source locations for constants
If there is no source location, at least use the file (but not line) for debug information. This attributes almost 1kB of string data for ./testdata/stdlib.go when compiling for WASI.
Этот коммит содержится в:
родитель
c6ac1cc969
коммит
1cb702ac4c
1 изменённых файлов: 8 добавлений и 0 удалений
|
@ -1863,6 +1863,14 @@ func (b *builder) createFunctionCall(instr *ssa.CallCommon) (llvm.Value, error)
|
|||
func (b *builder) getValue(expr ssa.Value, pos token.Pos) llvm.Value {
|
||||
switch expr := expr.(type) {
|
||||
case *ssa.Const:
|
||||
if pos == token.NoPos {
|
||||
// If the position isn't known, at least try to find in which file
|
||||
// it is defined.
|
||||
file := b.program.Fset.File(b.fn.Pos())
|
||||
if file != nil {
|
||||
pos = file.Pos(0)
|
||||
}
|
||||
}
|
||||
return b.createConst(expr, pos)
|
||||
case *ssa.Function:
|
||||
if b.getFunctionInfo(expr).exported {
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче