Lines Matching +full:ipa +full:- +full:shared

1 //===--- CGDeclCXX.cpp - Emit LLVM Code for C++ declarations --------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
35 assert(!D.getType()->isReferenceType() &&
77 // attribute. This also checks for -fno-c++-static-destructors and
104 // Special-case non-array C++ destructors, if they have the right signature.
108 const CXXRecordDecl *Record = Type->getAsCXXRecordDecl();
111 GlobalDecl(Record->getDestructor(), Dtor_Complete)) ||
118 assert(!Record->hasTrivialDestructor());
119 CXXDestructorDecl *Dtor = Record->getDestructor();
165 assert(Addr->getType()->isPointerTy() && "Address must be a pointer");
166 llvm::Type *ObjectPtr[1] = {Addr->getType()};
195 // "shared" address space qualifier, but the constructor of StructWithCtor
198 unsigned ActualAddrSpace = GV->getAddressSpace();
207 DeclPtr, GV->getValueType(), getContext().getDeclAlign(&D));
209 if (!T->isReferenceType()) {
213 &D, DeclAddr, D.getAttr<OMPThreadPrivateDeclAttr>()->getLocation(),
254 VD.getLocation(), VD.getInit()->getExprLoc());
262 dtor.getCallee()->stripPointerCastsAndAliases()))
263 call->setCallingConv(dtorFn->getCallingConv());
306 FI, Args, D.getLocation(), D.getInit()->getExprLoc());
315 Dtor.getCallee()->stripPointerCastsAndAliases()))
316 call->setCallingConv(DtorFn->getCallingConv());
348 assert(dtorStub->getType() ==
351 dtorStub->getType()->getPointerAddressSpace()) &&
355 llvm::FunctionType::get(IntTy, dtorStub->getType(), false);
361 atexitFn->setDoesNotThrow();
371 // termination and the unatexit returns a value of 0, otherwise a non-zero
375 assert(dtorStub->getType() ==
378 dtorStub->getType()->getPointerAddressSpace()) &&
382 llvm::FunctionType::get(IntTy, {dtorStub->getType()}, /*isVarArg=*/false);
387 cast<llvm::Function>(unatexit.getCallee())->setDoesNotThrow();
396 // This diagnostic is hard-coded for Darwin's use case; we can find
419 if (Kind == GuardKind::VariableGuard && !D->isLocalVarDecl()) {
420 // For non-local variables, don't apply any weighting for now. Due to our
429 if (Kind == GuardKind::TlsGuard || D->getTLSKind())
437 Weights = MDHelper.createBranchWeights(1, NumInits - 1);
451 Fn->setSection(Section);
457 Fn->setCallingConv(getRuntimeCC());
460 Fn->setDoesNotThrow();
464 Fn->addFnAttr(llvm::Attribute::SanitizeAddress);
468 Fn->addFnAttr(llvm::Attribute::SanitizeAddress);
472 Fn->addFnAttr(llvm::Attribute::SanitizeHWAddress);
476 Fn->addFnAttr(llvm::Attribute::SanitizeHWAddress);
480 Fn->addFnAttr(llvm::Attribute::SanitizeMemTag);
484 Fn->addFnAttr(llvm::Attribute::SanitizeThread);
488 Fn->addFnAttr(llvm::Attribute::SanitizeNumericalStability);
492 Fn->addFnAttr(llvm::Attribute::SanitizeMemory);
496 Fn->addFnAttr(llvm::Attribute::SanitizeMemory);
500 Fn->addFnAttr(llvm::Attribute::SafeStack);
504 Fn->addFnAttr(llvm::Attribute::ShadowCallStack);
517 TheModule, InitFunc->getType(), /*isConstant=*/true,
519 PtrArray->setSection(ISA->getSection());
523 if (llvm::Comdat *C = GV->getComdat())
524 PtrArray->setComdat(C);
532 // According to E.2.3.1 in CUDA-7.5 Programming guide: __device__,
534 // that are of class type, cannot have a non-empty constructor. All
538 (D->hasAttr<CUDADeviceAttr>() || D->hasAttr<CUDAConstantAttr>() ||
539 D->hasAttr<CUDASharedAttr>()))
544 if (I != DelayedCXXInitPosition.end() && I->second == ~0U)
556 FTy, FnName.str(), getTypes().arrangeNullaryFunction(), D->getLocation());
558 auto *ISA = D->getAttr<InitSegAttr>();
563 supportsCOMDAT() && D->isExternallyVisible() ? Addr : nullptr;
565 if (D->getTLSKind()) {
574 int Priority = -1;
575 if (ISA->getSection() == ".CRT$XCC")
577 else if (ISA->getSection() == ".CRT$XCL")
580 if (Priority != -1)
584 } else if (auto *IPA = D->getAttr<InitPriorityAttr>()) {
585 OrderGlobalInitsOrStermFinalizers Key(IPA->getPriority(),
588 } else if (isTemplateInstantiation(D->getTemplateSpecializationKind()) ||
590 D->hasAttr<SelectAnyAttr>()) {
604 // SelectAny globals will be comdat-folded. Put the initializer into a
609 // VarDecl. Use it when the current VarDecl is non-deferred. Although this
610 // lex order number is shared between current VarDecl and some following
615 I == DelayedCXXInitPosition.end() ? CXXGlobalInits.size() : I->second;
627 llvm::Comdat *C = Addr->getComdat();
631 Fn->setComdat(C);
634 I = DelayedCXXInitPosition.find(D); // Re-do lookup in case of re-hash.
637 } else if (I->second != ~0U) {
638 assert(I->second < CXXGlobalInits.size() &&
639 CXXGlobalInits[I->second] == nullptr);
640 CXXGlobalInits[I->second] = Fn;
673 assert(Primary->isInterfaceOrPartition() &&
686 for (auto I : Primary->Exports)
689 for (Module *M : Primary->Imports)
693 for (Module *SubM : Primary->submodules()) {
694 assert((SubM->isGlobalModule() || SubM->isPrivateModule()) &&
697 assert(SubM->Exports.empty() &&
700 for (Module *M : SubM->Imports)
707 if (M->isHeaderLikeModule())
711 if (!M->isNamedModuleInterfaceHasInit())
741 ModuleInits.push_back(I->second);
776 Guard->setAlignment(GuardAlign.getAsAlign());
793 Fn->setCallingConv(llvm::CallingConv::SPIR_KERNEL);
799 Fn->setCallingConv(llvm::CallingConv::AMDGPU_KERNEL);
800 Fn->addFnAttr("device-init");
817 // Replace everything that's not [a-zA-Z0-9._] with a _. This set happens
832 PrioritySuffix = std::string(6 - PrioritySuffix.size(), '0') + PrioritySuffix;
847 if (M->isHeaderLikeModule())
851 if (!M->isNamedModuleInterfaceHasInit())
880 // into separate function. Note - everything is sorted first by priority,
881 // second - by lex order, so we emit ctor functions in proper order.
890 unsigned int Priority = I->first.priority;
902 LocalCXXGlobalInits.push_back(I->second);
921 // way as a non-modular TU with imports.
924 !getContext().getCurrentNamedModule()->isModuleImplementation()) {
951 Fn->setCallingConv(llvm::CallingConv::SPIR_KERNEL);
957 Fn->setCallingConv(llvm::CallingConv::AMDGPU_KERNEL);
958 Fn->addFnAttr("device-init");
978 // into separate function. Note - everything is sorted first by priority,
979 // second - by lex order, so we emit dtor functions in proper order.
989 unsigned int Priority = I->first.priority;
994 llvm::FunctionCallee DtorFn = I->second;
1025 if (D->hasAttr<NoDebugAttr>())
1028 CurEHLocation = D->getBeginLoc();
1042 // layer will guard the whole-TU initialization for us.)
1043 if (Addr->hasWeakLinkage() || Addr->hasLinkOnceLinkage() ||
1044 (D->getTLSKind() == VarDecl::TLS_Dynamic &&
1045 isTemplateInstantiation(D->getTemplateSpecializationKind()))) {
1081 // initializers use previously-initialized thread_local vars, that's
1083 Builder.CreateStore(llvm::ConstantInt::get(GuardVal->getType(),1), Guard);
1089 CGM.getDataLayout().getTypeAllocSize(GuardVal->getType())));
1094 // When building in Objective-C++ ARC mode, create an autorelease pool
1133 std::tie(CalleeTy, Callee, Arg) = DtorsOrStermFinalizers[e - i - 1];
1146 CI->setCallingConv(F->getCallingConv());
1153 /// generateDestroyHelper - Generates a helper function which, when
1168 FTy, "__cxx_global_array_dtor", FI, VD->getLocation());
1170 CurEHLocation = VD->getBeginLoc();