Bug 43443 - We should yank ASM_OPERANDS locs from var-tracking preserved cselib VALUEs
Summary: We should yank ASM_OPERANDS locs from var-tracking preserved cselib VALUEs
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-19 17:10 UTC by Jakub Jelinek
Modified: 2010-03-22 10:49 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
gcc45-pr43443.patch (605 bytes, patch)
2010-03-19 17:12 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2010-03-19 17:10:14 UTC
__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
Comment 1 Jakub Jelinek 2010-03-19 17:12:05 UTC
Created attachment 20143 [details]
gcc45-pr43443.patch

Fix.
Comment 2 Jakub Jelinek 2010-03-22 10:26:53 UTC
Subject: Bug 43443

Author: jakub
Date: Mon Mar 22 10:26:33 2010
New Revision: 157620

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=157620
Log:
	PR debug/43443
	* var-tracking.c (add_cselib_value_chains): Remove ASM_OPERANDS
	locs from preserved VALUEs.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/var-tracking.c

Comment 3 Jakub Jelinek 2010-03-22 10:49:48 UTC
Fixed.