GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc/tree-optimization

Fix uninitialized read of bb_to_rpo in Sccvn

Corrects an uninitialized read in the Sccvn pass by conservatively handling out-of-region edges as backedges.

This change addresses an uninitialized read in the tree-ssa-sccvn.cc file, specifically within the walk_non_aliased_vuses function. The issue arose because the walk could proceed outside the intended region, leading to invalid backedge queries. The fix introduces a local BB flag to mark regions and treats edges leaving the region as backedges, except for the entry edge, thus preventing the uninitialized read and ensuring correct RPO computation.

In Details

The Sccvn pass in GCC computes the Strongly Connected Components (SCCs) of the Value Numbering (VN) graph to optimize loops. This patch fixes a bug in the RPO (Reverse Postorder) calculation within Sccvn. The vn_is_backedge function previously mishandled edges that exited the processed region, leading to an uninitialized read of bb_to_rpo. The fix ensures that out-of-region edges are conservatively treated as backedges, resolving the issue.

For Context
Sccvn
A GCC compiler pass that identifies Strongly Connected Components (SCCs) in the Value Numbering (VN) graph, primarily used for loop optimizations.
RPO
Reverse Postorder traversal of a control flow graph. It's an ordering of basic blocks used in various compiler optimizations.
BB
Basic Block. A sequence of instructions with a single entry point and a single exit point.
Value Numbering (VN)
An optimization technique that assigns unique numbers to expressions with the same value, allowing the compiler to identify and eliminate redundant computations.
Filed Under: gccoptimizationbugfix