docs(CLAUDE.md): document out.ll update process after IR changes
Add comprehensive documentation explaining: - What out.ll files are (IR comparison test files) - When to update them (after modifying IR generation logic) - How to update them (reinstall llgen, regenerate files) - Why this matters (test consistency and regression detection) This documentation will help avoid wasting time on repeatedly updating test files, as it clarifies the required workflow when making compiler changes that affect IR generation. Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
This commit is contained in:
42
CLAUDE.md
42
CLAUDE.md
@@ -51,6 +51,48 @@ go test ./...
|
||||
|
||||
**Important:** The `LLGO_ROOT` environment variable must be set to the repository root when running llgo commands during development.
|
||||
|
||||
### Update out.ll files after modifying compiler IR generation
|
||||
|
||||
**CRITICAL:** When you modify the compiler's IR generation logic (especially in `ssa/` or `cl/` packages), you MUST update all out.ll test files under the `cl/` directory.
|
||||
|
||||
#### Understanding out.ll files
|
||||
|
||||
The `out.ll` files under the `cl/` directory are comparison IR files that serve as reference outputs for the test suite:
|
||||
- They are generated by `llgen` from the corresponding `in.go` files in the same directory
|
||||
- They reflect the current compiler's LLVM IR representation of the Go source code
|
||||
- They are used by tests to verify that the compiler generates correct and consistent IR output
|
||||
|
||||
#### Required steps after modifying IR generation logic
|
||||
|
||||
1. **Reinstall llgen** to apply your compiler changes:
|
||||
```bash
|
||||
go install -v ./chore/llgen
|
||||
```
|
||||
|
||||
2. **Regenerate all out.ll files** under the `cl/` directory:
|
||||
```bash
|
||||
# llgen automatically finds and updates all test cases
|
||||
llgen
|
||||
```
|
||||
Or you can regenerate specific test directories:
|
||||
```bash
|
||||
llgen cl/_testgo/interface
|
||||
llgen cl/_testrt/tpmethod
|
||||
```
|
||||
|
||||
3. **Verify the changes** make sense by reviewing the diff in the out.ll files
|
||||
|
||||
4. **Commit the updated out.ll files** along with your compiler changes
|
||||
|
||||
#### Why this matters
|
||||
|
||||
Failing to update out.ll files after modifying IR generation will cause test failures in `TestFromTestgo` and `TestFromTestrt`. This process ensures that:
|
||||
- The test suite reflects the current compiler behavior
|
||||
- Changes to IR generation are properly documented and reviewed
|
||||
- Future regressions can be detected by comparing against the reference output
|
||||
|
||||
**Pro tip:** Always check if your changes affect IR generation. If you're unsure, run the tests first - they will fail if out.ll files need updating.
|
||||
|
||||
## Code Quality
|
||||
|
||||
Before submitting any code updates, you must run the following formatting and validation commands:
|
||||
|
||||
Reference in New Issue
Block a user