Lines Matching +full:local +full:- +full:bd +full:- +full:address +full:- +full:broken

1 //===--- CGDecl.cpp - Emit LLVM Code for declarations ---------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
113 DI->EmitAndRetainType(getContext().getRecordType(cast<RecordDecl>(&D)));
118 DI->EmitAndRetainType(getContext().getEnumType(cast<EnumDecl>(&D)));
142 DI->EmitNamespaceAlias(cast<NamespaceAliasDecl>(D));
146 DI->EmitUsingDecl(cast<UsingDecl>(D));
150 DI->EmitUsingEnumDecl(cast<UsingEnumDecl>(D));
158 DI->EmitUsingDirective(cast<UsingDirectiveDecl>(D));
164 "Should not see file-scope variables inside a function!");
167 for (auto *B : DD->bindings())
168 if (auto *HD = B->getHoldingVar())
183 DI->EmitAndRetainType(Ty);
184 if (Ty->isVariablyModifiedType())
191 /// EmitVarDecl - This method handles emission of any variable declaration
198 // Some function-scope variable does not have static storage but still
199 // needs to be emitted like a static variable, e.g. a function-scope
200 // variable in constant address space in OpenCL.
203 if (D.getType()->isSamplerT())
210 // some variables even if we can constant-evaluate them because
211 // we can't guarantee every translation unit will constant-evaluate them.
232 DC = cast<DeclContext>(CD->getNonClosureContext());
235 else if (const auto *BD = dyn_cast<BlockDecl>(DC))
236 ContextName = std::string(CGM.getBlockMangledName(GlobalDecl(), BD));
238 ContextName = OMD->getSelector().getAsString();
256 assert(Ty->isConstantSizeType() && "VLAs can't be static");
258 // Use the label if the variable is renamed with the asm-label extension.
269 // OpenCL variables in local address space and CUDA shared
281 GV->setAlignment(getContext().getDeclAlign(&D).getAsAlign());
283 if (supportsCOMDAT() && GV->isWeakForLinker())
284 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
304 // Ensure that the static local gets initialized by making sure the parent
311 DC = DC->getNonClosureContext();
325 // Don't do anything for Obj-C method decls or global closures. We should
338 /// AddInitializerToStaticVarDecl - Add the initializer for 'D' to the
352 CGM.ErrorUnsupported(D.getInit(), "constant l-value expression");
358 GV->setConstant(false);
369 CGM.getDataLayout().getTypeAllocSize(Init->getType()));
377 if (GV->getValueType() != Init->getType()) {
381 CGM.getModule(), Init->getType(), OldGV->isConstant(),
382 OldGV->getLinkage(), Init, "",
383 /*InsertBefore*/ OldGV, OldGV->getThreadLocalMode(),
384 OldGV->getType()->getPointerAddressSpace());
385 GV->setVisibility(OldGV->getVisibility());
386 GV->setDSOLocal(OldGV->isDSOLocal());
387 GV->setComdat(OldGV->getComdat());
390 GV->takeName(OldGV);
393 OldGV->replaceAllUsesWith(GV);
396 OldGV->eraseFromParent();
402 GV->setConstant(
404 GV->setInitializer(Init);
421 // declaration. This can happen when double-emitting function
429 setAddrOfLocalVar(&D, Address(addr, elemTy, alignment));
434 if (D.getType()->isVariablyModifiedType())
438 llvm::Type *expectedType = addr->getType();
441 cast<llvm::GlobalVariable>(addr->stripPointerCasts());
443 // CUDA's local and local static __shared__ variables should not
444 // have any non-empty initializers. This is ensured by Sema.
446 // a no-op and should not be emitted.
453 var->setAlignment(alignment.getAsAlign());
459 var->addAttribute("bss-section", SA->getName());
461 var->addAttribute("data-section", SA->getName());
463 var->addAttribute("rodata-section", SA->getName());
465 var->addAttribute("relro-section", SA->getName());
468 var->setSection(SA->getName());
485 LocalDeclMap.find(&D)->second = Address(castedAddr, elemTy, alignment);
488 CGM.getSanitizerMetadata()->reportGlobal(var, D);
493 DI->setLocation(D.getLocation());
494 DI->EmitGlobalVariable(var, &D);
500 DestroyObject(Address addr, QualType type,
506 Address addr;
514 flags.isForNormalCleanup() && this->useEHCleanupForArray;
522 DestroyNRVOVariable(Address addr, QualType type, llvm::Value *NRVOFlag)
526 Address Loc;
544 static_cast<Derived *>(this)->emitDestructorCall(CGF);
554 DestroyNRVOVariableCXX(Address addr, QualType type,
570 DestroyNRVOVariableC(Address addr, llvm::Value *NRVOFlag, QualType Ty)
579 Address Stack;
580 CallStackRestore(Address Stack) : Stack(Stack) {}
603 // Compute the address of the local variable, in case it's a
625 // Compute the address of the local variable, in case it's a byref
635 QualType ArgTy = FnInfo.arg_begin()->type;
648 /// EmitAutoVarWithLifetime - Does the setup required for an automatic
651 Address addr,
689 // hierarchy-walking expensive.
690 s = e = e->IgnoreParenCasts();
693 return (ref->getDecl() == &var);
695 const BlockDecl *block = be->getBlockDecl();
696 for (const auto &I : block->captures()) {
703 for (const Stmt *SubStmt : s->children())
704 // SubStmt might be null; as in missing decl or conditional of an if-stmt.
722 while (auto castExpr = dyn_cast<CastExpr>(init->IgnoreParens())) {
723 switch (castExpr->getCastKind()) {
731 // If we find an l-value to r-value cast from a __weak variable,
734 const Expr *srcExpr = castExpr->getSubExpr();
735 if (srcExpr->getType().getObjCLifetime() != Qualifiers::OCL_Weak)
738 // Emit the source l-value.
747 // If it was an l-value, use objc_copyWeak.
748 if (srcExpr->isLValue()) {
751 assert(srcExpr->isXValue());
762 init = castExpr->getSubExpr();
778 auto Nullability = LHS.getType()->getNullability();
801 EmitNullabilityCheck(lvalue, value, init->getExprLoc());
807 init = DIE->getExpr();
813 return EmitScalarInit(EWC->getSubExpr(), D, lvalue, capturedByInit);
817 // zero-initialized. If the variable might be accessed in its
818 // initializer, zero-initialize before running the initializer, then
854 if (!D || !isa<VarDecl>(D) || !cast<VarDecl>(D)->isARCPseudoStrong()) {
858 // If D is pseudo-strong, treat it like __unsafe_unretained here. This means
859 // that we omit the retain, and causes non-autoreleased return values to be
895 EmitNullabilityCheck(lvalue, value, init->getExprLoc());
901 llvm::Value *oldValue = EmitLoadOfScalar(lvalue, init->getExprLoc());
910 /// Decide whether we can emit the non-zero parts of the specified initializer
922 return Init->isNullValue() || NumStores--;
926 for (unsigned i = 0, e = Init->getNumOperands(); i != e; ++i) {
927 llvm::Constant *Elt = cast<llvm::Constant>(Init->getOperand(i));
936 for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
937 llvm::Constant *Elt = CDS->getElementAsConstant(i);
951 llvm::Constant *Init, Address Loc,
954 assert(!Init->isNullValue() && !isa<llvm::UndefValue>(Init) &&
962 I->addAnnotationMetadata("auto-init");
968 for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
969 llvm::Constant *Elt = CDS->getElementAsConstant(i);
972 if (!Elt->isNullValue() && !isa<llvm::UndefValue>(Elt))
983 for (unsigned i = 0, e = Init->getNumOperands(); i != e; ++i) {
984 llvm::Constant *Elt = cast<llvm::Constant>(Init->getOperand(i));
987 if (!Elt->isNullValue() && !isa<llvm::UndefValue>(Elt))
994 /// Decide whether we should use bzero plus some stores to initialize a local
1002 // If a non-zero global is <= 32 bytes, always use a memcpy. If it is large,
1013 /// Decide whether we should use memset to initialize a local variable instead
1066 for (unsigned i = 0, e = STy->getNumElements(); i != e; i++) {
1067 unsigned CurOff = Layout->getElementOffset(i);
1069 assert(!STy->isPacked());
1070 auto *PadTy = llvm::ArrayType::get(Int8Ty, CurOff - SizeSoFar);
1074 if (constant->isZeroValue())
1075 CurOp = llvm::Constant::getNullValue(STy->getElementType(i));
1077 CurOp = cast<llvm::Constant>(constant->getAggregateElement(i));
1082 SizeSoFar = CurOff + DL.getTypeAllocSize(CurOp->getType());
1084 unsigned TotalSize = Layout->getSizeInBytes();
1086 auto *PadTy = llvm::ArrayType::get(Int8Ty, TotalSize - SizeSoFar);
1089 if (NestedIntact && Values.size() == STy->getNumElements())
1091 return llvm::ConstantStruct::getAnon(Values, STy->isPacked());
1098 llvm::Type *OrigTy = constant->getType();
1103 uint64_t Size = ArrayTy->getNumElements();
1106 llvm::Type *ElemTy = ArrayTy->getElementType();
1107 bool ZeroInitializer = constant->isNullValue();
1115 OpValue = constant->getAggregateElement(Op);
1120 auto *NewElemTy = Values[0]->getType();
1132 Address CodeGenModule::createUnnamedGlobalFrom(const VarDecl &D,
1135 auto FunctionName = [&](const DeclContext *DC) -> std::string {
1138 return CC->getNameAsString();
1140 return CD->getNameAsString();
1143 return OM->getNameAsString();
1153 // Form a simple per-variable cache of these values in case we find we
1156 if (!CacheEntry || CacheEntry->getInitializer() != Constant) {
1157 auto *Ty = Constant->getType();
1168 llvm_unreachable("local variable has no parent function or method");
1172 GV->setAlignment(Align.getAsAlign());
1173 GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
1175 } else if (CacheEntry->getAlignment() < uint64_t(Align.getQuantity())) {
1176 CacheEntry->setAlignment(Align.getAsAlign());
1179 return Address(CacheEntry, CacheEntry->getValueType(), Align);
1182 static Address createUnnamedGlobalForMemcpyFrom(CodeGenModule &CGM,
1187 Address SrcPtr = CGM.createUnnamedGlobalFrom(D, Constant, Align);
1192 Address Loc, bool isVolatile,
1195 auto *Ty = constant->getType();
1200 bool canDoSingleStore = Ty->isIntOrIntVectorTy() ||
1201 Ty->isPtrOrPtrVectorTy() || Ty->isFPOrFPVectorTy();
1205 I->addAnnotationMetadata("auto-init");
1217 I->addAnnotationMetadata("auto-init");
1220 constant->isNullValue() || isa<llvm::UndefValue>(constant);
1235 const llvm::APInt &AP = cast<llvm::ConstantInt>(Pattern)->getValue();
1242 I->addAnnotationMetadata("auto-init");
1257 for (unsigned i = 0; i != constant->getNumOperands(); i++) {
1259 CharUnits::fromQuantity(Layout->getElementOffset(i));
1260 Address EltPtr = Builder.CreateConstInBoundsByteGEP(
1263 constant->getAggregateElement(i), IsAutoInit);
1270 for (unsigned i = 0; i != ATy->getNumElements(); i++) {
1271 Address EltPtr = Builder.CreateConstGEP(
1272 Loc.withElementType(ATy->getElementType()), i);
1274 constant->getAggregateElement(i), IsAutoInit);
1288 I->addAnnotationMetadata("auto-init");
1292 Address Loc, bool isVolatile,
1302 Address Loc, bool isVolatile,
1313 auto *Ty = constant->getType();
1316 if (Ty->isStructTy() || Ty->isArrayTy() || Ty->isVectorTy())
1317 for (llvm::Use &Op : constant->operands())
1325 auto *Ty = constant->getType();
1328 if (!(Ty->isStructTy() || Ty->isArrayTy() || Ty->isVectorTy()))
1332 llvm::SmallVector<llvm::Constant *, 8> Values(constant->getNumOperands());
1333 for (unsigned Op = 0, NumOp = constant->getNumOperands(); Op != NumOp; ++Op) {
1334 auto *OpValue = cast<llvm::Constant>(constant->getOperand(Op));
1337 if (Ty->isStructTy())
1339 if (Ty->isArrayTy())
1341 assert(Ty->isVectorTy());
1345 /// EmitAutoVarDecl - Emit code and set up an entry in LocalDeclMap for a
1362 assert(Addr->getType()->getPointerAddressSpace() ==
1364 "Pointer should be in alloca address space");
1366 Int64Ty, Size.isScalable() ? -1 : Size.getFixedValue());
1369 C->setDoesNotThrow();
1374 assert(Addr->getType()->getPointerAddressSpace() ==
1376 "Pointer should be in alloca address space");
1379 C->setDoesNotThrow();
1385 // size-expression Value.
1403 CreateDefaultAlignTempAlloca(VlaSize.NumElts->getType(), NameRef);
1414 // Register each dimension's size-expression with a DILocalVariable,
1426 SizeTy->getScalarSizeInBits(), false);
1431 ArtificialDecl->setImplicit();
1433 MD = DI->EmitDeclareOfAutoVariable(ArtificialDecl, VlaSize.NumElts,
1437 DI->registerVLASizeExpression(VlaSize.Type, MD);
1441 /// EmitAutoVarAlloca - Emit the alloca and debug information for a
1442 /// local variable. Does not emit initialization or destruction.
1457 // If the type is variably-modified, emit all the VLA sizes for it.
1458 if (Ty->isVariablyModifiedType())
1464 Address address = Address::invalid();
1466 Address OpenMPLocalAddr = Address::invalid();
1473 : Address::invalid();
1478 address = OpenMPLocalAddr;
1480 } else if (Ty->isConstantSizeType()) {
1484 // TODO: We should constant-evaluate the initializer of any variable,
1488 // for POD-ness protects us from some of these.
1489 if (D.getInit() && (Ty->isArrayType() || Ty->isRecordType()) &&
1492 getContext().getBaseElementType(Ty)->isObjCObjectPointerType()) &&
1493 D.getInit()->isConstantInitializer(getContext(), false)))) {
1498 // Exception is if a variable is located in non-constant address space
1510 emission.Addr = Address::invalid();
1521 // - it's an NRVO variable.
1522 // - we are compiling OpenMP and it's an OpenMP local variable.
1527 address = ReturnValue;
1533 if (const RecordType *RecordTy = Ty->getAs<RecordType>()) {
1534 const auto *RD = RecordTy->getDecl();
1536 if ((CXXRD && !CXXRD->hasTrivialDestructor()) ||
1537 RD->isNonTrivialToPrimitiveDestroy()) {
1543 CreateTempAlloca(Zero->getType(), CharUnits::One(), "nrvo");
1565 // building the instruction so that it's there even in no-asserts
1567 address = CreateTempAlloca(allocaTy, allocaAlignment, D.getName(),
1580 // gets broken up into several regions in IR, which requires more work
1587 // earlier point in the current block because non-VLA lifetimes begin as
1618 // Save the address of the allocation:
1622 address = Base.getAddress();
1637 Address Stack =
1641 assert(V->getType() == AllocaInt8PtrTy);
1655 address = CreateTempAlloca(llvmTy, alignment, "vla", VlaSize.NumElts,
1665 setAddrOfLocalVar(&D, address);
1666 emission.Addr = address;
1669 // Emit debug info for local var declaration.
1671 Address DebugAddr = address;
1673 DI->setLocation(D.getLocation());
1675 // If NRVO, use a pointer to the return address.
1680 (void)DI->EmitDeclareOfAutoVariable(&D, AllocaAddr.getPointer(), Builder,
1685 EmitVarAnnotations(&D, address.emitRawPointer(*this));
1703 for (const Stmt *SubStmt : S->children())
1713 // hierarchy-walking expensive.
1714 E = E->IgnoreParenCasts();
1717 const BlockDecl *Block = BE->getBlockDecl();
1718 for (const auto &I : Block->captures()) {
1728 const CompoundStmt *CS = SE->getSubStmt();
1729 for (const auto *BI : CS->body())
1736 for (const auto *I : DS->decls()) {
1738 const Expr *Init = VD->getInit();
1751 for (const Stmt *SubStmt : E->children())
1765 if (CXXConstructorDecl *Constructor = Construct->getConstructor())
1766 if (Constructor->isTrivial() &&
1767 Constructor->isDefaultConstructor() &&
1768 !Construct->requiresZeroInitialization())
1776 Address Loc) {
1783 // We skip auto-init variables by their alloc size. Take this as an example:
1784 // "struct Foo {int x; char buff[1024];}" Assume the max-size flag is 1023.
1786 // array and still auto-init X in this example.
1812 // VLAs look zero-sized to getTypeInfo. We can't emit constant stores to
1814 // Technically zero-sized or negative-sized VLAs are undefined, and UBSan
1815 // will catch that code, but there exists code which generates zero-sized
1834 I->addAnnotationMetadata("auto-init");
1845 llvm::BasicBlock *SetupBB = createBasicBlock("vla-setup.loop");
1846 llvm::BasicBlock *LoopBB = createBasicBlock("vla-init.loop");
1847 llvm::BasicBlock *ContBB = createBasicBlock("vla-init.cont");
1849 SizeVal, llvm::ConstantInt::get(SizeVal->getType(), 0),
1857 Address Begin = Loc.withElementType(Int8Ty);
1864 Cur->addIncoming(Begin.emitRawPointer(*this), OriginBB);
1867 Builder.CreateMemCpy(Address(Cur, Int8Ty, CurAlign),
1871 I->addAnnotationMetadata("auto-init");
1874 llvm::Value *Done = Builder.CreateICmpEQ(Next, End, "vla-init.isdone");
1876 Cur->addIncoming(Next, LoopBB);
1892 // If this local has an initializer, emit it now.
1907 // C struct that is non-trivial to initialize or an array containing such a
1926 const Address Loc =
1937 auto initializeWhatIsTechnicallyUninitialized = [&](Address Loc) {
1957 if (constant && !constant->isZeroValue() &&
1964 // C guarantees that brace-init with fewer initializers than members in
1965 // the aggregate will initialize the rest of the aggregate as-if it were
1967 // padding is initialized to zero bits. We could instead pattern-init if D
1974 if (D.getType()->isBitIntType() &&
1980 D.getType(), constant->getType());
1990 // - If D is not a scalar, auto-var-init conservatively (members may be
1992 // - If D is a scalar, we only need to auto-var-init if there is a
1993 // self-reference. Otherwise, the Init expression should be sufficient.
1995 // but auto-var-init here would not help, as auto-init would get
1997 if (!D.getType()->isScalarType() || capturedByInit ||
2021 /// initializer for the object, and the address is not necessarily
2028 /// whose address is potentially changed by the initializer
2031 QualType type = D->getType();
2033 if (type->isReferenceType()) {
2052 if (type->isAtomicType()) {
2071 /// Enter a destroy cleanup for the given local variable.
2079 Address addr = emission.getObjectAddress(*this);
2082 QualType type = var->getType();
2089 llvm_unreachable("no cleanup for trivially-destructible variable");
2095 assert(!type->isArrayType());
2096 CXXDestructorDecl *dtor = type->getAsCXXRecordDecl()->getDestructor();
2104 // Suppress cleanups for pseudo-strong variables.
2105 if (var->isARCPseudoStrong()) return;
2111 if (!var->hasAttr<ObjCPreciseLifetimeAttr>())
2121 assert(!type->isArrayType());
2163 const FunctionDecl *FD = CA->getFunctionDecl();
2173 // (on the unforwarded address). Don't enter this cleanup if we're in pure-GC
2178 if (emission.Variable->getType().isObjCGCWeak())
2182 cxxDestructorCanThrow(emission.Variable->getType()));
2202 /// pushEHDestroy - Push the standard destructor for the given type as
2203 /// an EH-only cleanup.
2205 Address addr, QualType type) {
2212 /// pushDestroy - Push the standard destructor for the given type as
2215 Address addr, QualType type) {
2223 void CodeGenFunction::pushDestroy(CleanupKind cleanupKind, Address addr,
2233 QualType::DestructionKind dtorKind, Address addr, QualType type) {
2242 CleanupKind cleanupKind, Address addr, QualType type, Destroyer *destroyer,
2251 void CodeGenFunction::pushStackRestore(CleanupKind Kind, Address SPMem) {
2261 Address addr, QualType type,
2270 // Add the cleanup to the EHStack. After the full-expr, this would be
2275 // Since this is lifetime-extended, push it once again to the EHStack after
2278 cleanupKind, Address::invalid(), addr, type, destroyer,
2285 EHScopeStack::ConditionalCleanup<DestroyObject, Address, QualType,
2287 DominatingValue<Address>::saved_type SavedAddr = saveValueInCond(addr);
2289 // Remember to emit cleanup if we branch-out before end of full-expression
2290 // (eg: through stmt-expr or coro suspensions).
2292 Address ActiveFlagForDeactivation = createCleanupActiveFlag();
2301 // Since this is lifetime-extended, push it once again to the EHStack after
2304 // deactivation. Use a separate flag for lifetime-extension to correctly
2306 Address ActiveFlagForLifetimeExt = createCleanupActiveFlag();
2312 /// emitDestroy - Immediately perform the destruction of the given
2315 /// \param addr - the address of the object; a type*
2316 /// \param type - the type of the object; if an array type, all
2318 /// \param destroyer - the function to call to destroy individual
2320 /// \param useEHCleanupForArray - whether an EH cleanup should be
2323 void CodeGenFunction::emitDestroy(Address addr, QualType type,
2336 // Normally we have to check whether the array is zero-length.
2342 if (constLength->isZero()) return;
2353 /// emitArrayDestroy - Destroys all the elements of the given array,
2354 /// beginning from last to first. The array cannot be zero-length.
2356 /// \param begin - a type* denoting the first element of the array
2357 /// \param end - a type* denoting one past the end of the array
2358 /// \param elementType - the element type of the array
2359 /// \param destroyer - the function to call to destroy elements
2360 /// \param useEHCleanup - whether to push an EH cleanup to destroy
2370 assert(!elementType->isArrayType());
2372 // The basic structure here is a do-while loop, because we don't
2373 // need to check for the zero-element case.
2383 // Enter the loop body, making that address the current address.
2387 Builder.CreatePHI(begin->getType(), 2, "arraydestroy.elementPast");
2388 elementPast->addIncoming(end, entryBB);
2390 // Shift the address back by one element.
2391 llvm::Value *negativeOne = llvm::ConstantInt::get(SizeTy, -1, true);
2401 destroyer(*this, Address(element, llvmElementType, elementAlign),
2410 elementPast->addIncoming(element, Builder.GetInsertBlock());
2430 type = arrayType->getElementType();
2451 /// RegularPartialArrayDestroy - a cleanup which performs a partial
2453 /// does not need to be loaded from a local.
2474 /// IrregularPartialArrayDestroy - a cleanup which performs a
2476 /// determined and must be loaded from a local.
2479 Address ArrayEndPointer;
2485 Address arrayEndPointer,
2501 /// pushIrregularPartialArrayCleanup - Push a NormalAndEHCleanup to
2502 /// destroy already-constructed elements of the given array. The cleanup may be
2505 /// \param elementType - the immediate element type of the array;
2508 Address arrayEndPointer,
2517 /// pushRegularPartialArrayCleanup - Push an EH cleanup to destroy
2518 /// already-constructed elements of the given array. The cleanup
2521 /// \param elementType - the immediate element type of the array;
2583 Arg.getAnyValue()->setName(D.getName());
2601 (IPD->getParameterKind() == ImplicitParamKind::ThreadPrivateVar);
2604 Address DeclPtr = Address::invalid();
2605 RawAddress AllocaPtr = Address::invalid();
2614 // Indirect argument is in alloca address space, which may be different
2615 // from the default address space.
2620 // For truly ABI indirect arguments -- those that are not `byval` -- store
2621 // the address of the argument on the stack to preserve debug information.
2622 ABIArgInfo ArgInfo = CurFnInfo->arguments()[ArgNo - 1].info;
2649 if (Ty->isRecordType() && !CurFuncIsThunk &&
2650 Ty->castAs<RecordType>()->getDecl()->isParamDestroyedInCallee()) {
2662 // Check if the parameter address is controlled by OpenMP runtime.
2663 Address OpenMPLocalAddr =
2666 : Address::invalid();
2690 // If a parameter is pseudo-strong then we can omit the implicit retain.
2693 "pseudo-strong variable isn't strong?");
2694 assert(qs.hasConst() && "pseudo-strong variable should be const!");
2745 // Emit debug info for param declarations in non-thunk functions.
2749 llvm::DILocalVariable *DILocalVar = DI->EmitDeclareOfArgVariable(
2752 DI->getParamDbgMappings().insert({Var, DILocalVar});
2763 auto Nullability = Ty->getNullability();
2775 if (!LangOpts.OpenMP || (!LangOpts.EmitAllDecls && !D->isUsed()))
2783 (!LangOpts.EmitAllDecls && !D->isUsed()))
2793 for (const Expr *E : D->varlists()) {
2795 const auto *VD = cast<VarDecl>(DE->getDecl());
2798 if (!VD->hasGlobalStorage())
2804 // OMPAllocateDeclAttr was attached, leading to the wrong address space
2813 // We can also keep the existing global if the address space is what we
2815 QualType ASTTy = VD->getType();
2818 if (Entry->getType()->getAddressSpace() == TargetAS)
2821 // Make a new global with the correct type / address space.
2829 getModule(), Entry->getValueType(), false,
2831 llvm::GlobalVariable::NotThreadLocal, Entry->getAddressSpace());
2832 Entry->replaceAllUsesWith(DummyGV);
2834 Entry->mutateType(PTy);
2837 Entry, DummyGV->getType());
2841 DummyGV->replaceAllUsesWith(NewPtrForOldDecl);
2842 DummyGV->eraseFromParent();
2848 if (const auto *AA = VD->getAttr<OMPAllocateDeclAttr>()) {
2849 if (Expr *Alignment = AA->getAlignment()) {
2851 Alignment->EvaluateKnownConstInt(getContext()).getExtValue();
2853 getNaturalTypeAlignment(VD->getType().getNonReferenceType());
2855 // OpenMP5.1 pg 185 lines 7-10