Skip to content

test: migrate _testdata IR cases to source checks#1780

Merged
xushiwei merged 1 commit intogoplus:mainfrom
zhouguangyuan0718:main-littest
Apr 11, 2026
Merged

test: migrate _testdata IR cases to source checks#1780
xushiwei merged 1 commit intogoplus:mainfrom
zhouguangyuan0718:main-littest

Conversation

@zhouguangyuan0718
Copy link
Copy Markdown
Contributor

Summary

  • migrate the direct cases under \ to source-embedded LITTEST/CHECK assertions
  • remove the tracked \ baselines for migrated cases
  • tighten simple cases to near-complete IR checks and keep noisier cases focused on key lowering points

Testing

  • go test ./cl -run TestFromTestdata

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request migrates LLVM IR test expectations from standalone files directly into the Go source files using LITTEST and CHECK directives. Feedback identifies a bug in cl/_testdata/debug/in.go where the CHECK directive for globalInt expects a value of 0 despite the variable being initialized to 301, which will cause the test to fail.

Comment thread cl/_testdata/debug/in.go Outdated
Comment on lines +257 to +258
// CHECK: @"{{.*}}.globalInt" = global i64 0, align 8, !dbg !
var globalInt int = 301
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The global variable globalInt is initialized with a value of 301, but the corresponding CHECK directive expects a global i64 0. This mismatch will cause the test to fail.

Copy link
Copy Markdown
Contributor

@xgopilot xgopilot bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Clean and well-structured migration from out.ll baseline files to source-embedded LITTEST/CHECK assertions. The approach is consistent across most files and the CHECK directives correctly verify key IR lowering points. A few consistency issues and one missed deletion noted below.

Key Findings:

  • Orphaned out.ll: embedunexport/out.ll was not deleted despite the source file having the // LITTEST marker
  • Inconsistent wildcard usage: embedunexport.go uses fully qualified package names while all other 21 files use {{.*}} wildcards
  • Mixed style in foo.go: Mixes fully qualified runtime.eface type names with {{.*}} wildcards in the same file
  • Detached CHECK blocks in debug/in.go: CHECK blocks for FuncWithAllTypeParams and FuncWithAllTypeStructParam are placed before the unrelated ScopeIf function, which could confuse readers

No security or performance concerns.

Comment on lines +4 to +11
@@ -7,23 +8,57 @@ type Object interface {
}

// Base implements Object
// CHECK: %"github.com/goplus/llgo/cl/_testdata/embedunexport.Base" = type { %"github.com/goplus/llgo/runtime/internal/runtime.String" }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file uses fully qualified package names (e.g., "github.com/goplus/llgo/cl/_testdata/embedunexport.Base") while all other 21 migrated files use {{.*}} wildcards. This makes the file fragile to package path changes and inconsistent with the rest of the migration.

Also, the corresponding out.ll file was not deleted for this directory — it's now dead code since LoadSpec prefers source-embedded specs when the // LITTEST marker is present.

Consider:

  1. Converting to {{.*}} wildcards for consistency
  2. Deleting cl/_testdata/embedunexport/out.ll

Comment thread cl/_testdata/foo/foo.go Outdated
Comment on lines +4 to +5
// CHECK-LABEL: define %"github.com/goplus/llgo/runtime/internal/runtime.eface" @"{{.*}}.Bar"() {
// CHECK: ret %"github.com/goplus/llgo/runtime/internal/runtime.eface"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: These two functions use the fully qualified %"github.com/goplus/llgo/runtime/internal/runtime.eface" type, while all other type references in this file (and across the migration) use {{.*}} wildcards (e.g., %"{{.*}}.Foo"). Consider using %"{{.*}}.eface" here for consistency.

Comment thread cl/_testdata/debug/in.go Outdated
Comment on lines +385 to +393
// CHECK-LABEL: define { i64, %"{{.*}}.iface" } @"{{.*}}.FuncWithAllTypeParams"({{.*}}) !dbg !{{[0-9]+}} {
// CHECK: %"{{.*}}.Slice" @"{{.*}}.NewSlice3"(ptr %54, i64 8, i64 3, i64 0, i64 3, i64 3)
// CHECK: call void @"{{.*}}.PrintComplex"(
// CHECK: call void @"{{.*}}.PrintSlice"(
// CHECK: call void @"{{.*}}.PrintIface"(%"{{.*}}.iface"
// CHECK: call %"{{.*}}.iface" @errors.New(
// CHECK: ret { i64, %"{{.*}}.iface" }
// CHECK-LABEL: define void @"{{.*}}.FuncWithAllTypeStructParam"({{.*}}) !dbg !{{[0-9]+}} {
// CHECK: %3 = call ptr @"{{.*}}.AllocZ"(i64 288)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These CHECK-LABEL blocks verify FuncWithAllTypeParams (defined at ~line 95) and FuncWithAllTypeStructParam (defined at ~line 61), but are placed here before the unrelated ScopeIf function. This is presumably because the IR emission order differs from source order.

Consider adding a brief comment explaining this, e.g.:

// The following CHECK blocks verify functions defined earlier whose IR is emitted after FuncStructPtrParams.

This would help future readers understand why the assertions appear detached from their corresponding source.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.44%. Comparing base (c70fe9c) to head (b3c001a).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1780   +/-   ##
=======================================
  Coverage   88.44%   88.44%           
=======================================
  Files          50       50           
  Lines       13656    13656           
=======================================
  Hits        12078    12078           
  Misses       1369     1369           
  Partials      209      209           

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: ZhouGuangyuan <zhouguangyuan.xian@gmail.com>
@xushiwei xushiwei merged commit 7161efb into goplus:main Apr 11, 2026
45 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.

3 participants