Lines Matching refs:GV
77 static unsigned getGVAlignmentLog2(const GlobalValue *GV, const DataLayout &TD,
80 if (const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV))
87 // If the GV has a specified alignment, take it into account.
88 if (GV->getAlignment() == 0)
91 unsigned GVAlign = Log2_32(GV->getAlignment());
94 // NumBits because the GV has an assigned section, obey it.
95 if (GVAlign > NumBits || GV->hasSection())
255 static bool canBeHidden(const GlobalValue *GV, const MCAsmInfo &MAI) {
256 GlobalValue::LinkageTypes Linkage = GV->getLinkage();
263 if (GV->hasUnnamedAddr())
268 if (isa<GlobalAlias>(GV))
273 if (const GlobalVariable *Var = dyn_cast<GlobalVariable>(GV)) {
279 if (!GlobalStatus::analyzeGlobal(GV, GS) && !GS.IsCompared)
285 void AsmPrinter::EmitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const {
286 GlobalValue::LinkageTypes Linkage = GV->getLinkage();
297 if (!canBeHidden(GV, *MAI))
331 const GlobalValue *GV) const {
332 TM.getNameWithPrefix(Name, GV, *Mang);
335 MCSymbol *AsmPrinter::getSymbol(const GlobalValue *GV) const {
336 return TM.getSymbol(GV, *Mang);
340 void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
341 if (GV->hasInitializer()) {
343 if (EmitSpecialLLVMGlobal(GV))
347 GV->printAsOperand(OutStreamer.GetCommentOS(),
348 /*PrintType=*/false, GV->getParent());
353 MCSymbol *GVSym = getSymbol(GV);
354 EmitVisibility(GVSym, GV->getVisibility(), !GV->isDeclaration());
356 if (!GV->hasInitializer()) // External globals require no extra code.
362 SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GV, TM);
365 uint64_t Size = DL->getTypeAllocSize(GV->getType()->getElementType());
370 unsigned AlignLog = getGVAlignmentLog2(GV, *DL);
395 getObjFileLowering().SectionForGlobal(GV, GVKind, *Mang, TM);
424 getObjFileLowering().SectionForGlobal(GV, GVKind, *Mang, TM);
459 EmitAlignment(AlignLog, GV);
462 EmitGlobalConstant(GV->getInitializer());
473 EmitLinkage(GV, GVSym);
480 unsigned PtrSize = DL->getPointerTypeSize(GV->getType());
492 EmitLinkage(GV, GVSym);
493 EmitAlignment(AlignLog, GV);
497 EmitGlobalConstant(GV->getInitializer());
1288 bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) {
1289 if (GV->getName() == "llvm.used") {
1291 EmitLLVMUsedList(cast<ConstantArray>(GV->getInitializer()));
1296 if (StringRef(GV->getSection()) == "llvm.metadata" ||
1297 GV->hasAvailableExternallyLinkage())
1300 if (!GV->hasAppendingLinkage()) return false;
1302 assert(GV->hasInitializer() && "Not a special LLVM global!");
1304 if (GV->getName() == "llvm.global_ctors") {
1305 EmitXXStructorList(GV->getInitializer(), /* isCtor */ true);
1316 if (GV->getName() == "llvm.global_dtors") {
1317 EmitXXStructorList(GV->getInitializer(), /* isCtor */ false);
1337 const GlobalValue *GV =
1339 if (GV)
1340 OutStreamer.EmitSymbolAttribute(getSymbol(GV), MCSA_NoDeadStrip);
1398 if (GlobalValue *GV = S.ComdatKey) {
1399 if (GV->hasAvailableExternallyLinkage())
1404 KeySym = getSymbol(GV);
1533 void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalObject *GV) const {
1534 if (GV) NumBits = getGVAlignmentLog2(GV, *TM.getDataLayout(), NumBits);
1559 if (const GlobalValue *GV = dyn_cast<GlobalValue>(CV))
1560 return MCSymbolRefExpr::Create(AP.getSymbol(GV), Ctx);
2103 MCSymbol *AsmPrinter::getSymbolWithGlobalValueBase(const GlobalValue *GV,
2105 return getObjFileLowering().getSymbolWithGlobalValueBase(GV, Suffix, *Mang,