GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
function

function: Take __builtin_dwarf_cfa from DRAP in realigned frames

Fixes incorrect DWARF Call Frame Information (CFA) calculation in realigned function frames on x86.

This change corrects how __builtin_dwarf_cfa determines the Call Frame Address (CFA) in function frames that are realigned using a Dynamic Realign Argument Pointer (DRAP). Previously, on x86, this could lead to an incorrect CFA address because the argument pointer was not accounted for correctly in a realigned frame. The fix ensures that __builtin_dwarf_cfa uses the DRAP pseudo with the correct offset, resolving a crash in test cases involving frame realignment.

In Details

In GCC's function frame handling, instantiate_new_reg previously used virtual_cfa_rtx which was not correctly handling frames realigned by a DRAP. DRAP frames on x86 can eliminate the argument pointer to a fake location, causing __builtin_dwarf_cfa to return an incorrect address. This commit modifies instantiate_new_reg to use the DRAP pseudo with an offset (cfa_offset - in_arg_offset) to correctly derive virtual_cfa_rtx, aligning it with virtual_incoming_args_rtx's handling of DRAPs.

Filed Under: dwarfdebuggingx86frame pointer