Repository navigation
Conversation
… to fix signed compares The compiler incorrectly mutated the 'vuns' (unsigned) attribute of an underlying SSA value when compiling an `as` cast to a type with a different signedness but the same MLIR base type (e.g. `i64` to `u64`). This caused subsequent usages of the original variable in signed comparisons (like `a < 0`) to incorrectly emit an unsigned comparison (`ult`), leading to miscompilations such as traps and bounds check failures. We now generate a distinct SSA value via `arith.ori` when the unsignedness differs, preserving the original variable's semantics. Part of MLIR parity. Fixes C 0 vs MLIR 24 (test_dynamic_invariants.flow) and out-of-bounds/bounds-check related diverges like C 0/MLIR 133. Co-authored-by: godofecht <[email protected]>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Co-authored-by: godofecht <[email protected]>
Co-authored-by: godofecht <[email protected]>
Fixes run-exit divergences where casts changing unsignedness (e.g. i64 to u64) mutated the underlying shared SSA variable's signedness flag. This caused subsequent usages of that variable in signed operations to miscompile to unsigned comparisons, which led to incorrect evaluation logic, bypassed bounds checks, and resulted in traps (C 0 vs MLIR 24, C 0 vs MLIR 133, C 139 vs MLIR 133, etc.). Fixed programs: test_dynamic_invariants and other related out-of-bounds/bounds-check diverged tests. Co-authored-by: godofecht <[email protected]>
Regenerate mlir_consts_calls golden to match recent changes introducing arith.ori cast. Co-authored-by: godofecht <[email protected]>
…-8884590759992762889-5015243584356900987 Fix mlir_consts_calls golden
Supersedes #1583 (re-applied on current main). Part of MLIR parity. Updated several corpus digests in corpus.txt due to changed MLIR generation outputs resulting from the distinct value casts. Co-authored-by: godofecht <[email protected]>
This commit fixes the root cause behind several run-exit divergences (
C 0, MLIR 24,C 0, MLIR 133) during C vs MLIR parity tests.The issue occurred because the
mlg_emit_cast_exprcompiler step would modify the internal unsignedness flag (vuns) of a shared SSA value instead of creating a new value when compiling casts between types that have the same MLIR base type (e.g., castingi64tou64). As a result, subsequent operations using the original variable (e.g., testinga < 0whereawas previously cast) would see the corruptedvunsflag and incorrectly compile to an unsigned comparison (likearith.cmpi ult), yielding incorrect behavior.The solution intercepts casts where
tu != vunsbutfrom_eff == dst, and emits a distinct identical SSA value (via a no-oparith.ori %v, %v) usingmlg_new_val(dst). The new value inherits the modified unsignedness logic, allowing the original value's unsignedness metadata to be preserved exactly as it was.The single impacted test
consts_calls.flow's MLIR parity golden has been updated to accommodate the expected output.PR created automatically by Jules for task 8884590759992762889 started by @godofecht