<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 --- - Broken transitivity in functions comparison in MergeFunction pass"
   href="http://llvm.org/bugs/show_bug.cgi?id=17925">17925</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Broken transitivity in functions comparison in MergeFunction pass
          </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>Transformation Utilities
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>stpworld@narod.ru
          </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>Created <span class=""><a href="attachment.cgi?id=11539" name="attach_11539" title="Fix">attachment 11539</a> <a href="attachment.cgi?id=11539&action=edit" title="Fix">[details]</a></span>
Fix

This issue is about case of treating pointers as integers.
We treat pointers as different if they references different address space. At
the same time, we treat pointers equal to integers (with machine address
width).
Its a point of false-positive now. Consider next case on 32bit machine:

void foo0(i32 addrespace(1)* %p)
void foo1(i32 addrespace(2)* %p)
void foo2(i32 %p)

foo0 != foo1, while
foo1 == foo2 and foo0 == foo2.

As you can see it breaks transitivity. That means that result depends on order
of how functions are presented in module. Next order causes merging of foo0 and
foo1:
foo2, foo0, foo1
First foo0 will be merged with foo2, foo0 will be erased. Second foo1 will be
merged with foo2.
Depending on order things could be merged we don't expect to.

The fix:
The are cases when we CAN treat pointers as integers, and places when we CAN'T.
Below is my proposal:
* We treat pointers as integers when we compare function formal arguments.
* Otherwise, we can't do that in general.
* We can add more exceptions, where address space affects nothing: for example
argument of "ret" instruction.
The patch is attached.

Though, by now, it breaks 3 tests, but only since these tests checks things
that are wrong in general.</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>