GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
dce

DCE avoids removing call LHS for no_delete case.

DCE will no longer remove the LHS of calls when the 'no_delete' attribute is present, preventing issues with exception handling and function requirements.

GCC’s Dead Code Elimination (DCE) pass has been modified to prevent the removal of the left-hand side (LHS) of a call instruction when the no_delete attribute is active. This change addresses a problem where removing the LHS and subsequently inserting an assignment could violate basic block invariants, particularly concerning exception handling and functions that require specific statement ordering (e.g., ‘returns twice’ functions). Instead of inserting a new statement, the LHS is now simply not removed, ensuring program correctness.

In Details

This commit resolves PR tree-optimization/126815 by altering the behavior of simple_dce_from_worklist in tree-ssa-dce.cc. Previously, when no_delete was enabled for a call, the pass would remove the LHS and insert an assignment statement afterwards. However, this strategy conflicts with stricter requirements for statement ordering within basic blocks, such as those for exception handling or functions that must appear as the first statement. The fix changes the logic to simply skip removing the LHS of the call when no_delete is active, thus avoiding these ordering conflicts and ensurin…

For Context
Dead Code Elimination (DCE)
A compiler optimization pass that removes code that does not affect the program's output or behavior. This can reduce code size and improve performance by eliminating unnecessary computations.
no_delete
A flag or attribute that signifies a particular statement or operation should not be removed by optimization passes like Dead Code Elimination, often due to specific requirements for side effects or program correctness.
basic block
A sequence of consecutive instructions in a program that has only one entry point (at the beginning) and one exit point (at the end). Control flow can only enter from the beginning and exit from the end.
returns twice functions
A specific type of function (often related to exception handling or coroutines) that has control flow diverging at two distinct points, requiring specific placement within the basic block structure for correct verification and execution.
SSA
Static Single Assignment form. An intermediate representation where every variable is assigned a value exactly once. SSA is widely used in optimizing compilers.
Filed Under: dceoptimizationcorrectness