Skip to content

cmd/compile: preserve file-backed data in LLVM IR - #140

Merged
zhouguangyuan0718 merged 1 commit into
goallc:go1.27.masterfrom
zhouguangyuan0718:codex/llvm-file-backed-lsym
Aug 18, 2026
Merged

cmd/compile: preserve file-backed data in LLVM IR#140
zhouguangyuan0718 merged 1 commit into
goallc:go1.27.masterfrom
zhouguangyuan0718:codex/llvm-file-backed-lsym

Conversation

@zhouguangyuan0718

Copy link
Copy Markdown

Large embedded files are represented by an LSym with FileInfo and a nil P slice. The native Go object writer streams FileInfo.Name, but LLVM data lowering previously allocated Size bytes and copied only P, producing a zero initializer. This made encoding/json/jsontext FuzzCoder consume a zeroed embedded corpus.

Materialize file-backed data once in the LLVM data lowerer and share the cached bytes between type construction and initializer construction. Validate the FileInfo size against the LSym, reject the invalid inline/file combination, and check both short and long reads. Native object emission and Go semantics are unchanged.

Add focused compiler tests for raw IR contents and malformed lengths, plus a >1 KiB string and []byte go:embed test that exercises LLVM O2 GoObj emission, linking, execution, writable storage, and separation from the read-only string.

Validation on darwin/arm64:

  • make.bash -llvm-version=23 -llvm-link=static (local development payload containing current Go ABI support)
  • go test -tags="llvm23 staticllvm" cmd/compile/internal/ssa
  • go test cmd/internal/testdir -run "^TestLLVM/llvm_file_backed_embed.go$" -count=1
  • go test with llvmtoolexec default, gcflags selecting encoding/json/jsontext, -run "^FuzzCoder$" -count=1 (all 170 seeds passed)

Linux qualification remains on the revision-locked release selected by CI.

@zhouguangyuan0718
zhouguangyuan0718 merged commit 2f77cc3 into goallc:go1.27.master Aug 18, 2026
3 checks passed
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