Lines Matching refs:llvm
78 llvm::Module &M, const llvm::DataLayout &TD, in CodeGenModule()
96 llvm::LLVMContext &LLVMContext = M.getContext(); in CodeGenModule()
97 VoidTy = llvm::Type::getVoidTy(LLVMContext); in CodeGenModule()
98 Int8Ty = llvm::Type::getInt8Ty(LLVMContext); in CodeGenModule()
99 Int16Ty = llvm::Type::getInt16Ty(LLVMContext); in CodeGenModule()
100 Int32Ty = llvm::Type::getInt32Ty(LLVMContext); in CodeGenModule()
101 Int64Ty = llvm::Type::getInt64Ty(LLVMContext); in CodeGenModule()
102 FloatTy = llvm::Type::getFloatTy(LLVMContext); in CodeGenModule()
103 DoubleTy = llvm::Type::getDoubleTy(LLVMContext); in CodeGenModule()
107 IntTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getIntWidth()); in CodeGenModule()
108 IntPtrTy = llvm::IntegerType::get(LLVMContext, PointerWidthInBits); in CodeGenModule()
145 llvm::IndexedInstrProfReader::create(CodeGenOpts.InstrProfileInput); in CodeGenModule()
203 void CodeGenModule::addReplacement(StringRef Name, llvm::Constant *C) { in addReplacement()
212 llvm::Constant *Replacement = I->second; in applyReplacements()
213 llvm::GlobalValue *Entry = GetGlobalValue(MangledName); in applyReplacements()
216 auto *OldF = cast<llvm::Function>(Entry); in applyReplacements()
217 auto *NewF = dyn_cast<llvm::Function>(Replacement); in applyReplacements()
219 if (auto *Alias = dyn_cast<llvm::GlobalAlias>(Replacement)) { in applyReplacements()
220 NewF = dyn_cast<llvm::Function>(Alias->getAliasee()); in applyReplacements()
222 auto *CE = cast<llvm::ConstantExpr>(Replacement); in applyReplacements()
223 assert(CE->getOpcode() == llvm::Instruction::BitCast || in applyReplacements()
224 CE->getOpcode() == llvm::Instruction::GetElementPtr); in applyReplacements()
225 NewF = dyn_cast<llvm::Function>(CE->getOperand(0)); in applyReplacements()
241 static const llvm::GlobalObject *getAliasedGlobal(const llvm::GlobalAlias &GA) { in getAliasedGlobal()
242 llvm::SmallPtrSet<const llvm::GlobalAlias*, 4> Visited; in getAliasedGlobal()
243 const llvm::Constant *C = &GA; in getAliasedGlobal()
246 if (auto *GO = dyn_cast<llvm::GlobalObject>(C)) in getAliasedGlobal()
249 auto *GA2 = dyn_cast<llvm::GlobalAlias>(C); in getAliasedGlobal()
270 llvm::GlobalValue *Entry = GetGlobalValue(MangledName); in checkAliases()
271 auto *Alias = cast<llvm::GlobalAlias>(Entry); in checkAliases()
272 const llvm::GlobalValue *GV = getAliasedGlobal(*Alias); in checkAliases()
281 llvm::Constant *Aliasee = Alias->getAliasee(); in checkAliases()
282 llvm::GlobalValue *AliaseeGV; in checkAliases()
283 if (auto CE = dyn_cast<llvm::ConstantExpr>(Aliasee)) in checkAliases()
284 AliaseeGV = cast<llvm::GlobalValue>(CE->getOperand(0)); in checkAliases()
286 AliaseeGV = cast<llvm::GlobalValue>(Aliasee); in checkAliases()
300 if (auto GA = dyn_cast<llvm::GlobalAlias>(AliaseeGV)) { in checkAliases()
304 Aliasee = llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast( in checkAliases()
317 llvm::GlobalValue *Entry = GetGlobalValue(MangledName); in checkAliases()
318 auto *Alias = cast<llvm::GlobalAlias>(Entry); in checkAliases()
319 Alias->replaceAllUsesWith(llvm::UndefValue::get(Alias->getType())); in checkAliases()
351 if (llvm::Function *ObjCInitFunction = ObjCRuntime->ModuleInitFunction()) in Release()
371 getModule().addModuleFlag(llvm::Module::Warning, "Dwarf Version", in Release()
377 getModule().addModuleFlag(llvm::Module::Warning, "Debug Info Version", in Release()
378 llvm::DEBUG_METADATA_VERSION); in Release()
382 llvm::Triple::ArchType Arch = Context.getTargetInfo().getTriple().getArch(); in Release()
383 if ( Arch == llvm::Triple::arm in Release()
384 || Arch == llvm::Triple::armeb in Release()
385 || Arch == llvm::Triple::thumb in Release()
386 || Arch == llvm::Triple::thumbeb) { in Release()
390 getModule().addModuleFlag(llvm::Module::Error, "wchar_size", WCharWidth); in Release()
394 getModule().addModuleFlag(llvm::Module::Error, "min_enum_size", EnumWidth); in Release()
398 llvm::PICLevel::Level PL = llvm::PICLevel::Default; in Release()
401 case 1: PL = llvm::PICLevel::Small; break; in Release()
402 case 2: PL = llvm::PICLevel::Large; break; in Release()
430 llvm::MDNode *CodeGenModule::getTBAAInfo(QualType QTy) { in getTBAAInfo()
436 llvm::MDNode *CodeGenModule::getTBAAInfoForVTablePtr() { in getTBAAInfoForVTablePtr()
442 llvm::MDNode *CodeGenModule::getTBAAStructInfo(QualType QTy) { in getTBAAStructInfo()
448 llvm::MDNode *CodeGenModule::getTBAAStructTypeInfo(QualType QTy) { in getTBAAStructTypeInfo()
454 llvm::MDNode *CodeGenModule::getTBAAStructTagInfo(QualType BaseTy, in getTBAAStructTagInfo()
455 llvm::MDNode *AccessN, in getTBAAStructTagInfo()
466 void CodeGenModule::DecorateInstruction(llvm::Instruction *Inst, in DecorateInstruction()
467 llvm::MDNode *TBAAInfo, in DecorateInstruction()
470 Inst->setMetadata(llvm::LLVMContext::MD_tbaa, in DecorateInstruction()
473 Inst->setMetadata(llvm::LLVMContext::MD_tbaa, TBAAInfo); in DecorateInstruction()
500 llvm::ConstantInt *CodeGenModule::getSize(CharUnits size) { in getSize()
501 return llvm::ConstantInt::get(SizeTy, size.getQuantity()); in getSize()
504 void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV, in setGlobalVisibility()
508 GV->setVisibility(llvm::GlobalValue::DefaultVisibility); in setGlobalVisibility()
518 static llvm::GlobalVariable::ThreadLocalMode GetLLVMTLSModel(StringRef S) { in GetLLVMTLSModel()
519 return llvm::StringSwitch<llvm::GlobalVariable::ThreadLocalMode>(S) in GetLLVMTLSModel()
520 .Case("global-dynamic", llvm::GlobalVariable::GeneralDynamicTLSModel) in GetLLVMTLSModel()
521 .Case("local-dynamic", llvm::GlobalVariable::LocalDynamicTLSModel) in GetLLVMTLSModel()
522 .Case("initial-exec", llvm::GlobalVariable::InitialExecTLSModel) in GetLLVMTLSModel()
523 .Case("local-exec", llvm::GlobalVariable::LocalExecTLSModel); in GetLLVMTLSModel()
526 static llvm::GlobalVariable::ThreadLocalMode GetLLVMTLSModel( in GetLLVMTLSModel()
530 return llvm::GlobalVariable::GeneralDynamicTLSModel; in GetLLVMTLSModel()
532 return llvm::GlobalVariable::LocalDynamicTLSModel; in GetLLVMTLSModel()
534 return llvm::GlobalVariable::InitialExecTLSModel; in GetLLVMTLSModel()
536 return llvm::GlobalVariable::LocalExecTLSModel; in GetLLVMTLSModel()
541 void CodeGenModule::setTLSMode(llvm::GlobalValue *GV, const VarDecl &D) const { in setTLSMode()
544 llvm::GlobalValue::ThreadLocalMode TLM; in setTLSMode()
564 llvm::raw_svector_ostream Out(Buffer); in getMangledName()
589 llvm::raw_svector_ostream Out(Buffer); in getBlockMangledName()
604 llvm::GlobalValue *CodeGenModule::GetGlobalValue(StringRef Name) { in GetGlobalValue()
610 void CodeGenModule::AddGlobalCtor(llvm::Function *Ctor, int Priority, in AddGlobalCtor()
611 llvm::Constant *AssociatedData) { in AddGlobalCtor()
618 void CodeGenModule::AddGlobalDtor(llvm::Function *Dtor, int Priority) { in AddGlobalDtor()
625 llvm::FunctionType* CtorFTy = llvm::FunctionType::get(VoidTy, false); in EmitCtorList()
626 llvm::Type *CtorPFTy = llvm::PointerType::getUnqual(CtorFTy); in EmitCtorList()
629 llvm::StructType *CtorStructTy = llvm::StructType::get( in EmitCtorList()
630 Int32Ty, llvm::PointerType::getUnqual(CtorFTy), VoidPtrTy, nullptr); in EmitCtorList()
633 SmallVector<llvm::Constant*, 8> Ctors; in EmitCtorList()
635 llvm::Constant *S[] = { in EmitCtorList()
636 llvm::ConstantInt::get(Int32Ty, I->Priority, false), in EmitCtorList()
637 llvm::ConstantExpr::getBitCast(I->Initializer, CtorPFTy), in EmitCtorList()
639 ? llvm::ConstantExpr::getBitCast(I->AssociatedData, VoidPtrTy) in EmitCtorList()
640 : llvm::Constant::getNullValue(VoidPtrTy)) in EmitCtorList()
642 Ctors.push_back(llvm::ConstantStruct::get(CtorStructTy, S)); in EmitCtorList()
646 llvm::ArrayType *AT = llvm::ArrayType::get(CtorStructTy, Ctors.size()); in EmitCtorList()
647 new llvm::GlobalVariable(TheModule, AT, false, in EmitCtorList()
648 llvm::GlobalValue::AppendingLinkage, in EmitCtorList()
649 llvm::ConstantArray::get(AT, Ctors), in EmitCtorList()
654 llvm::GlobalValue::LinkageTypes
665 return Linkage == GVA_Internal ? llvm::GlobalValue::InternalLinkage in getFunctionLinkage()
666 : llvm::GlobalValue::LinkOnceODRLinkage; in getFunctionLinkage()
673 llvm::Function *F) { in setFunctionDefinitionAttributes()
679 llvm::Function *F) { in SetLLVMFunctionAttributes()
683 F->setAttributes(llvm::AttributeSet::get(getLLVMContext(), AttributeList)); in SetLLVMFunctionAttributes()
684 F->setCallingConv(static_cast<llvm::CallingConv::ID>(CallingConv)); in SetLLVMFunctionAttributes()
708 llvm::Function *F) { in SetLLVMFunctionAttributesForDefinition()
709 llvm::AttrBuilder B; in SetLLVMFunctionAttributesForDefinition()
712 B.addAttribute(llvm::Attribute::UWTable); in SetLLVMFunctionAttributesForDefinition()
715 B.addAttribute(llvm::Attribute::NoUnwind); in SetLLVMFunctionAttributesForDefinition()
719 B.addAttribute(llvm::Attribute::Naked); in SetLLVMFunctionAttributesForDefinition()
720 B.addAttribute(llvm::Attribute::NoInline); in SetLLVMFunctionAttributesForDefinition()
722 B.addAttribute(llvm::Attribute::NoDuplicate); in SetLLVMFunctionAttributesForDefinition()
724 B.addAttribute(llvm::Attribute::NoInline); in SetLLVMFunctionAttributesForDefinition()
726 !F->getAttributes().hasAttribute(llvm::AttributeSet::FunctionIndex, in SetLLVMFunctionAttributesForDefinition()
727 llvm::Attribute::NoInline)) { in SetLLVMFunctionAttributesForDefinition()
729 B.addAttribute(llvm::Attribute::AlwaysInline); in SetLLVMFunctionAttributesForDefinition()
734 B.addAttribute(llvm::Attribute::OptimizeForSize); in SetLLVMFunctionAttributesForDefinition()
735 B.addAttribute(llvm::Attribute::Cold); in SetLLVMFunctionAttributesForDefinition()
739 B.addAttribute(llvm::Attribute::MinSize); in SetLLVMFunctionAttributesForDefinition()
742 B.addAttribute(llvm::Attribute::StackProtect); in SetLLVMFunctionAttributesForDefinition()
744 B.addAttribute(llvm::Attribute::StackProtectStrong); in SetLLVMFunctionAttributesForDefinition()
746 B.addAttribute(llvm::Attribute::StackProtectReq); in SetLLVMFunctionAttributesForDefinition()
754 B.addAttribute(llvm::Attribute::SanitizeAddress); in SetLLVMFunctionAttributesForDefinition()
758 B.addAttribute(llvm::Attribute::SanitizeThread); in SetLLVMFunctionAttributesForDefinition()
762 B.addAttribute(llvm::Attribute::SanitizeMemory); in SetLLVMFunctionAttributesForDefinition()
765 F->addAttributes(llvm::AttributeSet::FunctionIndex, in SetLLVMFunctionAttributesForDefinition()
766 llvm::AttributeSet::get( in SetLLVMFunctionAttributesForDefinition()
767 F->getContext(), llvm::AttributeSet::FunctionIndex, B)); in SetLLVMFunctionAttributesForDefinition()
771 F->addFnAttr(llvm::Attribute::OptimizeNone); in SetLLVMFunctionAttributesForDefinition()
772 F->addFnAttr(llvm::Attribute::NoInline); in SetLLVMFunctionAttributesForDefinition()
775 assert(!F->hasFnAttribute(llvm::Attribute::OptimizeForSize) && in SetLLVMFunctionAttributesForDefinition()
777 assert(!F->hasFnAttribute(llvm::Attribute::MinSize) && in SetLLVMFunctionAttributesForDefinition()
779 assert(!F->hasFnAttribute(llvm::Attribute::AlwaysInline) && in SetLLVMFunctionAttributesForDefinition()
784 F->removeFnAttr(llvm::Attribute::InlineHint); in SetLLVMFunctionAttributesForDefinition()
803 llvm::GlobalValue *GV) { in SetCommonAttributes()
807 GV->setVisibility(llvm::GlobalValue::DefaultVisibility); in SetCommonAttributes()
814 llvm::GlobalValue *GV) { in setAliasAttributes()
820 GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass); in setAliasAttributes()
824 llvm::GlobalObject *GO) { in setNonAliasAttributes()
834 llvm::Function *F, in SetInternalFunctionAttributes()
839 F->setLinkage(llvm::Function::InternalLinkage); in SetInternalFunctionAttributes()
844 static void setLinkageAndVisibilityForGV(llvm::GlobalValue *GV, in setLinkageAndVisibilityForGV()
852 GV->setLinkage(llvm::GlobalValue::ExternalLinkage); in setLinkageAndVisibilityForGV()
853 GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass); in setLinkageAndVisibilityForGV()
855 GV->setLinkage(llvm::GlobalValue::ExternalLinkage); in setLinkageAndVisibilityForGV()
856 GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass); in setLinkageAndVisibilityForGV()
860 GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage); in setLinkageAndVisibilityForGV()
869 void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, llvm::Function *F, in SetFunctionAttributes()
875 F->setAttributes(llvm::Intrinsic::getAttributes(getLLVMContext(), in SetFunctionAttributes()
876 (llvm::Intrinsic::ID)IID)); in SetFunctionAttributes()
895 F->addAttribute(1, llvm::Attribute::Returned); in SetFunctionAttributes()
906 F->setDLLStorageClass(llvm::GlobalValue::DefaultStorageClass); in SetFunctionAttributes()
916 F->addAttribute(llvm::AttributeSet::FunctionIndex, in SetFunctionAttributes()
917 llvm::Attribute::NoBuiltin); in SetFunctionAttributes()
920 void CodeGenModule::addUsedGlobal(llvm::GlobalValue *GV) { in addUsedGlobal()
926 void CodeGenModule::addCompilerUsedGlobal(llvm::GlobalValue *GV) { in addCompilerUsedGlobal()
933 std::vector<llvm::WeakVH> &List) { in emitUsed()
939 SmallVector<llvm::Constant*, 8> UsedArray; in emitUsed()
943 llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast( in emitUsed()
944 cast<llvm::Constant>(&*List[i]), CGM.Int8PtrTy); in emitUsed()
949 llvm::ArrayType *ATy = llvm::ArrayType::get(CGM.Int8PtrTy, UsedArray.size()); in emitUsed()
951 auto *GV = new llvm::GlobalVariable( in emitUsed()
952 CGM.getModule(), ATy, false, llvm::GlobalValue::AppendingLinkage, in emitUsed()
953 llvm::ConstantArray::get(ATy, UsedArray), Name); in emitUsed()
964 auto *MDOpts = llvm::MDString::get(getLLVMContext(), Opts); in AppendLinkerOptions()
965 LinkerOptionsMetadata.push_back(llvm::MDNode::get(getLLVMContext(), MDOpts)); in AppendLinkerOptions()
969 llvm::SmallString<32> Opt; in AddDetectMismatch()
971 auto *MDOpts = llvm::MDString::get(getLLVMContext(), Opt); in AddDetectMismatch()
972 LinkerOptionsMetadata.push_back(llvm::MDNode::get(getLLVMContext(), MDOpts)); in AddDetectMismatch()
976 llvm::SmallString<24> Opt; in AddDependentLib()
978 auto *MDOpts = llvm::MDString::get(getLLVMContext(), Opt); in AddDependentLib()
979 LinkerOptionsMetadata.push_back(llvm::MDNode::get(getLLVMContext(), MDOpts)); in AddDependentLib()
985 SmallVectorImpl<llvm::Metadata *> &Metadata, in addLinkOptionsPostorder()
986 llvm::SmallPtrSet<Module *, 16> &Visited) { in addLinkOptionsPostorder()
1000 llvm::LLVMContext &Context = CGM.getLLVMContext(); in addLinkOptionsPostorder()
1005 llvm::Metadata *Args[2] = { in addLinkOptionsPostorder()
1006 llvm::MDString::get(Context, "-framework"), in addLinkOptionsPostorder()
1007 llvm::MDString::get(Context, Mod->LinkLibraries[I - 1].Library)}; in addLinkOptionsPostorder()
1009 Metadata.push_back(llvm::MDNode::get(Context, Args)); in addLinkOptionsPostorder()
1014 llvm::SmallString<24> Opt; in addLinkOptionsPostorder()
1017 auto *OptString = llvm::MDString::get(Context, Opt); in addLinkOptionsPostorder()
1018 Metadata.push_back(llvm::MDNode::get(Context, OptString)); in addLinkOptionsPostorder()
1026 llvm::SetVector<clang::Module *> LinkModules; in EmitModuleLinkOptions()
1027 llvm::SmallPtrSet<clang::Module *, 16> Visited; in EmitModuleLinkOptions()
1031 for (llvm::SetVector<clang::Module *>::iterator M = ImportedModules.begin(), in EmitModuleLinkOptions()
1070 SmallVector<llvm::Metadata *, 16> MetadataArgs; in EmitModuleLinkOptions()
1072 for (llvm::SetVector<clang::Module *>::iterator M = LinkModules.begin(), in EmitModuleLinkOptions()
1082 getModule().addModuleFlag(llvm::Module::AppendUnique, "Linker Options", in EmitModuleLinkOptions()
1083 llvm::MDNode::get(getLLVMContext(), in EmitModuleLinkOptions()
1112 llvm::GlobalValue *GV = G.GV; in EmitDeferred()
1146 llvm::Constant *Array = llvm::ConstantArray::get(llvm::ArrayType::get( in EmitGlobalAnnotations()
1148 auto *gv = new llvm::GlobalVariable(getModule(), Array->getType(), false, in EmitGlobalAnnotations()
1149 llvm::GlobalValue::AppendingLinkage, in EmitGlobalAnnotations()
1154 llvm::Constant *CodeGenModule::EmitAnnotationString(StringRef Str) { in EmitAnnotationString()
1155 llvm::Constant *&AStr = AnnotationStrings[Str]; in EmitAnnotationString()
1160 llvm::Constant *s = llvm::ConstantDataArray::getString(getLLVMContext(), Str); in EmitAnnotationString()
1162 new llvm::GlobalVariable(getModule(), s->getType(), true, in EmitAnnotationString()
1163 llvm::GlobalValue::PrivateLinkage, s, ".str"); in EmitAnnotationString()
1170 llvm::Constant *CodeGenModule::EmitAnnotationUnit(SourceLocation Loc) { in EmitAnnotationUnit()
1178 llvm::Constant *CodeGenModule::EmitAnnotationLineNo(SourceLocation L) { in EmitAnnotationLineNo()
1183 return llvm::ConstantInt::get(Int32Ty, LineNo); in EmitAnnotationLineNo()
1186 llvm::Constant *CodeGenModule::EmitAnnotateAttr(llvm::GlobalValue *GV, in EmitAnnotateAttr()
1190 llvm::Constant *AnnoGV = EmitAnnotationString(AA->getAnnotation()), in EmitAnnotateAttr()
1195 llvm::Constant *Fields[4] = { in EmitAnnotateAttr()
1196 llvm::ConstantExpr::getBitCast(GV, Int8PtrTy), in EmitAnnotateAttr()
1197 llvm::ConstantExpr::getBitCast(AnnoGV, Int8PtrTy), in EmitAnnotateAttr()
1198 llvm::ConstantExpr::getBitCast(UnitGV, Int8PtrTy), in EmitAnnotateAttr()
1201 return llvm::ConstantStruct::getAnon(Fields); in EmitAnnotateAttr()
1205 llvm::GlobalValue *GV) { in AddGlobalAnnotations()
1212 bool CodeGenModule::isInSanitizerBlacklist(llvm::Function *Fn, in isInSanitizerBlacklist()
1230 bool CodeGenModule::isInSanitizerBlacklist(llvm::GlobalVariable *GV, in isInSanitizerBlacklist()
1276 llvm::Constant *CodeGenModule::GetAddrOfUuidDescriptor( in GetAddrOfUuidDescriptor()
1285 if (llvm::GlobalVariable *GV = getModule().getNamedGlobal(Name)) in GetAddrOfUuidDescriptor()
1288 llvm::Constant *Init = EmitUuidofInitializer(Uuid); in GetAddrOfUuidDescriptor()
1291 auto *GV = new llvm::GlobalVariable( in GetAddrOfUuidDescriptor()
1293 /*isConstant=*/true, llvm::GlobalValue::LinkOnceODRLinkage, Init, Name); in GetAddrOfUuidDescriptor()
1299 llvm::Constant *CodeGenModule::GetWeakRefReference(const ValueDecl *VD) { in GetWeakRefReference()
1303 llvm::Type *DeclTy = getTypes().ConvertTypeForMem(VD->getType()); in GetWeakRefReference()
1306 llvm::GlobalValue *Entry = GetGlobalValue(AA->getAliasee()); in GetWeakRefReference()
1309 return llvm::ConstantExpr::getBitCast(Entry, DeclTy->getPointerTo(AS)); in GetWeakRefReference()
1312 llvm::Constant *Aliasee; in GetWeakRefReference()
1313 if (isa<llvm::FunctionType>(DeclTy)) in GetWeakRefReference()
1319 llvm::PointerType::getUnqual(DeclTy), in GetWeakRefReference()
1322 auto *F = cast<llvm::GlobalValue>(Aliasee); in GetWeakRefReference()
1323 F->setLinkage(llvm::Function::ExternalWeakLinkage); in GetWeakRefReference()
1369 llvm::Type *Ty = getTypes().GetFunctionType(FI); in EmitGlobal()
1402 if (llvm::GlobalValue *GV = GetGlobalValue(MangledName)) { in EmitGlobal()
1474 if (getFunctionLinkage(GD) != llvm::Function::AvailableExternallyLinkage) in shouldEmitFunction()
1503 void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD, llvm::GlobalValue *GV) { in EmitGlobalDefinition()
1549 llvm::Constant *
1551 llvm::Type *Ty, in GetOrCreateLLVMFunction()
1554 llvm::AttributeSet ExtraAttrs) { in GetOrCreateLLVMFunction()
1558 llvm::GlobalValue *Entry = GetGlobalValue(MangledName); in GetOrCreateLLVMFunction()
1563 Entry->setLinkage(llvm::Function::ExternalLinkage); in GetOrCreateLLVMFunction()
1568 Entry->setDLLStorageClass(llvm::GlobalValue::DefaultStorageClass); in GetOrCreateLLVMFunction()
1574 return llvm::ConstantExpr::getBitCast(Entry, Ty->getPointerTo()); in GetOrCreateLLVMFunction()
1582 llvm::FunctionType *FTy; in GetOrCreateLLVMFunction()
1583 if (isa<llvm::FunctionType>(Ty)) { in GetOrCreateLLVMFunction()
1584 FTy = cast<llvm::FunctionType>(Ty); in GetOrCreateLLVMFunction()
1586 FTy = llvm::FunctionType::get(VoidTy, false); in GetOrCreateLLVMFunction()
1590 llvm::Function *F = llvm::Function::Create(FTy, in GetOrCreateLLVMFunction()
1591 llvm::Function::ExternalLinkage, in GetOrCreateLLVMFunction()
1596 if (ExtraAttrs.hasAttributes(llvm::AttributeSet::FunctionIndex)) { in GetOrCreateLLVMFunction()
1597 llvm::AttrBuilder B(ExtraAttrs, llvm::AttributeSet::FunctionIndex); in GetOrCreateLLVMFunction()
1598 F->addAttributes(llvm::AttributeSet::FunctionIndex, in GetOrCreateLLVMFunction()
1599 llvm::AttributeSet::get(VMContext, in GetOrCreateLLVMFunction()
1600 llvm::AttributeSet::FunctionIndex, in GetOrCreateLLVMFunction()
1655 llvm::Type *PTy = llvm::PointerType::getUnqual(Ty); in GetOrCreateLLVMFunction()
1656 return llvm::ConstantExpr::getBitCast(F, PTy); in GetOrCreateLLVMFunction()
1662 llvm::Constant *CodeGenModule::GetAddrOfFunction(GlobalDecl GD, in GetAddrOfFunction()
1663 llvm::Type *Ty, in GetAddrOfFunction()
1676 llvm::Constant *
1677 CodeGenModule::CreateRuntimeFunction(llvm::FunctionType *FTy, in CreateRuntimeFunction()
1679 llvm::AttributeSet ExtraAttrs) { in CreateRuntimeFunction()
1680 llvm::Constant *C = in CreateRuntimeFunction()
1683 if (auto *F = dyn_cast<llvm::Function>(C)) in CreateRuntimeFunction()
1691 llvm::Constant *
1692 CodeGenModule::CreateBuiltinFunction(llvm::FunctionType *FTy, in CreateBuiltinFunction()
1694 llvm::AttributeSet ExtraAttrs) { in CreateBuiltinFunction()
1695 llvm::Constant *C = in CreateBuiltinFunction()
1698 if (auto *F = dyn_cast<llvm::Function>(C)) in CreateBuiltinFunction()
1731 llvm::Constant *
1733 llvm::PointerType *Ty, in GetOrCreateLLVMGlobal()
1736 llvm::GlobalValue *Entry = GetGlobalValue(MangledName); in GetOrCreateLLVMGlobal()
1740 Entry->setLinkage(llvm::Function::ExternalLinkage); in GetOrCreateLLVMGlobal()
1745 Entry->setDLLStorageClass(llvm::GlobalValue::DefaultStorageClass); in GetOrCreateLLVMGlobal()
1752 return llvm::ConstantExpr::getAddrSpaceCast(Entry, Ty); in GetOrCreateLLVMGlobal()
1754 return llvm::ConstantExpr::getBitCast(Entry, Ty); in GetOrCreateLLVMGlobal()
1758 auto *GV = new llvm::GlobalVariable( in GetOrCreateLLVMGlobal()
1760 llvm::GlobalValue::ExternalLinkage, nullptr, MangledName, nullptr, in GetOrCreateLLVMGlobal()
1761 llvm::GlobalVariable::NotThreadLocal, AddrSpace); in GetOrCreateLLVMGlobal()
1795 if (getTarget().getTriple().getArch() == llvm::Triple::xcore && in GetOrCreateLLVMGlobal()
1803 return llvm::ConstantExpr::getAddrSpaceCast(GV, Ty); in GetOrCreateLLVMGlobal()
1809 llvm::GlobalVariable *
1811 llvm::Type *Ty, in CreateOrReplaceCXXRuntimeVariable()
1812 llvm::GlobalValue::LinkageTypes Linkage) { in CreateOrReplaceCXXRuntimeVariable()
1813 llvm::GlobalVariable *GV = getModule().getNamedGlobal(Name); in CreateOrReplaceCXXRuntimeVariable()
1814 llvm::GlobalVariable *OldGV = nullptr; in CreateOrReplaceCXXRuntimeVariable()
1828 GV = new llvm::GlobalVariable(getModule(), Ty, /*isConstant=*/true, in CreateOrReplaceCXXRuntimeVariable()
1836 llvm::Constant *NewPtrForOldDecl = in CreateOrReplaceCXXRuntimeVariable()
1837 llvm::ConstantExpr::getBitCast(GV, OldGV->getType()); in CreateOrReplaceCXXRuntimeVariable()
1855 llvm::Constant *CodeGenModule::GetAddrOfGlobalVar(const VarDecl *D, in GetAddrOfGlobalVar()
1856 llvm::Type *Ty) { in GetAddrOfGlobalVar()
1862 llvm::PointerType *PTy = in GetAddrOfGlobalVar()
1863 llvm::PointerType::get(Ty, getContext().getTargetAddressSpace(ASTTy)); in GetAddrOfGlobalVar()
1871 llvm::Constant *
1872 CodeGenModule::CreateRuntimeVariable(llvm::Type *Ty, in CreateRuntimeVariable()
1874 return GetOrCreateLLVMGlobal(Name, llvm::PointerType::getUnqual(Ty), nullptr); in CreateRuntimeVariable()
1895 CharUnits CodeGenModule::GetTargetTypeStoreSize(llvm::Type *Ty) const { in GetTargetTypeStoreSize()
1916 llvm::GlobalValue *GV) { in MaybeHandleStaticInExternC()
1973 llvm::GlobalObject &GO) { in maybeSetTrivialComdat()
1980 llvm::Constant *Init = nullptr; in EmitGlobalVarDefinition()
2015 Init = llvm::UndefValue::get(getTypes().ConvertType(T)); in EmitGlobalVarDefinition()
2026 llvm::Type* InitType = Init->getType(); in EmitGlobalVarDefinition()
2027 llvm::Constant *Entry = GetAddrOfGlobalVar(D, InitType); in EmitGlobalVarDefinition()
2030 if (auto *CE = dyn_cast<llvm::ConstantExpr>(Entry)) { in EmitGlobalVarDefinition()
2031 assert(CE->getOpcode() == llvm::Instruction::BitCast || in EmitGlobalVarDefinition()
2032 CE->getOpcode() == llvm::Instruction::AddrSpaceCast || in EmitGlobalVarDefinition()
2034 CE->getOpcode() == llvm::Instruction::GetElementPtr); in EmitGlobalVarDefinition()
2039 auto *GV = dyn_cast<llvm::GlobalVariable>(Entry); in EmitGlobalVarDefinition()
2059 GV = cast<llvm::GlobalVariable>(GetAddrOfGlobalVar(D, InitType)); in EmitGlobalVarDefinition()
2062 llvm::Constant *NewPtrForOldDecl = in EmitGlobalVarDefinition()
2063 llvm::ConstantExpr::getBitCast(GV, Entry->getType()); in EmitGlobalVarDefinition()
2067 cast<llvm::GlobalValue>(Entry)->eraseFromParent(); in EmitGlobalVarDefinition()
2091 llvm::GlobalValue::LinkageTypes Linkage = in EmitGlobalVarDefinition()
2100 Linkage = llvm::GlobalValue::InternalLinkage; in EmitGlobalVarDefinition()
2104 GV->setDLLStorageClass(llvm::GlobalVariable::DLLImportStorageClass); in EmitGlobalVarDefinition()
2106 GV->setDLLStorageClass(llvm::GlobalVariable::DLLExportStorageClass); in EmitGlobalVarDefinition()
2108 GV->setDLLStorageClass(llvm::GlobalVariable::DefaultStorageClass); in EmitGlobalVarDefinition()
2110 if (Linkage == llvm::GlobalVariable::CommonLinkage) in EmitGlobalVarDefinition()
2192 llvm::GlobalValue::LinkageTypes CodeGenModule::getLLVMLinkageForDeclarator( in getLLVMLinkageForDeclarator()
2195 return llvm::Function::InternalLinkage; in getLLVMLinkageForDeclarator()
2199 return llvm::GlobalVariable::WeakODRLinkage; in getLLVMLinkageForDeclarator()
2201 return llvm::GlobalVariable::WeakAnyLinkage; in getLLVMLinkageForDeclarator()
2207 return llvm::Function::AvailableExternallyLinkage; in getLLVMLinkageForDeclarator()
2221 return !Context.getLangOpts().AppleKext ? llvm::Function::LinkOnceODRLinkage in getLLVMLinkageForDeclarator()
2222 : llvm::Function::InternalLinkage; in getLLVMLinkageForDeclarator()
2229 return !Context.getLangOpts().AppleKext ? llvm::Function::WeakODRLinkage in getLLVMLinkageForDeclarator()
2230 : llvm::Function::ExternalLinkage; in getLLVMLinkageForDeclarator()
2237 return llvm::GlobalVariable::CommonLinkage; in getLLVMLinkageForDeclarator()
2244 return llvm::GlobalVariable::WeakODRLinkage; in getLLVMLinkageForDeclarator()
2248 return llvm::GlobalVariable::ExternalLinkage; in getLLVMLinkageForDeclarator()
2251 llvm::GlobalValue::LinkageTypes CodeGenModule::getLLVMLinkageVarDefinition( in getLLVMLinkageVarDefinition()
2259 static void replaceUsesOfNonProtoConstant(llvm::Constant *old, in replaceUsesOfNonProtoConstant()
2260 llvm::Function *newFn) { in replaceUsesOfNonProtoConstant()
2264 llvm::Type *newRetTy = newFn->getReturnType(); in replaceUsesOfNonProtoConstant()
2265 SmallVector<llvm::Value*, 4> newArgs; in replaceUsesOfNonProtoConstant()
2267 for (llvm::Value::use_iterator ui = old->use_begin(), ue = old->use_end(); in replaceUsesOfNonProtoConstant()
2269 llvm::Value::use_iterator use = ui++; // Increment before the use is erased. in replaceUsesOfNonProtoConstant()
2270 llvm::User *user = use->getUser(); in replaceUsesOfNonProtoConstant()
2274 if (auto *bitcast = dyn_cast<llvm::ConstantExpr>(user)) { in replaceUsesOfNonProtoConstant()
2275 if (bitcast->getOpcode() == llvm::Instruction::BitCast) in replaceUsesOfNonProtoConstant()
2281 llvm::CallSite callSite(user); in replaceUsesOfNonProtoConstant()
2291 SmallVector<llvm::AttributeSet, 8> newAttrs; in replaceUsesOfNonProtoConstant()
2292 llvm::AttributeSet oldAttrs = callSite.getAttributes(); in replaceUsesOfNonProtoConstant()
2295 if (oldAttrs.hasAttributes(llvm::AttributeSet::ReturnIndex)) in replaceUsesOfNonProtoConstant()
2297 llvm::AttributeSet::get(newFn->getContext(), in replaceUsesOfNonProtoConstant()
2308 for (llvm::Function::arg_iterator ai = newFn->arg_begin(), in replaceUsesOfNonProtoConstant()
2318 push_back(llvm:: in replaceUsesOfNonProtoConstant()
2325 if (oldAttrs.hasAttributes(llvm::AttributeSet::FunctionIndex)) in replaceUsesOfNonProtoConstant()
2326 newAttrs.push_back(llvm::AttributeSet::get(newFn->getContext(), in replaceUsesOfNonProtoConstant()
2333 llvm::CallSite newCall; in replaceUsesOfNonProtoConstant()
2335 newCall = llvm::CallInst::Create(newFn, newArgs, "", in replaceUsesOfNonProtoConstant()
2338 auto *oldInvoke = cast<llvm::InvokeInst>(callSite.getInstruction()); in replaceUsesOfNonProtoConstant()
2339 newCall = llvm::InvokeInst::Create(newFn, in replaceUsesOfNonProtoConstant()
2350 llvm::AttributeSet::get(newFn->getContext(), newAttrs)); in replaceUsesOfNonProtoConstant()
2373 static void ReplaceUsesOfNonProtoTypeWithRealFunction(llvm::GlobalValue *Old, in ReplaceUsesOfNonProtoTypeWithRealFunction()
2374 llvm::Function *NewFn) { in ReplaceUsesOfNonProtoTypeWithRealFunction()
2376 if (!isa<llvm::Function>(Old)) return; in ReplaceUsesOfNonProtoTypeWithRealFunction()
2392 llvm::GlobalValue *GV) { in EmitGlobalFunctionDefinition()
2397 llvm::FunctionType *Ty = getTypes().GetFunctionType(FI); in EmitGlobalFunctionDefinition()
2401 llvm::Constant *C = in EmitGlobalFunctionDefinition()
2405 if (auto *CE = dyn_cast<llvm::ConstantExpr>(C)) { in EmitGlobalFunctionDefinition()
2406 assert(CE->getOpcode() == llvm::Instruction::BitCast); in EmitGlobalFunctionDefinition()
2407 GV = cast<llvm::GlobalValue>(CE->getOperand(0)); in EmitGlobalFunctionDefinition()
2409 GV = cast<llvm::GlobalValue>(C); in EmitGlobalFunctionDefinition()
2434 auto *NewFn = cast<llvm::Function>(GetAddrOfFunction(GD, Ty)); in EmitGlobalFunctionDefinition()
2450 llvm::Constant *NewPtrForOldDecl = in EmitGlobalFunctionDefinition()
2451 llvm::ConstantExpr::getBitCast(NewFn, GV->getType()); in EmitGlobalFunctionDefinition()
2465 auto *Fn = cast<llvm::Function>(GV); in EmitGlobalFunctionDefinition()
2468 GV->setDLLStorageClass(llvm::GlobalVariable::DLLImportStorageClass); in EmitGlobalFunctionDefinition()
2470 GV->setDLLStorageClass(llvm::GlobalVariable::DLLExportStorageClass); in EmitGlobalFunctionDefinition()
2472 GV->setDLLStorageClass(llvm::GlobalVariable::DefaultStorageClass); in EmitGlobalFunctionDefinition()
2503 llvm::GlobalValue *Entry = GetGlobalValue(MangledName); in EmitAliasDefinition()
2509 llvm::Type *DeclTy = getTypes().ConvertTypeForMem(D->getType()); in EmitAliasDefinition()
2513 llvm::Constant *Aliasee; in EmitAliasDefinition()
2514 if (isa<llvm::FunctionType>(DeclTy)) in EmitAliasDefinition()
2519 llvm::PointerType::getUnqual(DeclTy), in EmitAliasDefinition()
2523 auto *GA = llvm::GlobalAlias::create( in EmitAliasDefinition()
2524 cast<llvm::PointerType>(Aliasee->getType())->getElementType(), 0, in EmitAliasDefinition()
2525 llvm::Function::ExternalLinkage, "", Aliasee, &getModule()); in EmitAliasDefinition()
2544 Entry->replaceAllUsesWith(llvm::ConstantExpr::getBitCast(GA, in EmitAliasDefinition()
2556 GA->setLinkage(llvm::Function::WeakAnyLinkage); in EmitAliasDefinition()
2566 llvm::Function *CodeGenModule::getIntrinsic(unsigned IID, in getIntrinsic()
2567 ArrayRef<llvm::Type*> Tys) { in getIntrinsic()
2568 return llvm::Intrinsic::getDeclaration(&getModule(), (llvm::Intrinsic::ID)IID, in getIntrinsic()
2572 static llvm::StringMapEntry<llvm::GlobalVariable *> &
2573 GetConstantCFStringEntry(llvm::StringMap<llvm::GlobalVariable *> &Map, in GetConstantCFStringEntry()
2607 static llvm::StringMapEntry<llvm::GlobalVariable *> &
2608 GetConstantStringEntry(llvm::StringMap<llvm::GlobalVariable *> &Map, in GetConstantStringEntry()
2615 llvm::Constant *
2619 llvm::StringMapEntry<llvm::GlobalVariable *> &Entry = in GetAddrOfConstantCFString()
2627 llvm::Constant *Zero = llvm::Constant::getNullValue(Int32Ty); in GetAddrOfConstantCFString()
2628 llvm::Constant *Zeros[] = { Zero, Zero }; in GetAddrOfConstantCFString()
2629 llvm::Value *V; in GetAddrOfConstantCFString()
2633 llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy); in GetAddrOfConstantCFString()
2634 Ty = llvm::ArrayType::get(Ty, 0); in GetAddrOfConstantCFString()
2635 llvm::Constant *GV = CreateRuntimeVariable(Ty, in GetAddrOfConstantCFString()
2638 V = llvm::ConstantExpr::getGetElementPtr(Ty, GV, Zeros); in GetAddrOfConstantCFString()
2646 auto *STy = cast<llvm::StructType>(getTypes().ConvertType(CFTy)); in GetAddrOfConstantCFString()
2648 llvm::Constant *Fields[4]; in GetAddrOfConstantCFString()
2651 Fields[0] = cast<llvm::ConstantExpr>(V); in GetAddrOfConstantCFString()
2654 llvm::Type *Ty = getTypes().ConvertType(getContext().UnsignedIntTy); in GetAddrOfConstantCFString()
2655 Fields[1] = isUTF16 ? llvm::ConstantInt::get(Ty, 0x07d0) : in GetAddrOfConstantCFString()
2656 llvm::ConstantInt::get(Ty, 0x07C8); in GetAddrOfConstantCFString()
2659 llvm::Constant *C = nullptr; in GetAddrOfConstantCFString()
2661 ArrayRef<uint16_t> Arr = llvm::makeArrayRef<uint16_t>( in GetAddrOfConstantCFString()
2664 C = llvm::ConstantDataArray::get(VMContext, Arr); in GetAddrOfConstantCFString()
2666 C = llvm::ConstantDataArray::getString(VMContext, Entry.first()); in GetAddrOfConstantCFString()
2672 new llvm::GlobalVariable(getModule(), C->getType(), /*isConstant=*/true, in GetAddrOfConstantCFString()
2673 llvm::GlobalValue::PrivateLinkage, C, ".str"); in GetAddrOfConstantCFString()
2691 Fields[2] = llvm::ConstantExpr::getGetElementPtr(GV->getType(), GV, Zeros); in GetAddrOfConstantCFString()
2695 Fields[2] = llvm::ConstantExpr::getBitCast(Fields[2], Int8PtrTy); in GetAddrOfConstantCFString()
2699 Fields[3] = llvm::ConstantInt::get(Ty, StringLength); in GetAddrOfConstantCFString()
2702 C = llvm::ConstantStruct::get(STy, Fields); in GetAddrOfConstantCFString()
2703 GV = new llvm::GlobalVariable(getModule(), C->getType(), true, in GetAddrOfConstantCFString()
2704 llvm::GlobalVariable::PrivateLinkage, C, in GetAddrOfConstantCFString()
2712 llvm::GlobalVariable *
2715 llvm::StringMapEntry<llvm::GlobalVariable *> &Entry = in GetAddrOfConstantString()
2721 llvm::Constant *Zero = llvm::Constant::getNullValue(Int32Ty); in GetAddrOfConstantString()
2722 llvm::Constant *Zeros[] = { Zero, Zero }; in GetAddrOfConstantString()
2723 llvm::Value *V; in GetAddrOfConstantString()
2727 llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy); in GetAddrOfConstantString()
2728 llvm::Constant *GV; in GetAddrOfConstantString()
2735 llvm::Type *PTy = llvm::PointerType::getUnqual(Ty); in GetAddrOfConstantString()
2736 V = llvm::ConstantExpr::getBitCast(GV, PTy); in GetAddrOfConstantString()
2742 llvm::Type *PTy = llvm::ArrayType::get(Ty, 0); in GetAddrOfConstantString()
2745 V = llvm::ConstantExpr::getGetElementPtr(PTy, GV, Zeros); in GetAddrOfConstantString()
2780 NSConstantStringType = cast<llvm::StructType>(getTypes().ConvertType(NSTy)); in GetAddrOfConstantString()
2783 llvm::Constant *Fields[3]; in GetAddrOfConstantString()
2786 Fields[0] = cast<llvm::ConstantExpr>(V); in GetAddrOfConstantString()
2789 llvm::Constant *C = in GetAddrOfConstantString()
2790 llvm::ConstantDataArray::getString(VMContext, Entry.first()); in GetAddrOfConstantString()
2792 llvm::GlobalValue::LinkageTypes Linkage; in GetAddrOfConstantString()
2794 Linkage = llvm::GlobalValue::PrivateLinkage; in GetAddrOfConstantString()
2797 auto *GV = new llvm::GlobalVariable(getModule(), C->getType(), isConstant, in GetAddrOfConstantString()
2805 llvm::ConstantExpr::getGetElementPtr(GV->getValueType(), GV, Zeros); in GetAddrOfConstantString()
2808 llvm::Type *Ty = getTypes().ConvertType(getContext().UnsignedIntTy); in GetAddrOfConstantString()
2809 Fields[2] = llvm::ConstantInt::get(Ty, StringLength); in GetAddrOfConstantString()
2812 C = llvm::ConstantStruct::get(NSConstantStringType, Fields); in GetAddrOfConstantString()
2813 GV = new llvm::GlobalVariable(getModule(), C->getType(), true, in GetAddrOfConstantString()
2814 llvm::GlobalVariable::PrivateLinkage, C, in GetAddrOfConstantString()
2838 llvm::APInt(32, 5), ArrayType::Normal, 0) in getObjCFastEnumerationStateType()
2861 llvm::Constant *
2873 return llvm::ConstantDataArray::getString(VMContext, Str, false); in GetConstantArrayFromStringLiteral()
2876 auto *AType = cast<llvm::ArrayType>(getTypes().ConvertType(E->getType())); in GetConstantArrayFromStringLiteral()
2877 llvm::Type *ElemTy = AType->getElementType(); in GetConstantArrayFromStringLiteral()
2888 return llvm::ConstantDataArray::get(VMContext, Elements); in GetConstantArrayFromStringLiteral()
2898 return llvm::ConstantDataArray::get(VMContext, Elements); in GetConstantArrayFromStringLiteral()
2901 static llvm::GlobalVariable *
2902 GenerateStringLiteral(llvm::Constant *C, llvm::GlobalValue::LinkageTypes LT, in GenerateStringLiteral()
2910 llvm::Module &M = CGM.getModule(); in GenerateStringLiteral()
2912 auto *GV = new llvm::GlobalVariable( in GenerateStringLiteral()
2914 nullptr, llvm::GlobalVariable::NotThreadLocal, AddrSpace); in GenerateStringLiteral()
2927 llvm::GlobalVariable *
2933 llvm::Constant *C = GetConstantArrayFromStringLiteral(S); in GetAddrOfConstantStringFromLiteral()
2934 llvm::GlobalVariable **Entry = nullptr; in GetAddrOfConstantStringFromLiteral()
2946 llvm::GlobalValue::LinkageTypes LT; in GetAddrOfConstantStringFromLiteral()
2954 llvm::raw_svector_ostream Out(MangledNameBuffer); in GetAddrOfConstantStringFromLiteral()
2958 LT = llvm::GlobalValue::LinkOnceODRLinkage; in GetAddrOfConstantStringFromLiteral()
2961 LT = llvm::GlobalValue::PrivateLinkage; in GetAddrOfConstantStringFromLiteral()
2976 llvm::GlobalVariable *
2987 llvm::GlobalVariable *CodeGenModule::GetAddrOfConstantCString( in GetAddrOfConstantCString()
2996 llvm::Constant *C = in GetAddrOfConstantCString()
2997 llvm::ConstantDataArray::getString(getLLVMContext(), StrWithNull, false); in GetAddrOfConstantCString()
3000 llvm::GlobalVariable **Entry = nullptr; in GetAddrOfConstantCString()
3014 auto GV = GenerateStringLiteral(C, llvm::GlobalValue::PrivateLinkage, *this, in GetAddrOfConstantCString()
3021 llvm::Constant *CodeGenModule::GetAddrOfGlobalTemporary( in GetAddrOfGlobalTemporary()
3033 llvm::Constant *&Slot = MaterializedGlobalTemporaryMap[E]; in GetAddrOfGlobalTemporary()
3041 llvm::raw_svector_ostream Out(Name); in GetAddrOfGlobalTemporary()
3063 llvm::Constant *InitialValue = nullptr; in GetAddrOfGlobalTemporary()
3065 llvm::Type *Type; in GetAddrOfGlobalTemporary()
3078 llvm::GlobalValue::LinkageTypes Linkage = in GetAddrOfGlobalTemporary()
3080 if (Linkage == llvm::GlobalVariable::ExternalLinkage) { in GetAddrOfGlobalTemporary()
3086 Linkage = llvm::GlobalVariable::LinkOnceODRLinkage; in GetAddrOfGlobalTemporary()
3090 Linkage = llvm::GlobalVariable::InternalLinkage; in GetAddrOfGlobalTemporary()
3095 auto *GV = new llvm::GlobalVariable( in GetAddrOfGlobalTemporary()
3097 /*InsertBefore=*/nullptr, llvm::GlobalVariable::NotThreadLocal, in GetAddrOfGlobalTemporary()
3483 static llvm::Constant *GetPointerConstant(llvm::LLVMContext &Context, in GetPointerConstant()
3486 llvm::Type *i64 = llvm::Type::getInt64Ty(Context); in GetPointerConstant()
3487 return llvm::ConstantInt::get(i64, PtrInt); in GetPointerConstant()
3491 llvm::NamedMDNode *&GlobalMetadata, in EmitGlobalDeclMetadata()
3493 llvm::GlobalValue *Addr) { in EmitGlobalDeclMetadata()
3499 llvm::Metadata *Ops[] = {llvm::ConstantAsMetadata::get(Addr), in EmitGlobalDeclMetadata()
3500 llvm::ConstantAsMetadata::get(GetPointerConstant( in EmitGlobalDeclMetadata()
3502 GlobalMetadata->addOperand(llvm::MDNode::get(CGM.getLLVMContext(), Ops)); in EmitGlobalDeclMetadata()
3515 llvm::GlobalValue *Val = I->second; in EmitStaticExternCAliases()
3517 addUsedGlobal(llvm::GlobalAlias::create(Name->getName(), Val)); in EmitStaticExternCAliases()
3538 llvm::NamedMDNode *GlobalMetadata = nullptr; in EmitDeclMetadata()
3542 llvm::GlobalValue *Addr = getModule().getNamedValue(I.second); in EmitDeclMetadata()
3552 llvm::LLVMContext &Context = getLLVMContext(); in EmitDeclMetadata()
3557 llvm::NamedMDNode *GlobalMetadata = nullptr; in EmitDeclMetadata()
3561 llvm::Value *Addr = I.second; in EmitDeclMetadata()
3562 if (auto *Alloca = dyn_cast<llvm::AllocaInst>(Addr)) { in EmitDeclMetadata()
3563 llvm::Value *DAddr = GetPointerConstant(getLLVMContext(), D); in EmitDeclMetadata()
3565 DeclPtrKind, llvm::MDNode::get( in EmitDeclMetadata()
3566 Context, llvm::ValueAsMetadata::getConstant(DAddr))); in EmitDeclMetadata()
3567 } else if (auto *GV = dyn_cast<llvm::GlobalValue>(Addr)) { in EmitDeclMetadata()
3575 llvm::NamedMDNode *IdentMetadata = in EmitVersionIdentMetadata()
3578 llvm::LLVMContext &Ctx = TheModule.getContext(); in EmitVersionIdentMetadata()
3580 llvm::Metadata *IdentNode[] = {llvm::MDString::get(Ctx, Version)}; in EmitVersionIdentMetadata()
3581 IdentMetadata->addOperand(llvm::MDNode::get(Ctx, IdentNode)); in EmitVersionIdentMetadata()
3594 llvm::GlobalValue *GV = GetGlobalValue(Val.second); in EmitTargetMetadata()
3601 if (llvm::NamedMDNode *CUNode = TheModule.getNamedMetadata("llvm.dbg.cu")) { in EmitCoverageFile()
3602 llvm::NamedMDNode *GCov = TheModule.getOrInsertNamedMetadata("llvm.gcov"); in EmitCoverageFile()
3603 llvm::LLVMContext &Ctx = TheModule.getContext(); in EmitCoverageFile()
3604 llvm::MDString *CoverageFile = in EmitCoverageFile()
3605 llvm::MDString::get(Ctx, getCodeGenOpts().CoverageFile); in EmitCoverageFile()
3607 llvm::MDNode *CU = CUNode->getOperand(i); in EmitCoverageFile()
3608 llvm::Metadata *Elts[] = {CoverageFile, CU}; in EmitCoverageFile()
3609 GCov->addOperand(llvm::MDNode::get(Ctx, Elts)); in EmitCoverageFile()
3615 llvm::Constant *CodeGenModule::EmitUuidofInitializer(StringRef Uuid) { in EmitUuidofInitializer()
3627 llvm::Constant *Field3[8]; in EmitUuidofInitializer()
3629 Field3[Idx] = llvm::ConstantInt::get( in EmitUuidofInitializer()
3632 llvm::Constant *Fields[4] = { in EmitUuidofInitializer()
3633 llvm::ConstantInt::get(Int32Ty, Uuid.substr(0, 8), 16), in EmitUuidofInitializer()
3634 llvm::ConstantInt::get(Int16Ty, Uuid.substr(9, 4), 16), in EmitUuidofInitializer()
3635 llvm::ConstantInt::get(Int16Ty, Uuid.substr(14, 4), 16), in EmitUuidofInitializer()
3636 llvm::ConstantArray::get(llvm::ArrayType::get(Int8Ty, 8), Field3) in EmitUuidofInitializer()
3639 return llvm::ConstantStruct::getAnon(Fields); in EmitUuidofInitializer()
3642 llvm::Constant *
3648 llvm::Constant *CodeGenModule::GetAddrOfRTTIDescriptor(QualType Ty, in GetAddrOfRTTIDescriptor()
3654 return llvm::Constant::getNullValue(Int8PtrTy); in GetAddrOfRTTIDescriptor()