<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 - [IPRA] wrong code: optimizing with a function that is not truly local"
   href="https://bugs.llvm.org/show_bug.cgi?id=37284">37284</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[IPRA] wrong code: optimizing with a function that is not truly local
          </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>Linux
          </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>Common Code Generator Code
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>paulsson@linux.vnet.ibm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When enabling IPRA on SystemZ on spec-2006/dealII, the benchmark crashes
immediately.

It seems that there is a 'begin_active_line' method defined in tria.h, that is
included and compiled in four source files. In tria.cc, this function does not
clobber %r3 (which is *this), and so the *this pointer is not moved into %r3
argument register before the second consecutive call to this method, by another
method in the same file.

The linker then uses another definition from one of the other object files,
which does actually clobber %r3, and the error occurs.

My first question is why those definitions are different in different files? If
the call-graph guaranteed a handling of leaf-functions before callers, they
should be identical, or?

On the other hand, I don't understand how IPRA would dare to make the
assumption about %r3 not being clobbered on a non-local function, not compiled
in the same translation unit at the same time. Anything else seems risky to me,
right?

In the module that has the actually used version (which clobbers %r3), I see
these function attributes: 'linkonce_odr dso_local' In tria.o I see 'weak_odr
dso_local', which is not quite the same, although nearly. Perhaps some
optimizer is confused here since linkonce indicate "merged with other globals
of the same name when linkage occurs", while dso_local is defined as "the
compiler may assume that a function or variable marked as dso_local will
resolve to a symbol within the same linkage unit". 

Still, I wonder how this attribute would come into play here, since neither the
RegUsageInfoCollector or RegUsageInfoPropagator even checks the function
attributes..??

Shold RegUsageInfoCollector check the Function attributes and abort in this
case? Or are the Function attributes confused? 

Side question: Is it perhaps the intent that IPRA should actually work on a
small function like this, perhaps by replicating it and making a local
definition with a similar name?</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>