<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 --- - Type merging regression in lib/Linker"
   href="http://llvm.org/bugs/show_bug.cgi?id=22807">22807</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Type merging regression in lib/Linker
          </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>Linker
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>dexonsmith@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu, rafael.espindola@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=13988" name="attach_13988" title="reinitialize-linker.patch: patch that "fixes" the bug (the wrong way)">attachment 13988</a> <a href="attachment.cgi?id=13988&action=edit" title="reinitialize-linker.patch: patch that "fixes" the bug (the wrong way)">[details]</a></span>
reinitialize-linker.patch: patch that "fixes" the bug (the wrong way)

Here's an interesting regression in type merging in lib/Linker.  The example
that follows would merge %struct.A in 3.5, but doesn't in ToT.

I've attached a patch that "fixes" the problem (the wrong way) by not reusing
the `Linker` in `llvm-link`.  I haven't dug into what's going on though.

Here's the example:

$ cat A1.ll
%struct.A = type { %struct.B* }
%struct.B = type opaque

define i32 @foo(%struct.A** %A) {
  ret i32 0
}
$ cat A2.ll
%struct.A = type { %struct.B* }
%struct.B = type opaque

define i32 @bar(%struct.A* %A) {
   ret i32 0
}
$ cat B.ll
%struct.B = type { %struct.A* }
%struct.A = type opaque

define i32 @baz(%struct.B* %BB) {
  ret i32 0
}
$ llvm-link -S -o - B.ll A1.ll A2.ll
; ModuleID = 'llvm-link'

%struct.B = type { %struct.A* }
%struct.A = type { %struct.B* }
%struct.A.2 = type { %struct.B* }

define i32 @baz(%struct.B* %BB) {
  ret i32 0
}

define i32 @foo(%struct.A** %A) {
  ret i32 0
}

define i32 @bar(%struct.A.2* %A) {
  ret i32 0
}</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>