39#include "llvm/ADT/ArrayRef.h"
40#include "llvm/ADT/ScopeExit.h"
41#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
42#include "llvm/IR/DataLayout.h"
43#include "llvm/IR/Dominators.h"
44#include "llvm/IR/FPEnv.h"
45#include "llvm/IR/Instruction.h"
46#include "llvm/IR/IntrinsicInst.h"
47#include "llvm/IR/Intrinsics.h"
48#include "llvm/IR/MDBuilder.h"
49#include "llvm/Support/CRC.h"
50#include "llvm/Support/xxhash.h"
51#include "llvm/Transforms/Scalar/LowerExpectIntrinsic.h"
52#include "llvm/Transforms/Utils/PromoteMemToReg.h"
66 if (CGOpts.DisableLifetimeMarkers)
70 if (CGOpts.SanitizeAddressUseAfterScope ||
77 return CGOpts.OptimizationLevel != 0;
80CodeGenFunction::CodeGenFunction(
CodeGenModule &cgm,
bool suppressNewContext)
85 DebugInfo(
CGM.getModuleDebugInfo()),
87 ShouldEmitLifetimeMarkers(
89 if (!suppressNewContext)
90 CGM.getCXXABI().getMangleContext().startNewFunction();
99 "missed to deactivate a cleanup");
102 CGM.getOpenMPRuntime().functionFinished(*
this);
109 if (
CGM.getLangOpts().OpenMPIRBuilder &&
CurFn)
110 CGM.getOpenMPRuntime().getOMPBuilder().finalize(
CurFn);
115llvm::fp::ExceptionBehavior
123 llvm_unreachable(
"Unsupported FP Exception Behavior");
128 llvm::FastMathFlags FMF;
129 FMF.setAllowReassoc(FPFeatures.getAllowFPReassociate());
130 FMF.setNoNaNs(FPFeatures.getNoHonorNaNs());
131 FMF.setNoInfs(FPFeatures.getNoHonorInfs());
132 FMF.setNoSignedZeros(FPFeatures.getNoSignedZero());
133 FMF.setAllowReciprocal(FPFeatures.getAllowReciprocal());
134 FMF.setApproxFunc(FPFeatures.getAllowApproxFunc());
148 ConstructorHelper(FPFeatures);
151void CodeGenFunction::CGFPOptionsRAII::ConstructorHelper(
FPOptions FPFeatures) {
152 OldFPFeatures = CGF.CurFPFeatures;
153 CGF.CurFPFeatures = FPFeatures;
155 OldExcept = CGF.Builder.getDefaultConstrainedExcept();
156 OldRounding = CGF.Builder.getDefaultConstrainedRounding();
158 if (OldFPFeatures == FPFeatures)
161 FMFGuard.emplace(CGF.Builder);
164 CGF.Builder.setDefaultConstrainedRounding(NewRoundingBehavior);
165 auto NewExceptionBehavior =
167 CGF.Builder.setDefaultConstrainedExcept(NewExceptionBehavior);
169 CGF.SetFastMathFlags(FPFeatures);
171 assert((CGF.CurFuncDecl ==
nullptr || CGF.Builder.getIsFPConstrained() ||
174 (NewExceptionBehavior == llvm::fp::ebIgnore &&
175 NewRoundingBehavior == llvm::RoundingMode::NearestTiesToEven)) &&
176 "FPConstrained should be enabled on entire function");
178 auto mergeFnAttrValue = [&](StringRef Name,
bool Value) {
180 CGF.CurFn->getFnAttribute(Name).getValueAsBool();
181 auto NewValue = OldValue &
Value;
182 if (OldValue != NewValue)
183 CGF.CurFn->addFnAttr(Name, llvm::toStringRef(NewValue));
185 mergeFnAttrValue(
"no-infs-fp-math", FPFeatures.getNoHonorInfs());
186 mergeFnAttrValue(
"no-nans-fp-math", FPFeatures.getNoHonorNaNs());
187 mergeFnAttrValue(
"no-signed-zeros-fp-math", FPFeatures.getNoSignedZero());
191 CGF.CurFPFeatures = OldFPFeatures;
192 CGF.Builder.setDefaultConstrainedExcept(OldExcept);
193 CGF.Builder.setDefaultConstrainedRounding(OldRounding);
207 nullptr, IsKnownNonNull)
215 return ::makeNaturalAlignAddrLValue(
V,
T,
false,
222 return ::makeNaturalAlignAddrLValue(
V,
T,
true,
228 return ::makeNaturalAlignAddrLValue(
V,
T,
false,
234 return ::makeNaturalAlignAddrLValue(
V,
T,
true,
239 return CGM.getTypes().ConvertTypeForMem(
T);
243 return CGM.getTypes().ConvertType(
T);
247 llvm::Type *LLVMTy) {
248 return CGM.getTypes().convertTypeForLoadStore(ASTTy, LLVMTy);
254 switch (
type->getTypeClass()) {
255#define TYPE(name, parent)
256#define ABSTRACT_TYPE(name, parent)
257#define NON_CANONICAL_TYPE(name, parent) case Type::name:
258#define DEPENDENT_TYPE(name, parent) case Type::name:
259#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(name, parent) case Type::name:
260#include "clang/AST/TypeNodes.inc"
261 llvm_unreachable(
"non-canonical or dependent type in IR-generation");
264 case Type::DeducedTemplateSpecialization:
265 llvm_unreachable(
"undeduced type in IR-generation");
270 case Type::BlockPointer:
271 case Type::LValueReference:
272 case Type::RValueReference:
273 case Type::MemberPointer:
275 case Type::ExtVector:
276 case Type::ConstantMatrix:
277 case Type::FunctionProto:
278 case Type::FunctionNoProto:
280 case Type::ObjCObjectPointer:
283 case Type::HLSLAttributedResource:
284 case Type::HLSLInlineSpirv:
292 case Type::ConstantArray:
293 case Type::IncompleteArray:
294 case Type::VariableArray:
296 case Type::ObjCObject:
297 case Type::ObjCInterface:
298 case Type::ArrayParameter:
306 llvm_unreachable(
"unknown type kind!");
313 llvm::BasicBlock *CurBB =
Builder.GetInsertBlock();
316 assert(!CurBB->getTerminator() &&
"Unexpected terminated block.");
320 if (CurBB->empty() ||
ReturnBlock.getBlock()->use_empty()) {
326 return llvm::DebugLoc();
333 llvm::BranchInst *BI =
334 dyn_cast<llvm::BranchInst>(*
ReturnBlock.getBlock()->user_begin());
335 if (BI && BI->isUnconditional() &&
339 llvm::DebugLoc Loc = BI->getDebugLoc();
340 Builder.SetInsertPoint(BI->getParent());
341 BI->eraseFromParent();
353 return llvm::DebugLoc();
358 if (!BB->use_empty()) {
366 assert(BreakContinueStack.empty() &&
367 "mismatched push/pop in break/continue stack!");
369 "mismatched push/pop of cleanups in EHStack!");
371 "mismatched activate/deactivate of cleanups!");
373 if (
CGM.shouldEmitConvergenceTokens()) {
376 "mismatched push/pop in convergence stack!");
379 bool OnlySimpleReturnStmts = NumSimpleReturnExprs > 0
380 && NumSimpleReturnExprs == NumReturnExprs
395 if (OnlySimpleReturnStmts)
396 DI->EmitLocation(
Builder, LastStopPoint);
398 DI->EmitLocation(
Builder, EndLoc);
406 bool HasOnlyNoopCleanups =
408 bool EmitRetDbgLoc = !HasCleanups || HasOnlyNoopCleanups;
410 std::optional<ApplyDebugLocation> OAL;
415 if (OnlySimpleReturnStmts)
416 DI->EmitLocation(
Builder, EndLoc);
430 if (
CGM.getCodeGenOpts().InstrumentFunctions)
431 CurFn->addFnAttr(
"instrument-function-exit",
"__cyg_profile_func_exit");
432 if (
CGM.getCodeGenOpts().InstrumentFunctionsAfterInlining)
433 CurFn->addFnAttr(
"instrument-function-exit-inlined",
434 "__cyg_profile_func_exit");
443 uint64_t RetKeyInstructionsAtomGroup = Loc ? Loc->getAtomGroup() : 0;
446 RetKeyInstructionsAtomGroup);
450 "did not remove all scopes from cleanup stack!");
454 if (IndirectBranch) {
461 if (!EscapedLocals.empty()) {
465 EscapeArgs.resize(EscapedLocals.size());
466 for (
auto &Pair : EscapedLocals)
467 EscapeArgs[Pair.second] = Pair.first;
468 llvm::Function *FrameEscapeFn = llvm::Intrinsic::getOrInsertDeclaration(
469 &
CGM.getModule(), llvm::Intrinsic::localescape);
476 Ptr->eraseFromParent();
480 if (PostAllocaInsertPt) {
481 llvm::Instruction *PostPtr = PostAllocaInsertPt;
482 PostAllocaInsertPt =
nullptr;
483 PostPtr->eraseFromParent();
488 if (IndirectBranch) {
490 if (PN->getNumIncomingValues() == 0) {
491 PN->replaceAllUsesWith(llvm::PoisonValue::get(PN->getType()));
492 PN->eraseFromParent();
501 for (
const auto &FuncletAndParent : TerminateFunclets)
504 if (
CGM.getCodeGenOpts().EmitDeclMetadata)
507 for (
const auto &R : DeferredReplacements) {
508 if (llvm::Value *Old = R.first) {
509 Old->replaceAllUsesWith(R.second);
513 DeferredReplacements.clear();
522 llvm::DominatorTree DT(*
CurFn);
523 llvm::PromoteMemToReg(
529 for (llvm::Argument &A :
CurFn->args())
530 if (
auto *VT = dyn_cast<llvm::VectorType>(A.getType()))
532 std::max((uint64_t)LargestVectorWidth,
533 VT->getPrimitiveSizeInBits().getKnownMinValue());
536 if (
auto *VT = dyn_cast<llvm::VectorType>(
CurFn->getReturnType()))
538 std::max((uint64_t)LargestVectorWidth,
539 VT->getPrimitiveSizeInBits().getKnownMinValue());
541 if (
CurFnInfo->getMaxVectorWidth() > LargestVectorWidth)
542 LargestVectorWidth =
CurFnInfo->getMaxVectorWidth();
551 if (
getContext().getTargetInfo().getTriple().isX86())
552 CurFn->addFnAttr(
"min-legal-vector-width",
553 llvm::utostr(LargestVectorWidth));
562 dyn_cast<llvm::AllocaInst>(
ReturnValue.emitRawPointer(*
this));
563 if (RetAlloca && RetAlloca->use_empty()) {
564 RetAlloca->eraseFromParent();
573 if (!
CGM.getCodeGenOpts().InstrumentFunctions &&
574 !
CGM.getCodeGenOpts().InstrumentFunctionsAfterInlining &&
575 !
CGM.getCodeGenOpts().InstrumentFunctionEntryBare)
585 return CurFuncDecl->hasAttr<DisableSanitizerInstrumentationAttr>();
591 return CGM.getCodeGenOpts().XRayInstrumentFunctions;
597 return CGM.getCodeGenOpts().XRayInstrumentFunctions &&
598 (
CGM.getCodeGenOpts().XRayAlwaysEmitCustomEvents ||
599 CGM.getCodeGenOpts().XRayInstrumentationBundle.Mask ==
604 return CGM.getCodeGenOpts().XRayInstrumentFunctions &&
605 (
CGM.getCodeGenOpts().XRayAlwaysEmitTypedEvents ||
606 CGM.getCodeGenOpts().XRayInstrumentationBundle.Mask ==
617 llvm::raw_string_ostream Out(Mangled);
618 CGM.getCXXABI().getMangleContext().mangleCanonicalTypeName(Ty, Out,
false);
619 return llvm::ConstantInt::get(
620 CGM.Int32Ty,
static_cast<uint32_t
>(llvm::xxh3_64bits(Mangled)));
623void CodeGenFunction::EmitKernelMetadata(
const FunctionDecl *FD,
624 llvm::Function *Fn) {
625 if (!FD->
hasAttr<DeviceKernelAttr>() && !FD->
hasAttr<CUDAGlobalAttr>())
634 getContext().getTargetInfo().getTriple().isSPIRV())))
637 if (
const VecTypeHintAttr *A = FD->
getAttr<VecTypeHintAttr>()) {
638 QualType HintQTy = A->getTypeHint();
640 bool IsSignedInteger =
642 (HintEltQTy && HintEltQTy->
getElementType()->isSignedIntegerType());
643 llvm::Metadata *AttrMDArgs[] = {
644 llvm::ConstantAsMetadata::get(llvm::PoisonValue::get(
646 llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
647 llvm::IntegerType::get(Context, 32),
648 llvm::APInt(32, (uint64_t)(IsSignedInteger ? 1 : 0))))};
649 Fn->setMetadata(
"vec_type_hint", llvm::MDNode::get(Context, AttrMDArgs));
652 if (
const WorkGroupSizeHintAttr *A = FD->
getAttr<WorkGroupSizeHintAttr>()) {
653 auto Eval = [&](
Expr *E) {
654 return E->EvaluateKnownConstInt(FD->
getASTContext()).getExtValue();
656 llvm::Metadata *AttrMDArgs[] = {
657 llvm::ConstantAsMetadata::get(
Builder.getInt32(Eval(A->getXDim()))),
658 llvm::ConstantAsMetadata::get(
Builder.getInt32(Eval(A->getYDim()))),
659 llvm::ConstantAsMetadata::get(
Builder.getInt32(Eval(A->getZDim())))};
660 Fn->setMetadata(
"work_group_size_hint", llvm::MDNode::get(Context, AttrMDArgs));
663 if (
const ReqdWorkGroupSizeAttr *A = FD->
getAttr<ReqdWorkGroupSizeAttr>()) {
664 auto Eval = [&](Expr *E) {
665 return E->EvaluateKnownConstInt(FD->
getASTContext()).getExtValue();
667 llvm::Metadata *AttrMDArgs[] = {
668 llvm::ConstantAsMetadata::get(
Builder.getInt32(Eval(A->getXDim()))),
669 llvm::ConstantAsMetadata::get(
Builder.getInt32(Eval(A->getYDim()))),
670 llvm::ConstantAsMetadata::get(
Builder.getInt32(Eval(A->getZDim())))};
671 Fn->setMetadata(
"reqd_work_group_size", llvm::MDNode::get(Context, AttrMDArgs));
674 if (
const OpenCLIntelReqdSubGroupSizeAttr *A =
675 FD->
getAttr<OpenCLIntelReqdSubGroupSizeAttr>()) {
676 llvm::Metadata *AttrMDArgs[] = {
677 llvm::ConstantAsMetadata::get(
Builder.getInt32(A->getSubGroupSize()))};
678 Fn->setMetadata(
"intel_reqd_sub_group_size",
679 llvm::MDNode::get(Context, AttrMDArgs));
685 const Stmt *Body =
nullptr;
686 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(F))
688 else if (
auto *OMD = dyn_cast_or_null<ObjCMethodDecl>(F))
689 Body = OMD->getBody();
691 if (
auto *CS = dyn_cast_or_null<CompoundStmt>(Body)) {
692 auto LastStmt = CS->body_rbegin();
693 if (LastStmt != CS->body_rend())
700 if (
SanOpts.has(SanitizerKind::Thread)) {
701 Fn->addFnAttr(
"sanitize_thread_no_checking_at_run_time");
702 Fn->removeFnAttr(llvm::Attribute::SanitizeThread);
707bool CodeGenFunction::requiresReturnValueCheck()
const {
708 return requiresReturnValueNullabilityCheck() ||
714 auto *MD = dyn_cast_or_null<CXXMethodDecl>(D);
715 if (!MD || !MD->getDeclName().getAsIdentifierInfo() ||
716 !MD->getDeclName().getAsIdentifierInfo()->isStr(
"allocate") ||
717 (MD->getNumParams() != 1 && MD->getNumParams() != 2))
723 if (MD->getNumParams() == 2) {
724 auto *PT = MD->parameters()[1]->getType()->getAs<
PointerType>();
725 if (!PT || !PT->isVoidPointerType() ||
726 !PT->getPointeeType().isConstQualified())
733bool CodeGenFunction::isInAllocaArgument(
CGCXXABI &ABI, QualType Ty) {
738bool CodeGenFunction::hasInAllocaArg(
const CXXMethodDecl *MD) {
741 llvm::any_of(MD->
parameters(), [&](ParmVarDecl *P) {
742 return isInAllocaArgument(CGM.getCXXABI(), P->getType());
749 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD))
762 "Do not use a CodeGenFunction object for more than one function");
766 DidCallStackSave =
false;
768 const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D);
775 assert(
CurFn->isDeclaration() &&
"Function already has body?");
780#define SANITIZER(NAME, ID) \
781 if (SanOpts.empty()) \
783 if (SanOpts.has(SanitizerKind::ID)) \
784 if (CGM.isInNoSanitizeList(SanitizerKind::ID, Fn, Loc)) \
785 SanOpts.set(SanitizerKind::ID, false);
787#include "clang/Basic/Sanitizers.def"
792 const bool SanitizeBounds =
SanOpts.hasOneOf(SanitizerKind::Bounds);
794 bool NoSanitizeCoverage =
false;
797 no_sanitize_mask |=
Attr->getMask();
799 if (
Attr->hasCoverage())
800 NoSanitizeCoverage =
true;
804 SanOpts.Mask &= ~no_sanitize_mask;
805 if (no_sanitize_mask & SanitizerKind::Address)
806 SanOpts.set(SanitizerKind::KernelAddress,
false);
807 if (no_sanitize_mask & SanitizerKind::KernelAddress)
808 SanOpts.set(SanitizerKind::Address,
false);
809 if (no_sanitize_mask & SanitizerKind::HWAddress)
810 SanOpts.set(SanitizerKind::KernelHWAddress,
false);
811 if (no_sanitize_mask & SanitizerKind::KernelHWAddress)
812 SanOpts.set(SanitizerKind::HWAddress,
false);
814 if (SanitizeBounds && !
SanOpts.hasOneOf(SanitizerKind::Bounds))
815 Fn->addFnAttr(llvm::Attribute::NoSanitizeBounds);
817 if (NoSanitizeCoverage &&
CGM.getCodeGenOpts().hasSanitizeCoverage())
818 Fn->addFnAttr(llvm::Attribute::NoSanitizeCoverage);
821 if (
CGM.getCodeGenOpts().hasSanitizeBinaryMetadata()) {
822 if (no_sanitize_mask & SanitizerKind::Thread)
823 Fn->addFnAttr(
"no_sanitize_thread");
828 CurFn->addFnAttr(llvm::Attribute::DisableSanitizerInstrumentation);
831 if (
SanOpts.hasOneOf(SanitizerKind::Address | SanitizerKind::KernelAddress))
832 Fn->addFnAttr(llvm::Attribute::SanitizeAddress);
833 if (
SanOpts.hasOneOf(SanitizerKind::HWAddress |
834 SanitizerKind::KernelHWAddress))
835 Fn->addFnAttr(llvm::Attribute::SanitizeHWAddress);
836 if (
SanOpts.has(SanitizerKind::MemtagStack))
837 Fn->addFnAttr(llvm::Attribute::SanitizeMemTag);
838 if (
SanOpts.has(SanitizerKind::Thread))
839 Fn->addFnAttr(llvm::Attribute::SanitizeThread);
840 if (
SanOpts.has(SanitizerKind::Type))
841 Fn->addFnAttr(llvm::Attribute::SanitizeType);
842 if (
SanOpts.has(SanitizerKind::NumericalStability))
843 Fn->addFnAttr(llvm::Attribute::SanitizeNumericalStability);
844 if (
SanOpts.hasOneOf(SanitizerKind::Memory | SanitizerKind::KernelMemory))
845 Fn->addFnAttr(llvm::Attribute::SanitizeMemory);
846 if (
SanOpts.has(SanitizerKind::AllocToken))
847 Fn->addFnAttr(llvm::Attribute::SanitizeAllocToken);
849 if (
SanOpts.has(SanitizerKind::SafeStack))
850 Fn->addFnAttr(llvm::Attribute::SafeStack);
851 if (
SanOpts.has(SanitizerKind::ShadowCallStack))
852 Fn->addFnAttr(llvm::Attribute::ShadowCallStack);
854 if (
SanOpts.has(SanitizerKind::Realtime))
858 Fn->addFnAttr(llvm::Attribute::SanitizeRealtime);
860 Fn->addFnAttr(llvm::Attribute::SanitizeRealtimeBlocking);
864 if (
SanOpts.hasOneOf(SanitizerKind::Fuzzer | SanitizerKind::FuzzerNoLink))
865 Fn->addFnAttr(llvm::Attribute::OptForFuzzing);
869 if (
SanOpts.has(SanitizerKind::Thread)) {
870 if (
const auto *OMD = dyn_cast_or_null<ObjCMethodDecl>(D)) {
871 const IdentifierInfo *II = OMD->getSelector().getIdentifierInfoForSlot(0);
874 (OMD->getSelector().isUnarySelector() && II->
isStr(
".cxx_destruct"))) {
883 if (D &&
SanOpts.has(SanitizerKind::CFIUnrelatedCast)) {
891 if (D &&
SanOpts.has(SanitizerKind::Null))
897 bool AlwaysXRayAttr =
false;
898 if (
const auto *XRayAttr = D ? D->
getAttr<XRayInstrumentAttr>() :
nullptr) {
899 if (
CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
901 CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
904 Fn->addFnAttr(
"function-instrument",
"xray-always");
905 AlwaysXRayAttr =
true;
907 if (XRayAttr->neverXRayInstrument())
908 Fn->addFnAttr(
"function-instrument",
"xray-never");
909 if (
const auto *LogArgs = D->
getAttr<XRayLogArgsAttr>())
911 Fn->addFnAttr(
"xray-log-args",
912 llvm::utostr(LogArgs->getArgumentCount()));
917 "xray-instruction-threshold",
918 llvm::itostr(
CGM.getCodeGenOpts().XRayInstructionThreshold));
922 if (
CGM.getCodeGenOpts().XRayIgnoreLoops)
923 Fn->addFnAttr(
"xray-ignore-loops");
925 if (!
CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
927 Fn->addFnAttr(
"xray-skip-exit");
929 if (!
CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
931 Fn->addFnAttr(
"xray-skip-entry");
933 auto FuncGroups =
CGM.getCodeGenOpts().XRayTotalFunctionGroups;
934 if (FuncGroups > 1) {
936 CurFn->getName().bytes_end());
937 auto Group = crc32(FuncName) % FuncGroups;
938 if (Group !=
CGM.getCodeGenOpts().XRaySelectedFunctionGroup &&
940 Fn->addFnAttr(
"function-instrument",
"xray-never");
944 if (
CGM.getCodeGenOpts().getProfileInstr() !=
945 llvm::driver::ProfileInstrKind::ProfileNone) {
946 switch (
CGM.isFunctionBlockedFromProfileInstr(Fn, Loc)) {
948 Fn->addFnAttr(llvm::Attribute::SkipProfile);
951 Fn->addFnAttr(llvm::Attribute::NoProfile);
958 unsigned Count, Offset;
960 if (
const auto *
Attr =
961 D ? D->
getAttr<PatchableFunctionEntryAttr>() :
nullptr) {
962 Count =
Attr->getCount();
963 Offset =
Attr->getOffset();
964 Section =
Attr->getSection();
966 Count =
CGM.getCodeGenOpts().PatchableFunctionEntryCount;
967 Offset =
CGM.getCodeGenOpts().PatchableFunctionEntryOffset;
970 Section =
CGM.getCodeGenOpts().PatchableFunctionEntrySection;
971 if (Count && Offset <= Count) {
972 Fn->addFnAttr(
"patchable-function-entry", std::to_string(Count - Offset));
974 Fn->addFnAttr(
"patchable-function-prefix", std::to_string(Offset));
975 if (!Section.empty())
976 Fn->addFnAttr(
"patchable-function-entry-section", Section);
982 if (
CGM.getCodeGenOpts().HotPatch &&
983 getContext().getTargetInfo().getTriple().isX86() &&
984 getContext().getTargetInfo().getTriple().getEnvironment() !=
985 llvm::Triple::CODE16)
986 Fn->addFnAttr(
"patchable-function",
"prologue-short-redirect");
989 if (
CGM.getCodeGenOpts().NoUseJumpTables)
990 Fn->addFnAttr(
"no-jump-tables",
"true");
993 if (
CGM.getCodeGenOpts().NoInlineLineTables)
994 Fn->addFnAttr(
"no-inline-line-tables");
997 if (
CGM.getCodeGenOpts().ProfileSampleAccurate)
998 Fn->addFnAttr(
"profile-sample-accurate");
1000 if (!
CGM.getCodeGenOpts().SampleProfileFile.empty())
1001 Fn->addFnAttr(
"use-sample-profile");
1003 if (D && D->
hasAttr<CFICanonicalJumpTableAttr>())
1004 Fn->addFnAttr(
"cfi-canonical-jump-table");
1006 if (D && D->
hasAttr<NoProfileFunctionAttr>())
1007 Fn->addFnAttr(llvm::Attribute::NoProfile);
1009 if (D && D->
hasAttr<HybridPatchableAttr>())
1010 Fn->addFnAttr(llvm::Attribute::HybridPatchable);
1014 if (
auto *A = D->
getAttr<FunctionReturnThunksAttr>()) {
1015 switch (A->getThunkType()) {
1016 case FunctionReturnThunksAttr::Kind::Keep:
1018 case FunctionReturnThunksAttr::Kind::Extern:
1019 Fn->addFnAttr(llvm::Attribute::FnRetThunkExtern);
1022 }
else if (
CGM.getCodeGenOpts().FunctionReturnThunks)
1023 Fn->addFnAttr(llvm::Attribute::FnRetThunkExtern);
1028 getContext().getTargetInfo().getTriple().isSPIRV()) ||
1032 EmitKernelMetadata(FD, Fn);
1035 if (FD && FD->
hasAttr<ClspvLibclcBuiltinAttr>()) {
1036 Fn->setMetadata(
"clspv_libclc_builtin",
1042 if (FD &&
SanOpts.has(SanitizerKind::Function) &&
1045 llvm::LLVMContext &Ctx = Fn->getContext();
1046 llvm::MDBuilder MDB(Ctx);
1048 llvm::LLVMContext::MD_func_sanitize,
1049 MDB.createRTTIPointerPrologue(
1056 if (
SanOpts.has(SanitizerKind::NullabilityReturn)) {
1057 auto Nullability =
FnRetTy->getNullability();
1060 if (!(
SanOpts.has(SanitizerKind::ReturnsNonnullAttribute) &&
1062 RetValNullabilityPrecondition =
1085 Fn->addFnAttr(llvm::Attribute::NoRecurse);
1088 llvm::fp::ExceptionBehavior FPExceptionBehavior =
1090 Builder.setDefaultConstrainedRounding(RM);
1091 Builder.setDefaultConstrainedExcept(FPExceptionBehavior);
1093 (!FD && (FPExceptionBehavior != llvm::fp::ebIgnore ||
1094 RM != llvm::RoundingMode::NearestTiesToEven))) {
1095 Builder.setIsFPConstrained(
true);
1096 Fn->addFnAttr(llvm::Attribute::StrictFP);
1102 CGM.getCodeGenOpts().StackAlignment))
1103 Fn->addFnAttr(
"stackrealign");
1107 Fn->removeFnAttr(
"zero-call-used-regs");
1110 llvm::StringMap<bool> FeatureMap;
1115 if (
T->getAArch64SMEAttributes() &
1122 std::optional<std::pair<unsigned, unsigned>> VScaleRange =
1126 CurFn->addFnAttr(llvm::Attribute::getWithVScaleRangeArgs(
1135 llvm::Value *Poison = llvm::PoisonValue::get(
Int32Ty);
1140 Builder.SetInsertPoint(EntryBB);
1144 if (requiresReturnValueCheck()) {
1155 DI->emitFunctionStart(GD, Loc, StartLoc,
1156 DI->getFunctionType(FD, RetTy, Args),
CurFn,
1161 if (
CGM.getCodeGenOpts().InstrumentFunctions)
1162 CurFn->addFnAttr(
"instrument-function-entry",
"__cyg_profile_func_enter");
1163 if (
CGM.getCodeGenOpts().InstrumentFunctionsAfterInlining)
1164 CurFn->addFnAttr(
"instrument-function-entry-inlined",
1165 "__cyg_profile_func_enter");
1166 if (
CGM.getCodeGenOpts().InstrumentFunctionEntryBare)
1167 CurFn->addFnAttr(
"instrument-function-entry-inlined",
1168 "__cyg_profile_func_enter_bare");
1175 if (
CGM.getCodeGenOpts().InstrumentForProfiling) {
1179 if (
CGM.getCodeGenOpts().CallFEntry)
1180 Fn->addFnAttr(
"fentry-call",
"true");
1182 Fn->addFnAttr(
"instrument-function-entry-inlined",
1185 if (
CGM.getCodeGenOpts().MNopMCount) {
1186 if (!
CGM.getCodeGenOpts().CallFEntry)
1187 CGM.getDiags().Report(diag::err_opt_not_valid_without_opt)
1188 <<
"-mnop-mcount" <<
"-mfentry";
1189 Fn->addFnAttr(
"mnop-mcount");
1192 if (
CGM.getCodeGenOpts().RecordMCount) {
1193 if (!
CGM.getCodeGenOpts().CallFEntry)
1194 CGM.getDiags().Report(diag::err_opt_not_valid_without_opt)
1195 <<
"-mrecord-mcount" <<
"-mfentry";
1196 Fn->addFnAttr(
"mrecord-mcount");
1201 if (
CGM.getCodeGenOpts().PackedStack) {
1202 if (
getContext().getTargetInfo().getTriple().getArch() !=
1203 llvm::Triple::systemz)
1204 CGM.getDiags().Report(diag::err_opt_not_valid_on_target)
1205 <<
"-mpacked-stack";
1206 Fn->addFnAttr(
"packed-stack");
1209 if (
CGM.getCodeGenOpts().WarnStackSize !=
UINT_MAX &&
1210 !
CGM.getDiags().isIgnored(diag::warn_fe_backend_frame_larger_than, Loc))
1211 Fn->addFnAttr(
"warn-stack-size",
1212 std::to_string(
CGM.getCodeGenOpts().WarnStackSize));
1224 auto AI =
CurFn->arg_begin();
1225 if (
CurFnInfo->getReturnInfo().isSRetAfterThis())
1228 &*AI, RetTy,
CurFnInfo->getReturnInfo().getIndirectAlign(),
false,
1230 if (!
CurFnInfo->getReturnInfo().getIndirectByVal()) {
1239 unsigned Idx =
CurFnInfo->getReturnInfo().getInAllocaFieldIndex();
1240 llvm::Function::arg_iterator EI =
CurFn->arg_end();
1272 if (FD->
hasAttr<HLSLShaderAttr>()) {
1273 CGM.getHLSLRuntime().emitEntryFunction(FD, Fn);
1279 if (
const CXXMethodDecl *MD = dyn_cast_if_present<CXXMethodDecl>(D);
1284 CGM.getCXXABI().EmitInstanceFunctionProlog(*
this);
1300 CXXThisValue = ThisFieldLValue.
getPointer(*
this);
1309 if (FD->hasCapturedVLAType()) {
1312 auto VAT = FD->getCapturedVLAType();
1313 VLASizeMap[VAT->getSizeExpr()] = ExprArg;
1320 CXXThisValue = CXXABIThisValue;
1324 if (CXXABIThisValue) {
1326 SkippedChecks.
set(SanitizerKind::ObjectSize,
true);
1333 SkippedChecks.
set(SanitizerKind::Null,
true);
1337 Loc, CXXABIThisValue, ThisTy, CXXABIThisAlignment, SkippedChecks);
1344 if (!FD || !FD->
hasAttr<NakedAttr>()) {
1345 for (
const VarDecl *VD : Args) {
1350 if (
const ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(VD))
1351 Ty = PVD->getOriginalType();
1361 DI->EmitLocation(
Builder, StartLoc);
1365 if (
const auto *VecWidth =
CurFuncDecl->getAttr<MinVectorWidthAttr>())
1366 LargestVectorWidth = VecWidth->getVectorWidth();
1368 if (
CGM.shouldEmitConvergenceTokens())
1375 if (
const CompoundStmt *S = dyn_cast<CompoundStmt>(Body))
1387 llvm::BasicBlock *SkipCountBB =
nullptr;
1412 if (F->isInterposable())
return;
1414 for (llvm::BasicBlock &BB : *F)
1415 for (llvm::Instruction &I : BB)
1419 F->setDoesNotThrow();
1429 if (
CGM.getCXXABI().HasThisReturn(GD))
1431 else if (
CGM.getCXXABI().hasMostDerivedReturn(GD))
1432 ResTy =
CGM.getContext().VoidPtrTy;
1433 CGM.getCXXABI().buildThisParam(*
this, Args);
1439 bool PassedParams =
true;
1441 if (
auto Inherited = CD->getInheritedConstructor())
1447 Args.push_back(Param);
1448 if (!Param->hasAttr<PassObjectSizeAttr>())
1452 getContext(), Param->getDeclContext(), Param->getLocation(),
1460 CGM.getCXXABI().addImplicitStructorParams(*
this, ResTy, Args);
1467 assert(Fn &&
"generating code for null Function");
1474 CGM.getTargetCodeGenInfo().checkFunctionABI(
CGM, FD);
1480 std::string FDInlineName = (Fn->getName() +
".inline").str();
1481 llvm::Module *M = Fn->getParent();
1482 llvm::Function *Clone = M->getFunction(FDInlineName);
1484 Clone = llvm::Function::Create(Fn->getFunctionType(),
1485 llvm::GlobalValue::InternalLinkage,
1486 Fn->getAddressSpace(), FDInlineName, M);
1487 Clone->addFnAttr(llvm::Attribute::AlwaysInline);
1489 Fn->setLinkage(llvm::GlobalValue::ExternalLinkage);
1499 if (LLVM_UNLIKELY(PD->isInlineBuiltinDeclaration())) {
1500 std::string FDInlineName = (Fn->getName() +
".inline").str();
1501 llvm::Module *M = Fn->getParent();
1502 if (llvm::Function *Clone = M->getFunction(FDInlineName)) {
1503 Clone->replaceAllUsesWith(Fn);
1504 Clone->eraseFromParent();
1512 if (FD->
hasAttr<NoDebugAttr>()) {
1515 Fn->setSubprogram(
nullptr);
1517 DebugInfo =
nullptr;
1520 llvm::scope_exit Cleanup([
this] {
1522 DI->completeFunction();
1529 BodyRange = Body->getSourceRange();
1532 CurEHLocation = BodyRange.getEnd();
1544 if (SpecDecl->hasBody(SpecDecl))
1545 Loc = SpecDecl->getLocation();
1552 ShouldEmitLifetimeMarkers =
true;
1556 if (ShouldEmitLifetimeMarkers)
1561 StartFunction(GD, ResTy, Fn, FnInfo, Args, Loc, BodyRange.getBegin());
1564 if (Body && isa_and_nonnull<CoroutineBodyStmt>(Body))
1572 CurFn->addFnAttr(llvm::Attribute::MustProgress);
1575 PGO->assignRegionCounters(GD,
CurFn);
1582 FD->
hasAttr<CUDAGlobalAttr>())
1583 CGM.getCUDARuntime().emitDeviceStub(*
this, Args);
1606 }
else if (DeviceKernelAttr::isOpenCLSpelling(
1607 FD->
getAttr<DeviceKernelAttr>()) &&
1610 for (
unsigned i = 0; i < Args.size(); ++i) {
1612 QualType ArgQualType = Args[i]->getType();
1614 CallArgs.
add(ArgRValue, ArgQualType);
1618 CGM.getTargetCodeGenInfo().setOCLKernelStubCallingConvention(FT);
1620 CallArgs, FT,
false);
1621 llvm::FunctionType *FTy =
CGM.getTypes().GetFunctionType(FnInfo);
1622 llvm::Constant *GDStubFunctionPointer =
1623 CGM.getRawFunctionPointer(GDStub, FTy);
1630 llvm_unreachable(
"no definition for emitted function");
1640 bool ShouldEmitUnreachable =
1641 CGM.getCodeGenOpts().StrictReturn ||
1643 if (
SanOpts.has(SanitizerKind::Return)) {
1644 auto CheckOrdinal = SanitizerKind::SO_Return;
1645 auto CheckHandler = SanitizerHandler::MissingReturn;
1647 llvm::Value *IsFalse =
Builder.getFalse();
1648 EmitCheck(std::make_pair(IsFalse, CheckOrdinal), CheckHandler,
1650 }
else if (ShouldEmitUnreachable) {
1651 if (
CGM.getCodeGenOpts().OptimizationLevel == 0)
1654 if (
SanOpts.has(SanitizerKind::Return) || ShouldEmitUnreachable) {
1656 Builder.ClearInsertionPoint();
1663 PGO->verifyCounterMap();
1667 if (!
CurFn->doesNotThrow())
1676 if (!S)
return false;
1693 IgnoreCaseStmts =
true;
1708 if (!S)
return false;
1728 if (!S)
return false;
1759 if (!AllowLabels &&
CGM.getCodeGenOpts().hasProfileClangInstr() &&
1760 CGM.getCodeGenOpts().MCDCCoverage)
1763 llvm::APSInt ResultInt;
1767 ResultBool = ResultInt.getBoolValue();
1775 llvm::APSInt &ResultInt,
1783 llvm::APSInt Int =
Result.Val.getInt();
1787 PGO->markStmtMaybeUsed(
Cond);
1817 llvm::BasicBlock *FalseBlock, uint64_t TrueCount ,
1820 bool InstrumentRegions =
CGM.getCodeGenOpts().hasProfileClangInstr();
1824 const Stmt *CntrStmt = (CntrIdx ? CntrIdx :
Cond);
1826 llvm::BasicBlock *ThenBlock =
nullptr;
1827 llvm::BasicBlock *ElseBlock =
nullptr;
1828 llvm::BasicBlock *NextBlock =
nullptr;
1845 if (LOp == BO_LAnd) {
1846 ThenBlock = CounterIncrBlock;
1847 ElseBlock = FalseBlock;
1848 NextBlock = TrueBlock;
1863 else if (LOp == BO_LOr) {
1864 ThenBlock = TrueBlock;
1865 ElseBlock = CounterIncrBlock;
1866 NextBlock = FalseBlock;
1868 llvm_unreachable(
"Expected Opcode must be that of a Logical Operator");
1892 const Expr *
Cond, llvm::BasicBlock *TrueBlock, llvm::BasicBlock *FalseBlock,
1894 const VarDecl *ConditionalDecl) {
1899 if (CondBOp->getOpcode() == BO_LAnd) {
1902 bool ConstantBool =
false;
1908 FalseBlock, TrueCount, LH);
1918 FalseBlock, TrueCount, LH, CondBOp);
1946 FalseBlock, TrueCount, LH);
1951 if (CondBOp->getOpcode() == BO_LOr) {
1954 bool ConstantBool =
false;
1960 FalseBlock, TrueCount, LH);
1970 FalseBlock, TrueCount, LH, CondBOp);
1981 uint64_t RHSCount = TrueCount - LHSCount;
2012 bool MCDCCondition =
CGM.getCodeGenOpts().hasProfileClangInstr() &&
2013 CGM.getCodeGenOpts().MCDCCoverage &&
2015 if (CondUOp->getOpcode() == UO_LNot && !MCDCCondition) {
2042 uint64_t LHSScaledTrueCount = 0;
2046 LHSScaledTrueCount = TrueCount * LHSRatio;
2055 LHSScaledTrueCount, LH, CondOp);
2062 TrueCount - LHSScaledTrueCount, LH, CondOp);
2097 MCDCBaseExpr = ConditionalOp;
2104 llvm::MDNode *Weights =
nullptr;
2105 llvm::MDNode *Unpredictable =
nullptr;
2110 auto *
Call = dyn_cast<CallExpr>(
Cond->IgnoreImpCasts());
2111 if (
Call &&
CGM.getCodeGenOpts().OptimizationLevel != 0) {
2112 auto *FD = dyn_cast_or_null<FunctionDecl>(
Call->getCalleeDecl());
2113 if (FD && FD->
getBuiltinID() == Builtin::BI__builtin_unpredictable) {
2115 Unpredictable = MDHelper.createUnpredictable();
2121 llvm::Value *NewCondV = emitCondLikelihoodViaExpectIntrinsic(CondV, LH);
2122 if (CondV != NewCondV)
2127 Weights = createProfileWeights(TrueCount, CurrentCount - TrueCount);
2130 llvm::Instruction *BrInst =
Builder.CreateCondBr(CondV, TrueBlock, FalseBlock,
2131 Weights, Unpredictable);
2135 case HLSLControlFlowHintAttr::Microsoft_branch:
2136 case HLSLControlFlowHintAttr::Microsoft_flatten: {
2137 llvm::MDBuilder MDHelper(
CGM.getLLVMContext());
2139 llvm::ConstantInt *BranchHintConstant =
2141 HLSLControlFlowHintAttr::Spelling::Microsoft_branch
2142 ? llvm::ConstantInt::get(
CGM.Int32Ty, 1)
2143 : llvm::ConstantInt::get(
CGM.Int32Ty, 2);
2146 {MDHelper.createString(
"hlsl.controlflow.hint"),
2147 MDHelper.createConstant(BranchHintConstant)});
2148 BrInst->setMetadata(
"hlsl.controlflow.hint",
2149 llvm::MDNode::get(
CGM.getLLVMContext(), Vals));
2153 case HLSLControlFlowHintAttr::SpellingNotCalculated:
2161 llvm::Value *Arg =
nullptr;
2162 if ((ICEArguments & (1 << Idx)) == 0) {
2167 std::optional<llvm::APSInt>
Result =
2169 assert(
Result &&
"Expected argument to be a constant");
2178 CGM.ErrorUnsupported(S,
Type);
2190 llvm::Value *sizeInChars) {
2194 llvm::Value *baseSizeInChars
2198 llvm::Value *end = Builder.CreateInBoundsGEP(begin.
getElementType(),
2200 sizeInChars,
"vla.end");
2202 llvm::BasicBlock *originBB = CGF.
Builder.GetInsertBlock();
2210 llvm::PHINode *cur = Builder.CreatePHI(begin.
getType(), 2,
"vla.cur");
2217 Builder.CreateMemCpy(
Address(cur, CGF.
Int8Ty, curAlign), src, baseSizeInChars,
2222 Builder.CreateInBoundsGEP(CGF.
Int8Ty, cur, baseSizeInChars,
"vla.next");
2225 llvm::Value *done = Builder.CreateICmpEQ(next, end,
"vla-init.isdone");
2226 Builder.CreateCondBr(done, contBB, loopBB);
2227 cur->addIncoming(next, loopBB);
2245 llvm::Value *SizeVal;
2252 dyn_cast_or_null<VariableArrayType>(
2255 SizeVal = VlaSize.NumElts;
2257 if (!eltSize.
isOne())
2258 SizeVal =
Builder.CreateNUWMul(SizeVal,
CGM.getSize(eltSize));
2264 SizeVal =
CGM.getSize(size);
2272 if (!
CGM.getTypes().isZeroInitializable(Ty)) {
2276 llvm::Constant *NullConstant =
CGM.EmitNullConstant(Ty);
2278 llvm::GlobalVariable *NullVariable =
2279 new llvm::GlobalVariable(
CGM.getModule(), NullConstant->getType(),
2281 llvm::GlobalVariable::PrivateLinkage,
2282 NullConstant, Twine());
2284 NullVariable->setAlignment(NullAlign.
getAsAlign());
2290 Builder.CreateMemCpy(DestPtr, SrcPtr, SizeVal,
false);
2297 Builder.CreateMemSet(DestPtr,
Builder.getInt8(0), SizeVal,
false);
2302 if (!IndirectBranch)
2308 IndirectBranch->addDestination(BB);
2309 return llvm::BlockAddress::get(
CurFn->getType(), BB);
2314 if (IndirectBranch)
return IndirectBranch->getParent();
2319 llvm::Value *DestVal = TmpBuilder.CreatePHI(
Int8PtrTy, 0,
2320 "indirect.goto.dest");
2323 IndirectBranch = TmpBuilder.CreateIndirectBr(DestVal);
2324 return IndirectBranch->getParent();
2336 llvm::Value *numVLAElements =
nullptr;
2348 baseType = elementType;
2349 return numVLAElements;
2363 llvm::ConstantInt *zero =
Builder.getInt32(0);
2364 gepIndices.push_back(zero);
2366 uint64_t countFromCLAs = 1;
2369 llvm::ArrayType *llvmArrayType =
2371 while (llvmArrayType) {
2374 llvmArrayType->getNumElements());
2376 gepIndices.push_back(zero);
2377 countFromCLAs *= llvmArrayType->getNumElements();
2381 dyn_cast<llvm::ArrayType>(llvmArrayType->getElementType());
2384 "LLVM and Clang types are out-of-synch");
2403 gepIndices,
"array.begin"),
2409 llvm::Value *numElements
2410 = llvm::ConstantInt::get(
SizeTy, countFromCLAs);
2414 numElements =
Builder.CreateNUWMul(numVLAElements, numElements);
2421 assert(vla &&
"type was not a variable array type!");
2428 llvm::Value *numElements =
nullptr;
2432 elementType =
type->getElementType();
2433 llvm::Value *vlaSize = VLASizeMap[
type->getSizeExpr()];
2434 assert(vlaSize &&
"no size for VLA!");
2435 assert(vlaSize->getType() ==
SizeTy);
2438 numElements = vlaSize;
2442 numElements =
Builder.CreateNUWMul(numElements, vlaSize);
2444 }
while ((
type =
getContext().getAsVariableArrayType(elementType)));
2446 return { numElements, elementType };
2452 assert(vla &&
"type was not a variable array type!");
2458 llvm::Value *VlaSize = VLASizeMap[Vla->
getSizeExpr()];
2459 assert(VlaSize &&
"no size for VLA!");
2460 assert(VlaSize->getType() ==
SizeTy);
2465 assert(
type->isVariablyModifiedType() &&
2466 "Must pass variably modified type to EmitVLASizes!");
2473 assert(
type->isVariablyModifiedType());
2475 const Type *ty =
type.getTypePtr();
2478#define TYPE(Class, Base)
2479#define ABSTRACT_TYPE(Class, Base)
2480#define NON_CANONICAL_TYPE(Class, Base)
2481#define DEPENDENT_TYPE(Class, Base) case Type::Class:
2482#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base)
2483#include "clang/AST/TypeNodes.inc"
2484 llvm_unreachable(
"unexpected dependent type!");
2490 case Type::ExtVector:
2491 case Type::ConstantMatrix:
2495 case Type::TemplateSpecialization:
2496 case Type::ObjCTypeParam:
2497 case Type::ObjCObject:
2498 case Type::ObjCInterface:
2499 case Type::ObjCObjectPointer:
2501 case Type::HLSLInlineSpirv:
2502 case Type::PredefinedSugar:
2503 llvm_unreachable(
"type class is never variably-modified!");
2505 case Type::Adjusted:
2517 case Type::BlockPointer:
2521 case Type::LValueReference:
2522 case Type::RValueReference:
2526 case Type::MemberPointer:
2530 case Type::ArrayParameter:
2531 case Type::ConstantArray:
2532 case Type::IncompleteArray:
2537 case Type::VariableArray: {
2546 llvm::Value *&entry = VLASizeMap[sizeExpr];
2554 if (
SanOpts.has(SanitizerKind::VLABound)) {
2555 auto CheckOrdinal = SanitizerKind::SO_VLABound;
2556 auto CheckHandler = SanitizerHandler::VLABoundNotPositive;
2558 llvm::Value *
Zero = llvm::Constant::getNullValue(size->getType());
2560 llvm::Value *CheckCondition =
2564 llvm::Constant *StaticArgs[] = {
2567 EmitCheck(std::make_pair(CheckCondition, CheckOrdinal),
2568 CheckHandler, StaticArgs, size);
2581 case Type::FunctionProto:
2582 case Type::FunctionNoProto:
2588 case Type::UnaryTransform:
2589 case Type::Attributed:
2590 case Type::BTFTagAttributed:
2591 case Type::HLSLAttributedResource:
2592 case Type::SubstTemplateTypeParm:
2593 case Type::MacroQualified:
2594 case Type::CountAttributed:
2600 case Type::Decltype:
2602 case Type::DeducedTemplateSpecialization:
2603 case Type::PackIndexing:
2607 case Type::TypeOfExpr:
2620 }
while (
type->isVariablyModifiedType());
2624 if (
getContext().getBuiltinVaListType()->isArrayType())
2635 assert(
Init.hasValue() &&
"Invalid DeclRefExpr initializer!");
2637 if (
CGM.getCodeGenOpts().hasReducedDebugInfo())
2653 llvm::Instruction *inst =
new llvm::BitCastInst(value, value->getType(),
"",
2657 protection.Inst = inst;
2662 if (!protection.Inst)
return;
2665 protection.Inst->eraseFromParent();
2671 llvm::Value *Alignment,
2672 llvm::Value *OffsetValue) {
2673 if (Alignment->getType() !=
IntPtrTy)
2676 if (OffsetValue && OffsetValue->getType() !=
IntPtrTy)
2679 llvm::Value *TheCheck =
nullptr;
2680 if (
SanOpts.has(SanitizerKind::Alignment)) {
2681 llvm::Value *PtrIntValue =
2685 bool IsOffsetZero =
false;
2686 if (
const auto *CI = dyn_cast<llvm::ConstantInt>(OffsetValue))
2687 IsOffsetZero = CI->isZero();
2690 PtrIntValue =
Builder.CreateSub(PtrIntValue, OffsetValue,
"offsetptr");
2693 llvm::Value *
Zero = llvm::ConstantInt::get(
IntPtrTy, 0);
2696 llvm::Value *MaskedPtr =
Builder.CreateAnd(PtrIntValue, Mask,
"maskedptr");
2697 TheCheck =
Builder.CreateICmpEQ(MaskedPtr,
Zero,
"maskcond");
2699 llvm::Instruction *Assumption =
Builder.CreateAlignmentAssumption(
2700 CGM.getDataLayout(), PtrValue, Alignment, OffsetValue);
2702 if (!
SanOpts.has(SanitizerKind::Alignment))
2705 OffsetValue, TheCheck, Assumption);
2711 llvm::Value *Alignment,
2712 llvm::Value *OffsetValue) {
2721 llvm::Value *AnnotatedVal,
2722 StringRef AnnotationStr,
2724 const AnnotateAttr *
Attr) {
2727 CGM.EmitAnnotationString(AnnotationStr),
2728 CGM.EmitAnnotationUnit(Location),
2729 CGM.EmitAnnotationLineNo(Location),
2732 Args.push_back(
CGM.EmitAnnotationArgs(
Attr));
2733 return Builder.CreateCall(AnnotationFn, Args);
2737 assert(D->
hasAttr<AnnotateAttr>() &&
"no annotate attribute");
2740 {V->getType(), CGM.ConstGlobalsPtrTy}),
2746 assert(D->
hasAttr<AnnotateAttr>() &&
"no annotate attribute");
2747 llvm::Value *
V =
Addr.emitRawPointer(*
this);
2748 llvm::Type *VTy =
V->getType();
2749 auto *PTy = dyn_cast<llvm::PointerType>(VTy);
2750 unsigned AS = PTy ? PTy->getAddressSpace() : 0;
2751 llvm::PointerType *IntrinTy =
2752 llvm::PointerType::get(
CGM.getLLVMContext(), AS);
2753 llvm::Function *F =
CGM.getIntrinsic(llvm::Intrinsic::ptr_annotation,
2754 {IntrinTy,
CGM.ConstGlobalsPtrTy});
2760 if (VTy != IntrinTy)
2773 assert(!CGF->IsSanitizerScope);
2774 CGF->IsSanitizerScope =
true;
2778 CGF->IsSanitizerScope =
false;
2782 const llvm::Twine &Name,
2783 llvm::BasicBlock::iterator InsertPt)
const {
2786 I->setNoSanitizeMetadata();
2790 llvm::Instruction *I,
const llvm::Twine &Name,
2791 llvm::BasicBlock::iterator InsertPt)
const {
2792 llvm::IRBuilderDefaultInserter::InsertHelper(I, Name, InsertPt);
2794 CGF->InsertHelper(I, Name, InsertPt);
2803 if (
CGM.getContext().getTargetInfo().getTriple().isX86()) {
2805 if (BuiltinID == X86::BI__builtin_ia32_cmpps ||
2806 BuiltinID == X86::BI__builtin_ia32_cmpss ||
2807 BuiltinID == X86::BI__builtin_ia32_cmppd ||
2808 BuiltinID == X86::BI__builtin_ia32_cmpsd) {
2810 llvm::StringMap<bool> TargetFetureMap;
2811 CGM.getContext().getFunctionFeatureMap(TargetFetureMap, FD);
2813 *(E->
getArg(2)->getIntegerConstantExpr(
CGM.getContext()));
2814 if (
Result.getSExtValue() > 7 && !TargetFetureMap.lookup(
"avx"))
2815 CGM.getDiags().Report(E->
getBeginLoc(), diag::err_builtin_needs_feature)
2836 bool IsAlwaysInline = TargetDecl->
hasAttr<AlwaysInlineAttr>();
2837 bool IsFlatten = FD && FD->
hasAttr<FlattenAttr>();
2843 std::string MissingFeature;
2844 llvm::StringMap<bool> CallerFeatureMap;
2845 CGM.getContext().getFunctionFeatureMap(CallerFeatureMap, FD);
2852 StringRef FeatureList(
CGM.getContext().BuiltinInfo.getRequiredFeatures(BuiltinID));
2854 FeatureList, CallerFeatureMap) && !IsHipStdPar) {
2855 CGM.getDiags().Report(Loc, diag::err_builtin_needs_feature)
2860 TargetDecl->
hasAttr<TargetAttr>()) {
2863 const TargetAttr *TD = TargetDecl->
getAttr<TargetAttr>();
2865 CGM.getContext().filterFunctionTargetAttrs(TD);
2868 llvm::StringMap<bool> CalleeFeatureMap;
2869 CGM.getContext().getFunctionFeatureMap(CalleeFeatureMap, TargetDecl);
2872 if (F[0] ==
'+' && CalleeFeatureMap.lookup(F.substr(1)))
2873 ReqFeatures.push_back(StringRef(F).substr(1));
2876 for (
const auto &F : CalleeFeatureMap) {
2879 ReqFeatures.push_back(F.getKey());
2881 if (!llvm::all_of(ReqFeatures,
2883 if (!CallerFeatureMap.lookup(
Feature)) {
2884 MissingFeature =
Feature.str();
2891 CGM.getDiags().Report(Loc, diag::err_function_needs_feature)
2894 CGM.getDiags().Report(Loc, diag::err_flatten_function_needs_feature)
2899 llvm::StringMap<bool> CalleeFeatureMap;
2900 CGM.getContext().getFunctionFeatureMap(CalleeFeatureMap, TargetDecl);
2902 for (
const auto &F : CalleeFeatureMap) {
2904 (!CallerFeatureMap.lookup(F.getKey()) ||
2905 !CallerFeatureMap.find(F.getKey())->getValue()) &&
2908 CGM.getDiags().Report(Loc, diag::err_function_needs_feature)
2911 CGM.getDiags().Report(Loc, diag::err_flatten_function_needs_feature)
2919 if (!
CGM.getCodeGenOpts().SanitizeStats)
2922 llvm::IRBuilder<> IRB(
Builder.GetInsertBlock(),
Builder.GetInsertPoint());
2923 IRB.SetCurrentDebugLocation(
Builder.getCurrentDebugLocation());
2924 CGM.getSanStats().create(IRB, SSK);
2936 Salt = Info.CFISalt;
2938 Bundles.emplace_back(
"kcfi",
CGM.CreateKCFITypeId(FP->
desugar(), Salt));
2942CodeGenFunction::FormAArch64ResolverCondition(
const FMVResolverOption &RO) {
2943 return RO.Features.empty() ?
nullptr : EmitAArch64CpuSupports(RO.Features);
2947CodeGenFunction::FormX86ResolverCondition(
const FMVResolverOption &RO) {
2950 if (RO.Architecture) {
2951 StringRef
Arch = *RO.Architecture;
2954 if (
Arch.starts_with(
"x86-64"))
2960 if (!RO.Features.empty()) {
2961 llvm::Value *FeatureCond = EmitX86CpuSupports(RO.Features);
2969 llvm::Function *Resolver,
2971 llvm::Function *FuncToReturn,
2972 bool SupportsIFunc) {
2973 if (SupportsIFunc) {
2974 Builder.CreateRet(FuncToReturn);
2979 llvm::make_pointer_range(Resolver->args()));
2981 llvm::CallInst *Result = Builder.CreateCall(FuncToReturn, Args);
2982 Result->setTailCallKind(llvm::CallInst::TCK_MustTail);
2984 if (Resolver->getReturnType()->isVoidTy())
2985 Builder.CreateRetVoid();
2987 Builder.CreateRet(Result);
2993 llvm::Triple::ArchType ArchType =
2997 case llvm::Triple::x86:
2998 case llvm::Triple::x86_64:
3001 case llvm::Triple::aarch64:
3004 case llvm::Triple::riscv32:
3005 case llvm::Triple::riscv64:
3010 assert(
false &&
"Only implemented for x86, AArch64 and RISC-V targets");
3017 if (
getContext().getTargetInfo().getTriple().getOS() !=
3018 llvm::Triple::OSType::Linux) {
3019 CGM.getDiags().Report(diag::err_os_unsupport_riscv_fmv);
3024 Builder.SetInsertPoint(CurBlock);
3028 bool HasDefault =
false;
3029 unsigned DefaultIndex = 0;
3032 for (
unsigned Index = 0; Index < Options.size(); Index++) {
3034 if (Options[Index].Features.empty()) {
3036 DefaultIndex = Index;
3040 Builder.SetInsertPoint(CurBlock);
3066 for (StringRef Feat : Options[Index].Features) {
3067 std::vector<std::string> FeatStr =
3070 assert(FeatStr.size() == 1 &&
"Feature string not delimited");
3072 std::string &CurrFeat = FeatStr.front();
3073 if (CurrFeat[0] ==
'+')
3074 TargetAttrFeats.push_back(CurrFeat.substr(1));
3077 if (TargetAttrFeats.empty())
3080 for (std::string &Feat : TargetAttrFeats)
3081 CurrTargetAttrFeats.push_back(Feat);
3083 Builder.SetInsertPoint(CurBlock);
3086 llvm::BasicBlock *RetBlock =
createBasicBlock(
"resolver_return", Resolver);
3089 Options[Index].
Function, SupportsIFunc);
3092 Builder.SetInsertPoint(CurBlock);
3093 Builder.CreateCondBr(FeatsCondition, RetBlock, ElseBlock);
3095 CurBlock = ElseBlock;
3100 Builder.SetInsertPoint(CurBlock);
3107 Builder.SetInsertPoint(CurBlock);
3108 llvm::CallInst *TrapCall =
EmitTrapCall(llvm::Intrinsic::trap);
3109 TrapCall->setDoesNotReturn();
3110 TrapCall->setDoesNotThrow();
3112 Builder.ClearInsertionPoint();
3117 assert(!Options.empty() &&
"No multiversion resolver options found");
3118 assert(Options.back().Features.size() == 0 &&
"Default case must be last");
3120 assert(SupportsIFunc &&
3121 "Multiversion resolver requires target IFUNC support");
3122 bool AArch64CpuInitialized =
false;
3126 Builder.SetInsertPoint(CurBlock);
3127 llvm::Value *
Condition = FormAArch64ResolverCondition(RO);
3136 if (!AArch64CpuInitialized) {
3137 Builder.SetInsertPoint(CurBlock, CurBlock->begin());
3138 EmitAArch64CpuInit();
3139 AArch64CpuInitialized =
true;
3140 Builder.SetInsertPoint(CurBlock);
3144 if (RO.Function ==
nullptr)
3147 llvm::BasicBlock *RetBlock =
createBasicBlock(
"resolver_return", Resolver);
3156 Builder.SetInsertPoint(CurBlock);
3157 llvm::CallInst *TrapCall =
EmitTrapCall(llvm::Intrinsic::trap);
3158 TrapCall->setDoesNotReturn();
3159 TrapCall->setDoesNotThrow();
3161 Builder.ClearInsertionPoint();
3171 Builder.SetInsertPoint(CurBlock);
3175 Builder.SetInsertPoint(CurBlock);
3176 llvm::Value *
Condition = FormX86ResolverCondition(RO);
3180 assert(&RO == Options.end() - 1 &&
3181 "Default or Generic case must be last");
3187 llvm::BasicBlock *RetBlock =
createBasicBlock(
"resolver_return", Resolver);
3196 Builder.SetInsertPoint(CurBlock);
3197 llvm::CallInst *TrapCall =
EmitTrapCall(llvm::Intrinsic::trap);
3198 TrapCall->setDoesNotReturn();
3199 TrapCall->setDoesNotThrow();
3201 Builder.ClearInsertionPoint();
3213 llvm::Value *OffsetValue, llvm::Value *TheCheck,
3214 llvm::Instruction *Assumption) {
3215 assert(isa_and_nonnull<llvm::CallInst>(Assumption) &&
3217 llvm::Intrinsic::getOrInsertDeclaration(
3218 Builder.GetInsertBlock()->getParent()->getParent(),
3219 llvm::Intrinsic::assume) &&
3220 "Assumption should be a call to llvm.assume().");
3221 assert(&(
Builder.GetInsertBlock()->back()) == Assumption &&
3222 "Assumption should be the last instruction of the basic block, "
3223 "since the basic block is still being generated.");
3225 if (!
SanOpts.has(SanitizerKind::Alignment))
3235 Assumption->removeFromParent();
3238 auto CheckOrdinal = SanitizerKind::SO_Alignment;
3239 auto CheckHandler = SanitizerHandler::AlignmentAssumption;
3243 OffsetValue =
Builder.getInt1(
false);
3248 llvm::Value *DynamicData[] = {Ptr, Alignment, OffsetValue};
3249 EmitCheck({std::make_pair(TheCheck, CheckOrdinal)}, CheckHandler,
3250 StaticData, DynamicData);
3261 return DI->SourceLocToDebugLoc(Location);
3263 return llvm::DebugLoc();
3267CodeGenFunction::emitCondLikelihoodViaExpectIntrinsic(llvm::Value *
Cond,
3278 llvm::Type *CondTy =
Cond->getType();
3279 assert(CondTy->isIntegerTy(1) &&
"expecting condition to be a boolean");
3280 llvm::Function *FnExpect =
3282 llvm::Value *ExpectedValueOfCond =
3284 return Builder.CreateCall(FnExpect, {
Cond, ExpectedValueOfCond},
3285 Cond->getName() +
".expval");
3287 llvm_unreachable(
"Unknown Likelihood");
3291 unsigned NumElementsDst,
3292 const llvm::Twine &Name) {
3294 unsigned NumElementsSrc = SrcTy->getNumElements();
3295 if (NumElementsSrc == NumElementsDst)
3298 std::vector<int> ShuffleMask(NumElementsDst, -1);
3299 for (
unsigned MaskIdx = 0;
3300 MaskIdx < std::min<>(NumElementsDst, NumElementsSrc); ++MaskIdx)
3301 ShuffleMask[MaskIdx] = MaskIdx;
3303 return Builder.CreateShuffleVector(SrcVec, ShuffleMask, Name);
3316 Discriminator =
Builder.getSize(0);
3318 llvm::Value *Args[] = {Key, Discriminator};
3319 Bundles.emplace_back(
"ptrauth", Args);
3325 unsigned IntrinsicID) {
3332 if (!Discriminator) {
3337 auto OrigType =
Pointer->getType();
3355 llvm::Intrinsic::ptrauth_sign);
3361 auto StripIntrinsic = CGF.
CGM.
getIntrinsic(llvm::Intrinsic::ptrauth_strip);
3365 auto OrigType =
Pointer->getType();
3382 llvm::Intrinsic::ptrauth_auth);
3386 llvm::Instruction *KeyInstruction, llvm::Value *Backup) {
3388 DI->addInstToCurrentSourceAtom(KeyInstruction, Backup);
3392 llvm::Instruction *KeyInstruction, llvm::Value *Backup, uint64_t Atom) {
3394 DI->addInstToSpecificSourceAtom(KeyInstruction, Backup, Atom);
3398 llvm::Value *Backup) {
3401 DI->addInstToCurrentSourceAtom(KeyInstruction, Backup);
Defines the clang::ASTContext interface.
This file provides some common utility functions for processing Lambda related AST Constructs.
Defines enum values for all the target-independent builtin functions.
static llvm::Value * EmitPointerAuthCommon(CodeGenFunction &CGF, const CGPointerAuthInfo &PointerAuth, llvm::Value *Pointer, unsigned IntrinsicID)
static void CreateMultiVersionResolverReturn(CodeGenModule &CGM, llvm::Function *Resolver, CGBuilderTy &Builder, llvm::Function *FuncToReturn, bool SupportsIFunc)
static llvm::Value * EmitStrip(CodeGenFunction &CGF, const CGPointerAuthInfo &PointerAuth, llvm::Value *Pointer)
static void emitNonZeroVLAInit(CodeGenFunction &CGF, QualType baseType, Address dest, Address src, llvm::Value *sizeInChars)
emitNonZeroVLAInit - Emit the "zero" initialization of a variable-length array whose elements have a ...
static void EmitIfUsed(CodeGenFunction &CGF, llvm::BasicBlock *BB)
static LValue makeNaturalAlignAddrLValue(llvm::Value *V, QualType T, bool ForPointeeType, bool MightBeSigned, CodeGenFunction &CGF, KnownNonNull_t IsKnownNonNull=NotKnownNonNull)
static void TryMarkNoThrow(llvm::Function *F)
Tries to mark the given function nounwind based on the non-existence of any throwing calls within it.
static llvm::Constant * getPrologueSignature(CodeGenModule &CGM, const FunctionDecl *FD)
Return the UBSan prologue signature for FD if one is available.
static bool endsWithReturn(const Decl *F)
Determine whether the function F ends with a return stmt.
static bool shouldEmitLifetimeMarkers(const CodeGenOptions &CGOpts, const LangOptions &LangOpts)
shouldEmitLifetimeMarkers - Decide whether we need emit the life-time markers.
static bool matchesStlAllocatorFn(const Decl *D, const ASTContext &Ctx)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the Objective-C statement AST node classes.
Enumerates target-specific builtins in their own namespaces within namespace clang.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getFunctionTypeWithExceptionSpec(QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI) const
Get a function type and produce the equivalent function type with the specified exception specificati...
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
bool hasAnyFunctionEffects() const
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
const VariableArrayType * getAsVariableArrayType(QualType T) const
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
const TargetInfo & getTargetInfo() const
void getFunctionFeatureMap(llvm::StringMap< bool > &FeatureMap, const FunctionDecl *) const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
Attr - This represents one attribute.
A builtin binary operation expression such as "x + y" or "x <= y".
static bool isLogicalOp(Opcode Opc)
BinaryOperatorKind Opcode
Represents a C++ constructor within a class.
Represents a static or instance method of a struct/union/class.
bool isImplicitObjectMemberFunction() const
[C++2b][dcl.fct]/p7 An implicit object member function is a non-static member function without an exp...
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
QualType getThisType() const
Return the type of the this pointer.
bool isLambda() const
Determine whether this class describes a lambda function object.
void getCaptureFields(llvm::DenseMap< const ValueDecl *, FieldDecl * > &Captures, FieldDecl *&ThisCapture) const
For a closure type, retrieve the mapping from captured variables and this to the non-static data memb...
bool isCapturelessLambda() const
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
A C++ throw-expression (C++ [except.throw]).
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
SourceLocation getBeginLoc() const
CharUnits - This is an opaque type for sizes expressed in character units.
bool isZero() const
isZero - Test whether the quantity equals zero.
llvm::Align getAsAlign() const
getAsAlign - Returns Quantity as a valid llvm::Align, Beware llvm::Align assumes power of two 8-bit b...
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
CharUnits alignmentOfArrayElement(CharUnits elementSize) const
Given that this is the alignment of the first element of an array, return the minimum alignment of an...
bool isOne() const
isOne - Test whether the quantity equals one.
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
@ InAlloca
InAlloca - Pass the argument directly using the LLVM inalloca attribute.
@ Indirect
Indirect - Pass the argument indirectly via a hidden pointer with the specified alignment (0 indicate...
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
llvm::Value * emitRawPointer(CodeGenFunction &CGF) const
Return the pointer contained in this class after authenticating it and adding offset to it if necessa...
CharUnits getAlignment() const
llvm::Type * getElementType() const
Return the type of the values stored in this address.
Address withElementType(llvm::Type *ElemTy) const
Return address with different element type, but same pointer and alignment.
llvm::PointerType * getType() const
Return the type of the pointer value.
A scoped helper to set the current source atom group for CGDebugInfo::addInstToCurrentSourceAtom.
A scoped helper to set the current debug location to the specified location or preferred location of ...
static ApplyDebugLocation CreateDefaultArtificial(CodeGenFunction &CGF, SourceLocation TemporaryLocation)
Apply TemporaryLocation if it is valid.
void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name, llvm::BasicBlock::iterator InsertPt) const override
This forwards to CodeGenFunction::InsertHelper.
llvm::ConstantInt * getSize(CharUnits N)
@ RAA_DirectInMemory
Pass it on the stack using its defined layout.
virtual RecordArgABI getRecordArgABI(const CXXRecordDecl *RD) const =0
Returns how an argument of the given record type should be passed.
Abstract information about a function or function prototype.
const FunctionProtoType * getCalleeFunctionProtoType() const
All available information about a concrete callee.
static CGCallee forDirect(llvm::Constant *functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
CGFunctionInfo - Class to encapsulate the information about a function definition.
bool isDelegateCall() const
llvm::Value * getDiscriminator() const
CallArgList - Type for representing both the value and type of arguments in a call.
void add(RValue rvalue, QualType type)
virtual ~CGCapturedStmtInfo()
CGFPOptionsRAII(CodeGenFunction &CGF, FPOptions FPFeatures)
An object to manage conditionally-evaluated expressions.
void begin(CodeGenFunction &CGF)
void end(CodeGenFunction &CGF)
An object which temporarily prevents a value from being destroyed by aggressive peephole optimization...
SanitizerScope(CodeGenFunction *CGF)
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
void EmitRISCVMultiVersionResolver(llvm::Function *Resolver, ArrayRef< FMVResolverOption > Options)
GlobalDecl CurGD
CurGD - The GlobalDecl for the current function being compiled.
void EmitBranchOnBoolExpr(const Expr *Cond, llvm::BasicBlock *TrueBlock, llvm::BasicBlock *FalseBlock, uint64_t TrueCount, Stmt::Likelihood LH=Stmt::LH_None, const Expr *ConditionalOp=nullptr, const VarDecl *ConditionalDecl=nullptr)
EmitBranchOnBoolExpr - Emit a branch on a boolean condition (e.g.
void setCurrentProfileCount(uint64_t Count)
Set the profiler's current count.
llvm::Value * emitBoolVecConversion(llvm::Value *SrcVec, unsigned NumElementsDst, const llvm::Twine &Name="")
void EmitAArch64MultiVersionResolver(llvm::Function *Resolver, ArrayRef< FMVResolverOption > Options)
JumpDest getJumpDestInCurrentScope(llvm::BasicBlock *Target)
The given basic block lies in the current EH scope, but may be a target of a potentially scope-crossi...
llvm::Value * EmitScalarOrConstFoldImmArg(unsigned ICEArguments, unsigned Idx, const CallExpr *E)
SanitizerSet SanOpts
Sanitizers enabled for this function.
void EmitNullInitialization(Address DestPtr, QualType Ty)
EmitNullInitialization - Generate code to set a value of the given type to null, If the type contains...
RawAddress CreateIRTemp(QualType T, const Twine &Name="tmp")
CreateIRTemp - Create a temporary IR object of the given type, with appropriate alignment.
void checkTargetFeatures(const CallExpr *E, const FunctionDecl *TargetDecl)
static bool ContainsLabel(const Stmt *S, bool IgnoreCaseStmts=false)
ContainsLabel - Return true if the statement contains a label in it.
bool ShouldSkipSanitizerInstrumentation()
ShouldSkipSanitizerInstrumentation - Return true if the current function should not be instrumented w...
llvm::BlockAddress * GetAddrOfLabel(const LabelDecl *L)
llvm::Value * EmitRISCVCpuSupports(const CallExpr *E)
llvm::Value * EmitRISCVCpuInit()
static bool hasScalarEvaluationKind(QualType T)
llvm::Type * ConvertType(QualType T)
void GenerateCode(GlobalDecl GD, llvm::Function *Fn, const CGFunctionInfo &FnInfo)
void EmitSanitizerStatReport(llvm::SanitizerStatKind SSK)
void addInstToNewSourceAtom(llvm::Instruction *KeyInstruction, llvm::Value *Backup)
Add KeyInstruction and an optional Backup instruction to a new atom group (See ApplyAtomGroup for mor...
FieldDecl * LambdaThisCaptureField
PeepholeProtection protectFromPeepholes(RValue rvalue)
protectFromPeepholes - Protect a value that we're intending to store to the side, but which will prob...
void EmitLambdaStaticInvokeBody(const CXXMethodDecl *MD)
bool CurFuncIsThunk
In C++, whether we are code generating a thunk.
LValue MakeNaturalAlignPointeeAddrLValue(llvm::Value *V, QualType T)
Given a value of type T* that may not be to a complete object, construct an l-value with the natural ...
JumpDest getJumpDestForLabel(const LabelDecl *S)
getBasicBlockForLabel - Return the LLVM basicblock that the specified label maps to.
void EmitCXXThrowExpr(const CXXThrowExpr *E, bool KeepInsertionPoint=true)
SmallVector< llvm::ConvergenceControlInst *, 4 > ConvergenceTokenStack
Stack to track the controlled convergence tokens.
void unprotectFromPeepholes(PeepholeProtection protection)
RValue convertTempToRValue(Address addr, QualType type, SourceLocation Loc)
Given the address of a temporary variable, produce an r-value of its type.
llvm::Constant * EmitCheckSourceLocation(SourceLocation Loc)
Emit a description of a source location in a format suitable for passing to a runtime sanitizer handl...
llvm::SmallVector< DeferredDeactivateCleanup > DeferredDeactivationCleanupStack
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
void addInstToCurrentSourceAtom(llvm::Instruction *KeyInstruction, llvm::Value *Backup)
See CGDebugInfo::addInstToCurrentSourceAtom.
const LangOptions & getLangOpts() const
void addInstToSpecificSourceAtom(llvm::Instruction *KeyInstruction, llvm::Value *Backup, uint64_t Atom)
See CGDebugInfo::addInstToSpecificSourceAtom.
LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T, KnownNonNull_t IsKnownNonNull=NotKnownNonNull)
void EmitVarAnnotations(const VarDecl *D, llvm::Value *V)
Emit local annotations for the local variable V, declared by D.
llvm::BasicBlock * EHResumeBlock
EHResumeBlock - Unified block containing a call to llvm.eh.resume.
Address EmitFieldAnnotations(const FieldDecl *D, Address V)
Emit field annotations for the given field & value.
void EmitConstructorBody(FunctionArgList &Args)
EmitConstructorBody - Emits the body of the current constructor.
void EmitKCFIOperandBundle(const CGCallee &Callee, SmallVectorImpl< llvm::OperandBundleDef > &Bundles)
void EmitDeclRefExprDbgValue(const DeclRefExpr *E, const APValue &Init)
Address makeNaturalAddressForPointer(llvm::Value *Ptr, QualType T, CharUnits Alignment=CharUnits::Zero(), bool ForPointeeType=false, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr, KnownNonNull_t IsKnownNonNull=NotKnownNonNull)
Construct an address with the natural alignment of T.
LValue MakeNaturalAlignPointeeRawAddrLValue(llvm::Value *V, QualType T)
Same as MakeNaturalAlignPointeeAddrLValue except that the pointer is known to be unsigned.
@ TCK_ConstructorCall
Checking the 'this' pointer for a constructor call.
@ TCK_MemberCall
Checking the 'this' pointer for a call to a non-static member function.
const Decl * CurCodeDecl
CurCodeDecl - This is the inner-most code context, which includes blocks.
llvm::AssertingVH< llvm::Instruction > AllocaInsertPt
AllocaInsertPoint - This is an instruction in the entry block before which we prefer to insert alloca...
void EmitFunctionBody(const Stmt *Body)
JumpDest ReturnBlock
ReturnBlock - Unified return block.
llvm::DebugLoc SourceLocToDebugLoc(SourceLocation Location)
Converts Location to a DebugLoc, if debug information is enabled.
llvm::Constant * EmitCheckTypeDescriptor(QualType T)
Emit a description of a type in a format suitable for passing to a runtime sanitizer handler.
llvm::DebugLoc EmitReturnBlock()
Emit the unified return block, trying to avoid its emission when possible.
RawAddress CreateDefaultAlignTempAlloca(llvm::Type *Ty, const Twine &Name="tmp")
CreateDefaultAlignedTempAlloca - This creates an alloca with the default ABI alignment of the given L...
const TargetInfo & getTarget() const
llvm::Value * EmitAnnotationCall(llvm::Function *AnnotationFn, llvm::Value *AnnotatedVal, StringRef AnnotationStr, SourceLocation Location, const AnnotateAttr *Attr)
Emit an annotation call (intrinsic).
Address EmitCompoundStmtWithoutScope(const CompoundStmt &S, bool GetLast=false, AggValueSlot AVS=AggValueSlot::ignored())
void PopCleanupBlocks(EHScopeStack::stable_iterator OldCleanupStackSize, std::initializer_list< llvm::Value ** > ValuesToReload={})
Takes the old cleanup stack size and emits the cleanup blocks that have been added.
void maybeCreateMCDCCondBitmap()
Allocate a temp value on the stack that MCDC can use to track condition results.
void EmitIgnoredExpr(const Expr *E)
EmitIgnoredExpr - Emit an expression in a context which ignores the result.
RValue EmitLoadOfLValue(LValue V, SourceLocation Loc)
EmitLoadOfLValue - Given an expression that represents a value lvalue, this method emits the address ...
static bool isInstrumentedCondition(const Expr *C)
isInstrumentedCondition - Determine whether the given condition is an instrumentable condition (i....
VlaSizePair getVLAElements1D(const VariableArrayType *vla)
Return the number of elements for a single dimension for the given array type.
bool AlwaysEmitXRayCustomEvents() const
AlwaysEmitXRayCustomEvents - Return true if we must unconditionally emit XRay custom event handling c...
void StartFunction(GlobalDecl GD, QualType RetTy, llvm::Function *Fn, const CGFunctionInfo &FnInfo, const FunctionArgList &Args, SourceLocation Loc=SourceLocation(), SourceLocation StartLoc=SourceLocation())
Emit code for the start of a function.
llvm::Value * EmitPointerAuthSign(const CGPointerAuthInfo &Info, llvm::Value *Pointer)
void markAsIgnoreThreadCheckingAtRuntime(llvm::Function *Fn)
Annotate the function with an attribute that disables TSan checking at runtime.
llvm::Value * EvaluateExprAsBool(const Expr *E)
EvaluateExprAsBool - Perform the usual unary conversions on the specified expression and compare the ...
void EmitPointerAuthOperandBundle(const CGPointerAuthInfo &Info, SmallVectorImpl< llvm::OperandBundleDef > &Bundles)
void EmitCheck(ArrayRef< std::pair< llvm::Value *, SanitizerKind::SanitizerOrdinal > > Checked, SanitizerHandler Check, ArrayRef< llvm::Constant * > StaticArgs, ArrayRef< llvm::Value * > DynamicArgs, const TrapReason *TR=nullptr)
Create a basic block that will either trap or call a handler function in the UBSan runtime with the p...
void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name, llvm::BasicBlock::iterator InsertPt) const
CGBuilder insert helper.
llvm::Value * emitArrayLength(const ArrayType *arrayType, QualType &baseType, Address &addr)
emitArrayLength - Compute the length of an array, even if it's a VLA, and drill down to the base elem...
bool HaveInsertPoint() const
HaveInsertPoint - True if an insertion point is defined.
bool AlwaysEmitXRayTypedEvents() const
AlwaysEmitXRayTypedEvents - Return true if clang must unconditionally emit XRay typed event handling ...
CGDebugInfo * getDebugInfo()
void EmitStartEHSpec(const Decl *D)
EmitStartEHSpec - Emit the start of the exception spec.
void EmitDestructorBody(FunctionArgList &Args)
EmitDestructorBody - Emits the body of the current destructor.
void EmitX86MultiVersionResolver(llvm::Function *Resolver, ArrayRef< FMVResolverOption > Options)
bool ShouldInstrumentFunction()
ShouldInstrumentFunction - Return true if the current function should be instrumented with __cyg_prof...
void maybeUpdateMCDCCondBitmap(const Expr *E, llvm::Value *Val)
Update the MCDC temp value with the condition's evaluated result.
void emitAlignmentAssumptionCheck(llvm::Value *Ptr, QualType Ty, SourceLocation Loc, SourceLocation AssumptionLoc, llvm::Value *Alignment, llvm::Value *OffsetValue, llvm::Value *TheCheck, llvm::Instruction *Assumption)
RValue EmitCall(const CGFunctionInfo &CallInfo, const CGCallee &Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, llvm::CallBase **CallOrInvoke, bool IsMustTail, SourceLocation Loc, bool IsVirtualFunctionPointerThunk=false)
EmitCall - Generate a call of the given function, expecting the given result type,...
llvm::ConstantInt * getUBSanFunctionTypeHash(QualType T) const
Return a type hash constant for a function instrumented by -fsanitize=function.
void EmitBranchToCounterBlock(const Expr *Cond, BinaryOperator::Opcode LOp, llvm::BasicBlock *TrueBlock, llvm::BasicBlock *FalseBlock, uint64_t TrueCount=0, Stmt::Likelihood LH=Stmt::LH_None, const Expr *CntrIdx=nullptr)
EmitBranchToCounterBlock - Emit a conditional branch to a new block that increments a profile counter...
VlaSizePair getVLASize(const VariableArrayType *vla)
Returns an LLVM value that corresponds to the size, in non-variably-sized elements,...
ASTContext & getContext() const
bool isMCDCBranchExpr(const Expr *E) const
void EmitMultiVersionResolver(llvm::Function *Resolver, ArrayRef< FMVResolverOption > Options)
const Decl * CurFuncDecl
CurFuncDecl - Holds the Decl for the current outermost non-closure context.
static const Expr * stripCond(const Expr *C)
Ignore parentheses and logical-NOT to track conditions consistently.
void EmitFunctionProlog(const CGFunctionInfo &FI, llvm::Function *Fn, const FunctionArgList &Args)
EmitFunctionProlog - Emit the target specific LLVM code to load the arguments for the given function.
void SetFastMathFlags(FPOptions FPFeatures)
Set the codegen fast-math flags.
llvm::SmallVector< char, 256 > LifetimeExtendedCleanupStack
Address EmitVAListRef(const Expr *E)
void EmitLambdaInAllocaCallOpBody(const CXXMethodDecl *MD)
Address ReturnValuePointer
ReturnValuePointer - The temporary alloca to hold a pointer to sret.
static bool mightAddDeclToScope(const Stmt *S)
Determine if the given statement might introduce a declaration into the current scope,...
void EmitStmt(const Stmt *S, ArrayRef< const Attr * > Attrs={})
EmitStmt - Emit the code for the statement.
llvm::DenseMap< const ValueDecl *, FieldDecl * > LambdaCaptureFields
bool AutoreleaseResult
In ARC, whether we should autorelease the return value.
llvm::CallInst * EmitRuntimeCall(llvm::FunctionCallee callee, const Twine &name="")
uint64_t getCurrentProfileCount()
Get the profiler's current count.
llvm::Type * ConvertTypeForMem(QualType T)
void EmitEndEHSpec(const Decl *D)
EmitEndEHSpec - Emit the end of the exception spec.
LValue EmitLValueForLambdaField(const FieldDecl *Field)
CodeGenTypes & getTypes() const
static TypeEvaluationKind getEvaluationKind(QualType T)
getEvaluationKind - Return the TypeEvaluationKind of QualType T.
bool IsSanitizerScope
True if CodeGen currently emits code implementing sanitizer checks.
static bool containsBreak(const Stmt *S)
containsBreak - Return true if the statement contains a break out of it.
void emitImplicitAssignmentOperatorBody(FunctionArgList &Args)
HLSLControlFlowHintAttr::Spelling HLSLControlFlowAttr
HLSL Branch attribute.
void EmitTypeCheck(TypeCheckKind TCK, SourceLocation Loc, LValue LV, QualType Type, SanitizerSet SkippedChecks=SanitizerSet(), llvm::Value *ArraySize=nullptr)
llvm::SmallVector< const ParmVarDecl *, 4 > FnArgs
Save Parameter Decl for coroutine.
const TargetInfo & Target
void EmitFunctionEpilog(const CGFunctionInfo &FI, bool EmitRetDbgLoc, SourceLocation EndLoc, uint64_t RetKeyInstructionsSourceAtom)
EmitFunctionEpilog - Emit the target specific LLVM code to return the given temporary.
Address EmitPointerWithAlignment(const Expr *Addr, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr, KnownNonNull_t IsKnownNonNull=NotKnownNonNull)
EmitPointerWithAlignment - Given an expression with a pointer type, emit the value and compute our be...
void EmitBranch(llvm::BasicBlock *Block)
EmitBranch - Emit a branch to the specified basic block from the current insert block,...
RawAddress NormalCleanupDest
i32s containing the indexes of the cleanup destinations.
llvm::Type * convertTypeForLoadStore(QualType ASTTy, llvm::Type *LLVMTy=nullptr)
VarBypassDetector Bypasses
llvm::BasicBlock * GetIndirectGotoBlock()
EHScopeStack::stable_iterator PrologueCleanupDepth
PrologueCleanupDepth - The cleanup depth enclosing all the cleanups associated with the parameters.
Address EmitMSVAListRef(const Expr *E)
Emit a "reference" to a __builtin_ms_va_list; this is always the value of the expression,...
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type,...
llvm::CallInst * EmitTrapCall(llvm::Intrinsic::ID IntrID)
Emit a call to trap or debugtrap and attach function attribute "trap-func-name" if specified.
LValue MakeAddrLValue(Address Addr, QualType T, AlignmentSource Source=AlignmentSource::Type)
void FinishFunction(SourceLocation EndLoc=SourceLocation())
FinishFunction - Complete IR generation of the current function.
const CGFunctionInfo * CurFnInfo
uint64_t getProfileCount(const Stmt *S)
Get the profiler's count for the given statement.
Address GetAddrOfLocalVar(const VarDecl *VD)
GetAddrOfLocalVar - Return the address of a local variable.
bool ConstantFoldsToSimpleInteger(const Expr *Cond, bool &Result, bool AllowLabels=false)
ConstantFoldsToSimpleInteger - If the specified expression does not fold to a constant,...
void ErrorUnsupported(const Stmt *S, const char *Type)
ErrorUnsupported - Print out an error that codegen doesn't support the specified stmt yet.
Address ReturnValue
ReturnValue - The temporary alloca to hold the return value.
LValue EmitLValue(const Expr *E, KnownNonNull_t IsKnownNonNull=NotKnownNonNull)
EmitLValue - Emit code to compute a designator that specifies the location of the expression.
bool ShouldXRayInstrumentFunction() const
ShouldXRayInstrument - Return true if the current function should be instrumented with XRay nop sleds...
void EnsureInsertPoint()
EnsureInsertPoint - Ensure that an insertion point is defined so that emitted IR has a place to go.
llvm::LLVMContext & getLLVMContext()
bool SawAsmBlock
Whether we processed a Microsoft-style asm block during CodeGen.
bool checkIfFunctionMustProgress()
Returns true if a function must make progress, which means the mustprogress attribute can be added.
void incrementProfileCounter(const Stmt *S, llvm::Value *StepV=nullptr)
Increment the profiler's counter for the given statement by StepV.
void emitAlignmentAssumption(llvm::Value *PtrValue, QualType Ty, SourceLocation Loc, SourceLocation AssumptionLoc, llvm::Value *Alignment, llvm::Value *OffsetValue=nullptr)
bool isMCDCDecisionExpr(const Expr *E) const
void EmitVariablyModifiedType(QualType Ty)
EmitVLASize - Capture all the sizes for the VLA expressions in the given variably-modified type and s...
void MaybeEmitDeferredVarDeclInit(const VarDecl *var)
void EmitBlockWithFallThrough(llvm::BasicBlock *BB, const Stmt *S)
When instrumenting to collect profile data, the counts for some blocks such as switch cases need to n...
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
LValue MakeNaturalAlignRawAddrLValue(llvm::Value *V, QualType T)
QualType BuildFunctionArgList(GlobalDecl GD, FunctionArgList &Args)
llvm::Value * EmitPointerAuthAuth(const CGPointerAuthInfo &Info, llvm::Value *Pointer)
This class organizes the cross-function state that is used while generating LLVM code.
CharUnits getNaturalTypeAlignment(QualType T, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr, bool forPointeeType=false)
CodeGenTypes & getTypes()
const TargetCodeGenInfo & getTargetCodeGenInfo()
const CodeGenOptions & getCodeGenOpts() const
void GenKernelArgMetadata(llvm::Function *FN, const FunctionDecl *FD=nullptr, CodeGenFunction *CGF=nullptr)
OpenCL v1.2 s5.6.4.6 allows the compiler to store kernel argument information in the program executab...
llvm::Function * getIntrinsic(unsigned IID, ArrayRef< llvm::Type * > Tys={})
llvm::Type * ConvertType(QualType T)
ConvertType - Convert type T into a llvm::Type.
bool inheritingCtorHasParams(const InheritedConstructor &Inherited, CXXCtorType Type)
Determine if a C++ inheriting constructor should have parameters matching those of its inherited cons...
FunctionArgList - Type for representing both the decl and type of parameters to a function.
LValue - This represents an lvalue references.
llvm::Value * getPointer(CodeGenFunction &CGF) const
Address getAddress() const
RValue - This trivial value class is used to represent the result of an expression that is evaluated.
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
ReturnValueSlot - Contains the address where the return value of a function can be stored,...
virtual llvm::Constant * getUBSanFunctionSignature(CodeGen::CodeGenModule &CGM) const
Return a constant used by UBSan as a signature to identify functions possessing type information,...
CompoundStmt - This represents a group of statements like { stmt stmt }.
ConditionalOperator - The ?
A reference to a declared variable, function, enum, etc.
Decl - This represents one declaration (or definition), e.g.
ASTContext & getASTContext() const LLVM_READONLY
Decl * getNonClosureContext()
Find the innermost non-closure ancestor of this declaration, walking up through blocks,...
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
SourceLocation getLocation() const
This represents one expression.
FPOptions getFPFeaturesInEffect(const LangOptions &LO) const
Returns the set of floating point options that apply to this expression.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
ExtVectorType - Extended vector type.
LangOptions::FPExceptionModeKind getExceptionMode() const
bool allowFPContractAcrossStatement() const
RoundingMode getRoundingMode() const
Represents a member of a struct/union/class.
Represents a function declaration or definition.
bool isMultiVersion() const
True if this function is considered a multiversioned function.
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
bool UsesFPIntrin() const
Determine whether the function was declared in source context that requires constrained FP intrinsics...
bool usesSEHTry() const
Indicates the function uses __try.
QualType getReturnType() const
ArrayRef< ParmVarDecl * > parameters() const
FunctionDecl * getTemplateInstantiationPattern(bool ForDefinition=true) const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
FunctionEffectsRef getFunctionEffects() const
bool isMSVCRTEntryPoint() const
Determines whether this function is a MSVCRT user defined entry point.
bool isInlineBuiltinDeclaration() const
Determine if this function provides an inline implementation of a builtin.
bool hasImplicitReturnZero() const
Whether falling off this function implicitly returns null/zero.
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program.
bool isDefaulted() const
Whether this function is defaulted.
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any.
FunctionDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
Represents a prototype with parameter type info, e.g.
FunctionTypeExtraAttributeInfo getExtraAttributeInfo() const
Return the extra attribute information.
FunctionType - C99 6.7.5.3 - Function Declarators.
@ SME_PStateSMCompatibleMask
GlobalDecl - represents a global declaration.
CXXCtorType getCtorType() const
KernelReferenceKind getKernelReferenceKind() const
const Decl * getDecl() const
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)
Create implicit parameter.
Represents the declaration of a label.
FPExceptionModeKind
Possible floating point exception behavior.
@ FPE_Strict
Strictly preserve the floating-point exception semantics.
@ FPE_MayTrap
Transformations do not cause new exceptions but may hide some.
@ FPE_Ignore
Assume that floating-point exceptions are masked.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
SanitizerSet Sanitize
Set of enabled sanitizers.
RoundingMode getDefaultRoundingMode() const
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Represents a parameter to a function.
ParsedAttr - Represents a syntactic attribute.
PointerType - C99 6.7.5.1 - Pointer Declarators.
@ Forbid
Profiling is forbidden using the noprofile attribute.
@ Skip
Profiling is skipped using the skipprofile attribute.
@ Allow
Profiling is allowed.
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
field_range fields() const
Encodes a location in the source.
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
StmtClass getStmtClass() const
Likelihood
The likelihood of a branch being taken.
@ LH_Unlikely
Branch has the [[unlikely]] attribute.
@ LH_None
No attribute set or branches of the IfStmt have the same attribute.
@ LH_Likely
Branch has the [[likely]] attribute.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
virtual std::optional< std::pair< unsigned, unsigned > > getVScaleRange(const LangOptions &LangOpts, ArmStreamingKind Mode, llvm::StringMap< bool > *FeatureMap=nullptr) const
Returns target-specific min and max values VScale_Range.
bool supportsIFunc() const
Identify whether this target supports IFuncs.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
virtual ParsedTargetAttr parseTargetAttr(StringRef Str) const
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
TypeClass getTypeClass() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isObjCRetainableType() const
bool isFunctionNoProtoType() const
bool isCFIUncheckedCalleeFunctionType() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Represents a variable declaration or definition.
Represents a C array with a specified size that is not an integer-constant-expression.
Expr * getSizeExpr() const
QualType getElementType() const
Defines the clang::TargetInfo interface.
bool evaluateRequiredTargetFeatures(llvm::StringRef RequiredFatures, const llvm::StringMap< bool > &TargetFetureMap)
Returns true if the required target features of a builtin function are enabled.
@ Type
The l-value was considered opaque, so the alignment was determined from a type.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
TypeEvaluationKind
The kind of evaluation to perform on values of a particular type.
CGBuilderInserter CGBuilderInserterTy
constexpr XRayInstrMask Typed
constexpr XRayInstrMask FunctionExit
constexpr XRayInstrMask FunctionEntry
constexpr XRayInstrMask Custom
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const AstTypeMatcher< ArrayType > arrayType
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
Expr * IgnoreBuiltinExpectSingleStep(Expr *E)
@ NonNull
Values of this type can never be null.
Expr * IgnoreExprNodes(Expr *E, FnTys &&... Fns)
Given an expression E and functions Fn_1,...,Fn_n : Expr * -> Expr *, Recursively apply each of the f...
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
bool isLambdaCallOperator(const CXXMethodDecl *MD)
@ Result
The result type of a method or function.
const FunctionProtoType * T
Expr * IgnoreImplicitCastsSingleStep(Expr *E)
Expr * IgnoreUOpLNotSingleStep(Expr *E)
Expr * IgnoreParensSingleStep(Expr *E)
llvm::fp::ExceptionBehavior ToConstrainedExceptMD(LangOptions::FPExceptionModeKind Kind)
U cast(CodeGen::Address addr)
bool IsArmStreamingFunction(const FunctionDecl *FD, bool IncludeLocallyStreaming)
Returns whether the given FunctionDecl has an __arm[_locally]_streaming attribute.
@ Other
Other implicit parameter.
@ EST_None
no exception specification
@ Implicit
An implicit conversion.
Diagnostic wrappers for TextAPI types for error reporting.
cl::opt< bool > EnableSingleByteCoverage
A jump destination is an abstract label, branching to which may require a jump out through normal cle...
llvm::BasicBlock * getBlock() const
This structure provides a set of types that are commonly used during IR emission.
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
llvm::IntegerType * SizeTy
llvm::IntegerType * Int32Ty
llvm::IntegerType * IntPtrTy
llvm::PointerType * Int8PtrTy
CharUnits getPointerAlign() const
EvalResult is a struct with detailed info about an evaluated expression.
A FunctionEffect plus a potential boolean expression determining whether the effect is declared (e....
Contains information gathered from parsing the contents of TargetAttr.
std::vector< std::string > Features
void set(SanitizerMask K, bool Value)
Enable or disable a certain (single) sanitizer.
bool has(SanitizerMask K) const
Check if a certain (single) sanitizer is enabled.