cl: LLGO_TRACE

This commit is contained in:
Li Jie
2025-02-10 22:28:25 +08:00
parent 43175bb642
commit 5b216153e9
4 changed files with 31 additions and 0 deletions

View File

@@ -49,6 +49,7 @@ var (
debugInstr bool
debugGoSSA bool
debugSymbols bool
debugTrace bool
)
// SetDebug sets debug flags.
@@ -61,6 +62,10 @@ func EnableDebugSymbols(b bool) {
debugSymbols = b
}
func EnableTrace(b bool) {
debugTrace = b
}
// -----------------------------------------------------------------------------
type instrOrValue interface {
@@ -380,6 +385,9 @@ func (p *context) compileBlock(b llssa.Builder, block *ssa.BasicBlock, n int, do
var instrs = block.Instrs[n:]
var ret = fn.Block(block.Index)
b.SetBlock(ret)
if block.Index == 0 && debugTrace && !strings.HasPrefix(fn.Name(), "github.com/goplus/llgo/runtime/internal/runtime.Print") {
b.Printf("call " + fn.Name() + "\n\x00")
}
// place here to avoid wrong current-block
if debugSymbols && block.Index == 0 {
p.debugParams(b, block.Parent())