compiler: avoid accidentally emitting debug info
Этот коммит содержится в:
родитель
bce697bcc1
коммит
e751e4afe9
1 изменённых файлов: 21 добавлений и 15 удалений
|
@ -434,12 +434,14 @@ func (c *Compiler) Compile(mainPath string) error {
|
||||||
// that calls the initializer of each package.
|
// that calls the initializer of each package.
|
||||||
initFn := c.ir.GetFunction(c.ir.Program.ImportedPackage("runtime").Members["initAll"].(*ssa.Function))
|
initFn := c.ir.GetFunction(c.ir.Program.ImportedPackage("runtime").Members["initAll"].(*ssa.Function))
|
||||||
initFn.LLVMFn.SetLinkage(llvm.InternalLinkage)
|
initFn.LLVMFn.SetLinkage(llvm.InternalLinkage)
|
||||||
difunc, err := c.attachDebugInfo(initFn)
|
if c.Debug {
|
||||||
if err != nil {
|
difunc, err := c.attachDebugInfo(initFn)
|
||||||
return err
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
pos := c.ir.Program.Fset.Position(initFn.Pos())
|
||||||
|
c.builder.SetCurrentDebugLocation(uint(pos.Line), uint(pos.Column), difunc, llvm.Metadata{})
|
||||||
}
|
}
|
||||||
pos := c.ir.Program.Fset.Position(initFn.Pos())
|
|
||||||
c.builder.SetCurrentDebugLocation(uint(pos.Line), uint(pos.Column), difunc, llvm.Metadata{})
|
|
||||||
block := c.ctx.AddBasicBlock(initFn.LLVMFn, "entry")
|
block := c.ctx.AddBasicBlock(initFn.LLVMFn, "entry")
|
||||||
c.builder.SetInsertPointAtEnd(block)
|
c.builder.SetInsertPointAtEnd(block)
|
||||||
for _, fn := range c.initFuncs {
|
for _, fn := range c.initFuncs {
|
||||||
|
@ -449,12 +451,14 @@ func (c *Compiler) Compile(mainPath string) error {
|
||||||
|
|
||||||
mainWrapper := c.ir.GetFunction(c.ir.Program.ImportedPackage("runtime").Members["mainWrapper"].(*ssa.Function))
|
mainWrapper := c.ir.GetFunction(c.ir.Program.ImportedPackage("runtime").Members["mainWrapper"].(*ssa.Function))
|
||||||
mainWrapper.LLVMFn.SetLinkage(llvm.InternalLinkage)
|
mainWrapper.LLVMFn.SetLinkage(llvm.InternalLinkage)
|
||||||
difunc, err = c.attachDebugInfo(mainWrapper)
|
if c.Debug {
|
||||||
if err != nil {
|
difunc, err := c.attachDebugInfo(mainWrapper)
|
||||||
return err
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
pos := c.ir.Program.Fset.Position(mainWrapper.Pos())
|
||||||
|
c.builder.SetCurrentDebugLocation(uint(pos.Line), uint(pos.Column), difunc, llvm.Metadata{})
|
||||||
}
|
}
|
||||||
pos = c.ir.Program.Fset.Position(mainWrapper.Pos())
|
|
||||||
c.builder.SetCurrentDebugLocation(uint(pos.Line), uint(pos.Column), difunc, llvm.Metadata{})
|
|
||||||
block = c.ctx.AddBasicBlock(mainWrapper.LLVMFn, "entry")
|
block = c.ctx.AddBasicBlock(mainWrapper.LLVMFn, "entry")
|
||||||
c.builder.SetInsertPointAtEnd(block)
|
c.builder.SetInsertPointAtEnd(block)
|
||||||
realMain := c.mod.NamedFunction(c.ir.MainPkg().Pkg.Path() + ".main")
|
realMain := c.mod.NamedFunction(c.ir.MainPkg().Pkg.Path() + ".main")
|
||||||
|
@ -869,12 +873,14 @@ func (c *Compiler) wrapInterfaceInvoke(f *ir.Function) (llvm.Value, error) {
|
||||||
wrapper.SetLinkage(llvm.InternalLinkage)
|
wrapper.SetLinkage(llvm.InternalLinkage)
|
||||||
|
|
||||||
// add debug info
|
// add debug info
|
||||||
pos := c.ir.Program.Fset.Position(f.Pos())
|
if c.Debug {
|
||||||
difunc, err := c.attachDebugInfoRaw(f, wrapper, "$invoke", pos.Filename, pos.Line)
|
pos := c.ir.Program.Fset.Position(f.Pos())
|
||||||
if err != nil {
|
difunc, err := c.attachDebugInfoRaw(f, wrapper, "$invoke", pos.Filename, pos.Line)
|
||||||
return llvm.Value{}, err
|
if err != nil {
|
||||||
|
return llvm.Value{}, err
|
||||||
|
}
|
||||||
|
c.builder.SetCurrentDebugLocation(uint(pos.Line), uint(pos.Column), difunc, llvm.Metadata{})
|
||||||
}
|
}
|
||||||
c.builder.SetCurrentDebugLocation(uint(pos.Line), uint(pos.Column), difunc, llvm.Metadata{})
|
|
||||||
|
|
||||||
// set up IR builder
|
// set up IR builder
|
||||||
block := c.ctx.AddBasicBlock(wrapper, "entry")
|
block := c.ctx.AddBasicBlock(wrapper, "entry")
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче