LLVM: lib/Target/X86/X86WinEHState.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
28#include "llvm/IR/IntrinsicsX86.h"
32#include
33
34using namespace llvm;
35
36#define DEBUG_TYPE "winehstate"
37
38namespace {
39const int OverdefinedState = INT_MIN;
40
42public:
43 static char ID;
44
46
48
49 bool doInitialization(Module &M) override;
50
51 bool doFinalization(Module &M) override;
52
53 void getAnalysisUsage(AnalysisUsage &AU) const override;
54
55 StringRef getPassName() const override {
56 return "Windows 32-bit x86 EH state insertion";
57 }
58
59private:
60 void emitExceptionRegistrationRecord(Function *F);
61
63 void unlinkExceptionRegistration(IRBuilder<> &Builder);
65 void insertStateNumberStore(Instruction *IP, int State);
66
68
70
78
79 void updateEspForInAllocas(Function &F);
80
81
82 Type *getEHLinkRegistrationType();
83 Type *getSEHRegistrationType();
84 Type *getCXXEHRegistrationType();
85
86
87 Module *TheModule = nullptr;
88 StructType *EHLinkRegistrationTy = nullptr;
89 StructType *CXXEHRegistrationTy = nullptr;
90 StructType *SEHRegistrationTy = nullptr;
93
94
96 Function *PersonalityFn = nullptr;
97 bool UseStackGuard = false;
98 int ParentBaseState = 0;
101
102
103
105
106
107 Type *RegNodeTy = nullptr;
108
109
111
112
113 int StateFieldIndex = ~0U;
114
115
116 Value *Link = nullptr;
117};
118}
119
121
122char WinEHStatePass::ID = 0;
123
125 "Insert stores for EH state numbers", false, false)
126
127bool WinEHStatePass::doInitialization(Module &M) {
128 TheModule = &M;
129 return false;
130}
131
132bool WinEHStatePass::doFinalization(Module &M) {
133 assert(TheModule == &M);
134 TheModule = nullptr;
135 EHLinkRegistrationTy = nullptr;
136 CXXEHRegistrationTy = nullptr;
137 SEHRegistrationTy = nullptr;
138 SetJmp3 = nullptr;
139 CxxLongjmpUnwind = nullptr;
140 SehLongjmpUnwind = nullptr;
141 Cookie = nullptr;
142 return false;
143}
144
145void WinEHStatePass::getAnalysisUsage(AnalysisUsage &AU) const {
146
147
149}
150
151bool WinEHStatePass::runOnFunction(Function &F) {
152
153
154
155 if (F.hasAvailableExternallyLinkage())
156 return false;
157
158
159 if (.hasPersonalityFn())
160 return false;
161 PersonalityFn = dyn_cast(F.getPersonalityFn()->stripPointerCasts());
162 if (!PersonalityFn)
163 return false;
166 return false;
167
168
169
170 bool HasPads = false;
171 for (BasicBlock &BB : F) {
172 if (BB.isEHPad()) {
173 HasPads = true;
174 break;
175 }
176 }
177 if (!HasPads)
178 return false;
179
180 Type *Int8PtrType = PointerType::getUnqual(TheModule->getContext());
182 "_setjmp3", FunctionType::get(
183 Type::getInt32Ty(TheModule->getContext()),
184 {Int8PtrType, Type::getInt32Ty(TheModule->getContext())},
185 true));
186
187 emitExceptionRegistrationRecord(&F);
188
189
190
191
192
193
194 WinEHFuncInfo FuncInfo;
195 addStateStores(F, FuncInfo);
196 updateEspForInAllocas(F);
197
198
199 PersonalityFn = nullptr;
200 Personality = EHPersonality::Unknown;
201 UseStackGuard = false;
202 RegNodeTy = nullptr;
203 RegNode = nullptr;
204 EHGuardNode = nullptr;
205
206 return true;
207}
208
209
210
211
212
213
214
215
216Type *WinEHStatePass::getEHLinkRegistrationType() {
217 if (EHLinkRegistrationTy)
218 return EHLinkRegistrationTy;
220 Type *FieldTys[] = {
221 PointerType::getUnqual(Context),
222 PointerType::getUnqual(Context)
223 };
224 EHLinkRegistrationTy = StructType::create(FieldTys, "EHRegistrationNode");
225 return EHLinkRegistrationTy;
226}
227
228
229
230
231
232
233
234Type *WinEHStatePass::getCXXEHRegistrationType() {
235 if (CXXEHRegistrationTy)
236 return CXXEHRegistrationTy;
238 Type *FieldTys[] = {
239 PointerType::getUnqual(Context),
240 getEHLinkRegistrationType(),
241 Type::getInt32Ty(Context)
242 };
243 CXXEHRegistrationTy =
245 return CXXEHRegistrationTy;
246}
247
248
249
250
251
252
253
254
255
256Type *WinEHStatePass::getSEHRegistrationType() {
257 if (SEHRegistrationTy)
258 return SEHRegistrationTy;
260 Type *FieldTys[] = {
261 PointerType::getUnqual(Context),
262 PointerType::getUnqual(Context),
263 getEHLinkRegistrationType(),
264 Type::getInt32Ty(Context),
265 Type::getInt32Ty(Context)
266 };
267 SEHRegistrationTy = StructType::create(FieldTys, "SEHExceptionRegistration");
268 return SEHRegistrationTy;
269}
270
271
272
273
274
275void WinEHStatePass::emitExceptionRegistrationRecord(Function *F) {
276 assert(Personality == EHPersonality::MSVC_CXX ||
277 Personality == EHPersonality::MSVC_X86SEH);
278
279 IRBuilder<> Builder(&F->getEntryBlock(), F->getEntryBlock().begin());
280 Type *Int8PtrType = Builder.getPtrTy();
282 Type *VoidTy = Builder.getVoidTy();
283
284 if (Personality == EHPersonality::MSVC_CXX) {
285 RegNodeTy = getCXXEHRegistrationType();
286 RegNode = Builder.CreateAlloca(RegNodeTy);
287
288 Value *SP = Builder.CreateStackSave();
289 Builder.CreateStore(SP, Builder.CreateStructGEP(RegNodeTy, RegNode, 0));
290
291 StateFieldIndex = 2;
292 ParentBaseState = -1;
293 insertStateNumberStore(&*Builder.GetInsertPoint(), ParentBaseState);
294
295 Function *Trampoline = generateLSDAInEAXThunk(F);
296 Link = Builder.CreateStructGEP(RegNodeTy, RegNode, 1);
297 linkExceptionRegistration(Builder, Trampoline);
298
300 "__CxxLongjmpUnwind",
301 FunctionType::get(VoidTy, Int8PtrType, false));
303 ->setCallingConv(CallingConv::X86_StdCall);
304 } else if (Personality == EHPersonality::MSVC_X86SEH) {
305
306
307 StringRef PersonalityName = PersonalityFn->getName();
308 UseStackGuard = (PersonalityName == "_except_handler4");
309
310
311 RegNodeTy = getSEHRegistrationType();
312 RegNode = Builder.CreateAlloca(RegNodeTy);
313 if (UseStackGuard)
314 EHGuardNode = Builder.CreateAlloca(Int32Ty);
315
316
317 Value *SP = Builder.CreateStackSave();
318 Builder.CreateStore(SP, Builder.CreateStructGEP(RegNodeTy, RegNode, 0));
319
320 StateFieldIndex = 4;
321 ParentBaseState = UseStackGuard ? -2 : -1;
322 insertStateNumberStore(&*Builder.GetInsertPoint(), ParentBaseState);
323
324 Value *LSDA = emitEHLSDA(Builder, F);
325 LSDA = Builder.CreatePtrToInt(LSDA, Int32Ty);
326
327
328 if (UseStackGuard) {
330 Value *Val = Builder.CreateLoad(Int32Ty, Cookie, "cookie");
331 LSDA = Builder.CreateXor(LSDA, Val);
332 }
333 Builder.CreateStore(LSDA, Builder.CreateStructGEP(RegNodeTy, RegNode, 3));
334
335
336 if (UseStackGuard) {
337 Value *Val = Builder.CreateLoad(Int32Ty, Cookie);
338 Value *FrameAddr = Builder.CreateIntrinsic(
339 Intrinsic::frameaddress,
341 Builder.getInt32(0), nullptr, "frameaddr");
342 Value *FrameAddrI32 = Builder.CreatePtrToInt(FrameAddr, Int32Ty);
343 FrameAddrI32 = Builder.CreateXor(FrameAddrI32, Val);
344 Builder.CreateStore(FrameAddrI32, EHGuardNode);
345 }
346
347
348 Link = Builder.CreateStructGEP(RegNodeTy, RegNode, 2);
349 linkExceptionRegistration(Builder, PersonalityFn);
350
352 UseStackGuard ? "_seh_longjmp_unwind4" : "_seh_longjmp_unwind",
353 FunctionType::get(Type::getVoidTy(TheModule->getContext()), Int8PtrType,
354 false));
356 ->setCallingConv(CallingConv::X86_StdCall);
357 } else {
359 }
360
361
362 for (BasicBlock &BB : *F) {
365 continue;
366
367
368 if (CallInst *CI = BB.getTerminatingMustTailCall())
369 T = CI;
370
371 Builder.SetInsertPoint(T);
372 unlinkExceptionRegistration(Builder);
373 }
374}
375
376Value *WinEHStatePass::emitEHLSDA(IRBuilder<> &Builder, Function *F) {
378}
379
380
381
382
383
384
385
386
387Function *WinEHStatePass::generateLSDAInEAXThunk(Function *ParentFunc) {
390 Type *Int8PtrType = PointerType::getUnqual(Context);
391 Type *ArgTys[5] = {Int8PtrType, Int8PtrType, Int8PtrType, Int8PtrType,
392 Int8PtrType};
393 FunctionType *TrampolineTy =
395 false);
396 FunctionType *TargetFuncTy =
398 false);
401 Twine("__ehhandler$") +
403 TheModule);
404 if (auto *C = ParentFunc->getComdat())
408 Value *LSDA = emitEHLSDA(Builder, ParentFunc);
409 auto AI = Trampoline->arg_begin();
410 Value *Args[5] = {LSDA, &*AI++, &*AI++, &*AI++, &*AI++};
411 CallInst *Call = Builder.CreateCall(TargetFuncTy, PersonalityFn, Args);
412
414
417 return Trampoline;
418}
419
420void WinEHStatePass::linkExceptionRegistration(IRBuilder<> &Builder,
421 Function *Handler) {
422
424
426 Type *LinkTy = getEHLinkRegistrationType();
427
429
433
435}
436
437void WinEHStatePass::unlinkExceptionRegistration(IRBuilder<> &Builder) {
438
442 Link = GEP;
443 }
444
446 Type *LinkTy = getEHLinkRegistrationType();
447
452}
453
454
455
456
457
458void WinEHStatePass::rewriteSetJmpCall(IRBuilder<> &Builder, Function &F,
460
462 return;
463
466
468 if (Personality == EHPersonality::MSVC_CXX) {
471 OptionalArgs.push_back(emitEHLSDA(Builder, &F));
472 } else if (Personality == EHPersonality::MSVC_X86SEH) {
475 if (UseStackGuard)
477 } else {
479 }
480
482 Args.push_back(
485 Args.append(OptionalArgs.begin(), OptionalArgs.end());
486
487 CallBase *NewCall;
489 CallInst *NewCI = Builder.CreateCall(SetJmp3, Args, OpBundles);
491 NewCall = NewCI;
492 } else {
494 NewCall = Builder.CreateInvoke(SetJmp3, II->getNormalDest(),
495 II->getUnwindDest(), Args, OpBundles);
496 }
500
504}
505
506
507int WinEHStatePass::getBaseStateForBB(
508 DenseMap<BasicBlock *, ColorVector> &BlockColors, WinEHFuncInfo &FuncInfo,
509 BasicBlock *BB) {
510 int BaseState = ParentBaseState;
511 auto &BBColors = BlockColors[BB];
512
513 assert(BBColors.size() == 1 && "multi-color BB not removed by preparation");
514 BasicBlock *FuncletEntryBB = BBColors.front();
515 if (auto *FuncletPad =
519 BaseState = BaseStateI->second;
520 }
521
522 return BaseState;
523}
524
529
533
537
538
539int WinEHStatePass::getStateForCall(
540 DenseMap<BasicBlock *, ColorVector> &BlockColors, WinEHFuncInfo &FuncInfo,
541 CallBase &Call) {
544 return getBaseStateForBB(BlockColors, FuncInfo, II->getNormalDest());
545 }
546
547
550 }
551
552
553 return getBaseStateForBB(BlockColors, FuncInfo, Call.getParent());
554}
555
556
557
559 int ParentBaseState, BasicBlock *BB) {
560
561
562 if (&F.getEntryBlock() == BB)
563 return ParentBaseState;
564
565
567 return OverdefinedState;
568
569 int CommonState = OverdefinedState;
571
572
573 auto PredEndState = FinalStates.find(PredBB);
574 if (PredEndState == FinalStates.end())
575 return OverdefinedState;
576
577
578
580 return OverdefinedState;
581
582 int PredState = PredEndState->second;
583 assert(PredState != OverdefinedState &&
584 "overdefined BBs shouldn't be in FinalStates");
585 if (CommonState == OverdefinedState)
586 CommonState = PredState;
587
588
589
590 if (CommonState != PredState)
591 return OverdefinedState;
592 }
593
594 return CommonState;
595}
596
597
598
600 int ParentBaseState, BasicBlock *BB) {
601
602
604 return OverdefinedState;
605
606 int CommonState = OverdefinedState;
608
609
610 auto SuccStartState = InitialStates.find(SuccBB);
611 if (SuccStartState == InitialStates.end())
612 return OverdefinedState;
613
614
615 if (SuccBB->isEHPad())
616 return OverdefinedState;
617
618 int SuccState = SuccStartState->second;
619 assert(SuccState != OverdefinedState &&
620 "overdefined BBs shouldn't be in FinalStates");
621 if (CommonState == OverdefinedState)
622 CommonState = SuccState;
623
624
625
626 if (CommonState != SuccState)
627 return OverdefinedState;
628 }
629
630 return CommonState;
631}
632
633bool WinEHStatePass::isStateStoreNeeded(EHPersonality Personality,
634 CallBase &Call) {
636 return true;
637 }
638
639
642
643
645}
646
647void WinEHStatePass::addStateStores(Function &F, WinEHFuncInfo &FuncInfo) {
648
649
652 Builder.CreateIntrinsic(Intrinsic::x86_seh_ehregnode, {RegNodeI8});
653
654 if (EHGuardNode) {
656 Value *EHGuardNodeI8 =
658 Builder.CreateIntrinsic(Intrinsic::x86_seh_ehguard, {EHGuardNodeI8});
659 }
660
661
664 else
666
667
668 DenseMap<BasicBlock *, ColorVector> BlockColors = colorEHFunclets(F);
669 ReversePostOrderTraversal<Function *> RPOT(&F);
670
671
672 DenseMap<BasicBlock *, int> InitialStates;
673
674 DenseMap<BasicBlock *, int> FinalStates;
675
676
677 std::deque<BasicBlock *> Worklist;
678
679 for (BasicBlock *BB : RPOT) {
680 int InitialState = OverdefinedState;
681 int FinalState;
682 if (&F.getEntryBlock() == BB)
683 InitialState = FinalState = ParentBaseState;
684 for (Instruction &I : *BB) {
686 if ( || !isStateStoreNeeded(Personality, *Call))
687 continue;
688
689 int State = getStateForCall(BlockColors, FuncInfo, *Call);
690 if (InitialState == OverdefinedState)
691 InitialState = State;
692 FinalState = State;
693 }
694
695
696 if (InitialState == OverdefinedState) {
697 Worklist.push_back(BB);
698 continue;
699 }
700 LLVM_DEBUG(dbgs() << "X86WinEHState: " << BB->getName()
701 << " InitialState=" << InitialState << '\n');
702 LLVM_DEBUG(dbgs() << "X86WinEHState: " << BB->getName()
703 << " FinalState=" << FinalState << '\n');
704 InitialStates.insert({BB, InitialState});
705 FinalStates.insert({BB, FinalState});
706 }
707
708
709 while (!Worklist.empty()) {
711 Worklist.pop_front();
712
713 if (InitialStates.count(BB) != 0)
714 continue;
715
716 int PredState = getPredState(FinalStates, F, ParentBaseState, BB);
717 if (PredState == OverdefinedState)
718 continue;
719
720
721
722 InitialStates.insert({BB, PredState});
723 FinalStates.insert({BB, PredState});
724 for (BasicBlock *SuccBB : successors(BB))
725 Worklist.push_back(SuccBB);
726 }
727
728
729 for (BasicBlock *BB : RPOT) {
730 int SuccState = getSuccState(InitialStates, F, ParentBaseState, BB);
731 if (SuccState == OverdefinedState)
732 continue;
733
734
735
736 FinalStates.insert({BB, SuccState});
737 }
738
739
740
741 for (BasicBlock *BB : RPOT) {
742 auto &BBColors = BlockColors[BB];
745 continue;
746
747 int PrevState = getPredState(FinalStates, F, ParentBaseState, BB);
749 << " PrevState=" << PrevState << '\n');
750
751 for (Instruction &I : *BB) {
753 if ( || !isStateStoreNeeded(Personality, *Call))
754 continue;
755
756 int State = getStateForCall(BlockColors, FuncInfo, *Call);
757 if (State != PrevState)
758 insertStateNumberStore(&I, State);
759 PrevState = State;
760 }
761
762
763 auto EndState = FinalStates.find(BB);
764 if (EndState != FinalStates.end())
765 if (EndState->second != PrevState)
766 insertStateNumberStore(BB->getTerminator(), EndState->second);
767 }
768
770 for (BasicBlock *BB : RPOT) {
771 for (Instruction &I : *BB) {
774 continue;
777 continue;
778
780 }
781 }
782
783 for (CallBase *Call : SetJmp3Calls) {
787
790 if (InCleanup) {
792 RegNode, StateFieldIndex);
794 } else {
795 State = Builder.getInt32(getStateForCall(BlockColors, FuncInfo, *Call));
796 }
797 rewriteSetJmpCall(Builder, F, *Call, State);
798 }
799}
800
801void WinEHStatePass::insertStateNumberStore(Instruction *IP, int State) {
804 RegNode, StateFieldIndex);
806}
807
808void WinEHStatePass::updateEspForInAllocas(Function &F) {
809 for (BasicBlock &BB : F) {
810 for (Instruction &I : BB) {
812 if (Alloca->isStaticAlloca())
813 continue;
814 IRBuilder<> Builder(Alloca->getNextNode());
815
818 }
819
821 if (II->getIntrinsicID() != Intrinsic::stackrestore)
822 continue;
824
827 }
828 }
829 }
830}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool runOnFunction(Function &F, bool PostInlining)
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
Module.h This file contains the declarations for the Module class.
uint64_t IntrinsicInst * II
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
static int getPredState(DenseMap< BasicBlock *, int > &FinalStates, Function &F, int ParentBaseState, BasicBlock *BB)
Definition X86WinEHState.cpp:558
static bool isSehScopeEnd(const CallBase &Call)
Definition X86WinEHState.cpp:530
static bool isSehScopeBegin(const CallBase &Call)
Definition X86WinEHState.cpp:534
static bool isIntrinsic(const CallBase &Call, Intrinsic::ID ID)
Definition X86WinEHState.cpp:525
static int getSuccState(DenseMap< BasicBlock *, int > &InitialStates, Function &F, int ParentBaseState, BasicBlock *BB)
Definition X86WinEHState.cpp:599
an instruction to allocate memory on the stack
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
Represent the analysis usage information of a pass.
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
LLVM Basic Block Representation.
LLVM_ABI InstListType::const_iterator getFirstNonPHIIt() const
Returns an iterator to the first instruction in this block that is not a PHINode instruction.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
const Instruction & front() const
bool isEHPad() const
Return true if this basic block is an exception handling block.
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
void setCallingConv(CallingConv::ID CC)
LLVM_ABI void getOperandBundlesAsDefs(SmallVectorImpl< OperandBundleDef > &Defs) const
Return the list of operand bundles attached to this instruction as a vector of OperandBundleDefs.
bool doesNotAccessMemory(unsigned OpNo) const
CallingConv::ID getCallingConv() const
Value * getCalledOperand() const
void setAttributes(AttributeList A)
Set the attributes for this call.
bool doesNotThrow() const
Determine if the call cannot unwind.
Value * getArgOperand(unsigned i) const
unsigned arg_size() const
AttributeList getAttributes() const
Return the attributes for this call.
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
void setTailCallKind(TailCallKind TCK)
void setTailCall(bool IsTc=true)
This is an important base class in LLVM.
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
unsigned getAllocaAddrSpace() const
iterator find(const_arg_type_t< KeyT > Val)
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
FunctionPass class - This class is used to implement most global optimizations.
void addFnAttr(Attribute::AttrKind Kind)
Add function attributes to this function.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
LLVM_ABI void setComdat(Comdat *C)
const Comdat * getComdat() const
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1',...
@ InternalLinkage
Rename collisions when linking (static functions).
CallInst * CreateStackSave(const Twine &Name="")
Create a call to llvm.stacksave.
InvokeInst * CreateInvoke(FunctionType *Ty, Value *Callee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > OpBundles, const Twine &Name="")
Create an invoke instruction.
Value * CreateStructGEP(Type *Ty, Value *Ptr, unsigned Idx, const Twine &Name="")
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
ReturnInst * CreateRet(Value *V)
Create a 'ret ' instruction.
LLVM_ABI CallInst * CreateIntrinsic(Intrinsic::ID ID, ArrayRef< Type * > Types, ArrayRef< Value * > Args, FMFSource FMFSource={}, const Twine &Name="")
Create a call to intrinsic ID with Args, mangled using Types.
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
InstTy * Insert(InstTy *I, const Twine &Name="") const
Insert and return the specified instruction.
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const char *Name)
Provided to resolve 'CreateLoad(Ty, Ptr, "...")' correctly, instead of converting the string to 'bool...
LLVMContext & getContext() const
StoreInst * CreateStore(Value *Val, Value *Ptr, bool isVolatile=false)
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args={}, const Twine &Name="", MDNode *FPMathTag=nullptr)
PointerType * getPtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
A Module instance is used to store all the information related to an LLVM module.
LLVMContext & getContext() const
Get the global data context.
FunctionCallee getOrInsertFunction(StringRef Name, FunctionType *T, AttributeList AttributeList)
Look up the specified function in the module symbol table.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
GlobalVariable * getOrInsertGlobal(StringRef Name, Type *Ty, function_ref< GlobalVariable *()> CreateGlobalCallback)
Look up the specified global in the module symbol table.
void push_back(const T &Elt)
StringRef - Represent a constant reference to a string, i.e.
Class to represent struct types.
static LLVM_ABI StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
LLVM_ABI const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
LLVM_ABI void takeName(Value *V)
Transfer the name from V to this value.
const ParentTy * getParent() const
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
@ BasicBlock
Various leaf nodes.
friend class Instruction
Iterator for Instructions in a `BasicBlock.
This is an optimization pass for GlobalISel generic memory operations.
FunctionPass * createX86WinEHStatePass()
Return an IR pass that inserts EH registration stack objects and explicit EH state updates.
Definition X86WinEHState.cpp:120
FunctionAddr VTableAddr Value
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
auto successors(const MachineBasicBlock *BB)
LLVM_ABI DenseMap< BasicBlock *, ColorVector > colorEHFunclets(Function &F)
If an EH funclet personality is in use (see isFuncletEHPersonality), this will recompute which blocks...
void calculateWinCXXEHStateNumbers(const Function *ParentFn, WinEHFuncInfo &FuncInfo)
Analyze the IR in ParentFn and it's handlers to build WinEHFuncInfo, which describes the state number...
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa - Return true if the parameter to the template is an instance of one of the template type argu...
bool isFuncletEHPersonality(EHPersonality Pers)
Returns true if this is a personality function that invokes handler funclets (which must return to it...
IRBuilder(LLVMContext &, FolderTy, InserterTy, MDNode *, ArrayRef< OperandBundleDef >) -> IRBuilder< FolderTy, InserterTy >
void calculateSEHStateNumbers(const Function *ParentFn, WinEHFuncInfo &FuncInfo)
FunctionAddr VTableAddr Next
ArrayRef(const T &OneElt) -> ArrayRef< T >
bool isAsynchronousEHPersonality(EHPersonality Pers)
Returns true if this personality function catches asynchronous exceptions.
decltype(auto) cast(const From &Val)
cast - Return the argument parameter cast to the specified type.
auto predecessors(const MachineBasicBlock *BB)
DenseMap< const FuncletPadInst *, int > FuncletBaseStateMap
DenseMap< const InvokeInst *, int > InvokeStateMap