Tree-CFGCleanup Retains Forwarder Blocks with PHIs and Abnormal Uses
The compiler now avoids incorrectly removing forwarder blocks that contain PHI nodes with abnormal uses, preventing potential code generation issues.
The tree-cfgcleanup pass in GCC could incorrectly remove forwarder blocks containing PHI nodes if the PHI arguments had abnormal uses. This commit fixes this issue by adding a check to ensure that forwarder blocks with PHIs referencing SSA names with abnormal uses are not removed. This prevents potential issues with live range overlap and incorrect code generation during optimization.
In Details
This commit addresses PR tree-optimization/125396 by preventing maybe_remove_forwarder_block from removing blocks where bb_phis_references_abnormal_uses returns true. This ensures that forwarder blocks with PHIs that have arguments with abnormal uses are not incorrectly removed, which could lead to overlapping live ranges.
For Context
GCC's compiler performs several optimization passes to improve the generated code. One of these passes, tree-cfgcleanup, simplifies the control flow graph of the program. This commit fixes a bug in this pass that could cause the compiler to incorrectly remove certain blocks of code (forwarder blocks) if they contained special instructions (PHI nodes) and had unusual control flow patterns (abnormal uses). This fix prevents potential errors and ensures that the compiler generates correct code.