Repository navigation
fix: handle failures exposed by full GOROOT coverage #2741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
cpunion
merged 5 commits into
xgo-dev:main
from
cpunion:codex/fix-restored-goroot-ci-20261006
Oct 6, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1b0a2e0
fix: handle restored GOROOT regression coverage
cpunion 5474876
test: bound Windows ARM64 generated-case heap usage
cpunion 54150be
test: bound GOROOT process resource sampling
cpunion be59990
docs: explain debug snapshot store typing
cpunion 5c4020c
test: leave more native memory for Windows ARM64 rangegen
cpunion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| package cl | ||
|
|
||
| import ( | ||
| "go/ast" | ||
| "go/parser" | ||
| "go/token" | ||
| "go/types" | ||
| "testing" | ||
|
|
||
| "github.com/xgo-dev/llgo/internal/optlevel" | ||
| llssa "github.com/xgo-dev/llgo/ssa" | ||
| "github.com/xgo-dev/llvm" | ||
| "golang.org/x/tools/go/ssa" | ||
| "golang.org/x/tools/go/ssa/ssautil" | ||
| ) | ||
|
|
||
| // GOROOT/test/abi/f_ret_z_not.go crashed in LLVM 22's | ||
| // SelectionDAGBuilder::resolveDanglingDebugInfo after optimization promoted an | ||
| // empty aggregate snapshot to dbg.value(empty zeroinitializer). Module | ||
| // verification alone does not catch it: exercise object emission too. | ||
| func TestZeroSizedDebugValuesEmitObjects(t *testing.T) { | ||
| const source = `package zero | ||
| type Z struct{} | ||
| type NZ struct { x, y int } | ||
| //go:noinline | ||
| func f(x, y int) (Z, NZ, Z) { | ||
| var z Z | ||
| return z, NZ{x, y}, z | ||
| } | ||
| //go:noinline | ||
| func g() (Z, NZ, Z) { | ||
| a, b, c := f(3, 4) | ||
| return c, b, a | ||
| } | ||
| func array(z [0]int) ([0]int, int, [0]int) { | ||
| var empty [0]int | ||
| return empty, 7, z | ||
| } | ||
| func check() int { | ||
| _, b, _ := g() | ||
| return b.x + b.y | ||
| } | ||
| ` | ||
| fset := token.NewFileSet() | ||
| file, err := parser.ParseFile(fset, "zero.go", source, parser.ParseComments) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| ssaPkg, _, err := ssautil.BuildPackage(&types.Config{}, fset, | ||
| types.NewPackage("zero", "zero"), []*ast.File{file}, | ||
| ssa.SanityCheckFunctions|ssa.InstantiateGenerics|ssa.GlobalDebug) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| for _, target := range []struct{ name, goos, triple string }{ | ||
| {"darwin", "darwin", "aarch64-apple-darwin"}, | ||
| {"linux", "linux", "aarch64-unknown-linux-gnu"}, | ||
| {"windows-msvc", "windows", "aarch64-pc-windows-msvc"}, | ||
| {"windows-mingw", "windows", "aarch64-w64-windows-gnu"}, | ||
| } { | ||
| for _, level := range []optlevel.Level{optlevel.O0, optlevel.O2, optlevel.Os} { | ||
| t.Run(target.name+"/"+level.String(), func(t *testing.T) { | ||
| prog := newLLSSAProgForTarget(t, &llssa.Target{ | ||
| GOOS: target.goos, GOARCH: "arm64", LLVMTarget: target.triple, OptLevel: level, | ||
| }) | ||
| defer prog.Dispose() | ||
| pkg, _, err := newPackageEx(prog, nil, nil, nil, ssaPkg, | ||
| []*ast.File{file}, nil, false, Options{Debug: true, DebugSymbols: true}) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| mod := pkg.Module() | ||
| mod.SetDataLayout(prog.DataLayout()) | ||
| mod.SetTarget(target.triple) | ||
| options := llvm.NewPassBuilderOptions() | ||
| defer options.Dispose() | ||
| options.SetVerifyEach(true) | ||
| if err := mod.RunPasses("default<"+level.String()+">", prog.TargetMachine(), options); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| object, err := prog.TargetMachine().EmitToMemoryBuffer(mod, llvm.ObjectFile) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| defer object.Dispose() | ||
| if len(object.Bytes()) == 0 { | ||
| t.Fatal("empty object") | ||
| } | ||
| }) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor / non-blocking: the Store is now intentionally emitted while
dbgPtr.Typeis stillPointer(ty)(the alloca'd type), before it's reset toPointer(v.Type). For most types wherety != v.Type(slice, string, named) this is benign — the same store is emitted. For signature/closure values it's a real emitted-IR change:Storenow takes the closure branch and writes a full{funcptr, nil}aggregate, whereas the old order stored only the function pointer and left the$dataslot as uninitialized stack garbage. This is actually an improvement (debug-only), but the surrounding comment only explains the zero-sized rationale. Consider a one-line note that the Store deliberately runs under the alloca typetyso closure-typed debug values are fully initialized.