@@ -350,12 +350,20 @@ void splitAndWriteThinLTOBitcode(
350350 });
351351 }
352352
353+ auto MustEmitToMergedModule = [](const GlobalValue *GV) {
354+ // The __cfi_check definition is filled in by the CrossDSOCFI pass which
355+ // runs only in the merged module.
356+ return GV->getName () == " __cfi_check" ;
357+ };
358+
353359 ValueToValueMapTy VMap;
354360 std::unique_ptr<Module> MergedM (
355361 CloneModule (M, VMap, [&](const GlobalValue *GV) -> bool {
356362 if (const auto *C = GV->getComdat ())
357363 if (MergedMComdats.count (C))
358364 return true ;
365+ if (MustEmitToMergedModule (GV))
366+ return true ;
359367 if (auto *F = dyn_cast<Function>(GV))
360368 return EligibleVirtualFns.count (F);
361369 if (auto *GVar =
@@ -372,7 +380,7 @@ void splitAndWriteThinLTOBitcode(
372380 cloneUsedGlobalVariables (M, *MergedM, /* CompilerUsed*/ true );
373381
374382 for (Function &F : *MergedM)
375- if (!F.isDeclaration ()) {
383+ if (!F.isDeclaration () && ! MustEmitToMergedModule (&F) ) {
376384 // Reset the linkage of all functions eligible for virtual constant
377385 // propagation. The canonical definitions live in the thin LTO module so
378386 // that they can be imported.
@@ -398,6 +406,8 @@ void splitAndWriteThinLTOBitcode(
398406 if (const auto *C = GV->getComdat ())
399407 if (MergedMComdats.count (C))
400408 return false ;
409+ if (MustEmitToMergedModule (GV))
410+ return false ;
401411 return true ;
402412 });
403413
0 commit comments