Lines Matching refs:SGV

425   GlobalValue *copyGlobalValueProto(const GlobalValue *SGV, bool ForDefinition);
463 bool shouldLink(GlobalValue *DGV, GlobalValue &SGV);
525 Value *GlobalValueMaterializer::materialize(Value *SGV) { in materialize() argument
526 return TheIRLinker.materialize(SGV, false); in materialize()
529 Value *LocalValueMaterializer::materialize(Value *SGV) { in materialize() argument
530 return TheIRLinker.materialize(SGV, true); in materialize()
534 auto *SGV = dyn_cast<GlobalValue>(V); in materialize() local
535 if (!SGV) in materialize()
538 Expected<Constant *> NewProto = linkGlobalValueProto(SGV, ForAlias); in materialize()
571 if (ForAlias && ValueMap.lookup(SGV) == New) in materialize()
574 if (ForAlias || shouldLink(New, *SGV)) in materialize()
575 setError(linkGlobalValueBody(*New, *SGV)); in materialize()
615 GlobalValue *IRLinker::copyGlobalValueProto(const GlobalValue *SGV, in copyGlobalValueProto() argument
618 if (auto *SGVar = dyn_cast<GlobalVariable>(SGV)) { in copyGlobalValueProto()
620 } else if (auto *SF = dyn_cast<Function>(SGV)) { in copyGlobalValueProto()
624 NewGV = copyGlobalAliasProto(cast<GlobalAlias>(SGV)); in copyGlobalValueProto()
627 DstM, TypeMap.get(SGV->getValueType()), in copyGlobalValueProto()
629 /*init*/ nullptr, SGV->getName(), in copyGlobalValueProto()
630 /*insertbefore*/ nullptr, SGV->getThreadLocalMode(), in copyGlobalValueProto()
631 SGV->getType()->getAddressSpace()); in copyGlobalValueProto()
635 NewGV->setLinkage(SGV->getLinkage()); in copyGlobalValueProto()
636 else if (SGV->hasExternalWeakLinkage()) in copyGlobalValueProto()
639 NewGV->copyAttributesFrom(SGV); in copyGlobalValueProto()
643 if (isa<GlobalVariable>(SGV) || SGV->isDeclaration()) in copyGlobalValueProto()
644 NewGO->copyMetadata(cast<GlobalObject>(SGV), 0); in copyGlobalValueProto()
664 for (GlobalValue &SGV : SrcM->globals()) { in computeTypeMapping()
665 GlobalValue *DGV = getLinkedToGlobal(&SGV); in computeTypeMapping()
669 if (!DGV->hasAppendingLinkage() || !SGV.hasAppendingLinkage()) { in computeTypeMapping()
670 TypeMap.addTypeMapping(DGV->getType(), SGV.getType()); in computeTypeMapping()
676 ArrayType *SAT = cast<ArrayType>(SGV.getValueType()); in computeTypeMapping()
680 for (GlobalValue &SGV : *SrcM) in computeTypeMapping()
681 if (GlobalValue *DGV = getLinkedToGlobal(&SGV)) in computeTypeMapping()
682 TypeMap.addTypeMapping(DGV->getType(), SGV.getType()); in computeTypeMapping()
684 for (GlobalValue &SGV : SrcM->aliases()) in computeTypeMapping()
685 if (GlobalValue *DGV = getLinkedToGlobal(&SGV)) in computeTypeMapping()
686 TypeMap.addTypeMapping(DGV->getType(), SGV.getType()); in computeTypeMapping()
848 bool IRLinker::shouldLink(GlobalValue *DGV, GlobalValue &SGV) { in shouldLink() argument
849 if (ValuesToLink.count(&SGV) || SGV.hasLocalLinkage()) in shouldLink()
855 if (SGV.hasAvailableExternallyLinkage()) in shouldLink()
858 if (SGV.isDeclaration() || DoneLinkingBodies) in shouldLink()
864 AddLazyFor(SGV, [this, &LazilyAdded](GlobalValue &GV) { in shouldLink()
871 Expected<Constant *> IRLinker::linkGlobalValueProto(GlobalValue *SGV, in linkGlobalValueProto() argument
873 GlobalValue *DGV = getLinkedToGlobal(SGV); in linkGlobalValueProto()
875 bool ShouldLink = shouldLink(DGV, *SGV); in linkGlobalValueProto()
879 auto I = ValueMap.find(SGV); in linkGlobalValueProto()
883 I = AliasValueMap.find(SGV); in linkGlobalValueProto()
892 assert(!DGV || SGV->hasAppendingLinkage() == DGV->hasAppendingLinkage()); in linkGlobalValueProto()
893 if (SGV->hasAppendingLinkage()) in linkGlobalValueProto()
895 cast<GlobalVariable>(SGV)); in linkGlobalValueProto()
907 NewGV = copyGlobalValueProto(SGV, ShouldLink); in linkGlobalValueProto()
909 forceRenaming(NewGV, SGV->getName()); in linkGlobalValueProto()
920 if (const Comdat *SC = SGV->getComdat()) { in linkGlobalValueProto()
934 C = ConstantExpr::getBitCast(NewGV, TypeMap.get(SGV->getType())); in linkGlobalValueProto()