We saw the same assertion failure mentioned here
https://bugs.llvm.org/show_bug.cgi?id=42063 in our internal tests.
The failure happens in the same circumstance as D47898 and D66814 where
uniqueing of DICompositeTypes causes Mapper::mapValue to be called on
GlobalValues(G) from a not-yet-linked module(M). The following type-mapping for
G may not complete correctly (fail to unique types etc. depending on the
the complexity of the types) because IRLinker::computeTypeMapping is not done for M
in this path.
D47898 and D66814 fixed some type-mapping issue after Mapper::mapValue
is called on G. However, it seems it did not handle some complex cases. I
think we should delay linking globals like G until its owing module is
linked. In this way, we could save unnecessary type mapping and prune
these corner cases. It is also supposed to reduce the total number of structs
ending up in the combined module.
D47898 is reverted (its test is kept) because it regresses the test case here.
D66814 could also be reverted (the check-all looks good). But it looks reasonable
anyway, so I thought I should keep it.
Also tested the patch with clang self-host regularLTO/ThinLTO build, things look
good as well.
I assume t1 refers to %t1.o, etc? Would be clearer to spell that out here and elsewhere.