<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - invalid location range for variables in certain cases in debug info"
   href="http://llvm.org/bugs/show_bug.cgi?id=22316">22316</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>invalid location range for variables in certain cases in debug info
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>DebugInfo
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>compnerd@compnerd.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This seems to be reproducible across different architectures and OSes.

For x86:

/* RUN: clang -target i386-linux-gnu -g -O2 -c %s -o %t.obj */
void * __attribute__ (( regparm(2) )) f(void *, void *);
void * __attribute__ (( regparm(0) )) g(void *, void *);

void *g(void *t, void *k) {
  if (k == (void *)0)
    return (void *)0;
  return f(t, k);
}

<...>
< 2><0x0000003c>      DW_TAG_formal_parameter
                        DW_AT_location              <loclist with 1 entries
follows>
            [ 0]<lowpc=0x00000000><highpc=0x00000011>DW_OP_reg0
                        DW_AT_name                  "clang version 3.5.0 
(based on LLVM 3.5.0svn)"
                        DW_AT_decl_file             0x00000001 /tmp/reduced.c
                        DW_AT_decl_line             0x00000005
                        DW_AT_type                  <0x0000005b>
<...>

00000000 <g>:
   0:    8b 54 24 08              mov    0x8(%esp),%edx ; end of prologue
   4:    85 d2                    test   %edx,%edx      ; if (k == (void *)0)
   6:    74 09                    je     11 <g+0x11>    ;   return (void *)0;
   8:    8b 44 24 04              mov    0x4(%esp),%eax ; setup $eax
   c:    e9 fc ff ff ff           jmp    d <g+0xd>
  11:    31 c0                    xor    %eax,%eax
  13:    c3                       ret    

However, the DIE indicates that formal argument 0 is at DW_OP_reg0 or eax for
the entire subprogram.  However, the disassembly clearly indicates that this
not the case for the if check.  This results in invalid accesses for variables.

For ARM, you need to try a slightly different approach due to the AAPCS calling
convention.  I believe the following worked:

void *f(void *, void *);
void *g(int, int, int, int, void *, void *);

void *g(int a, int b, int c, int d, void *t, void *k) {
  if (k == (void *)0)
    return (void *)0;
  return f(t, k);
}</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>