+TEST_F(LinkModuleTest, TypeMerge) {
+ LLVMContext C;
+ SMDiagnostic Err;
+
+ const char *M1Str = "%t = type {i32}\n"
+ "@t1 = weak global %t zeroinitializer\n";
+ std::unique_ptr<Module> M1 = parseAssemblyString(M1Str, Err, C);
+
+ const char *M2Str = "%t = type {i32}\n"
+ "@t2 = weak global %t zeroinitializer\n";
+ std::unique_ptr<Module> M2 = parseAssemblyString(M2Str, Err, C);
+
+ Linker::LinkModules(M1.get(), M2.get(), [](const llvm::DiagnosticInfo &){});
+
+ EXPECT_EQ(M1->getNamedGlobal("t1")->getType(),
+ M1->getNamedGlobal("t2")->getType());
+}
+