<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - Differences in DWARF line number info between directly generated and assembled object files"
   href="https://bugs.llvm.org/show_bug.cgi?id=45775">45775</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Differences in DWARF line number info between directly generated and assembled object files
          </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>Windows NT
          </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>LLVM assembly language parser
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>Wolfgang_Pieb@playstation.sony.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following source, when compiled directly to an object file vs. when first
compiled to an assembly file, and then assembled, produces different line
number information.

struct Ctx
{
  int m1;
  int m2;
};

static Ctx States[2] =
{
  {0, 1}, {2, 3}
};

int getType(struct s* myS);
int foo(struct s* myS)
{
  int type = getType(myS);
  if (type != -1) {
    return States[type].m2;
  }
  return 0;
}

The difference can be demonstrated with the following script:

#!/bin/sh
clang -g -O2 -c test.cpp -o test.o
clang -g -O2 -S test.cpp -o test.s
clang -g -c test.s -o test.assembled.o

objdump -WliarfsoR test.o > 1
objdump -WliarfsoR test.assembled.o > 2
diff 1 2


I'm seeing the following differences:
265c237
<   Length:                      87
---
<span class="quote">>   Length:                      88</span >
319,322c291,295
<   [0x00000053]  Advance Line by 20 to 20
<   [0x00000055]  Special opcode 33: advance Address by 2 to 0x18 and Line by 0
to 20
<   [0x00000056]  Advance PC by 2 to 0x1a
<   [0x00000058]  Extended opcode 1: End of Sequence
---
<span class="quote">>   [0x00000053]  Set is_stmt to 1
>   [0x00000054]  Advance Line by 20 to 20
>   [0x00000056]  Special opcode 33: advance Address by 2 to 0x18 and Line by 0 to 20
>   [0x00000057]  Advance PC by 2 to 0x1a
>   [0x00000059]  Extended opcode 1: End of Sequence</span ></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>