feat: quality improvements - label checks, CLI flags, duplicate pass removal#4
Merged
Conversation
Co-authored-by: traeagent <traeagent@users.noreply.github.com>
Co-authored-by: traeagent <traeagent@users.noreply.github.com>
- hoist all regexp.MustCompile from peephole passes to package-level vars (eliminated ~5000 allocations per call) - replace 13-fold strings.Contains check in hasVirtualRegs with a single-pass byte-scanning fast path - parallelize lint.Rule execution via sync.WaitGroup + goroutines when source has 64+ lines; sequential fast path for small inputs - deduplicate register lookup maps (regTo32/regTo64) - sort violation results by line number for deterministic output - optimize xorMovElim to avoid per-line regex compilation (prefix match) - remove dead regex variables from opt.go
…emoval Quality and robustness improvements across the codebase: CLI improvements: - cmdBuild refactored to use flag.FlagSet for consistent flag parsing - Added --linker-arg flag to pass extra args to the linker - Added --warn-only flag (registered, TODO: wire to AssembleWithOpt) - Updated buildHelpText with new flag documentation Robustness fixes: - Undefined label check in prep: Preprocess now checks for referenced but undefined labels after resolving includes and expanding macros - Remove duplicate PeepholeOnly call: Optimize() already runs peephole twice internally, so the redundant third call in core.go is removed - cmdTest: use defer os.RemoveAll(dir) to ensure temp dir cleanup even on early continue/return in the test loop Test improvements: - VAS_UPDATE_GOLDEN=1 env var enables golden file update mode - TestPreprocessBasic: fixed latent bug where lib.vas was missing lib_func label definition that was referenced in test source Bug fixes: - Fixed prep_test.go test fixture to define the lib_func label that was being CALLed Cleanup: - vas/reg.go: new file with unified AllRegs map for core/lint/opt - Updated golden files to reflect latest optimizer output - gofmt applied to vas/opt/opt.go and vas/reg.go
Co-authored-by: traeagent <traeagent@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Quality and robustness improvements:
CLI improvements
cmdBuildrefactored to useflag.FlagSetfor consistent flag parsing--linker-argflag to pass extra args to the linker--warn-onlyflag (registered, TODO: wire to AssembleWithOpt)Robustness fixes
Preprocessnow checks for referenced but undefined labels after resolving includes and expanding macrosOptimize()already runs peephole twice internally, so the redundant third call incore.gois removeddefer os.RemoveAll(dir)to ensure temp dir cleanup even on early continue/returnTest improvements
VAS_UPDATE_GOLDEN=1env var enables golden file update modeTestPreprocessBasicwherelib.vaswas missinglib_funclabel definitionCleanup
vas/reg.go: New file with unifiedAllRegsmap for core/lint/optvas/opt/opt.goandvas/reg.goTests
All tests pass:
go test -short ./...andgo test ./...