Possible bug with struct types and linking

Hi All,

I ran into what I think is a linker bug around structural uniquing of types when trying to make a long-overdue upgrade from LLVM 3.3 to LLVM 3.8.0. Verification can fail after linking together two well-formed modules due to mismatched pointer types.

What happens is that both of the types in the source module get mapped to the same type in the destination module. The old behaviour was to map each type to the type in the destination with matching name and structure. This means that the type signatures of functions called from the Dst module can change, causing verification failures, e.g. if a call instruction originally from Dst calls a function in Src with the wrong typed pointer.

Dst Module

I would be interested in seeing the fix and full testcase.

It has been a long time since I looked at the type merging, but I
would expect it to work for this case.

Cheers,
Rafael

Thanks for the quick response Rafael, that’s what I hoped to hear - I’ll see what I can do!

The original repro is ~150000 lines of IR so I’ll see if I can reduce it :slight_smile:

  • Tim

Thanks for the quick response Rafael, that's what I hoped to hear - I'll
see what I can do!

The original repro is ~150000 lines of IR so I'll see if I can reduce it :slight_smile:

bugpoint may be helpful:

-- Sean Silva

I was able to get a relatively simple reproduction of the issue and posted it along with a fix: http://reviews.llvm.org/D18683

Unfortunately I had to resort to writing a unit test rather than using the normal test infrastructure since llvm-link links modules in a way that avoids the bug.