Skip to content

runtime: track caller frames for LLGo metadata#1884

Draft
cpunion wants to merge 4 commits into
xgo-dev:mainfrom
cpunion:codex/goroot-debugline-coverage
Draft

runtime: track caller frames for LLGo metadata#1884
cpunion wants to merge 4 commits into
xgo-dev:mainfrom
cpunion:codex/goroot-debugline-coverage

Conversation

@cpunion
Copy link
Copy Markdown
Collaborator

@cpunion cpunion commented May 22, 2026

Summary

  • add LLGo-maintained caller frame metadata for runtime.Caller, runtime.Callers, CallersFrames, FuncForPC, and Func.FileLine
  • instrument non-runtime Go functions with caller frame push/pop and call-site line updates so metadata survives LLVM inlining
  • preserve caller-frame stack marks across recovered panics, set call-site line metadata before evaluating call operands, and normalize LLGo anonymous frame names like $1 to Go-style .func1
  • add focused test/go coverage for runtime.Caller, Callers, CallersFrames, FuncForPC, Func.FileLine, line numbers, function names, recovered nil-panic frame metadata, and inline caller/callers metadata
  • remove the verified inline_caller.go and inline_callers.go xfails for Go 1.24/1.25/1.26 on linux/amd64 and darwin/arm64, plus Go 1.26 devirtualization_nil_panics.go xfails already covered by this PR

Testing

  • go test ./test/go -count=1
  • env LLGO_GOROOT_VERBOSE=1 LLGO_GOROOT_HEARTBEAT_SECONDS=60 bash ./dev/test_goroot.sh /Users/lijie/sdk/go1.24.11 /Users/lijie/sdk/go1.25.0 /Users/lijie/sdk/go1.26.0 -- -dirs . -case '^(inline_caller|inline_callers|maymorestack)\\.go$' -directive-mode ci -xfail /tmp/llgo-empty-xfail-missing.yaml -run-timeout 60s (empty xfail reproduction: inline cases pass on darwin/arm64; maymorestack.go still fails with panic: mayMoreStack not called)
  • env LLGO_GOROOT_VERBOSE=1 LLGO_GOROOT_HEARTBEAT_SECONDS=60 bash ./dev/test_goroot.sh /Users/lijie/sdk/go1.24.11 /Users/lijie/sdk/go1.25.0 /Users/lijie/sdk/go1.26.0 -- -dirs . -case '^(inline_caller|inline_callers|maymorestack)\\.go$' -directive-mode ci -run-timeout 60s
  • (cd runtime && go test ./... -count=1)
  • go test ./ssa -count=1
  • go test ./runtime/... ./ssa/... ./cl/... -count=1 was attempted from the repo root; ssa/... and cl/... completed successfully, but the command exited 1 because runtime is a separate module and ./runtime/... is not a root-module package pattern
  • git diff --check

Scope Notes

  • inline_caller.go and inline_callers.go now pass locally on Go 1.24.11, Go 1.25.0, and Go 1.26.0 darwin/arm64 with an empty xfail file; their remaining xfails are removed because they exercise the same runtime caller/debugline metadata path now covered in test/go.
  • maymorestack.go remains xfailed for Go 1.24/1.25/1.26 on darwin/arm64 and linux/amd64. Its current local failure is panic: mayMoreStack not called, which is a -d=maymorestack hook/instrumentation issue rather than caller/debugline metadata.
  • No nil/chan/print/recover runtime, GC/liveness/finalizer, or goroutine behavior is changed here. I did not push any branch to xgo-dev/llgo.

@cpunion
Copy link
Copy Markdown
Collaborator Author

cpunion commented May 22, 2026

Pushed fix 5a8e97f (runtime: limit caller frame instrumentation).\n\nRoot cause from the failed logs: caller-frame instrumentation was enabled for nearly every non-runtime package. That shifted LLVM IR in the FileCheck suites and pulled caller runtime dependencies into embedded/cross-target builds, producing widespread link failures such as stdout/vfprintf/pthread_* undefined symbols.\n\nLocal validation on /Users/lijie/source/goplus/llgo-wt-goroot-debugline:\n- go test ./ssa\n- go test ./test/go -run TestRuntimeCaller\n- go test ./cl (cl package passed; the combined command exited after unrelated runtime/internal direct-package setup failures)\n- go build -o /tmp/llgo-debugline ./cmd/llgo\n- GOWORK=off /tmp/llgo-debugline run . in _demo/go/runtime\n- ../../../dev/llgo.sh build -target ae-rp2040 -o /tmp/llgo-debugline-ae-rp2040-empty.elf ./empty\n- ../../../dev/llgo.sh build -target ae-rp2040 -o /tmp/llgo-debugline-ae-rp2040-defer.elf ./defer\n\nNew CI is queued/running on head 5a8e97f; monitoring now.

@cpunion
Copy link
Copy Markdown
Collaborator Author

cpunion commented May 22, 2026

CI follow-up for 5a8e97f:\n\n- Go/test (ubuntu-latest, 19): success\n- Targets/llgo (ubuntu-latest, 19): success\n- LLGo/llgo (ubuntu-latest, 19, Go 1.21.13): success\n- LLGo/llgo (ubuntu-latest, 19, Go 1.24.2): success\n- LLGo/llgo (ubuntu-latest, 19, Go 1.26.0): success\n- LLGo ubuntu test shards and hello jobs observed so far: success\n\nNo failed checks on the new head at this point. Remaining macOS and release-artifact jobs are still queued by GitHub runners.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 23, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 61.22449% with 57 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cl/instr.go 57.14% 36 Missing and 6 partials ⚠️
cl/compile.go 72.34% 11 Missing and 2 partials ⚠️
ssa/package.go 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@cpunion
Copy link
Copy Markdown
Collaborator Author

cpunion commented May 24, 2026

Updated with fc4eae3. This narrows the new coverage to recovered nil panic -> runtime.CallersFrames metadata: frame stack marks are truncated on return after recover, call-site line metadata is set before callee/receiver evaluation, and LLGo anonymous frame names are normalized to Go-style .funcN. Removed only the Go 1.26 devirtualization_nil_panics.go xfails. I also checked inline_caller.go/inline_callers.go as same caller/debugline domain on Go 1.26 darwin-arm64, but left the remaining inline xfails in place because this commit did not revalidate every listed version/platform for those entries. No xgo-dev branch push.

@cpunion
Copy link
Copy Markdown
Collaborator Author

cpunion commented May 24, 2026

Update on bda9687b1734fd8fca652cc4f1ef68f38daca92a:

  • Added test/go coverage for inline runtime.Caller, runtime.Callers, runtime.CallersFrames, runtime.FuncForPC, and Func.FileLine metadata.
  • Removed inline_caller.go / inline_callers.go xfails for Go 1.24/1.25/1.26 on linux/amd64 and darwin/arm64.
  • Kept maymorestack.go xfails. Local empty-xfail reproduction on Go 1.24.11, 1.25.0, and 1.26.0 darwin/arm64 still fails with panic: mayMoreStack not called, which is outside the caller/debugline metadata path.
  • Local focused goroot verification with normal xfail now passes for all three local SDKs; maymorestack.go is the expected remaining failure.

CI has been retriggered from the fork head; at the time of this comment the new checks are queued on the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants