← Back to Pull requests

LATX, opt: Extend GHBR optimization across user-mode translation #498

Open
ganjue66da opened this pull request with 2392 lines diff across 33 files
View on GitHub
ganjue66da ganjue66da commented on Sep 30, 2026 02:29 UTC
Author

Summary / 变更说明

Extend user-mode LATX GHBR optimization across GPR writeback, implicit multiply/divide inputs, conditional definitions, fused AND/IMUL patterns, bit-scan results, and redundant IR2 zero extensions. Add a semantic inventory, JIT/AOT regression coverage, and opt-in GHBR statistics.

Preserve architectural state at guest exception points: potentially faulting instructions make all GPR high halves live before their destination definitions. MULXQ explicitly reads the RDX high half. A completed CMOVcc r32 clears the destination high half on both condition outcomes; CMPXCHG retains its conditional-definition model. Unknown IR2 operations reset tracked zero state, and external TU successors retain the full live-register fallback.

Validation / 验证

Validated head: 3c07c8eda7054b3b5c9627028e461f51a105fe6f, based on current master at 5e52e497307d34c23479731095fc86f6074c3b3d. Rebase reports the branch is up to date.

On a LoongArch host:

  • Complete x86_64 lat-pr-fast: 55/55 passed, no skips or timeouts.

  •   python3 meson/meson.py test -C build-validate64 \
        --suite lat-pr-fast --print-errorlogs --num-processes 1
      

    The test environment supplies the existing Clang UBSan standalone runtime through LIBRARY_PATH and LD_LIBRARY_PATH for the sanitizer-enabled callback test; sanitizer instrumentation remains enabled.
  • HBR/GHBR integration: 17/17 passed, no skips or timeouts, with AVX translation enabled. The registered HBR domain includes all 11 GHBR fixtures and six HBR fixtures. GHBR fixtures exercise JIT, cold AOT, and hot AOT, with an explicit marker proving that the intended guest cache was loaded.

  •   LATX_HBR_GUEST_ARTIFACT_DIR=<verified-guest-artifacts> \
        python3 meson/meson.py test -C build-validate-avx64 \
        --no-rebuild --suite latx-integration --print-errorlogs \
        --num-processes 2 <all-17-registered-HBR-and-GHBR-test-names>
      

    Guest artifacts are checked against source and binary SHA256 manifests.
  • x86_64, AVX-enabled x86_64, and i386 translator builds passed. The current i386 guest runtime matrix was not rerun.

  • MULXQ and signal-context regressions fail on the previous PR head under loaded hot AOT and pass with the fixes. Exception tests check the interrupted 64-bit RAX, fault PC, signal, and memory fault address for load, store, false-condition memory CMOV, division, and implicit memory access.

  • Native x86_64 CMOV checks confirm r32 zero-extension on both outcomes, with r16/r64 false-path controls.

  • Each new fix was built and checked with its focused regression before later fixes were added. Commit author/DCO and message checks passed. git diff --check passed; checkpatch reports no errors and one new-file MAINTAINERS advisory.
  • SPEC performance has not been rerun after adding the exception-state constraints; the previous performance benefit is not claimed for this candidate. This validation does not constitute exhaustive coverage of all instructions or asynchronous signal/debug paths.

    Checklist / 检查项

  • I have read CONTRIBUTING.md. / 我已阅读 CONTRIBUTING.md。

  • Every commit contains a matching DCO sign-off. / 每个提交均包含匹配的 DCO 签署。

  • Relevant build and test results, including remaining coverage limits, are included. / 已提供相关构建、测试结果及尚未覆盖的范围。
  • Diff: 2392 lines (+2293 / -99) across 33 files Reviewer: None requested Review duration: 94483m
    All Vouch review confidence checks passed
    Residual risk 0.50 = Change Risk (0.91) × (1 − Review Confidence (0.44)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.91 · 2392 lines diff across 33 files
    0.91
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 10%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Shallow Review Depth shallow_review_depth
    0.292
    No Reviewer Assigned no_reviewer_assigned
    0.120
    Mass File Touch mass_file_touch
    0.080
    Real PR Conversation Timeline
    2 items
    LaurenIsACoder LaurenIsACoder commented on Nov 02, 2026 08:41 UTC
    Contributor

    Rebase validation for 5a48356c824 on 5e52e497307 (LoongArch Linux)

    | Command | Result |
    | --- | --- |
    | meson test -C build64 --suite lat-pr-fast --print-errorlogs | 55/55 passed |
    | meson test -C build32 --suite lat-pr-fast --print-errorlogs | 44/44 passed |
    | meson test -C build64 --suite latx-integration 'test-latx-ghbr-' 'test-latx-hbr-' test-redundant-xvldi | 17/17 passed |
    | meson test -C build64 --suite latx-integration 'test-rip-relative-cache-*' | 5/5 passed |
    | meson test -C build32 --suite latx-integration test-latx-lea-i386-addr16 | 1/1 passed |

    The x86-64 guest fixtures were compiled on x86-64 Linux and supplied to the runners on LoongArch. All ten GHBR fixtures passed JIT and cold/hot AOT execution, with the hot run confirming that the guest's cache loaded. Both IR2 passes and upstream's address-temporary release are retained. Upstream already carries the GLib declarations and broader AOT truncation coverage.

    Reviewers
    None requested
    Assignees
    ganjue66da ganjue66da
    Labels
    risk: medium confidence: 44.4% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 90.5% (HIGH) · Higher = larger blast radius
    90.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.4% · Lower = rushed or shallow review
    44.4%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 50.4% · Moderate risk
    50.4%