+ if (const Comdat *SC = Src.getComdat()) {
+ // To ensure that we don't generate an incomplete comdat group,
+ // we must materialize and map in any other members that are not
+ // yet materialized in Dst, which also ensures their definitions
+ // are linked in. Otherwise, linkonce and other lazy linked GVs will
+ // not be materialized if they aren't referenced.
+ for (auto *SGV : ComdatMembers[SC]) {
+ if (ValueMap[SGV])
+ continue;
+ Value *NewV = ValMaterializer.materializeValueFor(SGV);
+ ValueMap[SGV] = NewV;
+ }
+ }