LLVM: lib/CodeGen/PreISelIntrinsicLowering.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
42
43using namespace llvm;
44
45
46
47
49 "mem-intrinsic-expand-size",
50 cl::desc("Set minimum mem intrinsic size to expand in IR"), cl::init(-1),
52
53namespace {
54
55struct PreISelIntrinsicLowering {
60
61
62
63
64 const bool UseMemIntrinsicLibFunc;
65
66 explicit PreISelIntrinsicLowering(
71 bool UseMemIntrinsicLibFunc_ = true)
72 : TM(TM_), ModuleLibcalls(ModuleLibcalls_), LookupTTI(LookupTTI_),
73 LookupTLI(LookupTLI_), UseMemIntrinsicLibFunc(UseMemIntrinsicLibFunc_) {
74 }
75
76 static bool shouldExpandMemIntrinsicWithSize(Value *Size,
77 const TargetTransformInfo &TTI);
78 bool
79 expandMemIntrinsicUses(Function &F,
80 DenseMap<Constant *, GlobalVariable *> &CMap) const;
81 bool lowerIntrinsics(Module &M) const;
82};
83
84}
85
87
88
89
90
91
92 Use *LastUse = nullptr;
94 while (!Intrin.use_empty() && (!LastUse || LastUse->getNext())) {
95 Use *U = LastUse ? LastUse->getNext() : &*Intrin.use_begin();
96 bool Removed = false;
97
98
100 Changed |= Removed = Callback(CI);
101 if (!Removed)
102 LastUse = U;
103 }
105}
106
108 if (F.use_empty())
109 return false;
110
113
116 if (!CI || CI->getCalledOperand() != &F)
117 continue;
118
120 Value *OffsetPtr =
121 B.CreatePtrAdd(CI->getArgOperand(0), CI->getArgOperand(1));
122 Value *OffsetI32 = B.CreateAlignedLoad(Int32Ty, OffsetPtr, Align(4));
123
124 Value *ResultPtr = B.CreatePtrAdd(CI->getArgOperand(0), OffsetI32);
125
126 CI->replaceAllUsesWith(ResultPtr);
127 CI->eraseFromParent();
129 }
130
132}
133
134
135
144
148 "Pre-ISel intrinsics do lower into regular function calls");
149 if (F.use_empty())
150 return false;
151
152
153
155
156
157
158 Module *M = F.getParent();
160 M->getOrInsertFunction(NewFnName, F.getFunctionType());
161
163 Fn->setLinkage(F.getLinkage());
165
166
167 Fn->addFnAttr(Attribute::NonLazyBind);
168 }
169 }
170
172
175
176 if (CB->getCalledFunction() != &F) {
178 "use expected to be the argument of operand bundle "
179 "\"clang.arc.attachedcall\"");
181 continue;
182 }
183
185 assert(CI->getCalledFunction() && "Cannot lower an indirect call!");
186
187 IRBuilder<> Builder(CI->getParent(), CI->getIterator());
190 CI->getOperandBundlesAsDefs(BundleList);
191 CallInst *NewCI = Builder.CreateCall(FCache, Args, BundleList);
192 NewCI->setName(CI->getName());
193
194
195
196
197
198
199
200
203
204
205
206
207
208 unsigned Index;
209 if (F.getAttributes().hasAttrSomewhere(Attribute::Returned, &Index) &&
210 Index)
211 NewCI->addParamAttr(Index - AttributeList::FirstArgIndex,
212 Attribute::Returned);
213
214 if (!CI->use_empty())
215 CI->replaceAllUsesWith(NewCI);
216 CI->eraseFromParent();
217 }
218
219 return true;
220}
221
222
223
224bool PreISelIntrinsicLowering::shouldExpandMemIntrinsicWithSize(
227 if (!CI)
228 return true;
233
234
235
236 return SizeVal > Threshold || Threshold == 0;
237}
238
239static bool
242
243 if (!TM)
244 return true;
247 return Lowering.getLibcallImpl(LC) != RTLIB::Unsupported;
248}
249
250static bool
253
254 if (!TM)
255 return true;
258 return Lowering.getMemcpyImpl() != RTLIB::Unsupported;
259}
260
261
262
263
266
267
268
269
271 return nullptr;
272
274 Type *VTy = V->getType();
277
279 return nullptr;
280
281
282
283
286 return nullptr;
287
288
291 return nullptr;
292
293
294 if (DL.isBigEndian())
295 return nullptr;
296
297
299
300
301
302 if (Size > 16)
303 return nullptr;
304
305
306 if (Size == 16)
307 return C;
308
309
313}
314
315
316
317bool PreISelIntrinsicLowering::expandMemIntrinsicUses(
318 Function &F, DenseMap<Constant *, GlobalVariable *> &CMap) const {
321
324
325 switch (ID) {
326 case Intrinsic::memcpy: {
328 Function *ParentFunc = Memcpy->getFunction();
329 const TargetTransformInfo &TTI = LookupTTI(*ParentFunc);
330 if (shouldExpandMemIntrinsicWithSize(Memcpy->getLength(), TTI)) {
331 if (UseMemIntrinsicLibFunc &&
333 break;
334
335
338 Memcpy->eraseFromParent();
339 }
340
341 break;
342 }
343 case Intrinsic::memcpy_inline: {
344
345
346
349 break;
350
352 const TargetTransformInfo &TTI = LookupTTI(*ParentFunc);
355 Memcpy->eraseFromParent();
356 break;
357 }
358 case Intrinsic::memmove: {
361 const TargetTransformInfo &TTI = LookupTTI(*ParentFunc);
362 if (shouldExpandMemIntrinsicWithSize(Memmove->getLength(), TTI)) {
363 if (UseMemIntrinsicLibFunc &&
364 canEmitLibcall(ModuleLibcalls, TM, ParentFunc, RTLIB::MEMMOVE))
365 break;
366
369 Memmove->eraseFromParent();
370 }
371 }
372
373 break;
374 }
375 case Intrinsic::memset: {
378 const TargetTransformInfo &TTI = LookupTTI(*ParentFunc);
379 if (shouldExpandMemIntrinsicWithSize(Memset->getLength(), TTI)) {
380 if (UseMemIntrinsicLibFunc &&
381 canEmitLibcall(ModuleLibcalls, TM, ParentFunc, RTLIB::MEMSET))
382 break;
383
386 Memset->eraseFromParent();
387 }
388
389 break;
390 }
391 case Intrinsic::memset_inline: {
392
393
394
397 break;
398
401 Memset->eraseFromParent();
402 break;
403 }
404 case Intrinsic::experimental_memset_pattern: {
406 const TargetLibraryInfo &TLI = LookupTLI(*Memset->getFunction());
408 if (!PatternValue) {
409
410
413 Memset->eraseFromParent();
414 break;
415 }
416
417
419 Module *M = Memset->getModule();
420 const DataLayout &DL = Memset->getDataLayout();
421
422 Type *DestPtrTy = Memset->getRawDest()->getType();
424 StringRef FuncName = "memset_pattern16";
425 FunctionCallee MSP = getOrInsertLibFunc(M, TLI, LibFunc_memset_pattern16,
426 Builder.getVoidTy(), DestPtrTy,
427 Builder.getPtrTy(), SizeTTy);
429
430
431
432
433 assert(Memset->getRawDest()->getType()->getPointerAddressSpace() == 0 &&
434 "Should have skipped if non-zero AS");
435 GlobalVariable *GV;
436 auto It = CMap.find(PatternValue);
437 if (It != CMap.end()) {
438 GV = It->second;
439 } else {
440 GV = new GlobalVariable(
441 *M, PatternValue->getType(), true,
444 GlobalValue::UnnamedAddr::Global);
445
447 CMap[PatternValue] = GV;
448 }
449 Value *PatternPtr = GV;
450 Value *NumBytes = Builder.CreateMul(
451 TLI.getAsSizeT(DL.getTypeAllocSize(Memset->getValue()->getType()),
452 *M),
453 Builder.CreateZExtOrTrunc(Memset->getLength(), SizeTTy));
454 CallInst *MemsetPattern16Call =
455 Builder.CreateCall(MSP, {Memset->getRawDest(), PatternPtr, NumBytes});
456 MemsetPattern16Call->setAAMetadata(Memset->getAAMetadata());
457
458
459 AttrBuilder ArgAttrs(Memset->getContext(),
460 Memset->getAttributes().getParamAttrs(0));
462 MemsetPattern16Call->getAttributes().addParamAttributes(
463 Memset->getContext(), 0, ArgAttrs));
465 Memset->eraseFromParent();
466 break;
467 }
468 default:
470 }
471 }
472
474}
475
478
480
484
489
490 auto *EmuFnTy = FunctionType::get(Int64Ty, {Int64Ty, Int64Ty}, false);
491
494 Function *F = B.GetInsertBlock()->getParent();
495 Attribute FSAttr = F->getFnAttribute("target-features");
497 return B.CreateCall(
498 SignIntr, {Val, B.getInt32( 2), Disc}, DSBundle);
500 M.getOrInsertFunction("__emupac_pacda", EmuFnTy);
501 return B.CreateCall(EmuSignIntr, {Val, Disc}, DSBundle);
502 };
503
506 Function *F = B.GetInsertBlock()->getParent();
507 Attribute FSAttr = F->getFnAttribute("target-features");
509 return B.CreateCall(
510 AuthIntr, {Val, B.getInt32( 2), Disc}, DSBundle);
512 M.getOrInsertFunction("__emupac_autda", EmuFnTy);
513 return B.CreateCall(EmuAuthIntr, {Val, Disc}, DSBundle);
514 };
515
517 if (auto Bundle =
520 return nullptr;
521 };
522
525
526 auto *Pointer = Call->getArgOperand(0);
527 auto *Disc = Call->getArgOperand(1);
528 bool UseHWEncoding =
530 if (!UseHWEncoding)
532
533 auto *DS = GetDeactivationSymbol(Call);
535
537
538
540 if (U.getOperandNo() == 1 &&
543 auto *SIValInt =
544 B.CreatePtrToInt(SI->getValueOperand(), B.getInt64Ty());
545 Value *Sign = CreateSign(B, SIValInt, Disc, DSBundle);
546 SI->setOperand(0, B.CreateIntToPtr(Sign, B.getPtrTy()));
547 SI->setOperand(1, Pointer);
548 continue;
549 }
550 }
551
552
553
554
559 NewLI->setOperand(0, Pointer);
560 B.Insert(NewLI);
561 auto *LIInt = B.CreatePtrToInt(NewLI, B.getInt64Ty());
562 Value *Auth = CreateAuth(B, LIInt, Disc, DSBundle);
563 LI->replaceAllUsesWith(B.CreateIntToPtr(Auth, B.getPtrTy()));
564 LI->eraseFromParent();
565 continue;
566 }
567 }
568
569
570
573 if (Op->isNullValue()) {
575 continue;
576 }
577 }
579 if (Op->isNullValue()) {
581 continue;
582 }
583 }
584 }
585
586
587
588 U.set(Pointer);
589 if (DS)
590 DSsToDeactivate.insert(DS);
591 }
592
593 Call->eraseFromParent();
594 }
595
596 if (!DSsToDeactivate.empty()) {
597
598
599
602 for (GlobalValue *OldDS : DSsToDeactivate) {
606 DS->takeName(OldDS);
607 OldDS->replaceAllUsesWith(DS);
608 OldDS->eraseFromParent();
609 }
610 }
611 return true;
612}
613
614bool PreISelIntrinsicLowering::lowerIntrinsics(Module &M) const {
615
616 DenseMap<Constant *, GlobalVariable *> CMap;
618 for (Function &F : M) {
619 switch (F.getIntrinsicID()) {
620 default:
621 break;
622 case Intrinsic::memcpy:
623 case Intrinsic::memcpy_inline:
624 case Intrinsic::memmove:
625 case Intrinsic::memset:
626 case Intrinsic::memset_inline:
627 case Intrinsic::experimental_memset_pattern:
628 Changed |= expandMemIntrinsicUses(F, CMap);
629 break;
630 case Intrinsic::load_relative:
632 break;
633 case Intrinsic::is_constant:
634 case Intrinsic::objectsize:
637 TargetLibraryInfo &TLI = LookupTLI(*Parent);
638
641 });
642 break;
643#define BEGIN_REGISTER_VP_INTRINSIC(VPID, MASKPOS, VLENPOS) \
644 case Intrinsic::VPID:
645#include "llvm/IR/VPIntrinsics.def"
648 const TargetTransformInfo &TTI = LookupTTI(*Parent);
651
652
653
654 Changed |= ED != VPExpansionDetails::IntrinsicUnchanged;
655 bool Removed = ED == VPExpansionDetails::IntrinsicReplaced;
656 return Removed;
657 });
658 break;
659 case Intrinsic::objc_autorelease:
661 break;
662 case Intrinsic::objc_autoreleasePoolPop:
664 break;
665 case Intrinsic::objc_autoreleasePoolPush:
667 break;
668 case Intrinsic::objc_autoreleaseReturnValue:
670 break;
671 case Intrinsic::objc_copyWeak:
673 break;
674 case Intrinsic::objc_destroyWeak:
676 break;
677 case Intrinsic::objc_initWeak:
679 break;
680 case Intrinsic::objc_loadWeak:
682 break;
683 case Intrinsic::objc_loadWeakRetained:
685 break;
686 case Intrinsic::objc_moveWeak:
688 break;
689 case Intrinsic::objc_release:
691 break;
692 case Intrinsic::objc_retain:
694 break;
695 case Intrinsic::objc_retainAutorelease:
697 break;
698 case Intrinsic::objc_retainAutoreleaseReturnValue:
700 lowerObjCCall(F, RTLIB::impl_objc_retainAutoreleaseReturnValue);
701 break;
702 case Intrinsic::objc_retainAutoreleasedReturnValue:
704 lowerObjCCall(F, RTLIB::impl_objc_retainAutoreleasedReturnValue);
705 break;
706 case Intrinsic::objc_claimAutoreleasedReturnValue:
708 lowerObjCCall(F, RTLIB::impl_objc_claimAutoreleasedReturnValue);
709 break;
710 case Intrinsic::objc_retainBlock:
712 break;
713 case Intrinsic::objc_storeStrong:
715 break;
716 case Intrinsic::objc_storeWeak:
718 break;
719 case Intrinsic::objc_unsafeClaimAutoreleasedReturnValue:
721 lowerObjCCall(F, RTLIB::impl_objc_unsafeClaimAutoreleasedReturnValue);
722 break;
723 case Intrinsic::objc_retainedObject:
725 break;
726 case Intrinsic::objc_unretainedObject:
728 break;
729 case Intrinsic::objc_unretainedPointer:
731 break;
732 case Intrinsic::objc_retain_autorelease:
734 break;
735 case Intrinsic::objc_sync_enter:
737 break;
738 case Intrinsic::objc_sync_exit:
740 break;
741 case Intrinsic::exp:
742 case Intrinsic::exp2:
743 case Intrinsic:🪵
747 return false;
752 return false;
754 });
755 break;
756 case Intrinsic::protected_field_ptr:
758 break;
759 }
760 }
762}
763
764namespace {
765
766class PreISelIntrinsicLoweringLegacyPass : public ModulePass {
767public:
768 static char ID;
769
770 PreISelIntrinsicLoweringLegacyPass() : ModulePass(ID) {}
771
772 void getAnalysisUsage(AnalysisUsage &AU) const override {
773 AU.addRequired();
774 AU.addRequired();
775 AU.addRequired();
777 }
778
779 bool runOnModule(Module &M) override {
780 const LibcallLoweringModuleAnalysisResult &ModuleLibcalls =
781 getAnalysis().getResult();
782
783 auto LookupTTI = [this](Function &F) -> TargetTransformInfo & {
784 return this->getAnalysis().getTTI(F);
785 };
786 auto LookupTLI = [this](Function &F) -> TargetLibraryInfo & {
787 return this->getAnalysis().getTLI(F);
788 };
789
790 const auto *TM = &getAnalysis().getTM();
791 PreISelIntrinsicLowering Lowering(TM, ModuleLibcalls, LookupTTI, LookupTLI);
792 return Lowering.lowerIntrinsics(M);
793 }
794};
795
796}
797
798char PreISelIntrinsicLoweringLegacyPass::ID;
799
801 "pre-isel-intrinsic-lowering",
802 "Pre-ISel Intrinsic Lowering", false, false)
809 "pre-isel-intrinsic-lowering",
811
813 return new PreISelIntrinsicLoweringLegacyPass();
814}
815
820
822
825 };
828 };
829
830 PreISelIntrinsicLowering Lowering(TM, LibcallLowering, LookupTTI, LookupTLI);
831 if (.lowerIntrinsics(M))
833 else
835}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static bool setNonLazyBind(Function &F)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Module.h This file contains the declarations for the Module class.
This defines the Use class.
The header file for the LowerConstantIntrinsics pass as used by the new pass manager.
Machine Check Debug Module
This file defines ARC utility functions which are used by various parts of the compiler.
FunctionAnalysisManager FAM
ModuleAnalysisManager MAM
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
static cl::opt< int64_t > MemIntrinsicExpandSizeThresholdOpt("mem-intrinsic-expand-size", cl::desc("Set minimum mem intrinsic size to expand in IR"), cl::init(-1), cl::Hidden)
Threshold to leave statically sized memory intrinsic calls.
static bool forEachCall(Function &Intrin, T Callback)
Definition PreISelIntrinsicLowering.cpp:86
pre isel intrinsic Pre ISel Intrinsic Lowering
Definition PreISelIntrinsicLowering.cpp:810
static bool canEmitLibcall(const LibcallLoweringModuleAnalysisResult &ModuleLowering, const TargetMachine *TM, Function *F, RTLIB::Libcall LC)
Definition PreISelIntrinsicLowering.cpp:240
static CallInst::TailCallKind getOverridingTailCallKind(const Function &F)
Definition PreISelIntrinsicLowering.cpp:136
static bool canEmitMemcpy(const LibcallLoweringModuleAnalysisResult &ModuleLowering, const TargetMachine *TM, Function *F)
Definition PreISelIntrinsicLowering.cpp:251
static Constant * getMemSetPattern16Value(MemSetPatternInst *Inst, const TargetLibraryInfo &TLI)
Definition PreISelIntrinsicLowering.cpp:264
static bool expandProtectedFieldPtr(Function &Intr)
Definition PreISelIntrinsicLowering.cpp:476
static bool lowerObjCCall(Function &F, RTLIB::LibcallImpl NewFn, bool setNonLazyBind=false)
Definition PreISelIntrinsicLowering.cpp:145
static bool lowerLoadRelative(Function &F)
Definition PreISelIntrinsicLowering.cpp:107
This file describes how to lower LLVM code to machine code.
Target-Independent Code Generator Pass Configuration Options pass.
This pass exposes codegen information to IR-level passes.
AnalysisUsage & addRequired()
static LLVM_ABI ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
Functions, function parameters, and return types can have attributes to indicate how they should be t...
LLVM_ABI StringRef getValueAsString() const
Return the attribute's value as a string.
bool isValid() const
Return true if the attribute is any kind of attribute.
void setAttributes(AttributeList A)
Set the attributes for this call.
Value * getArgOperand(unsigned i) const
AttributeList getAttributes() const
Return the attributes for this call.
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
This class represents a function call, abstracting a target machine's calling convention.
void setTailCallKind(TailCallKind TCK)
static LLVM_ABI Constant * get(ArrayType *T, ArrayRef< Constant * > V)
static LLVM_ABI Constant * getIntToPtr(Constant *C, Type *Ty, bool OnlyIfReduced=false)
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
iterator find(const_arg_type_t< KeyT > Val)
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
const Function & getFunction() const
static LLVM_ABI GlobalAlias * create(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Aliasee, Module *Parent)
If a parent module is specified, the alias is automatically inserted into the end of the specified mo...
void setUnnamedAddr(UnnamedAddr Val)
Module * getParent()
Get the module that this global value is contained inside of...
@ HiddenVisibility
The GV is hidden.
@ PrivateLinkage
Like Internal, but omit from symbol table.
@ ExternalLinkage
Externally visible function.
void setAlignment(Align Align)
Sets the alignment attribute of the GlobalVariable.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
LLVM_ABI const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
LLVM_ABI void setAAMetadata(const AAMDNodes &N)
Sets the AA metadata on this instruction from the AAMDNodes structure.
LLVM_ABI const DataLayout & getDataLayout() const
Get the data layout of the module this instruction belongs to.
static LLVM_ABI bool mayLowerToFunctionCall(Intrinsic::ID IID)
Check if the intrinsic might lower into a regular function call in the course of IR transformations.
Tracks which library functions to use for a particular subtarget.
Record a mapping from subtarget to LibcallLoweringInfo.
const LibcallLoweringInfo & getLibcallLowering(const TargetSubtargetInfo &Subtarget) const
Value * getRawDest() const
This class wraps the llvm.experimental.memset.pattern intrinsic.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
A Module instance is used to store all the information related to an LLVM module.
static LLVM_ABI PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
Analysis pass providing the TargetTransformInfo.
Analysis pass providing the TargetLibraryInfo.
Provides information about what library functions are available for the current target.
ConstantInt * getAsSizeT(uint64_t V, const Module &M) const
Returns a constant materialized as a size_t type.
IntegerType * getSizeTType(const Module &M) const
Returns an IntegerType corresponding to size_t.
bool isOperationExpand(unsigned Op, EVT VT) const
Return true if the specified operation is illegal on this target or unlikely to be made legal with cu...
int IntrinsicIDToISD(Intrinsic::ID ID) const
Get the ISD node that corresponds to the Intrinsic ID.
Primary interface to the complete machine description for the target machine.
virtual const TargetSubtargetInfo * getSubtargetImpl(const Function &) const
Virtual method implemented by subclasses that returns a reference to that target's TargetSubtargetInf...
Target-Independent Code Generator Pass Configuration Options.
virtual const TargetLowering * getTargetLowering() const
Wrapper pass for TargetTransformInfo.
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
LLVM_ABI uint64_t getMaxMemIntrinsicInlineSizeThreshold() const
Returns the maximum memset / memcpy size in bytes that still makes it profitable to inline the call.
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
LLVM_ABI unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)
A Use represents the edge between a Value definition and its users.
void setOperand(unsigned i, Value *Val)
Value * getOperand(unsigned i) const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI void setName(const Twine &Name)
Change the name of the value.
iterator_range< user_iterator > users()
An efficient, type-erasing, non-owning reference to a callable.
const ParentTy * getParent() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
@ DELETED_NODE
DELETED_NODE - This is an illegal value that is used to catch errors.
LLVM_ABI Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > Tys={})
Look up the Function declaration of the intrinsic id in the Module M.
initializer< Ty > init(const Ty &Val)
bool IsNeverTail(ARCInstKind Class)
Test if the given class represents instructions which are never safe to mark with the "tail" keyword.
bool IsAlwaysTail(ARCInstKind Class)
Test if the given class represents instructions which are always safe to mark with the "tail" keyword...
ARCInstKind
Equivalence classes of instructions in the ARC Model.
ARCInstKind GetFunctionClass(const Function *F)
Determine if F is one of the special known Functions.
std::optional< Function * > getAttachedARCFunction(const CallBase *CB)
This function returns operand bundle clang_arc_attachedcall's argument, which is the address of the A...
friend class Instruction
Iterator for Instructions in a `BasicBlock.
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
bool lowerUnaryVectorIntrinsicAsLoop(Module &M, CallInst *CI)
Lower CI as a loop.
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
FunctionAddr VTableAddr uintptr_t uintptr_t Int32Ty
bool lowerConstantIntrinsics(Function &F, const TargetLibraryInfo &TLI, DominatorTree *DT)
LLVM_ABI void expandMemSetPatternAsLoop(MemSetPatternInst *MemSet)
Expand MemSetPattern as a loop. MemSet is not deleted.
LLVM_ABI bool expandMemMoveAsLoop(MemMoveInst *MemMove, const TargetTransformInfo &TTI)
Expand MemMove as a loop.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
InnerAnalysisManagerProxy< FunctionAnalysisManager, Module > FunctionAnalysisManagerModuleProxy
Provide the FunctionAnalysisManager to Module proxy.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
LLVM_ABI bool inferNonMandatoryLibFuncAttrs(Module *M, StringRef Name, const TargetLibraryInfo &TLI)
Analyze the name and prototype of the given function and set any applicable attributes.
LLVM_ABI bool isLibFuncEmittable(const Module *M, const TargetLibraryInfo *TLI, LibFunc TheLibFunc)
Check whether the library function is available on target and also that it in the current Module is a...
LLVM_ABI ModulePass * createPreISelIntrinsicLoweringPass()
This pass lowers the @llvm.load.relative and @llvm.objc.
Definition PreISelIntrinsicLowering.cpp:812
LLVM_ABI FunctionCallee getOrInsertLibFunc(Module *M, const TargetLibraryInfo &TLI, LibFunc TheLibFunc, FunctionType *T, AttributeList AttributeList)
Calls getOrInsertFunction() and then makes sure to add mandatory argument attributes.
bool isa(const From &Val)
isa - Return true if the parameter to the template is an instance of one of the template type argu...
VPExpansionDetails expandVectorPredicationIntrinsic(VPIntrinsic &VPI, const TargetTransformInfo &TTI)
Expand a vector predication intrinsic.
IRBuilder(LLVMContext &, FolderTy, InserterTy, MDNode *, ArrayRef< OperandBundleDef >) -> IRBuilder< FolderTy, InserterTy >
OperandBundleDefT< Value * > OperandBundleDef
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast - Return the argument parameter cast to the specified type.
LLVM_ABI void expandMemCpyAsLoop(MemCpyInst *MemCpy, const TargetTransformInfo &TTI, ScalarEvolution *SE=nullptr)
Expand MemCpy as a loop. MemCpy is not deleted.
VPExpansionDetails
Represents the details the expansion of a VP intrinsic.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
LLVM_ABI void expandMemSetAsLoop(MemSetInst *MemSet)
Expand MemSet as a loop. MemSet is not deleted.
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
This struct is a compact representation of a valid (non-zero power of two) alignment.
static LLVM_ABI EVT getEVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition PreISelIntrinsicLowering.cpp:817
static StringRef getLibcallImplName(RTLIB::LibcallImpl CallImpl)
Get the libcall routine name for the specified libcall implementation.