<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 --- - merging of code can lead to misleading line number information; add flag to disable it in some cases?"
   href="http://llvm.org/bugs/show_bug.cgi?id=22579">22579</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>merging of code can lead to misleading line number information; add flag to disable it in some cases?
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.3
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>FreeBSD
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>llvm@insonuit.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>In cases where several lines of code are merged together to share instructions,
llvm
currently picks a single line number to 'represent' those in the DWARF.  This
can lead
to misleading backtraces.

An example from our source base is a large function with some 20 assertion
failure
points.  If any of those assertions fails, the backtrace will point to a single
one
of them, because all of them share the code to our assertion failure function. 
This
is, in part, because that function has __attribute((noreturn)).

We could remove that attribute, but that opens us up to warnings based on
static
analysis of the code.

If there were a flag to disable the code merging which is happening here, we
could
get useful backtraces.

For example, code like this

  extern int do_assert(const char *, int, const char *, ...)
__attribute((noreturn));

  void try(int a)
  {
    if (a & 1)
      do_assert("one", 0, "");
    if (a & 2)
      do_assert("two", 0, "");
    if (a & 4)
      do_assert("three", 0, "");
  }

generates a single call to do_assert.  This is normally a Good Thing, but it
has been
confusing some of our developers (and we don't care that much).

Changing __attribute((noreturn)) to __attribute((analyzer_noreturn)) seems like
it
might be a path forward, but it triggers missing-return-value warnings for code
like

  int val(int a)
  {
    if (a == 1) return 1;
    if (a == 2) return 2;
    do_assert("bad a", 0, "");
  }

Interestingly, it does *not* trigger a number of other warnings, such as
uninitialized
variables in the default case of a switch, so perhaps this is a case where this
warning
should have been disabled [somehow] by the analyzer_noreturn attribute?

An alternative would be to avoid generating line numbers in the DWARF at all
for this
type of merged code.  That might be reasonable too.</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>