Skip to content

feat: add escape analysis MVP - #2247

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

feat: add escape analysis MVP#2247
MeteorsLiu wants to merge 15 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

5df423ea436b | workflow run | long-term charts

Program measurements

Platform Workload File size vs main Build vs main Run vs main
Linux cprintf 18544 B new 351.155 ms new 1.288 ms new
Linux fmtprintf 2214984 B new 3.240 s new 2.430 ms new
Linux println 71504 B new 341.664 ms new 1.584 ms new
macOS cprintf 84672 B new 402.685 ms new 3.275 ms new
macOS fmtprintf 2360880 B new 3.326 s new 23.826 ms new
macOS println 125712 B new 403.087 ms new 4.005 ms new
Core language and compiler benchmarks
Platform Benchmark ns/op vs main
Linux BenchmarkLookupPCRandom 13.230 ns/op new
Linux BenchmarkMergeCompilerFlags 150 ns/op new
Linux BenchmarkMergeLinkerFlags 93.800 ns/op new
Linux BenchmarkChannelBuffered 35.510 ns/op new
Linux BenchmarkChannelHandoff 30201 ns/op new
Linux BenchmarkDefer 45.990 ns/op new
Linux BenchmarkDirectCall 1.557 ns/op new
Linux BenchmarkGlobalRead 1.872 ns/op new
Linux BenchmarkGlobalWrite 2.487 ns/op new
Linux BenchmarkGoroutine 45261 ns/op new
Linux BenchmarkInterfaceCall 8.094 ns/op new
Linux BenchmarkRuntimeGetG 2.490 ns/op new
macOS BenchmarkLookupPCRandom 15.330 ns/op new
macOS BenchmarkMergeCompilerFlags 139.300 ns/op new
macOS BenchmarkMergeLinkerFlags 91.390 ns/op new
macOS BenchmarkChannelBuffered 27.250 ns/op new
macOS BenchmarkChannelHandoff 7813 ns/op new
macOS BenchmarkDefer 45.280 ns/op new
macOS BenchmarkDirectCall 1.075 ns/op new
macOS BenchmarkGlobalRead 1.150 ns/op new
macOS BenchmarkGlobalWrite 1.049 ns/op new
macOS BenchmarkGoroutine 35879 ns/op new
macOS BenchmarkInterfaceCall 5.279 ns/op new
macOS BenchmarkRuntimeGetG 2.199 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 48.88889% with 23 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/build/build.go 48.88% 15 Missing and 8 partials ⚠️

📢 Thoughts on this report? Let us know!

@MeteorsLiu
MeteorsLiu force-pushed the feat/escape-phase1-mvp branch 2 times, most recently from a82bf19 to f246ce2 Compare August 3, 2026 03:03
@MeteorsLiu
MeteorsLiu force-pushed the feat/escape-phase1-mvp branch from f246ce2 to 03f8f8f Compare August 3, 2026 03:11
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