__attribute__((noinline)) void bar (void) { asm volatile ("" : : : "memory"); }
int main (void) { int i = 6; bar (); i++; asm ("" : "+r" (i)); i++; return i; } on x86_64-linux -g -O2 has bogosity in VAR_LOCATION note: (note 33 13 21 2 (var_location i (expr_list:REG_DEP_TRUE (plus:SI (asm_operands:SI ("") ("=r") 0 [ (const_int 7 [0x7]) ] [ (asm_input:SI ("0") (null):0) ] [] dm.c:16) (const_int 1 [0x1])) This is because the register that was set by this non-volatile asm was clobbered and ASM_OPERANDS definitely is not something we can emit into the debug info. And, if it wasn't there, vt_expand_loc could see that this doesn't lead to useful location and try another one, in particular the one provided by reverse_op stuff. With the patch I'm going to attach on this testcase we end up with: (note 33 13 21 2 (var_location i (expr_list:REG_DEP_TRUE (reg:SI 0 ax [63]) note instead, with assembly diff: @@ -70,6 +70,10 @@ main: .byte0x70# DW_OP_breg0 .sleb128 1 .byte0x9f# DW_OP_stack_value +.quad.LVL3-.Ltext0# Location list begin address (*.LLST0) +.quad.LFE1-.Ltext0# Location list end address (*.LLST0) +.value0x1# Location expression size +.byte0x50# DW_OP_reg0 .quad0x0# Location list terminator begin (*.LLST0) .quad0x0# Location list terminator end (*.LLST0) .section.debug_info -- Summary: We should yank ASM_OPERANDS locs from var-tracking preserved cselib VALUEs Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jakub at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43443