Implement dead code elimination as a file-level transformation#68
Merged
Implement dead code elimination as a file-level transformation#68
Conversation
Wire up the existing DCE algorithm as a usable `dce` / `dead-code-elimination` transformation by adding a file-level wrapper (`FileToDeadCodeElimination`) and a `DoTransform`-compatible adapter (`TransformFileToDeadCodeElimination`) to the `opt` package, then importing `opt` in `usm.go` and setting the previously commented-out `Transform` field. https://claude.ai/code/session_014WTWo1Uuxa1bHiQVUCUCQg
Add three test cases for SSA register renaming using the existing RunOptimizationTests framework: simple renaming, reassignment, and multiple registers. https://claude.ai/code/session_014WTWo1Uuxa1bHiQVUCUCQg
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #68 +/- ##
==========================================
- Coverage 41.00% 40.89% -0.11%
==========================================
Files 123 123
Lines 3790 3800 +10
==========================================
Hits 1554 1554
- Misses 2134 2144 +10
Partials 102 102 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
This PR enables the dead code elimination (DCE) optimization pass to operate at the file level by implementing the necessary transformation interface and wiring it into the transformation pipeline.
Key Changes
FileToDeadCodeElimination()function to apply DCE across all defined functions in a fileTransformFileToDeadCodeElimination()adapter function to integrate with the transformation frameworktransformpackage inopt/dead_code_elimination.goto support the new transformation interfaceusm.goby assigningopt.TransformFileToDeadCodeEliminationto the "dead-code-elimination" target's Transform fieldoptpackage import tousm.goImplementation Details
The new
FileToDeadCodeElimination()function iterates through all functions in a file and applies the existingDeadCodeElimination()function to each defined function, aggregating results. TheTransformFileToDeadCodeElimination()wrapper follows the standard transformation interface pattern, accepting and returning*transform.TargetDataalong with acore.ResultList.https://claude.ai/code/session_014WTWo1Uuxa1bHiQVUCUCQg