Lines Matching defs:GV

267 static const GlobalObject *getBaseObject(const GlobalValue &GV) {
268 if (auto *GA = dyn_cast<GlobalAlias>(&GV))
270 return cast<GlobalObject>(&GV);
382 const GlobalValue *GV = Obj->getSymbolGV(Sym.getRawDataRefImpl());
385 if (GV) {
386 switch (GV->getVisibility()) {
401 if (GV && GV->hasExternalWeakLinkage())
405 if (GV) {
406 assert(!GV->hasExternalWeakLinkage() &&
407 !GV->hasAvailableExternallyLinkage() && "Not a declaration!");
408 if (GV->hasCommonLinkage())
410 else if (GV->isWeakForLinker())
417 if (GV) {
418 const GlobalObject *Base = getBaseObject(*GV);
441 static void keepGlobalValue(GlobalValue &GV,
443 assert(!GV.hasLocalLinkage());
445 if (auto *GA = dyn_cast<GlobalAlias>(&GV))
448 switch (GV.getLinkage()) {
452 GV.setLinkage(GlobalValue::WeakAnyLinkage);
455 GV.setLinkage(GlobalValue::WeakODRLinkage);
459 assert(!GV.isDiscardableIfUnused());
462 static void internalize(GlobalValue &GV) {
463 if (GV.isDeclarationForLinker())
465 if (!GV.hasLocalLinkage())
466 GV.setLinkage(GlobalValue::InternalLinkage);
469 static void drop(GlobalValue &GV) {
470 if (auto *F = dyn_cast<Function>(&GV)) {
476 if (auto *Var = dyn_cast<GlobalVariable>(&GV)) {
484 auto &Alias = cast<GlobalAlias>(GV);
628 GlobalValue *GV = Obj.getSymbolGV(ObjSym.getRawDataRefImpl());
629 if (!GV) {
634 if (Resolution != LDPR_PREVAILING_DEF_IRONLY && GV->hasCommonLinkage()) {
637 // The IR linker does that for us if we just pass it every common GV.
651 assert(GV->isDeclarationForLinker());
655 if (!GV->isDeclarationForLinker()) {
656 assert(GV->hasComdat());
657 Drop.insert(GV);
662 keepGlobalValue(*GV, KeptAliases);
663 if (!Used.count(GV)) {
664 // Since we use the regular lib/Linker, we cannot just internalize GV
667 Internalize.insert(GV->getName());
673 keepGlobalValue(*GV, KeptAliases);
679 if (!GV->isDiscardableIfUnused())
680 Maybe.erase(GV->getName());
684 Drop.insert(GV);
689 // reason is that this GV might have a copy in another module
692 if (GV->hasLinkOnceODRLinkage())
693 Maybe.insert(GV->getName());
694 keepGlobalValue(*GV, KeptAliases);
705 // Gold told us to keep GA. It is possible that a GV usied in the aliasee
706 // expression is being dropped. If that is the case, that GV must be copied.
712 for (auto *GV : Drop)
713 drop(*GV);
859 GlobalValue *GV = Combined->getNamedValue(Name.first());
860 if (GV)
861 internalize(*GV);
865 GlobalValue *GV = Combined->getNamedValue(Name.first());
866 if (!GV)
868 GV->setLinkage(GlobalValue::LinkOnceODRLinkage);
869 if (canBeOmittedFromSymbolTable(GV))
870 internalize(*GV);