Fix offset computation association in VNVN
Corrects an offset computation in GCC's SCCVN pass to prevent potential overflows and UBSAN issues.
GCC’s Sparse Conditional Constant Propagation (SCCVN) pass has been fixed to correctly associate offset computations. This change addresses a bug flagged by UBSAN, ensuring that the computation order prevents overflows and accurately reflects the intended logic, thereby improving the robustness of the optimization.
In Details
In tree-ssa-sccvn.cc, the vn_walk_cb_data::push_partial_def function's offset calculation was re-associated to prevent potential integer overflows. This addresses a UBSAN-reported issue related to the order of operations within the Value Numbering (VN) framework, ensuring the invariant is maintained correctly before the partial definition is pushed.
- UBSAN
- Undefined Behavior Sanitizer. A runtime instrumentation tool that detects undefined behavior in C/C++ code, such as integer overflow, which can lead to crashes or security vulnerabilities.
- Value Numbering (VN)
- A compiler optimization technique used to identify and eliminate redundant computations by assigning unique numbers (values) to expressions. SCCVN (Sparse Conditional Value Numbering) is an advanced form that operates efficiently even on sparse data.
- SSA
- Static Single Assignment. An intermediate representation form in compilers where every variable is assigned a value exactly once, simplifying many optimization analyses.
- tree-ssa-sccvn.cc
- The source file in GCC containing the implementation of the Sparse Conditional Value Numbering (SCCVN) optimization pass.