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

tree-optimization: Fix UB path isolation to correctly associate later UBs

Improves the path isolation scheme to correctly track undefined behavior across multiple UBs on the same path.

This commit addresses an issue in the isolate_paths iteration scheme within gimple-ssa-isolate-paths.cc where multiple undefined behaviors (UBs) on the same code path were not correctly associated. The fix changes the discovery of NULL dereferences to iterate over incoming edges (paths) and then PHIs, ensuring that all UBs on a specific path are processed together. This improves the accuracy of UB detection and isolation.

In Details

The gimple-ssa-isolate-paths.cc pass aims to isolate code paths to simplify analysis, particularly for undefined behavior (UB). Previously, the iteration over PHIs and arguments in find_implicit_erroneous_behavior led to incorrect association of later UBs with incorrectly isolated paths. This patch modifies the iteration to traverse edges first, then PHIs, ensuring that all UBs detected on a given edge are processed within the context of that single, duplicated path, thus correctly associating subsequent UBs with their originating path.

For Context
Undefined Behavior (UB)
Program behavior that results from violations of the C/C++ standards, for which the standard imposes no requirements. Compilers may assume UB does not occur, leading to optimizations that can produce unexpected results if UB is present.
GIMPLE
GCC's internal representation (IR) for code, which is a three-address pseudo-instruction language used for optimizations. It sits between the parsed source code and the machine code.
SSA
Static Single Assignment form. An intermediate representation where every variable is assigned a value exactly once. This simplifies many optimizations.
PHI node
In SSA form, a special instruction used at the join of control flow paths to select the correct value based on which path was taken to reach that point.
NULL dereference
An attempt to access memory through a pointer that has a value of NULL, which is undefined behavior.
Filed Under: optimizationundefined behaviorgimple