LLVM 20.0.0git
Function.cpp
Go to the documentation of this file.
1//===- Function.cpp - Implement the Global object classes -----------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the Function class for the IR library.
10//
11//===----------------------------------------------------------------------===//
12
13#include "llvm/IR/Function.h"
15#include "llvm/ADT/ArrayRef.h"
16#include "llvm/ADT/BitVector.h"
17#include "llvm/ADT/DenseSet.h"
18#include "llvm/ADT/STLExtras.h"
22#include "llvm/ADT/StringRef.h"
24#include "llvm/IR/Argument.h"
25#include "llvm/IR/Attributes.h"
26#include "llvm/IR/BasicBlock.h"
27#include "llvm/IR/Constant.h"
29#include "llvm/IR/Constants.h"
31#include "llvm/IR/GlobalValue.h"
33#include "llvm/IR/Instruction.h"
35#include "llvm/IR/Intrinsics.h"
36#include "llvm/IR/IntrinsicsAArch64.h"
37#include "llvm/IR/IntrinsicsAMDGPU.h"
38#include "llvm/IR/IntrinsicsARM.h"
39#include "llvm/IR/IntrinsicsBPF.h"
40#include "llvm/IR/IntrinsicsDirectX.h"
41#include "llvm/IR/IntrinsicsHexagon.h"
42#include "llvm/IR/IntrinsicsLoongArch.h"
43#include "llvm/IR/IntrinsicsMips.h"
44#include "llvm/IR/IntrinsicsNVPTX.h"
45#include "llvm/IR/IntrinsicsPowerPC.h"
46#include "llvm/IR/IntrinsicsR600.h"
47#include "llvm/IR/IntrinsicsRISCV.h"
48#include "llvm/IR/IntrinsicsS390.h"
49#include "llvm/IR/IntrinsicsSPIRV.h"
50#include "llvm/IR/IntrinsicsVE.h"
51#include "llvm/IR/IntrinsicsWebAssembly.h"
52#include "llvm/IR/IntrinsicsX86.h"
53#include "llvm/IR/IntrinsicsXCore.h"
54#include "llvm/IR/LLVMContext.h"
55#include "llvm/IR/MDBuilder.h"
56#include "llvm/IR/Metadata.h"
57#include "llvm/IR/Module.h"
58#include "llvm/IR/Operator.h"
60#include "llvm/IR/Type.h"
61#include "llvm/IR/Use.h"
62#include "llvm/IR/User.h"
63#include "llvm/IR/Value.h"
69#include "llvm/Support/ModRef.h"
70#include <cassert>
71#include <cstddef>
72#include <cstdint>
73#include <cstring>
74#include <string>
75
76using namespace llvm;
78
79// Explicit instantiations of SymbolTableListTraits since some of the methods
80// are not in the public header file...
82
84 "non-global-value-max-name-size", cl::Hidden, cl::init(1024),
85 cl::desc("Maximum size for the name of non-global values."));
86
88
90 validateBlockNumbers();
91
92 NextBlockNum = 0;
93 for (auto &BB : *this)
94 BB.Number = NextBlockNum++;
95 BlockNumEpoch++;
96}
97
98void Function::validateBlockNumbers() const {
99#ifndef NDEBUG
100 BitVector Numbers(NextBlockNum);
101 for (const auto &BB : *this) {
102 unsigned Num = BB.getNumber();
103 assert(Num < NextBlockNum && "out of range block number");
104 assert(!Numbers[Num] && "duplicate block numbers");
105 Numbers.set(Num);
106 }
107#endif
108}
109
111 IsNewDbgInfoFormat = true;
112 for (auto &BB : *this) {
113 BB.convertToNewDbgValues();
114 }
115}
116
118 IsNewDbgInfoFormat = false;
119 for (auto &BB : *this) {
120 BB.convertFromNewDbgValues();
121 }
122}
123
125 if (NewFlag && !IsNewDbgInfoFormat)
127 else if (!NewFlag && IsNewDbgInfoFormat)
129}
131 for (auto &BB : *this) {
132 BB.setNewDbgInfoFormatFlag(NewFlag);
133 }
134 IsNewDbgInfoFormat = NewFlag;
135}
136
137//===----------------------------------------------------------------------===//
138// Argument Implementation
139//===----------------------------------------------------------------------===//
140
141Argument::Argument(Type *Ty, const Twine &Name, Function *Par, unsigned ArgNo)
142 : Value(Ty, Value::ArgumentVal), Parent(Par), ArgNo(ArgNo) {
143 setName(Name);
144}
145
146void Argument::setParent(Function *parent) {
147 Parent = parent;
148}
149
150bool Argument::hasNonNullAttr(bool AllowUndefOrPoison) const {
151 if (!getType()->isPointerTy()) return false;
152 if (getParent()->hasParamAttribute(getArgNo(), Attribute::NonNull) &&
153 (AllowUndefOrPoison ||
154 getParent()->hasParamAttribute(getArgNo(), Attribute::NoUndef)))
155 return true;
156 else if (getDereferenceableBytes() > 0 &&
159 return true;
160 return false;
161}
162
164 if (!getType()->isPointerTy()) return false;
165 return hasAttribute(Attribute::ByVal);
166}
167
169 if (!getType()->isPointerTy())
170 return false;
171 return hasAttribute(Attribute::ByRef);
172}
173
175 return getParent()->hasParamAttribute(getArgNo(), Attribute::SwiftSelf);
176}
177
179 return getParent()->hasParamAttribute(getArgNo(), Attribute::SwiftError);
180}
181
183 if (!getType()->isPointerTy()) return false;
184 return hasAttribute(Attribute::InAlloca);
185}
186
188 if (!getType()->isPointerTy())
189 return false;
190 return hasAttribute(Attribute::Preallocated);
191}
192
194 if (!getType()->isPointerTy()) return false;
196 return Attrs.hasParamAttr(getArgNo(), Attribute::ByVal) ||
197 Attrs.hasParamAttr(getArgNo(), Attribute::InAlloca) ||
198 Attrs.hasParamAttr(getArgNo(), Attribute::Preallocated);
199}
200
202 if (!getType()->isPointerTy())
203 return false;
205 return Attrs.hasParamAttr(getArgNo(), Attribute::ByVal) ||
206 Attrs.hasParamAttr(getArgNo(), Attribute::StructRet) ||
207 Attrs.hasParamAttr(getArgNo(), Attribute::InAlloca) ||
208 Attrs.hasParamAttr(getArgNo(), Attribute::Preallocated) ||
209 Attrs.hasParamAttr(getArgNo(), Attribute::ByRef);
210}
211
212/// For a byval, sret, inalloca, or preallocated parameter, get the in-memory
213/// parameter type.
215 // FIXME: All the type carrying attributes are mutually exclusive, so there
216 // should be a single query to get the stored type that handles any of them.
217 if (Type *ByValTy = ParamAttrs.getByValType())
218 return ByValTy;
219 if (Type *ByRefTy = ParamAttrs.getByRefType())
220 return ByRefTy;
221 if (Type *PreAllocTy = ParamAttrs.getPreallocatedType())
222 return PreAllocTy;
223 if (Type *InAllocaTy = ParamAttrs.getInAllocaType())
224 return InAllocaTy;
225 if (Type *SRetTy = ParamAttrs.getStructRetType())
226 return SRetTy;
227
228 return nullptr;
229}
230
232 AttributeSet ParamAttrs =
234 if (Type *MemTy = getMemoryParamAllocType(ParamAttrs))
235 return DL.getTypeAllocSize(MemTy);
236 return 0;
237}
238
240 AttributeSet ParamAttrs =
242 return getMemoryParamAllocType(ParamAttrs);
243}
244
246 assert(getType()->isPointerTy() && "Only pointers have alignments");
247 return getParent()->getParamAlign(getArgNo());
248}
249
252}
253
255 assert(getType()->isPointerTy() && "Only pointers have byval types");
257}
258
260 assert(getType()->isPointerTy() && "Only pointers have sret types");
262}
263
265 assert(getType()->isPointerTy() && "Only pointers have byref types");
267}
268
270 assert(getType()->isPointerTy() && "Only pointers have inalloca types");
272}
273
276 "Only pointers have dereferenceable bytes");
278}
279
282 "Only pointers have dereferenceable bytes");
284}
285
288}
289
290std::optional<ConstantRange> Argument::getRange() const {
291 const Attribute RangeAttr = getAttribute(llvm::Attribute::Range);
292 if (RangeAttr.isValid())
293 return RangeAttr.getRange();
294 return std::nullopt;
295}
296
298 if (!getType()->isPointerTy()) return false;
299 return hasAttribute(Attribute::Nest);
300}
301
303 if (!getType()->isPointerTy()) return false;
304 return hasAttribute(Attribute::NoAlias);
305}
306
308 if (!getType()->isPointerTy()) return false;
309 return hasAttribute(Attribute::NoCapture);
310}
311
313 if (!getType()->isPointerTy()) return false;
314 return hasAttribute(Attribute::NoFree);
315}
316
318 if (!getType()->isPointerTy()) return false;
319 return hasAttribute(Attribute::StructRet);
320}
321
323 return hasAttribute(Attribute::InReg);
324}
325
327 return hasAttribute(Attribute::Returned);
328}
329
331 return hasAttribute(Attribute::ZExt);
332}
333
335 return hasAttribute(Attribute::SExt);
336}
337
340 return Attrs.hasParamAttr(getArgNo(), Attribute::ReadOnly) ||
341 Attrs.hasParamAttr(getArgNo(), Attribute::ReadNone);
342}
343
346 AL = AL.addParamAttributes(Parent->getContext(), getArgNo(), B);
348}
349
351 getParent()->addParamAttr(getArgNo(), Kind);
352}
353
355 getParent()->addParamAttr(getArgNo(), Attr);
356}
357
360}
361
364 AL = AL.removeParamAttributes(Parent->getContext(), getArgNo(), AM);
366}
367
369 return getParent()->hasParamAttribute(getArgNo(), Kind);
370}
371
373 return getParent()->getParamAttribute(getArgNo(), Kind);
374}
375
376//===----------------------------------------------------------------------===//
377// Helper Methods in Function
378//===----------------------------------------------------------------------===//
379
381 return getType()->getContext();
382}
383
385 return getParent()->getDataLayout();
386}
387
389 unsigned NumInstrs = 0;
390 for (const BasicBlock &BB : BasicBlocks)
391 NumInstrs += std::distance(BB.instructionsWithoutDebug().begin(),
392 BB.instructionsWithoutDebug().end());
393 return NumInstrs;
394}
395
397 const Twine &N, Module &M) {
398 return Create(Ty, Linkage, M.getDataLayout().getProgramAddressSpace(), N, &M);
399}
400
402 LinkageTypes Linkage,
403 unsigned AddrSpace, const Twine &N,
404 Module *M) {
405 auto *F = new Function(Ty, Linkage, AddrSpace, N, M);
406 AttrBuilder B(F->getContext());
407 UWTableKind UWTable = M->getUwtable();
408 if (UWTable != UWTableKind::None)
409 B.addUWTableAttr(UWTable);
410 switch (M->getFramePointer()) {
412 // 0 ("none") is the default.
413 break;
415 B.addAttribute("frame-pointer", "reserved");
416 break;
418 B.addAttribute("frame-pointer", "non-leaf");
419 break;
421 B.addAttribute("frame-pointer", "all");
422 break;
423 }
424 if (M->getModuleFlag("function_return_thunk_extern"))
425 B.addAttribute(Attribute::FnRetThunkExtern);
426 StringRef DefaultCPU = F->getContext().getDefaultTargetCPU();
427 if (!DefaultCPU.empty())
428 B.addAttribute("target-cpu", DefaultCPU);
429 StringRef DefaultFeatures = F->getContext().getDefaultTargetFeatures();
430 if (!DefaultFeatures.empty())
431 B.addAttribute("target-features", DefaultFeatures);
432
433 // Check if the module attribute is present and not zero.
434 auto isModuleAttributeSet = [&](const StringRef &ModAttr) -> bool {
435 const auto *Attr =
436 mdconst::extract_or_null<ConstantInt>(M->getModuleFlag(ModAttr));
437 return Attr && !Attr->isZero();
438 };
439
440 auto AddAttributeIfSet = [&](const StringRef &ModAttr) {
441 if (isModuleAttributeSet(ModAttr))
442 B.addAttribute(ModAttr);
443 };
444
445 StringRef SignType = "none";
446 if (isModuleAttributeSet("sign-return-address"))
447 SignType = "non-leaf";
448 if (isModuleAttributeSet("sign-return-address-all"))
449 SignType = "all";
450 if (SignType != "none") {
451 B.addAttribute("sign-return-address", SignType);
452 B.addAttribute("sign-return-address-key",
453 isModuleAttributeSet("sign-return-address-with-bkey")
454 ? "b_key"
455 : "a_key");
456 }
457 AddAttributeIfSet("branch-target-enforcement");
458 AddAttributeIfSet("branch-protection-pauth-lr");
459 AddAttributeIfSet("guarded-control-stack");
460
461 F->addFnAttrs(B);
462 return F;
463}
464
467}
468
471}
472
474 Function::iterator FromBeginIt,
475 Function::iterator FromEndIt) {
476#ifdef EXPENSIVE_CHECKS
477 // Check that FromBeginIt is before FromEndIt.
478 auto FromFEnd = FromF->end();
479 for (auto It = FromBeginIt; It != FromEndIt; ++It)
480 assert(It != FromFEnd && "FromBeginIt not before FromEndIt!");
481#endif // EXPENSIVE_CHECKS
482 BasicBlocks.splice(ToIt, FromF->BasicBlocks, FromBeginIt, FromEndIt);
483}
484
486 Function::iterator ToIt) {
487 return BasicBlocks.erase(FromIt, ToIt);
488}
489
490//===----------------------------------------------------------------------===//
491// Function Implementation
492//===----------------------------------------------------------------------===//
493
494static unsigned computeAddrSpace(unsigned AddrSpace, Module *M) {
495 // If AS == -1 and we are passed a valid module pointer we place the function
496 // in the program address space. Otherwise we default to AS0.
497 if (AddrSpace == static_cast<unsigned>(-1))
498 return M ? M->getDataLayout().getProgramAddressSpace() : 0;
499 return AddrSpace;
500}
501
502Function::Function(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace,
503 const Twine &name, Module *ParentModule)
504 : GlobalObject(Ty, Value::FunctionVal,
505 OperandTraits<Function>::op_begin(this), 0, Linkage, name,
506 computeAddrSpace(AddrSpace, ParentModule)),
507 NumArgs(Ty->getNumParams()), IsNewDbgInfoFormat(UseNewDbgInfoFormat) {
508 assert(FunctionType::isValidReturnType(getReturnType()) &&
509 "invalid return type");
510 setGlobalObjectSubClassData(0);
511
512 // We only need a symbol table for a function if the context keeps value names
513 if (!getContext().shouldDiscardValueNames())
514 SymTab = std::make_unique<ValueSymbolTable>(NonGlobalValueMaxNameSize);
515
516 // If the function has arguments, mark them as lazily built.
517 if (Ty->getNumParams())
518 setValueSubclassData(1); // Set the "has lazy arguments" bit.
519
520 if (ParentModule) {
521 ParentModule->getFunctionList().push_back(this);
522 IsNewDbgInfoFormat = ParentModule->IsNewDbgInfoFormat;
523 }
524
525 HasLLVMReservedName = getName().starts_with("llvm.");
526 // Ensure intrinsics have the right parameter attributes.
527 // Note, the IntID field will have been set in Value::setName if this function
528 // name is a valid intrinsic ID.
529 if (IntID)
530 setAttributes(Intrinsic::getAttributes(getContext(), IntID));
531}
532
534 validateBlockNumbers();
535
536 dropAllReferences(); // After this it is safe to delete instructions.
537
538 // Delete all of the method arguments and unlink from symbol table...
539 if (Arguments)
540 clearArguments();
541
542 // Remove the function from the on-the-side GC table.
543 clearGC();
544}
545
546void Function::BuildLazyArguments() const {
547 // Create the arguments vector, all arguments start out unnamed.
548 auto *FT = getFunctionType();
549 if (NumArgs > 0) {
550 Arguments = std::allocator<Argument>().allocate(NumArgs);
551 for (unsigned i = 0, e = NumArgs; i != e; ++i) {
552 Type *ArgTy = FT->getParamType(i);
553 assert(!ArgTy->isVoidTy() && "Cannot have void typed arguments!");
554 new (Arguments + i) Argument(ArgTy, "", const_cast<Function *>(this), i);
555 }
556 }
557
558 // Clear the lazy arguments bit.
559 unsigned SDC = getSubclassDataFromValue();
560 SDC &= ~(1 << 0);
561 const_cast<Function*>(this)->setValueSubclassData(SDC);
563}
564
566 return MutableArrayRef<Argument>(Args, Count);
567}
568
571}
572
573void Function::clearArguments() {
574 for (Argument &A : makeArgArray(Arguments, NumArgs)) {
575 A.setName("");
576 A.~Argument();
577 }
578 std::allocator<Argument>().deallocate(Arguments, NumArgs);
579 Arguments = nullptr;
580}
581
583 assert(isDeclaration() && "Expected no references to current arguments");
584
585 // Drop the current arguments, if any, and set the lazy argument bit.
586 if (!hasLazyArguments()) {
587 assert(llvm::all_of(makeArgArray(Arguments, NumArgs),
588 [](const Argument &A) { return A.use_empty(); }) &&
589 "Expected arguments to be unused in declaration");
590 clearArguments();
591 setValueSubclassData(getSubclassDataFromValue() | (1 << 0));
592 }
593
594 // Nothing to steal if Src has lazy arguments.
595 if (Src.hasLazyArguments())
596 return;
597
598 // Steal arguments from Src, and fix the lazy argument bits.
599 assert(arg_size() == Src.arg_size());
600 Arguments = Src.Arguments;
601 Src.Arguments = nullptr;
602 for (Argument &A : makeArgArray(Arguments, NumArgs)) {
603 // FIXME: This does the work of transferNodesFromList inefficiently.
605 if (A.hasName())
606 Name = A.getName();
607 if (!Name.empty())
608 A.setName("");
609 A.setParent(this);
610 if (!Name.empty())
611 A.setName(Name);
612 }
613
614 setValueSubclassData(getSubclassDataFromValue() & ~(1 << 0));
616 Src.setValueSubclassData(Src.getSubclassDataFromValue() | (1 << 0));
617}
618
619void Function::deleteBodyImpl(bool ShouldDrop) {
620 setIsMaterializable(false);
621
622 for (BasicBlock &BB : *this)
624
625 // Delete all basic blocks. They are now unused, except possibly by
626 // blockaddresses, but BasicBlock's destructor takes care of those.
627 while (!BasicBlocks.empty())
628 BasicBlocks.begin()->eraseFromParent();
629
630 if (getNumOperands()) {
631 if (ShouldDrop) {
632 // Drop uses of any optional data (real or placeholder).
635 } else {
636 // The code needs to match Function::allocHungoffUselist().
638 Op<0>().set(CPN);
639 Op<1>().set(CPN);
640 Op<2>().set(CPN);
641 }
642 setValueSubclassData(getSubclassDataFromValue() & ~0xe);
643 }
644
645 // Metadata is stored in a side-table.
647}
648
650 AttributeSets = AttributeSets.addAttributeAtIndex(getContext(), i, Attr);
651}
652
654 AttributeSets = AttributeSets.addFnAttribute(getContext(), Kind);
655}
656
658 AttributeSets = AttributeSets.addFnAttribute(getContext(), Kind, Val);
659}
660
662 AttributeSets = AttributeSets.addFnAttribute(getContext(), Attr);
663}
664
666 AttributeSets = AttributeSets.addFnAttributes(getContext(), Attrs);
667}
668
670 AttributeSets = AttributeSets.addRetAttribute(getContext(), Kind);
671}
672
674 AttributeSets = AttributeSets.addRetAttribute(getContext(), Attr);
675}
676
678 AttributeSets = AttributeSets.addRetAttributes(getContext(), Attrs);
679}
680
681void Function::addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) {
682 AttributeSets = AttributeSets.addParamAttribute(getContext(), ArgNo, Kind);
683}
684
685void Function::addParamAttr(unsigned ArgNo, Attribute Attr) {
686 AttributeSets = AttributeSets.addParamAttribute(getContext(), ArgNo, Attr);
687}
688
689void Function::addParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs) {
690 AttributeSets = AttributeSets.addParamAttributes(getContext(), ArgNo, Attrs);
691}
692
694 AttributeSets = AttributeSets.removeAttributeAtIndex(getContext(), i, Kind);
695}
696
698 AttributeSets = AttributeSets.removeAttributeAtIndex(getContext(), i, Kind);
699}
700
702 AttributeSets = AttributeSets.removeFnAttribute(getContext(), Kind);
703}
704
706 AttributeSets = AttributeSets.removeFnAttribute(getContext(), Kind);
707}
708
710 AttributeSets = AttributeSets.removeFnAttributes(getContext(), AM);
711}
712
714 AttributeSets = AttributeSets.removeRetAttribute(getContext(), Kind);
715}
716
718 AttributeSets = AttributeSets.removeRetAttribute(getContext(), Kind);
719}
720
722 AttributeSets = AttributeSets.removeRetAttributes(getContext(), Attrs);
723}
724
726 AttributeSets = AttributeSets.removeParamAttribute(getContext(), ArgNo, Kind);
727}
728
729void Function::removeParamAttr(unsigned ArgNo, StringRef Kind) {
730 AttributeSets = AttributeSets.removeParamAttribute(getContext(), ArgNo, Kind);
731}
732
733void Function::removeParamAttrs(unsigned ArgNo, const AttributeMask &Attrs) {
734 AttributeSets =
735 AttributeSets.removeParamAttributes(getContext(), ArgNo, Attrs);
736}
737
739 AttributeSets =
740 AttributeSets.addDereferenceableParamAttr(getContext(), ArgNo, Bytes);
741}
742
744 return AttributeSets.hasFnAttr(Kind);
745}
746
748 return AttributeSets.hasFnAttr(Kind);
749}
750
752 return AttributeSets.hasRetAttr(Kind);
753}
754
755bool Function::hasParamAttribute(unsigned ArgNo,
756 Attribute::AttrKind Kind) const {
757 return AttributeSets.hasParamAttr(ArgNo, Kind);
758}
759
761 Attribute::AttrKind Kind) const {
762 return AttributeSets.getAttributeAtIndex(i, Kind);
763}
764
766 return AttributeSets.getAttributeAtIndex(i, Kind);
767}
768
770 return AttributeSets.getFnAttr(Kind);
771}
772
774 return AttributeSets.getFnAttr(Kind);
775}
776
778 return AttributeSets.getRetAttr(Kind);
779}
780
782 uint64_t Default) const {
784 uint64_t Result = Default;
785 if (A.isStringAttribute()) {
786 StringRef Str = A.getValueAsString();
787 if (Str.getAsInteger(0, Result))
788 getContext().emitError("cannot parse integer attribute " + Name);
789 }
790
791 return Result;
792}
793
794/// gets the specified attribute from the list of attributes.
796 Attribute::AttrKind Kind) const {
797 return AttributeSets.getParamAttr(ArgNo, Kind);
798}
799
801 uint64_t Bytes) {
802 AttributeSets = AttributeSets.addDereferenceableOrNullParamAttr(getContext(),
803 ArgNo, Bytes);
804}
805
807 AttributeSets = AttributeSets.addRangeRetAttr(getContext(), CR);
808}
809
811 if (&FPType == &APFloat::IEEEsingle()) {
813 // If the f32 variant of the attribute isn't specified, try to use the
814 // generic one.
815 if (Mode.isValid())
816 return Mode;
817 }
818
819 return getDenormalModeRaw();
820}
821
823 Attribute Attr = getFnAttribute("denormal-fp-math");
824 StringRef Val = Attr.getValueAsString();
825 return parseDenormalFPAttribute(Val);
826}
827
829 Attribute Attr = getFnAttribute("denormal-fp-math-f32");
830 if (Attr.isValid()) {
831 StringRef Val = Attr.getValueAsString();
832 return parseDenormalFPAttribute(Val);
833 }
834
836}
837
838const std::string &Function::getGC() const {
839 assert(hasGC() && "Function has no collector");
840 return getContext().getGC(*this);
841}
842
843void Function::setGC(std::string Str) {
844 setValueSubclassDataBit(14, !Str.empty());
845 getContext().setGC(*this, std::move(Str));
846}
847
849 if (!hasGC())
850 return;
851 getContext().deleteGC(*this);
852 setValueSubclassDataBit(14, false);
853}
854
856 return hasFnAttribute(Attribute::StackProtect) ||
857 hasFnAttribute(Attribute::StackProtectStrong) ||
858 hasFnAttribute(Attribute::StackProtectReq);
859}
860
861/// Copy all additional attributes (those not needed to create a Function) from
862/// the Function Src to this one.
865 setCallingConv(Src->getCallingConv());
866 setAttributes(Src->getAttributes());
867 if (Src->hasGC())
868 setGC(Src->getGC());
869 else
870 clearGC();
871 if (Src->hasPersonalityFn())
872 setPersonalityFn(Src->getPersonalityFn());
873 if (Src->hasPrefixData())
874 setPrefixData(Src->getPrefixData());
875 if (Src->hasPrologueData())
876 setPrologueData(Src->getPrologueData());
877}
878
881}
884}
885
886/// Determine if the function does not access memory.
889}
892}
893
894/// Determine if the function does not access or only reads memory.
897}
900}
901
902/// Determine if the function does not access or only writes memory.
905}
908}
909
910/// Determine if the call can access memmory only using pointers based
911/// on its arguments.
914}
917}
918
919/// Determine if the function may only access memory that is
920/// inaccessible from the IR.
923}
926}
927
928/// Determine if the function may only access memory that is
929/// either inaccessible from the IR or pointed to by its arguments.
932}
936}
937
938/// Table of string intrinsic names indexed by enum value.
939static const char * const IntrinsicNameTable[] = {
940 "not_intrinsic",
941#define GET_INTRINSIC_NAME_TABLE
942#include "llvm/IR/IntrinsicImpl.inc"
943#undef GET_INTRINSIC_NAME_TABLE
944};
945
946/// Table of per-target intrinsic name tables.
947#define GET_INTRINSIC_TARGET_DATA
948#include "llvm/IR/IntrinsicImpl.inc"
949#undef GET_INTRINSIC_TARGET_DATA
950
952 return IID > TargetInfos[0].Count;
953}
954
956 return isTargetIntrinsic(IntID);
957}
958
959/// Find the segment of \c IntrinsicNameTable for intrinsics with the same
960/// target as \c Name, or the generic table if \c Name is not target specific.
961///
962/// Returns the relevant slice of \c IntrinsicNameTable
964 assert(Name.starts_with("llvm."));
965
966 ArrayRef<IntrinsicTargetInfo> Targets(TargetInfos);
967 // Drop "llvm." and take the first dotted component. That will be the target
968 // if this is target specific.
969 StringRef Target = Name.drop_front(5).split('.').first;
970 auto It = partition_point(
971 Targets, [=](const IntrinsicTargetInfo &TI) { return TI.Name < Target; });
972 // We've either found the target or just fall back to the generic set, which
973 // is always first.
974 const auto &TI = It != Targets.end() && It->Name == Target ? *It : Targets[0];
975 return ArrayRef(&IntrinsicNameTable[1] + TI.Offset, TI.Count);
976}
977
978/// This does the actual lookup of an intrinsic ID which
979/// matches the given function name.
983 if (Idx == -1)
985
986 // Intrinsic IDs correspond to the location in IntrinsicNameTable, but we have
987 // an index into a sub-table.
988 int Adjust = NameTable.data() - IntrinsicNameTable;
989 Intrinsic::ID ID = static_cast<Intrinsic::ID>(Idx + Adjust);
990
991 // If the intrinsic is not overloaded, require an exact match. If it is
992 // overloaded, require either exact or prefix match.
993 const auto MatchSize = strlen(NameTable[Idx]);
994 assert(Name.size() >= MatchSize && "Expected either exact or prefix match");
995 bool IsExactMatch = Name.size() == MatchSize;
996 return IsExactMatch || Intrinsic::isOverloaded(ID) ? ID
998}
999
1001 LibFuncCache = UnknownLibFunc;
1003 if (!Name.starts_with("llvm.")) {
1004 HasLLVMReservedName = false;
1006 return;
1007 }
1008 HasLLVMReservedName = true;
1010}
1011
1012/// Returns a stable mangling for the type specified for use in the name
1013/// mangling scheme used by 'any' types in intrinsic signatures. The mangling
1014/// of named types is simply their name. Manglings for unnamed types consist
1015/// of a prefix ('p' for pointers, 'a' for arrays, 'f_' for functions)
1016/// combined with the mangling of their component types. A vararg function
1017/// type will have a suffix of 'vararg'. Since function types can contain
1018/// other function types, we close a function type mangling with suffix 'f'
1019/// which can't be confused with it's prefix. This ensures we don't have
1020/// collisions between two unrelated function types. Otherwise, you might
1021/// parse ffXX as f(fXX) or f(fX)X. (X is a placeholder for any other type.)
1022/// The HasUnnamedType boolean is set if an unnamed type was encountered,
1023/// indicating that extra care must be taken to ensure a unique name.
1024static std::string getMangledTypeStr(Type *Ty, bool &HasUnnamedType) {
1025 std::string Result;
1026 if (PointerType *PTyp = dyn_cast<PointerType>(Ty)) {
1027 Result += "p" + utostr(PTyp->getAddressSpace());
1028 } else if (ArrayType *ATyp = dyn_cast<ArrayType>(Ty)) {
1029 Result += "a" + utostr(ATyp->getNumElements()) +
1030 getMangledTypeStr(ATyp->getElementType(), HasUnnamedType);
1031 } else if (StructType *STyp = dyn_cast<StructType>(Ty)) {
1032 if (!STyp->isLiteral()) {
1033 Result += "s_";
1034 if (STyp->hasName())
1035 Result += STyp->getName();
1036 else
1037 HasUnnamedType = true;
1038 } else {
1039 Result += "sl_";
1040 for (auto *Elem : STyp->elements())
1041 Result += getMangledTypeStr(Elem, HasUnnamedType);
1042 }
1043 // Ensure nested structs are distinguishable.
1044 Result += "s";
1045 } else if (FunctionType *FT = dyn_cast<FunctionType>(Ty)) {
1046 Result += "f_" + getMangledTypeStr(FT->getReturnType(), HasUnnamedType);
1047 for (size_t i = 0; i < FT->getNumParams(); i++)
1048 Result += getMangledTypeStr(FT->getParamType(i), HasUnnamedType);
1049 if (FT->isVarArg())
1050 Result += "vararg";
1051 // Ensure nested function types are distinguishable.
1052 Result += "f";
1053 } else if (VectorType *VTy = dyn_cast<VectorType>(Ty)) {
1054 ElementCount EC = VTy->getElementCount();
1055 if (EC.isScalable())
1056 Result += "nx";
1057 Result += "v" + utostr(EC.getKnownMinValue()) +
1058 getMangledTypeStr(VTy->getElementType(), HasUnnamedType);
1059 } else if (TargetExtType *TETy = dyn_cast<TargetExtType>(Ty)) {
1060 Result += "t";
1061 Result += TETy->getName();
1062 for (Type *ParamTy : TETy->type_params())
1063 Result += "_" + getMangledTypeStr(ParamTy, HasUnnamedType);
1064 for (unsigned IntParam : TETy->int_params())
1065 Result += "_" + utostr(IntParam);
1066 // Ensure nested target extension types are distinguishable.
1067 Result += "t";
1068 } else if (Ty) {
1069 switch (Ty->getTypeID()) {
1070 default: llvm_unreachable("Unhandled type");
1071 case Type::VoidTyID: Result += "isVoid"; break;
1072 case Type::MetadataTyID: Result += "Metadata"; break;
1073 case Type::HalfTyID: Result += "f16"; break;
1074 case Type::BFloatTyID: Result += "bf16"; break;
1075 case Type::FloatTyID: Result += "f32"; break;
1076 case Type::DoubleTyID: Result += "f64"; break;
1077 case Type::X86_FP80TyID: Result += "f80"; break;
1078 case Type::FP128TyID: Result += "f128"; break;
1080 Result += "ppcf128";
1081 break;
1082 case Type::X86_AMXTyID: Result += "x86amx"; break;
1083 case Type::IntegerTyID:
1084 Result += "i" + utostr(cast<IntegerType>(Ty)->getBitWidth());
1085 break;
1086 }
1087 }
1088 return Result;
1089}
1090
1092 assert(id < num_intrinsics && "Invalid intrinsic ID!");
1093 return IntrinsicNameTable[id];
1094}
1095
1097 assert(id < num_intrinsics && "Invalid intrinsic ID!");
1099 "This version of getName does not support overloading");
1100 return getBaseName(id);
1101}
1102
1104 Module *M, FunctionType *FT,
1105 bool EarlyModuleCheck) {
1106
1107 assert(Id < Intrinsic::num_intrinsics && "Invalid intrinsic ID!");
1108 assert((Tys.empty() || Intrinsic::isOverloaded(Id)) &&
1109 "This version of getName is for overloaded intrinsics only");
1110 (void)EarlyModuleCheck;
1111 assert((!EarlyModuleCheck || M ||
1112 !any_of(Tys, [](Type *T) { return isa<PointerType>(T); })) &&
1113 "Intrinsic overloading on pointer types need to provide a Module");
1114 bool HasUnnamedType = false;
1115 std::string Result(Intrinsic::getBaseName(Id));
1116 for (Type *Ty : Tys)
1117 Result += "." + getMangledTypeStr(Ty, HasUnnamedType);
1118 if (HasUnnamedType) {
1119 assert(M && "unnamed types need a module");
1120 if (!FT)
1121 FT = Intrinsic::getType(M->getContext(), Id, Tys);
1122 else
1123 assert((FT == Intrinsic::getType(M->getContext(), Id, Tys)) &&
1124 "Provided FunctionType must match arguments");
1125 return M->getUniqueIntrinsicName(Result, Id, FT);
1126 }
1127 return Result;
1128}
1129
1131 FunctionType *FT) {
1132 assert(M && "We need to have a Module");
1133 return getIntrinsicNameImpl(Id, Tys, M, FT, true);
1134}
1135
1137 return getIntrinsicNameImpl(Id, Tys, nullptr, nullptr, false);
1138}
1139
1140/// IIT_Info - These are enumerators that describe the entries returned by the
1141/// getIntrinsicInfoTableEntries function.
1142///
1143/// Defined in Intrinsics.td.
1145#define GET_INTRINSIC_IITINFO
1146#include "llvm/IR/IntrinsicImpl.inc"
1147#undef GET_INTRINSIC_IITINFO
1148};
1149
1150static void DecodeIITType(unsigned &NextElt, ArrayRef<unsigned char> Infos,
1151 IIT_Info LastInfo,
1153 using namespace Intrinsic;
1154
1155 bool IsScalableVector = (LastInfo == IIT_SCALABLE_VEC);
1156
1157 IIT_Info Info = IIT_Info(Infos[NextElt++]);
1158 unsigned StructElts = 2;
1159
1160 switch (Info) {
1161 case IIT_Done:
1162 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Void, 0));
1163 return;
1164 case IIT_VARARG:
1165 OutputTable.push_back(IITDescriptor::get(IITDescriptor::VarArg, 0));
1166 return;
1167 case IIT_MMX:
1168 OutputTable.push_back(IITDescriptor::get(IITDescriptor::MMX, 0));
1169 return;
1170 case IIT_AMX:
1171 OutputTable.push_back(IITDescriptor::get(IITDescriptor::AMX, 0));
1172 return;
1173 case IIT_TOKEN:
1174 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Token, 0));
1175 return;
1176 case IIT_METADATA:
1177 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Metadata, 0));
1178 return;
1179 case IIT_F16:
1180 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Half, 0));
1181 return;
1182 case IIT_BF16:
1183 OutputTable.push_back(IITDescriptor::get(IITDescriptor::BFloat, 0));
1184 return;
1185 case IIT_F32:
1186 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Float, 0));
1187 return;
1188 case IIT_F64:
1189 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Double, 0));
1190 return;
1191 case IIT_F128:
1192 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Quad, 0));
1193 return;
1194 case IIT_PPCF128:
1195 OutputTable.push_back(IITDescriptor::get(IITDescriptor::PPCQuad, 0));
1196 return;
1197 case IIT_I1:
1198 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 1));
1199 return;
1200 case IIT_I2:
1201 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 2));
1202 return;
1203 case IIT_I4:
1204 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 4));
1205 return;
1206 case IIT_AARCH64_SVCOUNT:
1207 OutputTable.push_back(IITDescriptor::get(IITDescriptor::AArch64Svcount, 0));
1208 return;
1209 case IIT_I8:
1210 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 8));
1211 return;
1212 case IIT_I16:
1213 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer,16));
1214 return;
1215 case IIT_I32:
1216 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 32));
1217 return;
1218 case IIT_I64:
1219 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 64));
1220 return;
1221 case IIT_I128:
1222 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Integer, 128));
1223 return;
1224 case IIT_V1:
1225 OutputTable.push_back(IITDescriptor::getVector(1, IsScalableVector));
1226 DecodeIITType(NextElt, Infos, Info, OutputTable);
1227 return;
1228 case IIT_V2:
1229 OutputTable.push_back(IITDescriptor::getVector(2, IsScalableVector));
1230 DecodeIITType(NextElt, Infos, Info, OutputTable);
1231 return;
1232 case IIT_V3:
1233 OutputTable.push_back(IITDescriptor::getVector(3, IsScalableVector));
1234 DecodeIITType(NextElt, Infos, Info, OutputTable);
1235 return;
1236 case IIT_V4:
1237 OutputTable.push_back(IITDescriptor::getVector(4, IsScalableVector));
1238 DecodeIITType(NextElt, Infos, Info, OutputTable);
1239 return;
1240 case IIT_V6:
1241 OutputTable.push_back(IITDescriptor::getVector(6, IsScalableVector));
1242 DecodeIITType(NextElt, Infos, Info, OutputTable);
1243 return;
1244 case IIT_V8:
1245 OutputTable.push_back(IITDescriptor::getVector(8, IsScalableVector));
1246 DecodeIITType(NextElt, Infos, Info, OutputTable);
1247 return;
1248 case IIT_V10:
1249 OutputTable.push_back(IITDescriptor::getVector(10, IsScalableVector));
1250 DecodeIITType(NextElt, Infos, Info, OutputTable);
1251 return;
1252 case IIT_V16:
1253 OutputTable.push_back(IITDescriptor::getVector(16, IsScalableVector));
1254 DecodeIITType(NextElt, Infos, Info, OutputTable);
1255 return;
1256 case IIT_V32:
1257 OutputTable.push_back(IITDescriptor::getVector(32, IsScalableVector));
1258 DecodeIITType(NextElt, Infos, Info, OutputTable);
1259 return;
1260 case IIT_V64:
1261 OutputTable.push_back(IITDescriptor::getVector(64, IsScalableVector));
1262 DecodeIITType(NextElt, Infos, Info, OutputTable);
1263 return;
1264 case IIT_V128:
1265 OutputTable.push_back(IITDescriptor::getVector(128, IsScalableVector));
1266 DecodeIITType(NextElt, Infos, Info, OutputTable);
1267 return;
1268 case IIT_V256:
1269 OutputTable.push_back(IITDescriptor::getVector(256, IsScalableVector));
1270 DecodeIITType(NextElt, Infos, Info, OutputTable);
1271 return;
1272 case IIT_V512:
1273 OutputTable.push_back(IITDescriptor::getVector(512, IsScalableVector));
1274 DecodeIITType(NextElt, Infos, Info, OutputTable);
1275 return;
1276 case IIT_V1024:
1277 OutputTable.push_back(IITDescriptor::getVector(1024, IsScalableVector));
1278 DecodeIITType(NextElt, Infos, Info, OutputTable);
1279 return;
1280 case IIT_EXTERNREF:
1281 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Pointer, 10));
1282 return;
1283 case IIT_FUNCREF:
1284 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Pointer, 20));
1285 return;
1286 case IIT_PTR:
1287 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Pointer, 0));
1288 return;
1289 case IIT_ANYPTR: // [ANYPTR addrspace]
1290 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Pointer,
1291 Infos[NextElt++]));
1292 return;
1293 case IIT_ARG: {
1294 unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1295 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Argument, ArgInfo));
1296 return;
1297 }
1298 case IIT_EXTEND_ARG: {
1299 unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1300 OutputTable.push_back(IITDescriptor::get(IITDescriptor::ExtendArgument,
1301 ArgInfo));
1302 return;
1303 }
1304 case IIT_TRUNC_ARG: {
1305 unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1306 OutputTable.push_back(IITDescriptor::get(IITDescriptor::TruncArgument,
1307 ArgInfo));
1308 return;
1309 }
1310 case IIT_HALF_VEC_ARG: {
1311 unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1312 OutputTable.push_back(IITDescriptor::get(IITDescriptor::HalfVecArgument,
1313 ArgInfo));
1314 return;
1315 }
1316 case IIT_SAME_VEC_WIDTH_ARG: {
1317 unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1318 OutputTable.push_back(IITDescriptor::get(IITDescriptor::SameVecWidthArgument,
1319 ArgInfo));
1320 return;
1321 }
1322 case IIT_VEC_OF_ANYPTRS_TO_ELT: {
1323 unsigned short ArgNo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1324 unsigned short RefNo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1325 OutputTable.push_back(
1326 IITDescriptor::get(IITDescriptor::VecOfAnyPtrsToElt, ArgNo, RefNo));
1327 return;
1328 }
1329 case IIT_EMPTYSTRUCT:
1330 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Struct, 0));
1331 return;
1332 case IIT_STRUCT9: ++StructElts; [[fallthrough]];
1333 case IIT_STRUCT8: ++StructElts; [[fallthrough]];
1334 case IIT_STRUCT7: ++StructElts; [[fallthrough]];
1335 case IIT_STRUCT6: ++StructElts; [[fallthrough]];
1336 case IIT_STRUCT5: ++StructElts; [[fallthrough]];
1337 case IIT_STRUCT4: ++StructElts; [[fallthrough]];
1338 case IIT_STRUCT3: ++StructElts; [[fallthrough]];
1339 case IIT_STRUCT2: {
1340 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Struct,StructElts));
1341
1342 for (unsigned i = 0; i != StructElts; ++i)
1343 DecodeIITType(NextElt, Infos, Info, OutputTable);
1344 return;
1345 }
1346 case IIT_SUBDIVIDE2_ARG: {
1347 unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1348 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Subdivide2Argument,
1349 ArgInfo));
1350 return;
1351 }
1352 case IIT_SUBDIVIDE4_ARG: {
1353 unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1354 OutputTable.push_back(IITDescriptor::get(IITDescriptor::Subdivide4Argument,
1355 ArgInfo));
1356 return;
1357 }
1358 case IIT_VEC_ELEMENT: {
1359 unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1360 OutputTable.push_back(IITDescriptor::get(IITDescriptor::VecElementArgument,
1361 ArgInfo));
1362 return;
1363 }
1364 case IIT_SCALABLE_VEC: {
1365 DecodeIITType(NextElt, Infos, Info, OutputTable);
1366 return;
1367 }
1368 case IIT_VEC_OF_BITCASTS_TO_INT: {
1369 unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]);
1370 OutputTable.push_back(IITDescriptor::get(IITDescriptor::VecOfBitcastsToInt,
1371 ArgInfo));
1372 return;
1373 }
1374 }
1375 llvm_unreachable("unhandled");
1376}
1377
1378#define GET_INTRINSIC_GENERATOR_GLOBAL
1379#include "llvm/IR/IntrinsicImpl.inc"
1380#undef GET_INTRINSIC_GENERATOR_GLOBAL
1381
1384 // Check to see if the intrinsic's type was expressible by the table.
1385 unsigned TableVal = IIT_Table[id-1];
1386
1387 // Decode the TableVal into an array of IITValues.
1389 ArrayRef<unsigned char> IITEntries;
1390 unsigned NextElt = 0;
1391 if ((TableVal >> 31) != 0) {
1392 // This is an offset into the IIT_LongEncodingTable.
1393 IITEntries = IIT_LongEncodingTable;
1394
1395 // Strip sentinel bit.
1396 NextElt = (TableVal << 1) >> 1;
1397 } else {
1398 // Decode the TableVal into an array of IITValues. If the entry was encoded
1399 // into a single word in the table itself, decode it now.
1400 do {
1401 IITValues.push_back(TableVal & 0xF);
1402 TableVal >>= 4;
1403 } while (TableVal);
1404
1405 IITEntries = IITValues;
1406 NextElt = 0;
1407 }
1408
1409 // Okay, decode the table into the output vector of IITDescriptors.
1410 DecodeIITType(NextElt, IITEntries, IIT_Done, T);
1411 while (NextElt != IITEntries.size() && IITEntries[NextElt] != 0)
1412 DecodeIITType(NextElt, IITEntries, IIT_Done, T);
1413}
1414
1416 ArrayRef<Type*> Tys, LLVMContext &Context) {
1417 using namespace Intrinsic;
1418
1419 IITDescriptor D = Infos.front();
1420 Infos = Infos.slice(1);
1421
1422 switch (D.Kind) {
1423 case IITDescriptor::Void: return Type::getVoidTy(Context);
1424 case IITDescriptor::VarArg: return Type::getVoidTy(Context);
1425 case IITDescriptor::MMX:
1426 return llvm::FixedVectorType::get(llvm::IntegerType::get(Context, 64), 1);
1427 case IITDescriptor::AMX: return Type::getX86_AMXTy(Context);
1428 case IITDescriptor::Token: return Type::getTokenTy(Context);
1429 case IITDescriptor::Metadata: return Type::getMetadataTy(Context);
1430 case IITDescriptor::Half: return Type::getHalfTy(Context);
1431 case IITDescriptor::BFloat: return Type::getBFloatTy(Context);
1432 case IITDescriptor::Float: return Type::getFloatTy(Context);
1433 case IITDescriptor::Double: return Type::getDoubleTy(Context);
1434 case IITDescriptor::Quad: return Type::getFP128Ty(Context);
1435 case IITDescriptor::PPCQuad: return Type::getPPC_FP128Ty(Context);
1436 case IITDescriptor::AArch64Svcount:
1437 return TargetExtType::get(Context, "aarch64.svcount");
1438
1439 case IITDescriptor::Integer:
1440 return IntegerType::get(Context, D.Integer_Width);
1441 case IITDescriptor::Vector:
1442 return VectorType::get(DecodeFixedType(Infos, Tys, Context),
1443 D.Vector_Width);
1444 case IITDescriptor::Pointer:
1445 return PointerType::get(Context, D.Pointer_AddressSpace);
1446 case IITDescriptor::Struct: {
1448 for (unsigned i = 0, e = D.Struct_NumElements; i != e; ++i)
1449 Elts.push_back(DecodeFixedType(Infos, Tys, Context));
1450 return StructType::get(Context, Elts);
1451 }
1452 case IITDescriptor::Argument:
1453 return Tys[D.getArgumentNumber()];
1454 case IITDescriptor::ExtendArgument: {
1455 Type *Ty = Tys[D.getArgumentNumber()];
1456 if (VectorType *VTy = dyn_cast<VectorType>(Ty))
1458
1459 return IntegerType::get(Context, 2 * cast<IntegerType>(Ty)->getBitWidth());
1460 }
1461 case IITDescriptor::TruncArgument: {
1462 Type *Ty = Tys[D.getArgumentNumber()];
1463 if (VectorType *VTy = dyn_cast<VectorType>(Ty))
1465
1466 IntegerType *ITy = cast<IntegerType>(Ty);
1467 assert(ITy->getBitWidth() % 2 == 0);
1468 return IntegerType::get(Context, ITy->getBitWidth() / 2);
1469 }
1470 case IITDescriptor::Subdivide2Argument:
1471 case IITDescriptor::Subdivide4Argument: {
1472 Type *Ty = Tys[D.getArgumentNumber()];
1473 VectorType *VTy = dyn_cast<VectorType>(Ty);
1474 assert(VTy && "Expected an argument of Vector Type");
1475 int SubDivs = D.Kind == IITDescriptor::Subdivide2Argument ? 1 : 2;
1476 return VectorType::getSubdividedVectorType(VTy, SubDivs);
1477 }
1478 case IITDescriptor::HalfVecArgument:
1479 return VectorType::getHalfElementsVectorType(cast<VectorType>(
1480 Tys[D.getArgumentNumber()]));
1481 case IITDescriptor::SameVecWidthArgument: {
1482 Type *EltTy = DecodeFixedType(Infos, Tys, Context);
1483 Type *Ty = Tys[D.getArgumentNumber()];
1484 if (auto *VTy = dyn_cast<VectorType>(Ty))
1485 return VectorType::get(EltTy, VTy->getElementCount());
1486 return EltTy;
1487 }
1488 case IITDescriptor::VecElementArgument: {
1489 Type *Ty = Tys[D.getArgumentNumber()];
1490 if (VectorType *VTy = dyn_cast<VectorType>(Ty))
1491 return VTy->getElementType();
1492 llvm_unreachable("Expected an argument of Vector Type");
1493 }
1494 case IITDescriptor::VecOfBitcastsToInt: {
1495 Type *Ty = Tys[D.getArgumentNumber()];
1496 VectorType *VTy = dyn_cast<VectorType>(Ty);
1497 assert(VTy && "Expected an argument of Vector Type");
1498 return VectorType::getInteger(VTy);
1499 }
1500 case IITDescriptor::VecOfAnyPtrsToElt:
1501 // Return the overloaded type (which determines the pointers address space)
1502 return Tys[D.getOverloadArgNumber()];
1503 }
1504 llvm_unreachable("unhandled");
1505}
1506
1508 ID id, ArrayRef<Type*> Tys) {
1511
1513 Type *ResultTy = DecodeFixedType(TableRef, Tys, Context);
1514
1515 SmallVector<Type*, 8> ArgTys;
1516 while (!TableRef.empty())
1517 ArgTys.push_back(DecodeFixedType(TableRef, Tys, Context));
1518
1519 // DecodeFixedType returns Void for IITDescriptor::Void and IITDescriptor::VarArg
1520 // If we see void type as the type of the last argument, it is vararg intrinsic
1521 if (!ArgTys.empty() && ArgTys.back()->isVoidTy()) {
1522 ArgTys.pop_back();
1523 return FunctionType::get(ResultTy, ArgTys, true);
1524 }
1525 return FunctionType::get(ResultTy, ArgTys, false);
1526}
1527
1529#define GET_INTRINSIC_OVERLOAD_TABLE
1530#include "llvm/IR/IntrinsicImpl.inc"
1531#undef GET_INTRINSIC_OVERLOAD_TABLE
1532}
1533
1534/// This defines the "Intrinsic::getAttributes(ID id)" method.
1535#define GET_INTRINSIC_ATTRIBUTES
1536#include "llvm/IR/IntrinsicImpl.inc"
1537#undef GET_INTRINSIC_ATTRIBUTES
1538
1540 // There can never be multiple globals with the same name of different types,
1541 // because intrinsics must be a specific type.
1542 auto *FT = getType(M->getContext(), id, Tys);
1543 return cast<Function>(
1544 M->getOrInsertFunction(
1545 Tys.empty() ? getName(id) : getName(id, Tys, M, FT), FT)
1546 .getCallee());
1547}
1548
1549// This defines the "Intrinsic::getIntrinsicForClangBuiltin()" method.
1550#define GET_LLVM_INTRINSIC_FOR_CLANG_BUILTIN
1551#include "llvm/IR/IntrinsicImpl.inc"
1552#undef GET_LLVM_INTRINSIC_FOR_CLANG_BUILTIN
1553
1554// This defines the "Intrinsic::getIntrinsicForMSBuiltin()" method.
1555#define GET_LLVM_INTRINSIC_FOR_MS_BUILTIN
1556#include "llvm/IR/IntrinsicImpl.inc"
1557#undef GET_LLVM_INTRINSIC_FOR_MS_BUILTIN
1558
1560 switch (QID) {
1561#define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC) \
1562 case Intrinsic::INTRINSIC:
1563#include "llvm/IR/ConstrainedOps.def"
1564#undef INSTRUCTION
1565 return true;
1566 default:
1567 return false;
1568 }
1569}
1570
1572 switch (QID) {
1573#define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC) \
1574 case Intrinsic::INTRINSIC: \
1575 return ROUND_MODE == 1;
1576#include "llvm/IR/ConstrainedOps.def"
1577#undef INSTRUCTION
1578 default:
1579 return false;
1580 }
1581}
1582
1584 std::pair<Type *, ArrayRef<Intrinsic::IITDescriptor>>;
1585
1590 bool IsDeferredCheck) {
1591 using namespace Intrinsic;
1592
1593 // If we ran out of descriptors, there are too many arguments.
1594 if (Infos.empty()) return true;
1595
1596 // Do this before slicing off the 'front' part
1597 auto InfosRef = Infos;
1598 auto DeferCheck = [&DeferredChecks, &InfosRef](Type *T) {
1599 DeferredChecks.emplace_back(T, InfosRef);
1600 return false;
1601 };
1602
1603 IITDescriptor D = Infos.front();
1604 Infos = Infos.slice(1);
1605
1606 switch (D.Kind) {
1607 case IITDescriptor::Void: return !Ty->isVoidTy();
1608 case IITDescriptor::VarArg: return true;
1609 case IITDescriptor::MMX: {
1610 FixedVectorType *VT = dyn_cast<FixedVectorType>(Ty);
1611 return !VT || VT->getNumElements() != 1 ||
1612 !VT->getElementType()->isIntegerTy(64);
1613 }
1614 case IITDescriptor::AMX: return !Ty->isX86_AMXTy();
1615 case IITDescriptor::Token: return !Ty->isTokenTy();
1616 case IITDescriptor::Metadata: return !Ty->isMetadataTy();
1617 case IITDescriptor::Half: return !Ty->isHalfTy();
1618 case IITDescriptor::BFloat: return !Ty->isBFloatTy();
1619 case IITDescriptor::Float: return !Ty->isFloatTy();
1620 case IITDescriptor::Double: return !Ty->isDoubleTy();
1621 case IITDescriptor::Quad: return !Ty->isFP128Ty();
1622 case IITDescriptor::PPCQuad: return !Ty->isPPC_FP128Ty();
1623 case IITDescriptor::Integer: return !Ty->isIntegerTy(D.Integer_Width);
1624 case IITDescriptor::AArch64Svcount:
1625 return !isa<TargetExtType>(Ty) ||
1626 cast<TargetExtType>(Ty)->getName() != "aarch64.svcount";
1627 case IITDescriptor::Vector: {
1628 VectorType *VT = dyn_cast<VectorType>(Ty);
1629 return !VT || VT->getElementCount() != D.Vector_Width ||
1630 matchIntrinsicType(VT->getElementType(), Infos, ArgTys,
1631 DeferredChecks, IsDeferredCheck);
1632 }
1633 case IITDescriptor::Pointer: {
1634 PointerType *PT = dyn_cast<PointerType>(Ty);
1635 return !PT || PT->getAddressSpace() != D.Pointer_AddressSpace;
1636 }
1637
1638 case IITDescriptor::Struct: {
1639 StructType *ST = dyn_cast<StructType>(Ty);
1640 if (!ST || !ST->isLiteral() || ST->isPacked() ||
1641 ST->getNumElements() != D.Struct_NumElements)
1642 return true;
1643
1644 for (unsigned i = 0, e = D.Struct_NumElements; i != e; ++i)
1645 if (matchIntrinsicType(ST->getElementType(i), Infos, ArgTys,
1646 DeferredChecks, IsDeferredCheck))
1647 return true;
1648 return false;
1649 }
1650
1651 case IITDescriptor::Argument:
1652 // If this is the second occurrence of an argument,
1653 // verify that the later instance matches the previous instance.
1654 if (D.getArgumentNumber() < ArgTys.size())
1655 return Ty != ArgTys[D.getArgumentNumber()];
1656
1657 if (D.getArgumentNumber() > ArgTys.size() ||
1658 D.getArgumentKind() == IITDescriptor::AK_MatchType)
1659 return IsDeferredCheck || DeferCheck(Ty);
1660
1661 assert(D.getArgumentNumber() == ArgTys.size() && !IsDeferredCheck &&
1662 "Table consistency error");
1663 ArgTys.push_back(Ty);
1664
1665 switch (D.getArgumentKind()) {
1666 case IITDescriptor::AK_Any: return false; // Success
1667 case IITDescriptor::AK_AnyInteger: return !Ty->isIntOrIntVectorTy();
1668 case IITDescriptor::AK_AnyFloat: return !Ty->isFPOrFPVectorTy();
1669 case IITDescriptor::AK_AnyVector: return !isa<VectorType>(Ty);
1670 case IITDescriptor::AK_AnyPointer: return !isa<PointerType>(Ty);
1671 default: break;
1672 }
1673 llvm_unreachable("all argument kinds not covered");
1674
1675 case IITDescriptor::ExtendArgument: {
1676 // If this is a forward reference, defer the check for later.
1677 if (D.getArgumentNumber() >= ArgTys.size())
1678 return IsDeferredCheck || DeferCheck(Ty);
1679
1680 Type *NewTy = ArgTys[D.getArgumentNumber()];
1681 if (VectorType *VTy = dyn_cast<VectorType>(NewTy))
1683 else if (IntegerType *ITy = dyn_cast<IntegerType>(NewTy))
1684 NewTy = IntegerType::get(ITy->getContext(), 2 * ITy->getBitWidth());
1685 else
1686 return true;
1687
1688 return Ty != NewTy;
1689 }
1690 case IITDescriptor::TruncArgument: {
1691 // If this is a forward reference, defer the check for later.
1692 if (D.getArgumentNumber() >= ArgTys.size())
1693 return IsDeferredCheck || DeferCheck(Ty);
1694
1695 Type *NewTy = ArgTys[D.getArgumentNumber()];
1696 if (VectorType *VTy = dyn_cast<VectorType>(NewTy))
1698 else if (IntegerType *ITy = dyn_cast<IntegerType>(NewTy))
1699 NewTy = IntegerType::get(ITy->getContext(), ITy->getBitWidth() / 2);
1700 else
1701 return true;
1702
1703 return Ty != NewTy;
1704 }
1705 case IITDescriptor::HalfVecArgument:
1706 // If this is a forward reference, defer the check for later.
1707 if (D.getArgumentNumber() >= ArgTys.size())
1708 return IsDeferredCheck || DeferCheck(Ty);
1709 return !isa<VectorType>(ArgTys[D.getArgumentNumber()]) ||
1711 cast<VectorType>(ArgTys[D.getArgumentNumber()])) != Ty;
1712 case IITDescriptor::SameVecWidthArgument: {
1713 if (D.getArgumentNumber() >= ArgTys.size()) {
1714 // Defer check and subsequent check for the vector element type.
1715 Infos = Infos.slice(1);
1716 return IsDeferredCheck || DeferCheck(Ty);
1717 }
1718 auto *ReferenceType = dyn_cast<VectorType>(ArgTys[D.getArgumentNumber()]);
1719 auto *ThisArgType = dyn_cast<VectorType>(Ty);
1720 // Both must be vectors of the same number of elements or neither.
1721 if ((ReferenceType != nullptr) != (ThisArgType != nullptr))
1722 return true;
1723 Type *EltTy = Ty;
1724 if (ThisArgType) {
1725 if (ReferenceType->getElementCount() !=
1726 ThisArgType->getElementCount())
1727 return true;
1728 EltTy = ThisArgType->getElementType();
1729 }
1730 return matchIntrinsicType(EltTy, Infos, ArgTys, DeferredChecks,
1731 IsDeferredCheck);
1732 }
1733 case IITDescriptor::VecOfAnyPtrsToElt: {
1734 unsigned RefArgNumber = D.getRefArgNumber();
1735 if (RefArgNumber >= ArgTys.size()) {
1736 if (IsDeferredCheck)
1737 return true;
1738 // If forward referencing, already add the pointer-vector type and
1739 // defer the checks for later.
1740 ArgTys.push_back(Ty);
1741 return DeferCheck(Ty);
1742 }
1743
1744 if (!IsDeferredCheck){
1745 assert(D.getOverloadArgNumber() == ArgTys.size() &&
1746 "Table consistency error");
1747 ArgTys.push_back(Ty);
1748 }
1749
1750 // Verify the overloaded type "matches" the Ref type.
1751 // i.e. Ty is a vector with the same width as Ref.
1752 // Composed of pointers to the same element type as Ref.
1753 auto *ReferenceType = dyn_cast<VectorType>(ArgTys[RefArgNumber]);
1754 auto *ThisArgVecTy = dyn_cast<VectorType>(Ty);
1755 if (!ThisArgVecTy || !ReferenceType ||
1756 (ReferenceType->getElementCount() != ThisArgVecTy->getElementCount()))
1757 return true;
1758 return !ThisArgVecTy->getElementType()->isPointerTy();
1759 }
1760 case IITDescriptor::VecElementArgument: {
1761 if (D.getArgumentNumber() >= ArgTys.size())
1762 return IsDeferredCheck ? true : DeferCheck(Ty);
1763 auto *ReferenceType = dyn_cast<VectorType>(ArgTys[D.getArgumentNumber()]);
1764 return !ReferenceType || Ty != ReferenceType->getElementType();
1765 }
1766 case IITDescriptor::Subdivide2Argument:
1767 case IITDescriptor::Subdivide4Argument: {
1768 // If this is a forward reference, defer the check for later.
1769 if (D.getArgumentNumber() >= ArgTys.size())
1770 return IsDeferredCheck || DeferCheck(Ty);
1771
1772 Type *NewTy = ArgTys[D.getArgumentNumber()];
1773 if (auto *VTy = dyn_cast<VectorType>(NewTy)) {
1774 int SubDivs = D.Kind == IITDescriptor::Subdivide2Argument ? 1 : 2;
1775 NewTy = VectorType::getSubdividedVectorType(VTy, SubDivs);
1776 return Ty != NewTy;
1777 }
1778 return true;
1779 }
1780 case IITDescriptor::VecOfBitcastsToInt: {
1781 if (D.getArgumentNumber() >= ArgTys.size())
1782 return IsDeferredCheck || DeferCheck(Ty);
1783 auto *ReferenceType = dyn_cast<VectorType>(ArgTys[D.getArgumentNumber()]);
1784 auto *ThisArgVecTy = dyn_cast<VectorType>(Ty);
1785 if (!ThisArgVecTy || !ReferenceType)
1786 return true;
1787 return ThisArgVecTy != VectorType::getInteger(ReferenceType);
1788 }
1789 }
1790 llvm_unreachable("unhandled");
1791}
1792
1796 SmallVectorImpl<Type *> &ArgTys) {
1798 if (matchIntrinsicType(FTy->getReturnType(), Infos, ArgTys, DeferredChecks,
1799 false))
1801
1802 unsigned NumDeferredReturnChecks = DeferredChecks.size();
1803
1804 for (auto *Ty : FTy->params())
1805 if (matchIntrinsicType(Ty, Infos, ArgTys, DeferredChecks, false))
1807
1808 for (unsigned I = 0, E = DeferredChecks.size(); I != E; ++I) {
1809 DeferredIntrinsicMatchPair &Check = DeferredChecks[I];
1810 if (matchIntrinsicType(Check.first, Check.second, ArgTys, DeferredChecks,
1811 true))
1812 return I < NumDeferredReturnChecks ? MatchIntrinsicTypes_NoMatchRet
1814 }
1815
1817}
1818
1819bool
1822 // If there are no descriptors left, then it can't be a vararg.
1823 if (Infos.empty())
1824 return isVarArg;
1825
1826 // There should be only one descriptor remaining at this point.
1827 if (Infos.size() != 1)
1828 return true;
1829
1830 // Check and verify the descriptor.
1831 IITDescriptor D = Infos.front();
1832 Infos = Infos.slice(1);
1833 if (D.Kind == IITDescriptor::VarArg)
1834 return !isVarArg;
1835
1836 return true;
1837}
1838
1840 SmallVectorImpl<Type *> &ArgTys) {
1841 if (!ID)
1842 return false;
1843
1847
1850 return false;
1851 }
1853 return false;
1854 return true;
1855}
1856
1858 SmallVectorImpl<Type *> &ArgTys) {
1859 return getIntrinsicSignature(F->getIntrinsicID(), F->getFunctionType(),
1860 ArgTys);
1861}
1862
1865 if (!getIntrinsicSignature(F, ArgTys))
1866 return std::nullopt;
1867
1868 Intrinsic::ID ID = F->getIntrinsicID();
1869 StringRef Name = F->getName();
1870 std::string WantedName =
1871 Intrinsic::getName(ID, ArgTys, F->getParent(), F->getFunctionType());
1872 if (Name == WantedName)
1873 return std::nullopt;
1874
1875 Function *NewDecl = [&] {
1876 if (auto *ExistingGV = F->getParent()->getNamedValue(WantedName)) {
1877 if (auto *ExistingF = dyn_cast<Function>(ExistingGV))
1878 if (ExistingF->getFunctionType() == F->getFunctionType())
1879 return ExistingF;
1880
1881 // The name already exists, but is not a function or has the wrong
1882 // prototype. Make place for the new one by renaming the old version.
1883 // Either this old version will be removed later on or the module is
1884 // invalid and we'll get an error.
1885 ExistingGV->setName(WantedName + ".renamed");
1886 }
1887 return Intrinsic::getDeclaration(F->getParent(), ID, ArgTys);
1888 }();
1889
1890 NewDecl->setCallingConv(F->getCallingConv());
1891 assert(NewDecl->getFunctionType() == F->getFunctionType() &&
1892 "Shouldn't change the signature");
1893 return NewDecl;
1894}
1895
1896/// hasAddressTaken - returns true if there are any uses of this function
1897/// other than direct calls or invokes to it. Optionally ignores callback
1898/// uses, assume like pointer annotation calls, and references in llvm.used
1899/// and llvm.compiler.used variables.
1900bool Function::hasAddressTaken(const User **PutOffender,
1901 bool IgnoreCallbackUses,
1902 bool IgnoreAssumeLikeCalls, bool IgnoreLLVMUsed,
1903 bool IgnoreARCAttachedCall,
1904 bool IgnoreCastedDirectCall) const {
1905 for (const Use &U : uses()) {
1906 const User *FU = U.getUser();
1907 if (isa<BlockAddress>(FU))
1908 continue;
1909
1910 if (IgnoreCallbackUses) {
1911 AbstractCallSite ACS(&U);
1912 if (ACS && ACS.isCallbackCall())
1913 continue;
1914 }
1915
1916 const auto *Call = dyn_cast<CallBase>(FU);
1917 if (!Call) {
1918 if (IgnoreAssumeLikeCalls &&
1919 isa<BitCastOperator, AddrSpaceCastOperator>(FU) &&
1920 all_of(FU->users(), [](const User *U) {
1921 if (const auto *I = dyn_cast<IntrinsicInst>(U))
1922 return I->isAssumeLikeIntrinsic();
1923 return false;
1924 })) {
1925 continue;
1926 }
1927
1928 if (IgnoreLLVMUsed && !FU->user_empty()) {
1929 const User *FUU = FU;
1930 if (isa<BitCastOperator, AddrSpaceCastOperator>(FU) &&
1931 FU->hasOneUse() && !FU->user_begin()->user_empty())
1932 FUU = *FU->user_begin();
1933 if (llvm::all_of(FUU->users(), [](const User *U) {
1934 if (const auto *GV = dyn_cast<GlobalVariable>(U))
1935 return GV->hasName() &&
1936 (GV->getName() == "llvm.compiler.used" ||
1937 GV->getName() == "llvm.used");
1938 return false;
1939 }))
1940 continue;
1941 }
1942 if (PutOffender)
1943 *PutOffender = FU;
1944 return true;
1945 }
1946
1947 if (IgnoreAssumeLikeCalls) {
1948 if (const auto *I = dyn_cast<IntrinsicInst>(Call))
1949 if (I->isAssumeLikeIntrinsic())
1950 continue;
1951 }
1952
1953 if (!Call->isCallee(&U) || (!IgnoreCastedDirectCall &&
1954 Call->getFunctionType() != getFunctionType())) {
1955 if (IgnoreARCAttachedCall &&
1956 Call->isOperandBundleOfType(LLVMContext::OB_clang_arc_attachedcall,
1957 U.getOperandNo()))
1958 continue;
1959
1960 if (PutOffender)
1961 *PutOffender = FU;
1962 return true;
1963 }
1964 }
1965 return false;
1966}
1967
1969 // Check the linkage
1970 if (!hasLinkOnceLinkage() && !hasLocalLinkage() &&
1972 return false;
1973
1974 // Check if the function is used by anything other than a blockaddress.
1975 for (const User *U : users())
1976 if (!isa<BlockAddress>(U))
1977 return false;
1978
1979 return true;
1980}
1981
1982/// callsFunctionThatReturnsTwice - Return true if the function has a call to
1983/// setjmp or other function that gcc recognizes as "returning twice".
1985 for (const Instruction &I : instructions(this))
1986 if (const auto *Call = dyn_cast<CallBase>(&I))
1987 if (Call->hasFnAttr(Attribute::ReturnsTwice))
1988 return true;
1989
1990 return false;
1991}
1992
1995 return cast<Constant>(Op<0>());
1996}
1997
1999 setHungoffOperand<0>(Fn);
2000 setValueSubclassDataBit(3, Fn != nullptr);
2001}
2002
2005 return cast<Constant>(Op<1>());
2006}
2007
2009 setHungoffOperand<1>(PrefixData);
2010 setValueSubclassDataBit(1, PrefixData != nullptr);
2011}
2012
2015 return cast<Constant>(Op<2>());
2016}
2017
2019 setHungoffOperand<2>(PrologueData);
2020 setValueSubclassDataBit(2, PrologueData != nullptr);
2021}
2022
2023void Function::allocHungoffUselist() {
2024 // If we've already allocated a uselist, stop here.
2025 if (getNumOperands())
2026 return;
2027
2028 allocHungoffUses(3, /*IsPhi=*/ false);
2030
2031 // Initialize the uselist with placeholder operands to allow traversal.
2033 Op<0>().set(CPN);
2034 Op<1>().set(CPN);
2035 Op<2>().set(CPN);
2036}
2037
2038template <int Idx>
2039void Function::setHungoffOperand(Constant *C) {
2040 if (C) {
2041 allocHungoffUselist();
2042 Op<Idx>().set(C);
2043 } else if (getNumOperands()) {
2045 }
2046}
2047
2048void Function::setValueSubclassDataBit(unsigned Bit, bool On) {
2049 assert(Bit < 16 && "SubclassData contains only 16 bits");
2050 if (On)
2051 setValueSubclassData(getSubclassDataFromValue() | (1 << Bit));
2052 else
2053 setValueSubclassData(getSubclassDataFromValue() & ~(1 << Bit));
2054}
2055
2057 const DenseSet<GlobalValue::GUID> *S) {
2058#if !defined(NDEBUG)
2059 auto PrevCount = getEntryCount();
2060 assert(!PrevCount || PrevCount->getType() == Count.getType());
2061#endif
2062
2063 auto ImportGUIDs = getImportGUIDs();
2064 if (S == nullptr && ImportGUIDs.size())
2065 S = &ImportGUIDs;
2066
2067 MDBuilder MDB(getContext());
2069 LLVMContext::MD_prof,
2070 MDB.createFunctionEntryCount(Count.getCount(), Count.isSynthetic(), S));
2071}
2072
2074 const DenseSet<GlobalValue::GUID> *Imports) {
2075 setEntryCount(ProfileCount(Count, Type), Imports);
2076}
2077
2078std::optional<ProfileCount> Function::getEntryCount(bool AllowSynthetic) const {
2079 MDNode *MD = getMetadata(LLVMContext::MD_prof);
2080 if (MD && MD->getOperand(0))
2081 if (MDString *MDS = dyn_cast<MDString>(MD->getOperand(0))) {
2082 if (MDS->getString() == "function_entry_count") {
2083 ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(1));
2084 uint64_t Count = CI->getValue().getZExtValue();
2085 // A value of -1 is used for SamplePGO when there were no samples.
2086 // Treat this the same as unknown.
2087 if (Count == (uint64_t)-1)
2088 return std::nullopt;
2089 return ProfileCount(Count, PCT_Real);
2090 } else if (AllowSynthetic &&
2091 MDS->getString() == "synthetic_function_entry_count") {
2092 ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(1));
2093 uint64_t Count = CI->getValue().getZExtValue();
2094 return ProfileCount(Count, PCT_Synthetic);
2095 }
2096 }
2097 return std::nullopt;
2098}
2099
2102 if (MDNode *MD = getMetadata(LLVMContext::MD_prof))
2103 if (MDString *MDS = dyn_cast<MDString>(MD->getOperand(0)))
2104 if (MDS->getString() == "function_entry_count")
2105 for (unsigned i = 2; i < MD->getNumOperands(); i++)
2106 R.insert(mdconst::extract<ConstantInt>(MD->getOperand(i))
2107 ->getValue()
2108 .getZExtValue());
2109 return R;
2110}
2111
2113 MDBuilder MDB(getContext());
2114 setMetadata(LLVMContext::MD_section_prefix,
2115 MDB.createFunctionSectionPrefix(Prefix));
2116}
2117
2118std::optional<StringRef> Function::getSectionPrefix() const {
2119 if (MDNode *MD = getMetadata(LLVMContext::MD_section_prefix)) {
2120 assert(cast<MDString>(MD->getOperand(0))->getString() ==
2121 "function_section_prefix" &&
2122 "Metadata not match");
2123 return cast<MDString>(MD->getOperand(1))->getString();
2124 }
2125 return std::nullopt;
2126}
2127
2129 return hasFnAttribute(Attribute::NullPointerIsValid);
2130}
2131
2132bool llvm::NullPointerIsDefined(const Function *F, unsigned AS) {
2133 if (F && F->nullPointerIsDefined())
2134 return true;
2135
2136 if (AS != 0)
2137 return true;
2138
2139 return false;
2140}
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Expand Atomic instructions
This file contains the simple types necessary to represent the attributes associated with functions a...
basic Basic Alias true
This file implements the BitVector class.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file defines the DenseSet and SmallDenseSet classes.
std::string Name
static Type * getMemoryParamAllocType(AttributeSet ParamAttrs)
For a byval, sret, inalloca, or preallocated parameter, get the in-memory parameter type.
Definition: Function.cpp:214
static cl::opt< int > NonGlobalValueMaxNameSize("non-global-value-max-name-size", cl::Hidden, cl::init(1024), cl::desc("Maximum size for the name of non-global values."))
static bool matchIntrinsicType(Type *Ty, ArrayRef< Intrinsic::IITDescriptor > &Infos, SmallVectorImpl< Type * > &ArgTys, SmallVectorImpl< DeferredIntrinsicMatchPair > &DeferredChecks, bool IsDeferredCheck)
Definition: Function.cpp:1586
static std::string getIntrinsicNameImpl(Intrinsic::ID Id, ArrayRef< Type * > Tys, Module *M, FunctionType *FT, bool EarlyModuleCheck)
Definition: Function.cpp:1103
static MutableArrayRef< Argument > makeArgArray(Argument *Args, size_t Count)
Definition: Function.cpp:565
std::pair< Type *, ArrayRef< Intrinsic::IITDescriptor > > DeferredIntrinsicMatchPair
Definition: Function.cpp:1584
static ArrayRef< const char * > findTargetSubtable(StringRef Name)
Find the segment of IntrinsicNameTable for intrinsics with the same target as Name,...
Definition: Function.cpp:963
static void DecodeIITType(unsigned &NextElt, ArrayRef< unsigned char > Infos, IIT_Info LastInfo, SmallVectorImpl< Intrinsic::IITDescriptor > &OutputTable)
Definition: Function.cpp:1150
IIT_Info
IIT_Info - These are enumerators that describe the entries returned by the getIntrinsicInfoTableEntri...
Definition: Function.cpp:1144
static Type * DecodeFixedType(ArrayRef< Intrinsic::IITDescriptor > &Infos, ArrayRef< Type * > Tys, LLVMContext &Context)
Definition: Function.cpp:1415
static const char *const IntrinsicNameTable[]
Table of string intrinsic names indexed by enum value.
Definition: Function.cpp:939
static std::string getMangledTypeStr(Type *Ty, bool &HasUnnamedType)
Returns a stable mangling for the type specified for use in the name mangling scheme used by 'any' ty...
Definition: Function.cpp:1024
static unsigned computeAddrSpace(unsigned AddrSpace, Module *M)
Definition: Function.cpp:494
cl::opt< bool > UseNewDbgInfoFormat
#define Check(C,...)
This defines the Use class.
iv users
Definition: IVUsers.cpp:48
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
This file contains the declarations for metadata subclasses.
Module.h This file contains the declarations for the Module class.
llvm::cl::opt< bool > UseNewDbgInfoFormat
static StringRef getName(Value *V)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static const char * name
Definition: SMEABIPass.cpp:50
This file contains some templates that are useful if you are working with the STL at all.
This file defines the SmallString class.
This file defines the SmallVector class.
This file contains some functions that are useful when dealing with strings.
static SymbolRef::Type getType(const Symbol *Sym)
Definition: TapiFile.cpp:40
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
uint64_t getZExtValue() const
Get zero extended value.
Definition: APInt.h:1500
AbstractCallSite.
bool isCallbackCall() const
Return true if this ACS represents a callback call.
This class represents an incoming formal argument to a Function.
Definition: Argument.h:31
Type * getParamByRefType() const
If this is a byref argument, return its type.
Definition: Function.cpp:264
Attribute getAttribute(Attribute::AttrKind Kind) const
Definition: Function.cpp:372
bool hasNoAliasAttr() const
Return true if this argument has the noalias attribute.
Definition: Function.cpp:302
bool hasNonNullAttr(bool AllowUndefOrPoison=true) const
Return true if this argument has the nonnull attribute.
Definition: Function.cpp:150
bool hasByRefAttr() const
Return true if this argument has the byref attribute.
Definition: Function.cpp:168
uint64_t getDereferenceableOrNullBytes() const
If this argument has the dereferenceable_or_null attribute, return the number of bytes known to be de...
Definition: Function.cpp:280
void addAttr(Attribute::AttrKind Kind)
Definition: Function.cpp:350
Argument(Type *Ty, const Twine &Name="", Function *F=nullptr, unsigned ArgNo=0)
Argument constructor.
Definition: Function.cpp:141
bool onlyReadsMemory() const
Return true if this argument has the readonly or readnone attribute.
Definition: Function.cpp:338
bool hasPointeeInMemoryValueAttr() const
Return true if this argument has the byval, sret, inalloca, preallocated, or byref attribute.
Definition: Function.cpp:201
bool hasAttribute(Attribute::AttrKind Kind) const
Check if an argument has a given attribute.
Definition: Function.cpp:368
bool hasReturnedAttr() const
Return true if this argument has the returned attribute.
Definition: Function.cpp:326
Type * getParamStructRetType() const
If this is an sret argument, return its type.
Definition: Function.cpp:259
bool hasInRegAttr() const
Return true if this argument has the inreg attribute.
Definition: Function.cpp:322
bool hasByValAttr() const
Return true if this argument has the byval attribute.
Definition: Function.cpp:163
bool hasPreallocatedAttr() const
Return true if this argument has the preallocated attribute.
Definition: Function.cpp:187
bool hasSExtAttr() const
Return true if this argument has the sext attribute.
Definition: Function.cpp:334
void removeAttr(Attribute::AttrKind Kind)
Remove attributes from an argument.
Definition: Function.cpp:358
uint64_t getPassPointeeByValueCopySize(const DataLayout &DL) const
If this argument satisfies has hasPassPointeeByValueAttr, return the in-memory ABI size copied to the...
Definition: Function.cpp:231
void removeAttrs(const AttributeMask &AM)
Definition: Function.cpp:362
const Function * getParent() const
Definition: Argument.h:43
Type * getPointeeInMemoryValueType() const
If hasPointeeInMemoryValueAttr returns true, the in-memory ABI type is returned.
Definition: Function.cpp:239
bool hasInAllocaAttr() const
Return true if this argument has the inalloca attribute.
Definition: Function.cpp:182
bool hasSwiftErrorAttr() const
Return true if this argument has the swifterror attribute.
Definition: Function.cpp:178
FPClassTest getNoFPClass() const
If this argument has nofpclass attribute, return the mask representing disallowed floating-point valu...
Definition: Function.cpp:286
void addAttrs(AttrBuilder &B)
Add attributes to an argument.
Definition: Function.cpp:344
bool hasNoFreeAttr() const
Return true if this argument has the nofree attribute.
Definition: Function.cpp:312
bool hasSwiftSelfAttr() const
Return true if this argument has the swiftself attribute.
Definition: Function.cpp:174
Type * getParamInAllocaType() const
If this is an inalloca argument, return its type.
Definition: Function.cpp:269
bool hasZExtAttr() const
Return true if this argument has the zext attribute.
Definition: Function.cpp:330
unsigned getArgNo() const
Return the index of this formal argument in its containing function.
Definition: Argument.h:49
Type * getParamByValType() const
If this is a byval argument, return its type.
Definition: Function.cpp:254
bool hasNestAttr() const
Return true if this argument has the nest attribute.
Definition: Function.cpp:297
MaybeAlign getParamAlign() const
If this is a byval or inalloca argument, return its alignment.
Definition: Function.cpp:245
std::optional< ConstantRange > getRange() const
If this argument has a range attribute, return the value range of the argument.
Definition: Function.cpp:290
bool hasStructRetAttr() const
Return true if this argument has the sret attribute.
Definition: Function.cpp:317
bool hasPassPointeeByValueCopyAttr() const
Return true if this argument has the byval, inalloca, or preallocated attribute.
Definition: Function.cpp:193
MaybeAlign getParamStackAlign() const
Definition: Function.cpp:250
bool hasNoCaptureAttr() const
Return true if this argument has the nocapture attribute.
Definition: Function.cpp:307
uint64_t getDereferenceableBytes() const
If this argument has the dereferenceable attribute, return the number of bytes known to be dereferenc...
Definition: Function.cpp:274
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
const T & front() const
front - Get the first element.
Definition: ArrayRef.h:168
iterator end() const
Definition: ArrayRef.h:154
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:165
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:160
const T * data() const
Definition: ArrayRef.h:162
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
Definition: ArrayRef.h:195
AttributeList addDereferenceableParamAttr(LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const
Add the dereferenceable attribute to the attribute set at the given arg index.
AttributeList removeAttributeAtIndex(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified index from this attribute list.
AttributeList removeParamAttributes(LLVMContext &C, unsigned ArgNo, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the specified arg index from this attribute list.
Definition: Attributes.h:725
AttributeList addRangeRetAttr(LLVMContext &C, const ConstantRange &CR) const
Add the range attribute to the attribute set at the return value index.
AttributeList addRetAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add a return value attribute to the list.
Definition: Attributes.h:584
AttributeList addRetAttributes(LLVMContext &C, const AttrBuilder &B) const
Add a return value attribute to the list.
Definition: Attributes.h:598
AttributeList removeRetAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the return value index from this attribute list.
Definition: Attributes.h:702
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return the attribute object that exists at the arg index.
Definition: Attributes.h:854
AttributeList addFnAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add a function attribute to the list.
Definition: Attributes.h:555
AttributeList addFnAttributes(LLVMContext &C, const AttrBuilder &B) const
Add function attribute to the list.
Definition: Attributes.h:577
bool hasFnAttr(Attribute::AttrKind Kind) const
Return true if the attribute exists for the function.
Attribute getFnAttr(Attribute::AttrKind Kind) const
Return the attribute object that exists for the function.
Definition: Attributes.h:864
Attribute getAttributeAtIndex(unsigned Index, Attribute::AttrKind Kind) const
Return the attribute object that exists at the given index.
AttributeList removeParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Remove the specified attribute at the specified arg index from this attribute list.
Definition: Attributes.h:710
bool hasParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Return true if the attribute exists for the given argument.
Definition: Attributes.h:805
Attribute getRetAttr(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind for the return value.
Definition: Attributes.h:874
AttributeList removeFnAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute at the function index from this attribute list.
Definition: Attributes.h:661
AttributeList addDereferenceableOrNullParamAttr(LLVMContext &C, unsigned ArgNo, uint64_t Bytes) const
Add the dereferenceable_or_null attribute to the attribute set at the given arg index.
AttributeList removeFnAttributes(LLVMContext &C, const AttributeMask &AttrsToRemove) const
Remove the specified attribute at the function index from this attribute list.
Definition: Attributes.h:675
AttributeList addAttributeAtIndex(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Add an attribute to the attribute set at the given index.
AttributeSet getParamAttrs(unsigned ArgNo) const
The attributes for the argument or parameter at the given index are returned.
AttributeList addParamAttributes(LLVMContext &C, unsigned ArgNo, const AttrBuilder &B) const
Add an argument attribute to the list.
Definition: Attributes.h:627
AttributeList removeRetAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Remove the specified attribute at the return value index from this attribute list.
Definition: Attributes.h:688
AttributeList addParamAttribute(LLVMContext &C, unsigned ArgNo, Attribute::AttrKind Kind) const
Add an argument attribute to the list.
Definition: Attributes.h:606
MemoryEffects getMemoryEffects() const
Returns memory effects of the function.
bool hasRetAttr(Attribute::AttrKind Kind) const
Return true if the attribute exists for the return value.
Definition: Attributes.h:820
Type * getInAllocaType() const
Definition: Attributes.cpp:958
Type * getByValType() const
Definition: Attributes.cpp:946
Type * getStructRetType() const
Definition: Attributes.cpp:950
Type * getPreallocatedType() const
Definition: Attributes.cpp:954
Type * getByRefType() const
Definition: Attributes.cpp:942
const ConstantRange & getRange() const
Returns the value of the range attribute.
Definition: Attributes.cpp:496
StringRef getValueAsString() const
Return the attribute's value as a string.
Definition: Attributes.cpp:392
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
Definition: Attributes.h:86
static Attribute getWithMemoryEffects(LLVMContext &Context, MemoryEffects ME)
Definition: Attributes.cpp:280
bool isValid() const
Return true if the attribute is any kind of attribute.
Definition: Attributes.h:203
LLVM Basic Block Representation.
Definition: BasicBlock.h:61
void dropAllReferences()
Cause all subinstructions to "let go" of all the references that said subinstructions are maintaining...
Definition: BasicBlock.cpp:454
This is the shared class of boolean and integer constants.
Definition: Constants.h:81
const APInt & getValue() const
Return the constant as an APInt value reference.
Definition: Constants.h:146
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
Definition: Constants.cpp:1800
This class represents a range of values.
Definition: ConstantRange.h:47
This is an important base class in LLVM.
Definition: Constant.h:42
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:103
Implements a dense probed hash-table based set.
Definition: DenseSet.h:271
Class to represent fixed width SIMD vectors.
Definition: DerivedTypes.h:539
unsigned getNumElements() const
Definition: DerivedTypes.h:582
static FixedVectorType * get(Type *ElementType, unsigned NumElts)
Definition: Type.cpp:680
Class to represent function types.
Definition: DerivedTypes.h:103
ArrayRef< Type * > params() const
Definition: DerivedTypes.h:130
bool isVarArg() const
Definition: DerivedTypes.h:123
Type * getReturnType() const
Definition: DerivedTypes.h:124
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
Class to represent profile counts.
Definition: Function.h:296
uint64_t getCount() const
Definition: Function.h:304
ProfileCountType getType() const
Definition: Function.h:305
void addFnAttr(Attribute::AttrKind Kind)
Add function attributes to this function.
Definition: Function.cpp:653
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
Definition: Function.h:172
void addParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs)
adds the attributes to the list of attributes for the given arg.
Definition: Function.cpp:689
void removeRetAttr(Attribute::AttrKind Kind)
removes the attribute from the return value list of attributes.
Definition: Function.cpp:713
void addRetAttrs(const AttrBuilder &Attrs)
Add return value attributes to this function.
Definition: Function.cpp:677
std::optional< StringRef > getSectionPrefix() const
Get the section prefix for this function.
Definition: Function.cpp:2118
bool isDefTriviallyDead() const
isDefTriviallyDead - Return true if it is trivially safe to remove this function definition from the ...
Definition: Function.cpp:1968
bool onlyAccessesInaccessibleMemOrArgMem() const
Determine if the function may only access memory that is either inaccessible from the IR or pointed t...
Definition: Function.cpp:930
void splice(Function::iterator ToIt, Function *FromF)
Transfer all blocks from FromF to this function at ToIt.
Definition: Function.h:759
BasicBlockListType::iterator iterator
Definition: Function.h:69
bool hasAddressTaken(const User **=nullptr, bool IgnoreCallbackUses=false, bool IgnoreAssumeLikeCalls=true, bool IngoreLLVMUsed=false, bool IgnoreARCAttachedCall=false, bool IgnoreCastedDirectCall=false) const
hasAddressTaken - returns true if there are any uses of this function other than direct calls or invo...
Definition: Function.cpp:1900
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
removes the attribute from the list of attributes.
Definition: Function.cpp:725
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Definition: Function.h:214
bool nullPointerIsDefined() const
Check if null pointer dereferencing is considered undefined behavior for the function.
Definition: Function.cpp:2128
Attribute getParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const
gets the specified attribute from the list of attributes.
Definition: Function.cpp:795
void setPrefixData(Constant *PrefixData)
Definition: Function.cpp:2008
bool hasStackProtectorFnAttr() const
Returns true if the function has ssp, sspstrong, or sspreq fn attrs.
Definition: Function.cpp:855
void removeFromParent()
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it.
Definition: Function.cpp:465
const DataLayout & getDataLayout() const
Get the data layout of the module this function belongs to.
Definition: Function.cpp:384
void addFnAttrs(const AttrBuilder &Attrs)
Add function attributes to this function.
Definition: Function.cpp:665
void renumberBlocks()
Renumber basic blocks into a dense value range starting from 0.
Definition: Function.cpp:89
void setDoesNotAccessMemory()
Definition: Function.cpp:890
static Intrinsic::ID lookupIntrinsicID(StringRef Name)
This does the actual lookup of an intrinsic ID which matches the given function name.
Definition: Function.cpp:980
void setGC(std::string Str)
Definition: Function.cpp:843
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
Definition: Function.cpp:769
uint64_t getFnAttributeAsParsedInteger(StringRef Kind, uint64_t Default=0) const
For a string attribute Kind, parse attribute as an integer.
Definition: Function.cpp:781
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
Definition: Function.h:249
bool isConstrainedFPIntrinsic() const
Returns true if the function is one of the "Constrained Floating-Point Intrinsics".
Definition: Function.cpp:569
void setOnlyAccessesArgMemory()
Definition: Function.cpp:915
MemoryEffects getMemoryEffects() const
Definition: Function.cpp:879
void setOnlyAccessesInaccessibleMemory()
Definition: Function.cpp:924
void removeParamAttrs(unsigned ArgNo, const AttributeMask &Attrs)
removes the attribute from the list of attributes.
Definition: Function.cpp:733
void setIsMaterializable(bool V)
Definition: Function.h:237
uint64_t getParamDereferenceableBytes(unsigned ArgNo) const
Extract the number of dereferenceable bytes for a parameter.
Definition: Function.h:521
bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const
check if an attributes is in the list of attributes.
Definition: Function.cpp:755
static Function * createWithDefaultAttr(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
Creates a function with some attributes recorded in llvm.module.flags and the LLVMContext applied.
Definition: Function.cpp:401
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
Definition: Function.h:349
bool IsNewDbgInfoFormat
Is this function using intrinsics to record the position of debugging information,...
Definition: Function.h:115
void setSectionPrefix(StringRef Prefix)
Set the section prefix for this function.
Definition: Function.cpp:2112
void setOnlyReadsMemory()
Definition: Function.cpp:898
bool isTargetIntrinsic() const
isTargetIntrinsic - Returns true if this function is an intrinsic and the intrinsic is specific to a ...
Definition: Function.cpp:955
Type * getParamByValType(unsigned ArgNo) const
Extract the byval type for a parameter.
Definition: Function.h:495
FPClassTest getParamNoFPClass(unsigned ArgNo) const
Extract the nofpclass attribute for a parameter.
Definition: Function.h:533
void removeFnAttrs(const AttributeMask &Attrs)
Definition: Function.cpp:709
DenormalMode getDenormalModeRaw() const
Return the representational value of "denormal-fp-math".
Definition: Function.cpp:822
bool hasPrefixData() const
Check whether this function has prefix data.
Definition: Function.h:912
bool hasPersonalityFn() const
Check whether this function has a personality function.
Definition: Function.h:903
void addRetAttr(Attribute::AttrKind Kind)
Add return value attributes to this function.
Definition: Function.cpp:669
DenormalMode getDenormalModeF32Raw() const
Return the representational value of "denormal-fp-math-f32".
Definition: Function.cpp:828
Constant * getPrologueData() const
Get the prologue data associated with this function.
Definition: Function.cpp:2013
void convertFromNewDbgValues()
Definition: Function.cpp:117
Constant * getPersonalityFn() const
Get the personality function associated with this function.
Definition: Function.cpp:1993
void setOnlyWritesMemory()
Definition: Function.cpp:906
void setPersonalityFn(Constant *Fn)
Definition: Function.cpp:1998
AttributeList getAttributes() const
Return the attribute list for this Function.
Definition: Function.h:357
void dropAllReferences()
dropAllReferences() - This method causes all the subinstructions to "let go" of all references that t...
Definition: Function.h:975
DenseSet< GlobalValue::GUID > getImportGUIDs() const
Returns the set of GUIDs that needs to be imported to the function for sample PGO,...
Definition: Function.cpp:2100
Type * getParamByRefType(unsigned ArgNo) const
Extract the byref type for a parameter.
Definition: Function.h:510
void removeAttributeAtIndex(unsigned i, Attribute::AttrKind Kind)
removes the attribute from the list of attributes.
Definition: Function.cpp:693
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
Definition: Function.cpp:469
uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const
Extract the number of dereferenceable_or_null bytes for a parameter.
Definition: Function.h:528
void removeFnAttr(Attribute::AttrKind Kind)
Remove function attributes from this function.
Definition: Function.cpp:701
void addDereferenceableOrNullParamAttr(unsigned ArgNo, uint64_t Bytes)
adds the dereferenceable_or_null attribute to the list of attributes for the given arg.
Definition: Function.cpp:800
void addRangeRetAttr(const ConstantRange &CR)
adds the range attribute to the list of attributes for the return value.
Definition: Function.cpp:806
MaybeAlign getParamAlign(unsigned ArgNo) const
Definition: Function.h:486
void stealArgumentListFrom(Function &Src)
Steal arguments from another function.
Definition: Function.cpp:582
void setAttributes(AttributeList Attrs)
Set the attribute list for this Function.
Definition: Function.h:360
void setNewDbgInfoFormatFlag(bool NewVal)
Definition: Function.cpp:130
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
Definition: Function.cpp:380
const std::string & getGC() const
Definition: Function.cpp:838
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
adds the attribute to the list of attributes for the given arg.
Definition: Function.cpp:681
bool doesNotAccessMemory() const
Determine if the function does not access memory.
Definition: Function.cpp:887
DenormalMode getDenormalMode(const fltSemantics &FPType) const
Returns the denormal handling type for the default rounding mode of the function.
Definition: Function.cpp:810
Type * getParamInAllocaType(unsigned ArgNo) const
Extract the inalloca type for a parameter.
Definition: Function.h:505
void updateAfterNameChange()
Update internal caches that depend on the function name (such as the intrinsic ID and libcall cache).
Definition: Function.cpp:1000
bool callsFunctionThatReturnsTwice() const
callsFunctionThatReturnsTwice - Return true if the function has a call to setjmp or other function th...
Definition: Function.cpp:1984
bool hasRetAttribute(Attribute::AttrKind Kind) const
check if an attribute is in the list of attributes for the return value.
Definition: Function.cpp:751
bool onlyWritesMemory() const
Determine if the function does not access or only writes memory.
Definition: Function.cpp:903
std::optional< ProfileCount > getEntryCount(bool AllowSynthetic=false) const
Get the entry count for this function.
Definition: Function.cpp:2078
bool onlyAccessesInaccessibleMemory() const
Determine if the function may only access memory that is inaccessible from the IR.
Definition: Function.cpp:921
MaybeAlign getParamStackAlign(unsigned ArgNo) const
Definition: Function.h:490
size_t arg_size() const
Definition: Function.h:899
void setPrologueData(Constant *PrologueData)
Definition: Function.cpp:2018
void removeRetAttrs(const AttributeMask &Attrs)
removes the attributes from the return value list of attributes.
Definition: Function.cpp:721
void setIsNewDbgInfoFormat(bool NewVal)
Definition: Function.cpp:124
void clearGC()
Definition: Function.cpp:848
bool hasLazyArguments() const
hasLazyArguments/CheckLazyArguments - The argument list of a function is built on demand,...
Definition: Function.h:121
bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
Definition: Function.cpp:912
Function::iterator erase(Function::iterator FromIt, Function::iterator ToIt)
Erases a range of BasicBlocks from FromIt to (not including) ToIt.
Definition: Function.cpp:485
void setMemoryEffects(MemoryEffects ME)
Definition: Function.cpp:882
Constant * getPrefixData() const
Get the prefix data associated with this function.
Definition: Function.cpp:2003
Attribute getAttributeAtIndex(unsigned i, Attribute::AttrKind Kind) const
gets the attribute from the list of attributes.
Definition: Function.cpp:760
iterator end()
Definition: Function.h:853
void setCallingConv(CallingConv::ID CC)
Definition: Function.h:285
void convertToNewDbgValues()
Definition: Function.cpp:110
void setOnlyAccessesInaccessibleMemOrArgMem()
Definition: Function.cpp:933
bool hasPrologueData() const
Check whether this function has prologue data.
Definition: Function.h:921
Type * getParamStructRetType(unsigned ArgNo) const
Extract the sret type for a parameter.
Definition: Function.h:500
void setEntryCount(ProfileCount Count, const DenseSet< GlobalValue::GUID > *Imports=nullptr)
Set the entry count for this function.
Definition: Function.cpp:2056
void addDereferenceableParamAttr(unsigned ArgNo, uint64_t Bytes)
adds the dereferenceable attribute to the list of attributes for the given arg.
Definition: Function.cpp:738
unsigned getInstructionCount() const
Returns the number of non-debug IR instructions in this function.
Definition: Function.cpp:388
bool onlyReadsMemory() const
Determine if the function does not access or only reads memory.
Definition: Function.cpp:895
void addAttributeAtIndex(unsigned i, Attribute Attr)
adds the attribute to the list of attributes.
Definition: Function.cpp:649
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.cpp:743
void copyAttributesFrom(const Function *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...
Definition: Function.cpp:863
Attribute getRetAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind for the return value.
Definition: Function.cpp:777
void setMetadata(unsigned KindID, MDNode *Node)
Set a particular kind of metadata attachment.
Definition: Metadata.cpp:1494
void copyAttributesFrom(const GlobalObject *Src)
Definition: Globals.cpp:147
void clearMetadata()
Erase all metadata attached to this Value.
Definition: Metadata.cpp:1566
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
Definition: Value.h:565
bool hasLinkOnceLinkage() const
Definition: GlobalValue.h:515
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
Definition: Globals.cpp:290
bool hasLocalLinkage() const
Definition: GlobalValue.h:528
Intrinsic::ID IntID
The intrinsic ID for this subclass (which must be a Function).
Definition: GlobalValue.h:173
unsigned HasLLVMReservedName
True if the function's name starts with "llvm.".
Definition: GlobalValue.h:109
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:656
PointerType * getType() const
Global values are always pointers.
Definition: GlobalValue.h:294
unsigned Linkage
Definition: GlobalValue.h:98
bool hasAvailableExternallyLinkage() const
Definition: GlobalValue.h:512
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:51
Class to represent integer types.
Definition: DerivedTypes.h:40
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition: Type.cpp:266
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
Definition: DerivedTypes.h:72
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
void deleteGC(const Function &Fn)
Remove the GC for a function.
const std::string & getGC(const Function &Fn)
Return the GC for a function.
void setGC(const Function &Fn, std::string GCName)
Define the GC for a function.
void emitError(uint64_t LocCookie, const Twine &ErrorStr)
emitError - Emit an error message to the currently installed error handler with optional location inf...
MDNode * createFunctionEntryCount(uint64_t Count, bool Synthetic, const DenseSet< GlobalValue::GUID > *Imports)
Return metadata containing the entry Count for a function, a boolean \Synthetic indicating whether th...
Definition: MDBuilder.cpp:73
MDNode * createFunctionSectionPrefix(StringRef Prefix)
Return metadata containing the section prefix for a function.
Definition: MDBuilder.cpp:92
Metadata node.
Definition: Metadata.h:1069
const MDOperand & getOperand(unsigned I) const
Definition: Metadata.h:1430
A single uniqued string.
Definition: Metadata.h:720
static MemoryEffectsBase readOnly()
Create MemoryEffectsBase that can read any memory.
Definition: ModRef.h:122
bool onlyWritesMemory() const
Whether this function only (at most) writes memory.
Definition: ModRef.h:198
bool doesNotAccessMemory() const
Whether this function accesses no memory.
Definition: ModRef.h:192
static MemoryEffectsBase argMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
Create MemoryEffectsBase that can only access argument memory.
Definition: ModRef.h:132
static MemoryEffectsBase inaccessibleMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
Create MemoryEffectsBase that can only access inaccessible memory.
Definition: ModRef.h:138
bool onlyAccessesInaccessibleMem() const
Whether this function only (at most) accesses inaccessible memory.
Definition: ModRef.h:211
bool onlyAccessesArgPointees() const
Whether this function only (at most) accesses argument memory.
Definition: ModRef.h:201
bool onlyReadsMemory() const
Whether this function only (at most) reads memory.
Definition: ModRef.h:195
static MemoryEffectsBase writeOnly()
Create MemoryEffectsBase that can write any memory.
Definition: ModRef.h:127
static MemoryEffectsBase inaccessibleOrArgMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
Create MemoryEffectsBase that can only access inaccessible or argument memory.
Definition: ModRef.h:145
static MemoryEffectsBase none()
Create MemoryEffectsBase that cannot read or write any memory.
Definition: ModRef.h:117
bool onlyAccessesInaccessibleOrArgMem() const
Whether this function only (at most) accesses argument and inaccessible memory.
Definition: ModRef.h:217
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
bool IsNewDbgInfoFormat
Is this Module using intrinsics to record the position of debugging information, or non-intrinsic rec...
Definition: Module.h:217
const FunctionListType & getFunctionList() const
Get the Module's list of functions (constant).
Definition: Module.h:611
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Definition: Module.h:291
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:307
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
bool empty() const
Definition: SmallVector.h:95
size_t size() const
Definition: SmallVector.h:92
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:587
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:951
void push_back(const T &Elt)
Definition: SmallVector.h:427
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1210
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition: StringRef.h:250
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:134
Class to represent struct types.
Definition: DerivedTypes.h:216
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
Definition: Type.cpp:361
Class to represent target extensions types, which are generally unintrospectable from target-independ...
Definition: DerivedTypes.h:720
static TargetExtType * get(LLVMContext &Context, StringRef Name, ArrayRef< Type * > Types=std::nullopt, ArrayRef< unsigned > Ints=std::nullopt)
Return a target extension type having the specified name and optional type and integer parameters.
Definition: Type.cpp:784
Target - Wrapper for Target specific information.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
static Type * getHalfTy(LLVMContext &C)
static Type * getDoubleTy(LLVMContext &C)
static Type * getBFloatTy(LLVMContext &C)
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
Definition: Type.h:230
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
Definition: Type.h:153
static Type * getX86_AMXTy(LLVMContext &C)
bool isBFloatTy() const
Return true if this is 'bfloat', a 16-bit bfloat type.
Definition: Type.h:145
static Type * getMetadataTy(LLVMContext &C)
@ X86_AMXTyID
AMX vectors (8192 bits, X86 specific)
Definition: Type.h:66
@ HalfTyID
16-bit floating point type
Definition: Type.h:56
@ VoidTyID
type with no size
Definition: Type.h:63
@ FloatTyID
32-bit floating point type
Definition: Type.h:58
@ IntegerTyID
Arbitrary bit width integers.
Definition: Type.h:70
@ BFloatTyID
16-bit floating point type (7-bit significand)
Definition: Type.h:57
@ DoubleTyID
64-bit floating point type
Definition: Type.h:59
@ X86_FP80TyID
80-bit floating point type (X87)
Definition: Type.h:60
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
Definition: Type.h:62
@ MetadataTyID
Metadata.
Definition: Type.h:65
@ FP128TyID
128-bit floating point type (112-bit significand)
Definition: Type.h:61
bool isPPC_FP128Ty() const
Return true if this is powerpc long double.
Definition: Type.h:165
bool isFP128Ty() const
Return true if this is 'fp128'.
Definition: Type.h:162
static Type * getVoidTy(LLVMContext &C)
static Type * getFP128Ty(LLVMContext &C)
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
Definition: Type.h:142
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition: Type.h:128
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
Definition: Type.h:156
static Type * getTokenTy(LLVMContext &C)
bool isX86_AMXTy() const
Return true if this is X86 AMX.
Definition: Type.h:200
static Type * getFloatTy(LLVMContext &C)
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition: Type.h:224
TypeID getTypeID() const
Return the type id for the type.
Definition: Type.h:136
bool isTokenTy() const
Return true if this is 'token'.
Definition: Type.h:221
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
Definition: Type.h:212
static Type * getPPC_FP128Ty(LLVMContext &C)
bool isVoidTy() const
Return true if this is 'void'.
Definition: Type.h:139
bool isMetadataTy() const
Return true if this is 'metadata'.
Definition: Type.h:218
A Use represents the edge between a Value definition and its users.
Definition: Use.h:43
void allocHungoffUses(unsigned N, bool IsPhi=false)
Allocate the array of Uses, followed by a pointer (with bottom bit set) to the User.
Definition: User.cpp:50
void dropAllReferences()
Drop all references to operands.
Definition: User.h:299
void setNumHungOffUseOperands(unsigned NumOps)
Subclasses with hung off uses need to manage the operand count themselves.
Definition: User.h:215
unsigned getNumOperands() const
Definition: User.h:191
LLVM Value Representation.
Definition: Value.h:74
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
unsigned short getSubclassDataFromValue() const
Definition: Value.h:866
user_iterator user_begin()
Definition: Value.h:397
void setName(const Twine &Name)
Change the name of the value.
Definition: Value.cpp:377
bool hasOneUse() const
Return true if there is exactly one use of this value.
Definition: Value.h:434
iterator_range< user_iterator > users()
Definition: Value.h:421
iterator_range< use_iterator > uses()
Definition: Value.h:376
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:309
bool user_empty() const
Definition: Value.h:385
static VectorType * getHalfElementsVectorType(VectorType *VTy)
This static method returns a VectorType with half as many elements as the input type and the same ele...
Definition: DerivedTypes.h:507
static VectorType * getExtendedElementVectorType(VectorType *VTy)
This static method is like getInteger except that the element types are twice as wide as the elements...
Definition: DerivedTypes.h:463
static VectorType * getSubdividedVectorType(VectorType *VTy, int NumSubdivs)
Definition: DerivedTypes.h:497
static VectorType * getInteger(VectorType *VTy)
This static method gets a VectorType with the same number of elements as the input type,...
Definition: DerivedTypes.h:454
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
Definition: Type.cpp:664
static VectorType * getTruncatedElementVectorType(VectorType *VTy)
Definition: DerivedTypes.h:472
Type * getElementType() const
Definition: DerivedTypes.h:436
size_type size() const
Definition: DenseSet.h:81
self_iterator getIterator()
Definition: ilist_node.h:132
void splice(iterator where, iplist_impl &L2)
Definition: ilist.h:266
void push_back(pointer val)
Definition: ilist.h:250
iterator erase(iterator where)
Definition: ilist.h:204
pointer remove(iterator &IT)
Definition: ilist.h:188
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=std::nullopt)
Return the function type for an intrinsic.
Definition: Function.cpp:1507
MatchIntrinsicTypesResult matchIntrinsicSignature(FunctionType *FTy, ArrayRef< IITDescriptor > &Infos, SmallVectorImpl< Type * > &ArgTys)
Match the specified function type with the type constraints specified by the .td file.
Definition: Function.cpp:1794
void getIntrinsicInfoTableEntries(ID id, SmallVectorImpl< IITDescriptor > &T)
Return the IIT table descriptor for the specified intrinsic into an array of IITDescriptors.
Definition: Function.cpp:1382
@ MatchIntrinsicTypes_Match
Definition: Intrinsics.h:217
@ MatchIntrinsicTypes_NoMatchRet
Definition: Intrinsics.h:218
@ MatchIntrinsicTypes_NoMatchArg
Definition: Intrinsics.h:219
int lookupLLVMIntrinsicByName(ArrayRef< const char * > NameTable, StringRef Name)
Looks up Name in NameTable via binary search.
std::string getNameNoUnnamedTypes(ID Id, ArrayRef< Type * > Tys)
Return the LLVM name for an intrinsic.
Definition: Function.cpp:1136
std::optional< Function * > remangleIntrinsicFunction(Function *F)
Definition: Function.cpp:1863
bool hasConstrainedFPRoundingModeOperand(ID QID)
Returns true if the intrinsic ID is for one of the "Constrained Floating-Point Intrinsics" that take ...
Definition: Function.cpp:1571
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
Definition: Function.cpp:1096
bool isConstrainedFPIntrinsic(ID QID)
Returns true if the intrinsic ID is for one of the "Constrained Floating-Point Intrinsics".
Definition: Function.cpp:1559
AttributeList getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
StringRef getBaseName(ID id)
Return the LLVM name for an intrinsic, without encoded types for overloading, such as "llvm....
Definition: Function.cpp:1091
bool isOverloaded(ID id)
Returns true if the intrinsic can be overloaded.
Definition: Function.cpp:1528
bool getIntrinsicSignature(Intrinsic::ID, FunctionType *FT, SmallVectorImpl< Type * > &ArgTys)
Gets the type arguments of an intrinsic call by matching type contraints specified by the ....
Definition: Function.cpp:1839
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=std::nullopt)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
Definition: Function.cpp:1539
bool matchIntrinsicVarArg(bool isVarArg, ArrayRef< IITDescriptor > &Infos)
Verify if the intrinsic has variable arguments.
Definition: Function.cpp:1820
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:443
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1722
unsigned getPointerAddressSpace(const Type *T)
Definition: SPIRVUtils.h:126
auto partition_point(R &&Range, Predicate P)
Binary search for the first iterator in a range where a predicate is false.
Definition: STLExtras.h:2008
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1729
UWTableKind
Definition: CodeGen.h:120
@ None
No unwind table requested.
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
bool NullPointerIsDefined(const Function *F, unsigned AS=0)
Check whether null pointer dereferencing is considered undefined behavior for a given function or an ...
Definition: Function.cpp:2132
bool isPointerTy(const Type *T)
Definition: SPIRVUtils.h:120
DenormalMode parseDenormalFPAttribute(StringRef Str)
Returns the denormal mode to use for inputs and outputs.
@ Default
The result values are uniform if and only if all operands are uniform.
#define N
static const fltSemantics & IEEEsingle() LLVM_READNONE
Definition: APFloat.cpp:281
Helper struct shared between Function Specialization and SCCP Solver.
Definition: SCCPSolver.h:41
Represent subnormal handling kind for floating point instruction inputs and outputs.
static constexpr DenormalMode getInvalid()
This is a type descriptor which explains the type requirements of an intrinsic.
Definition: Intrinsics.h:118
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition: Alignment.h:117
Compile-time customization of User operands.
Definition: User.h:42