Skip to content

feat: add escape analysis MVP - #2247

Draft
MeteorsLiu wants to merge 11 commits into
xgo-dev:mainfrom
MeteorsLiu:feat/escape-phase1-mvp
Draft

feat: add escape analysis MVP#2247
MeteorsLiu wants to merge 11 commits into
xgo-dev:mainfrom
MeteorsLiu:feat/escape-phase1-mvp

Conversation

@MeteorsLiu

@MeteorsLiu MeteorsLiu commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

This draft starts the Phase 1 LLVM-IR escape-analysis MVP proposed in #2244.

The implementation includes:

  • Add a sparse per-allocation LLVM use walker with conservative operand-role handling and exact forwarding through proven local alloca slots.
  • Cache pointer-parameter summaries for heap, mutator, callee, result, and alignment facts, including direct-call composition and recursive fixed-point evaluation.
  • Rewrite bounded local AllocZ and AllocU calls before large-aggregate and C ABI lowering, preserving zero initialization and rejecting loops, unsupported sizes, alignments, and address spaces.
  • Drive focused pass coverage from literal LITTEST fixtures where in.txt contains input LLVM IR and out.txt contains the complete transformed module, plus a build-pipeline integration fixture.
  • Keep call-argument alignment propagation and recursive alignment-level saturation as explicit follow-up correctness work before this draft is ready for review.

This establishes the LLGo-owned analysis and rewrite boundary while keeping unknown calls and unsupported LLVM behavior conservative.

@MeteorsLiu MeteorsLiu changed the title feat: add LLVM escape analysis MVP feat: add escape analysis MVP Jul 31, 2026
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

LLGo baseline benchmarks

97ae05374b21 | workflow run | long-term charts

Program measurements

Platform Workload File size vs main Build vs main Run vs main
Linux cprintf 18544 B new 348.361 ms new 1.301 ms new
Linux fmtprintf 2214984 B new 3.399 s new 2.498 ms new
Linux println 71504 B new 347.496 ms new 1.635 ms new
macOS cprintf 84672 B new 440.807 ms new 5.018 ms new
macOS fmtprintf 2360880 B new 3.958 s new 20.668 ms new
macOS println 125712 B new 426.287 ms new 4.534 ms new
Core language and compiler benchmarks
Platform Benchmark ns/op vs main
Linux BenchmarkLookupPCRandom 13.210 ns/op new
Linux BenchmarkMergeCompilerFlags 150.600 ns/op new
Linux BenchmarkMergeLinkerFlags 94.250 ns/op new
Linux BenchmarkChannelBuffered 35.270 ns/op new
Linux BenchmarkChannelHandoff 31298 ns/op new
Linux BenchmarkDefer 45.400 ns/op new
Linux BenchmarkDirectCall 1.557 ns/op new
Linux BenchmarkGlobalRead 1.868 ns/op new
Linux BenchmarkGlobalWrite 2.488 ns/op new
Linux BenchmarkGoroutine 35489 ns/op new
Linux BenchmarkInterfaceCall 8.099 ns/op new
Linux BenchmarkRuntimeGetG 2.510 ns/op new
macOS BenchmarkLookupPCRandom 12 ns/op new
macOS BenchmarkMergeCompilerFlags 113.300 ns/op new
macOS BenchmarkMergeLinkerFlags 74.890 ns/op new
macOS BenchmarkChannelBuffered 20.890 ns/op new
macOS BenchmarkChannelHandoff 6718 ns/op new
macOS BenchmarkDefer 27.610 ns/op new
macOS BenchmarkDirectCall 0.971 ns/op new
macOS BenchmarkGlobalRead 0.958 ns/op new
macOS BenchmarkGlobalWrite 0.943 ns/op new
macOS BenchmarkGoroutine 37800 ns/op new
macOS BenchmarkInterfaceCall 4.241 ns/op new
macOS BenchmarkRuntimeGetG 1.969 ns/op new

No main baseline exists yet; all metrics are marked new.

Warning

  • The rendered benchmark data could not be pushed.

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.44944% with 34 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/escape/escape.go 90.39% 23 Missing and 9 partials ⚠️
internal/littest/littest.go 90.47% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@MeteorsLiu
MeteorsLiu force-pushed the feat/escape-phase1-mvp branch from cf42be6 to 279731f Compare August 1, 2026 06:59
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.

1 participant