Merge pull request #1381 from goplus/xgopilot/claude/document-outll-process-1730340128
docs(CLAUDE.md): document out.ll update process after IR changes
This commit is contained in:
50
CLAUDE.md
50
CLAUDE.md
@@ -51,6 +51,56 @@ go test ./...
|
|||||||
|
|
||||||
**Important:** The `LLGO_ROOT` environment variable must be set to the repository root when running llgo commands during development.
|
**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 the tools** to apply your compiler changes:
|
||||||
|
```bash
|
||||||
|
go install -v ./chore/gentests
|
||||||
|
go install -v ./chore/llgen
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Regenerate out.ll files**:
|
||||||
|
|
||||||
|
**For batch updates (recommended)** - Use `gentests` to regenerate all test files:
|
||||||
|
```bash
|
||||||
|
gentests
|
||||||
|
```
|
||||||
|
This will automatically regenerate all out.ll files in these directories:
|
||||||
|
- `cl/_testlibc`
|
||||||
|
- `cl/_testlibgo`
|
||||||
|
- `cl/_testrt`
|
||||||
|
- `cl/_testgo`
|
||||||
|
- `cl/_testpy`
|
||||||
|
- `cl/_testdata`
|
||||||
|
|
||||||
|
**For individual test inspection** - Use `llgen` to 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
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
## Code Quality
|
## Code Quality
|
||||||
|
|
||||||
Before submitting any code updates, you must run the following formatting and validation commands:
|
Before submitting any code updates, you must run the following formatting and validation commands:
|
||||||
|
|||||||
Reference in New Issue
Block a user