Skip to content

Implement dead code elimination as a file-level transformation#68

Merged
RealA10N merged 3 commits intomainfrom
claude/add-dead-code-elimination-X5iAA
Mar 27, 2026
Merged

Implement dead code elimination as a file-level transformation#68
RealA10N merged 3 commits intomainfrom
claude/add-dead-code-elimination-X5iAA

Conversation

@RealA10N
Copy link
Copy Markdown
Owner

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

  • Added FileToDeadCodeElimination() function to apply DCE across all defined functions in a file
  • Implemented TransformFileToDeadCodeElimination() adapter function to integrate with the transformation framework
  • Imported the transform package in opt/dead_code_elimination.go to support the new transformation interface
  • Wired the DCE transformation into the target collection in usm.go by assigning opt.TransformFileToDeadCodeElimination to the "dead-code-elimination" target's Transform field
  • Added opt package import to usm.go

Implementation Details

The new FileToDeadCodeElimination() function iterates through all functions in a file and applies the existing DeadCodeElimination() function to each defined function, aggregating results. The TransformFileToDeadCodeElimination() wrapper follows the standard transformation interface pattern, accepting and returning *transform.TargetData along with a core.ResultList.

https://claude.ai/code/session_014WTWo1Uuxa1bHiQVUCUCQg

claude added 3 commits March 27, 2026 17:47
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
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

❌ Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.89%. Comparing base (661e744) to head (ee8b58a).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
opt/dead_code_elimination.go 0.00% 10 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@RealA10N RealA10N merged commit 8df569a into main Mar 27, 2026
3 of 5 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.

2 participants