+
+ StringRef Name = AVI.NewGV->getName();
+ bool IsNewStructor =
+ (Name == "llvm.global_ctors" || Name == "llvm.global_dtors") &&
+ cast<StructType>(NewType->getElementType())->getNumElements() == 3;
+
+ for (auto *V : SrcElements) {
+ if (IsNewStructor) {
+ Constant *Key = V->getAggregateElement(2);
+ if (DoNotLinkFromSource.count(Key))
+ continue;
+ }
+ DstElements.push_back(
+ MapValue(V, ValueMap, RF_None, &TypeMap, &ValMaterializer));
+ }
+ if (IsNewStructor) {
+ NewType = ArrayType::get(NewType->getElementType(), DstElements.size());
+ AVI.NewGV->mutateType(PointerType::get(NewType, 0));
+ }
+
+ AVI.NewGV->setInitializer(ConstantArray::get(NewType, DstElements));