Skip to content

ssa: implement -B bounds-check disabling#2106

Open
cpunion wants to merge 2 commits into
xgo-dev:mainfrom
cpunion:codex/xfail-disable-bounds
Open

ssa: implement -B bounds-check disabling#2106
cpunion wants to merge 2 commits into
xgo-dev:mainfrom
cpunion:codex/xfail-disable-bounds

Conversation

@cpunion

@cpunion cpunion commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • accept the gc-compatible llgo tool compile -B flag and propagate it through build configuration into SSA lowering
  • omit index, string/slice, two/three-index slice, and slice-to-array conversion bounds checks when enabled
  • retain integer-width conversions, required nil checks for *array, and mandatory unsafe.String / unsafe.Slice validity checks
  • include the setting in build fingerprints and keep the default checked path unchanged
  • retire the Go 1.26 fixedbugs/issue48092.go compile xfail

Scope

This change implements the compiler-action -B used by GOROOT tests and an explicit build Config setting. It does not reinterpret top-level llgo build/run/test -gcflags=-B: Go gcflags are package-pattern scoped with last-match replacement semantics, which require a separate per-package design.

The compatibility command accepts -o, but its compile-only path validates lowering without emitting an object file. This PR preserves that behavior; output-file compatibility is outside its scope.

Validation

Rebased on current xgo-dev/llgo main (73fa30fbf):

  • macOS arm64, Go 1.26.5:
    • complete cmd/internal/compile, ssa, and internal/build suites pass
    • coverage: 97.4%, 87.9%, and 73.4%; combined 80.8%
    • GOROOT fixedbugs/issue48092.go passes with its xfail removed
  • Linux amd64, LLVM 19, Go 1.26.5:
    • complete cmd/internal/compile, ssa, and internal/build suites pass
    • coverage: 97.4%, 88.0%, and 72.6%
    • GOROOT fixedbugs/issue48092.go passes
  • key lowering coverage: checkIndex 100%, Slice 98.6%, SliceToArrayPointer 100%, and DisableBoundsChecks 100%
  • checked and unchecked programs retain identical legal results; IR tests prove bounds helpers disappear under -B
  • negative tests retain required *array nil panics and unsafe.String / unsafe.Slice validity panics
  • git diff --check passes

The previous Ubuntu LLGo failure was unrelated to -B: it exercised the former main behavior that rejected DWARF omission for c-shared/c-archive. That support is present in current main and the rebased CI reruns it.

@cpunion cpunion added progress go-test-compat Go standard-library and GOROOT test compatibility go1.26 Go 1.26 compatibility and support feature and removed progress labels Jul 16, 2026
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cpunion
cpunion force-pushed the codex/xfail-disable-bounds branch 3 times, most recently from 84aa898 to 339edb0 Compare July 18, 2026 23:48
@xushiwei xushiwei removed the feature label Jul 19, 2026
@xushiwei

Copy link
Copy Markdown
Contributor

@gemini-code-assist /review

@cpunion
cpunion force-pushed the codex/xfail-disable-bounds branch from 339edb0 to 05a6663 Compare July 20, 2026 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go1.26 Go 1.26 compatibility and support go-test-compat Go standard-library and GOROOT test compatibility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants