45#define DEBUG_TYPE "win-eh-prepare"
49 switch (Personality) {
103class WinEHPrepareImpl {
105 explicit WinEHPrepareImpl(
const CodeGenOptions &Opts) : Opts(Opts) {}
109 void insertPHIStores(PHINode *OriginalPHI, AllocaInst *SpillSlot);
111 insertPHIStore(BasicBlock *PredBlock,
Value *PredVal, AllocaInst *SpillSlot,
112 SmallVectorImpl<std::pair<BasicBlock *, Value *>> &Worklist);
113 AllocaInst *insertPHILoads(PHINode *PN,
Function &
F);
114 void replaceUseWithLoad(
Value *
V, Use &U, AllocaInst *&SpillSlot,
115 DenseMap<BasicBlock *, Value *> &Loads,
Function &
F);
119 bool demotePHIsOnFunclets(
Function &
F,
bool DemoteCatchSwitchPHIOnly);
121 bool removeMalformedCatchswitch(
Value *FuncletToken);
122 bool removeImplausibleInstructions(
Function &
F);
123 bool cleanupPreparedFunclets(
Function &
F);
124 void verifyPreparedFunclets(
Function &
F);
126 const CodeGenOptions &Opts;
129 bool DemoteCatchSwitchPHIOnly =
false;
134 const DataLayout *DL =
nullptr;
135 DenseMap<BasicBlock *, ColorVector> BlockColors;
136 MapVector<BasicBlock *, std::vector<BasicBlock *>> FuncletBlocks;
143 WinEHPrepare() : FunctionPass(ID) {}
145 StringRef getPassName()
const override {
146 return "Windows exception handling preparation";
162char WinEHPrepare::ID = 0;
168bool WinEHPrepareImpl::runOnFunction(
Function &Fn) {
185 return prepareExplicitEH(Fn);
198 int TryHigh,
int CatchHigh,
208 "Malformed CatchPadInst not caught by win-eh-prepare");
227 for (
const User *U : CleanupPad->
users())
229 return CRI->getUnwindDest();
242 auto &BBColors = BlockColors[&BB];
243 assert(BBColors.size() == 1 &&
"multi-color BB not removed by preparation");
251 FuncletUnwindDest =
nullptr;
253 FuncletUnwindDest = CatchPad->getCatchSwitch()->getUnwindDest();
261 if (FuncletUnwindDest == InvokeUnwindDest) {
264 BaseState = BaseStateI->second;
267 if (BaseState != -1) {
290 struct WorkItem *WI =
new WorkItem(BB, State);
293 while (!WorkList.
empty()) {
296 int State = WI->State;
299 if (!Inserted && StateIt->second <= State)
306 StateIt->second = State;
330 WI =
new WorkItem(SuccBB, State);
352 struct WorkItem *WI =
new WorkItem(BB, State);
355 while (!WorkList.
empty()) {
358 int State = WI->State;
373 "Malformed CatchPadInst not caught by win-eh-prepare");
377 if (!
Filter || !
Filter->getName().starts_with(
"__IsLocalUnwind"))
397 WI =
new WorkItem(SuccBB, State);
411 if (CatchSwitch->getParentPad() != ParentPad)
417 if (CleanupPad->getParentPad() != ParentPad)
419 return CleanupPad->getParent();
433 "shouldn't revist catch funclets!");
436 for (
const BasicBlock *CatchPadBB : CatchSwitch->handlers()) {
444 CatchSwitch->getParentPad())))
450 int TryHigh = CatchLow - 1;
456 bool IsPreOrder =
Mod->getTargetTriple().isArch64Bit();
459 unsigned TBMEIdx = FuncInfo.
TryBlockMap.size() - 1;
461 for (
const auto *CatchPad : Handlers) {
466 BasicBlock *UnwindDest = InnerCatchSwitch->getUnwindDest();
467 if (!UnwindDest || UnwindDest == CatchSwitch->getUnwindDest())
475 if (!UnwindDest || UnwindDest == CatchSwitch->getUnwindDest())
483 FuncInfo.
TryBlockMap[TBMEIdx].CatchHigh = CatchHigh;
497 auto [It, Inserted] = FuncInfo.
EHPadStateMap.try_emplace(CleanupPad);
502 It->second = CleanupState;
503 LLVM_DEBUG(
dbgs() <<
"Assigning state #" << CleanupState <<
" to BB "
507 CleanupPad->getParentPad()))) {
513 if (UserI->isEHPad())
515 "contain exceptional actions");
524 Entry.IsFinally =
false;
526 Entry.Handler = Handler;
535 Entry.IsFinally =
true;
536 Entry.Filter =
nullptr;
537 Entry.Handler = Handler;
553 "shouldn't revist catch funclets!");
557 assert(CatchSwitch->getNumHandlers() == 1 &&
558 "SEH doesn't have multiple handlers per __try");
559 const auto *CatchPad =
563 "Malformed CatchPadInst not caught by win-eh-prepare");
568 "unexpected filter value");
575 << CatchPadBB->
getName() <<
'\n');
578 CatchSwitch->getParentPad())))
586 BasicBlock *UnwindDest = InnerCatchSwitch->getUnwindDest();
587 if (!UnwindDest || UnwindDest == CatchSwitch->getUnwindDest())
595 if (!UnwindDest || UnwindDest == CatchSwitch->getUnwindDest())
604 auto [It, Inserted] = FuncInfo.
EHPadStateMap.try_emplace(CleanupPad);
609 It->second = CleanupState;
610 LLVM_DEBUG(
dbgs() <<
"Assigning state #" << CleanupState <<
" to BB "
618 if (UserI->isEHPad())
620 "contain exceptional actions");
628 CatchSwitch->unwindsToCaller();
646 const Instruction *FirstNonPHI = &*BB.getFirstNonPHIIt();
670 const Instruction *FirstNonPHI = &*BB.getFirstNonPHIIt();
690 Entry.TryParentState = TryParentState;
691 Entry.Handler = Handler;
692 Entry.HandlerType = HandlerType;
693 Entry.TypeToken = TypeToken;
730 const Instruction *FirstNonPHI = &*BB.getFirstNonPHIIt();
731 const Value *ParentPad;
733 ParentPad = CPI->getParentPad();
735 ParentPad = CSI->getParentPad();
748 while (!Worklist.
empty()) {
750 int HandlerParentState;
751 std::tie(Pad, HandlerParentState) = Worklist.
pop_back_val();
771 int CatchState = -1, FollowerState = -1;
778 "Malformed CatchPadInst not caught by win-eh-prepare");
790 FollowerState = CatchState;
793 assert(CatchSwitch->getNumHandlers());
813 if (Entry.TryParentState != -1)
816 UnwindDest =
Catch->getCatchSwitch()->getUnwindDest();
819 UnwindDest =
nullptr;
824 UnwindDest = CleanupRet->getUnwindDest();
831 UserUnwindDest = Invoke->getUnwindDest();
833 UserUnwindDest = CatchSwitch->getUnwindDest();
836 int UserUnwindState =
838 if (UserUnwindState != -1)
853 const Value *UserUnwindParent;
855 UserUnwindParent = CSI->getParentPad();
862 if (UserUnwindParent ==
Cleanup)
866 UnwindDest = UserUnwindDest;
885 UnwindDestState = -1;
891 Entry.TryParentState = UnwindDestState;
898void WinEHPrepareImpl::colorFunclets(
Function &
F) {
905 FuncletBlocks[Color].push_back(&BB);
909bool WinEHPrepareImpl::demotePHIsOnFunclets(
Function &
F,
910 bool DemoteCatchSwitchPHIOnly) {
928 if (DemoteCatchSwitchPHIOnly) {
930 bool HasIncomingCatchSwitchBB =
false;
931 for (
unsigned I = 0,
E = PN->getNumIncomingValues();
I <
E; ++
I) {
933 PN->getIncomingBlock(
I)->getFirstNonPHIIt())) {
934 HasIncomingCatchSwitchBB =
true;
938 if (!IsCatchSwitchBB && !HasIncomingCatchSwitchBB)
946 insertPHIStores(PN, SpillSlot);
952 for (
auto *PN : PHINodes) {
955 PN->eraseFromParent();
961bool WinEHPrepareImpl::removeMalformedCatchswitch(
Value *FuncletToken) {
973 "catchpad with unexpected arguments", *CatchPad->
getParent()->getParent(),
987 switch (Personality) {
989 args = {nullPtr, constantZero, nullPtr};
998 args = {constantZero};
1003 Value *NewCatchPad =
1004 Builder.CreateCatchPad(CPI->getParentPad(),
args, CPI->getName());
1013bool WinEHPrepareImpl::cloneCommonBlocks(
Function &
F) {
1019 for (
auto &Funclets : FuncletBlocks) {
1021 std::vector<BasicBlock *> &BlocksInFunclet = Funclets.second;
1022 Value *FuncletToken;
1023 if (FuncletPadBB == &
F.getEntryBlock())
1027 Changed |= removeMalformedCatchswitch(FuncletToken);
1030 std::vector<std::pair<BasicBlock *, BasicBlock *>> Orig2Clone;
1035 size_t NumColorsForBB = ColorsForBB.
size();
1036 if (NumColorsForBB == 1)
1040 dbgs() <<
" Cloning block \'" << BB->getName()
1041 <<
"\' for funclet \'" << FuncletPadBB->
getName()
1055 Orig2Clone.emplace_back(BB, CBB);
1059 if (Orig2Clone.empty())
1066 for (
auto &BBMapping : Orig2Clone) {
1070 BlocksInFunclet.push_back(NewBlock);
1072 assert(NewColors.
empty() &&
"A new block should only have one color!");
1076 dbgs() <<
" Assigned color \'" << FuncletPadBB->
getName()
1077 <<
"\' to block \'" << NewBlock->
getName()
1085 dbgs() <<
" Removed color \'" << FuncletPadBB->
getName()
1086 <<
"\' from block \'" << OldBlock->
getName()
1101 for (
auto &BBMapping : Orig2Clone) {
1105 FixupCatchrets.
clear();
1108 if (CatchRet->getCatchSwitchParentPad() == FuncletToken)
1112 CatchRet->setSuccessor(NewBlock);
1115 auto UpdatePHIOnClonedBlock = [&](
PHINode *PN,
bool IsForOldBlock) {
1119 bool EdgeTargetsFunclet;
1122 EdgeTargetsFunclet =
1123 (CRI->getCatchSwitchParentPad() == FuncletToken);
1125 ColorVector &IncomingColors = BlockColors[IncomingBlock];
1126 assert(!IncomingColors.
empty() &&
"Block not colored!");
1128 (IncomingColors.
size() == 1 ||
1130 "Cloning should leave this funclet's blocks monochromatic");
1131 EdgeTargetsFunclet = (IncomingColors.
front() == FuncletPadBB);
1133 return IsForOldBlock == EdgeTargetsFunclet;
1138 for (
auto &BBMapping : Orig2Clone) {
1142 UpdatePHIOnClonedBlock(&OldPN,
true);
1145 UpdatePHIOnClonedBlock(&NewPN,
false);
1151 for (
auto &BBMapping : Orig2Clone) {
1155 for (
PHINode &SuccPN : SuccBB->phis()) {
1158 int OldBlockIdx = SuccPN.getBasicBlockIndex(OldBlock);
1159 if (OldBlockIdx == -1)
1161 Value *
IV = SuccPN.getIncomingValue(OldBlockIdx);
1166 if (
I != VMap.
end())
1170 SuccPN.addIncoming(
IV, NewBlock);
1192 ColorVector &ColorsForUserBB = BlockColors[UserBB];
1194 if (ColorsForUserBB.
size() > 1 ||
1195 *ColorsForUserBB.
begin() != FuncletPadBB)
1201 if (UsesToRename.
empty())
1208 SSAUpdate.
Initialize(OldI->getType(), OldI->getName());
1212 while (!UsesToRename.
empty())
1220bool WinEHPrepareImpl::removeImplausibleInstructions(
Function &
F) {
1224 for (
auto &Funclet : FuncletBlocks) {
1226 std::vector<BasicBlock *> &BlocksInFunclet = Funclet.second;
1238 Value *FuncletBundleOperand =
nullptr;
1240 FuncletBundleOperand = BU->Inputs.front();
1242 if (FuncletBundleOperand == FuncletPad)
1248 if (CB->isInlineAsm() ||
1249 (CalledFn && CalledFn->isIntrinsic() && CB->doesNotThrow()))
1260 std::prev(BB->getTerminator()->getIterator());
1276 bool IsUnreachableCatchret =
false;
1278 IsUnreachableCatchret = CRI->getCatchPad() != CatchPad;
1280 bool IsUnreachableCleanupret =
false;
1282 IsUnreachableCleanupret = CRI->getCleanupPad() != CleanupPad;
1283 if (IsUnreachableRet || IsUnreachableCatchret ||
1284 IsUnreachableCleanupret) {
1302bool WinEHPrepareImpl::cleanupPreparedFunclets(
Function &
F) {
1321void WinEHPrepareImpl::verifyPreparedFunclets(
Function &
F) {
1323 size_t NumColors = BlockColors[&BB].size();
1324 assert(NumColors == 1 &&
"Expected monochromatic BB!");
1329 assert((!Opts.win_eh_prepare_demotion ||
1331 "EH Pad still has a PHI!");
1336bool WinEHPrepareImpl::prepareExplicitEH(
Function &
F) {
1347 if (Opts.win_eh_prepare_demotion)
1348 Changed |= demotePHIsOnFunclets(
F, DemoteCatchSwitchPHIOnly);
1350 if (Opts.win_eh_prepare_cleanups) {
1352 Changed |= removeImplausibleInstructions(
F);
1355 Changed |= cleanupPreparedFunclets(
F);
1378 F.getEntryBlock().begin());
1391 if (
isa<PHINode>(UsingInst) && UsingInst->getParent()->isEHPad()) {
1396 replaceUseWithLoad(PN, U, SpillSlot, Loads,
F);
1405void WinEHPrepareImpl::insertPHIStores(
PHINode *OriginalPHI,
1413 while (!Worklist.
empty()) {
1436 insertPHIStore(PredBlock, InVal, SpillSlot, Worklist);
1442void WinEHPrepareImpl::insertPHIStore(
1448 Worklist.
push_back({PredBlock, PredVal});
1456void WinEHPrepareImpl::replaceUseWithLoad(
1461 SpillSlot =
new AllocaInst(
V->getType(),
DL->getAllocaAddrSpace(),
nullptr,
1462 Twine(
V->getName(),
".wineh.spillslot"),
1463 F.getEntryBlock().begin());
1476 BasicBlock *IncomingBlock = UsingPHI->getIncomingBlock(U);
1477 if (
auto *CatchRet =
1500 CatchRet->removeFromParent();
1501 CatchRet->insertInto(IncomingBlock, IncomingBlock->
end());
1504 CatchRet->setSuccessor(NewBlock);
1509 ColorVector &ColorsForNewBlock = BlockColors[NewBlock];
1510 ColorVector &ColorsForPHIBlock = BlockColors[PHIBlock];
1511 ColorsForNewBlock = ColorsForPHIBlock;
1512 for (
BasicBlock *FuncletPad : ColorsForPHIBlock)
1513 FuncletBlocks[FuncletPad].
push_back(NewBlock);
1515 IncomingBlock = NewBlock;
1521 V->getType(), SpillSlot,
Twine(
V->getName(),
".wineh.reload"),
1528 Twine(
V->getName(),
".wineh.reload"),
1529 false, UsingInst->getIterator());
1538 "should get invoke with precomputed state");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file defines the DenseMap class.
static bool runOnFunction(Function &F, bool PostInlining)
ManagedStatic< HTTPClientCleanup > Cleanup
Module.h This file contains the declarations for the Module class.
This file implements a map that provides insertion order iteration.
uint64_t IntrinsicInst * II
if(auto Err=PB.parsePassPipeline(MPM, Passes)) return wrap(std MPM run * Mod
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
#define DEBUG_WITH_TYPE(TYPE,...)
DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug information.
static bool isMalformedCatchpad(const CatchPadInst *CPI, EHPersonality Personality)
static int addUnwindMapEntry(WinEHFuncInfo &FuncInfo, int ToState, const BasicBlock *BB)
static void calculateStateNumbersForInvokes(const Function *Fn, WinEHFuncInfo &FuncInfo)
static BasicBlock * getCleanupRetUnwindDest(const CleanupPadInst *CleanupPad)
static int addSEHFinally(WinEHFuncInfo &FuncInfo, int ParentState, const BasicBlock *Handler)
static const BasicBlock * getEHPadFromPredecessor(const BasicBlock *BB, Value *ParentPad)
static int addClrEHHandler(WinEHFuncInfo &FuncInfo, int HandlerParentState, int TryParentState, ClrHandlerType HandlerType, uint32_t TypeToken, const BasicBlock *Handler)
static void calculateCXXStateNumbers(WinEHFuncInfo &FuncInfo, const Instruction *FirstNonPHI, int ParentState)
static void addTryBlockMapEntry(WinEHFuncInfo &FuncInfo, int TryLow, int TryHigh, int CatchHigh, ArrayRef< const CatchPadInst * > Handlers)
static bool isTopLevelPadForMSVC(const Instruction *EHPad)
static int addSEHExcept(WinEHFuncInfo &FuncInfo, int ParentState, const Function *Filter, const BasicBlock *Handler)
static const uint32_t IV[8]
an instruction to allocate memory on the stack
Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
iterator_range< const_phi_iterator > phis() const
Returns a range that iterates over the phis in the basic block.
LLVM_ABI const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
const Function * getParent() const
Return the enclosing method, or null if none.
LLVM_ABI InstListType::const_iterator getFirstNonPHIIt() const
Returns an iterator to the first instruction in this block that is not a PHINode instruction.
InstListType::const_iterator const_iterator
const Instruction & front() const
LLVM_ABI void insertInto(Function *Parent, BasicBlock *InsertBefore=nullptr)
Insert unlinked basic block into a function.
InstListType::iterator iterator
Instruction iterators...
bool isEHPad() const
Return true if this basic block is an exception handling block.
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction; assumes that the block is well-formed.
CatchSwitchInst * getCatchSwitch() const
Convenience accessors.
handler_range handlers()
iteration adapter for range-for loops.
static LLVM_ABI ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
static LLVM_ABI ConstantTokenNone * get(LLVMContext &Context)
Return the ConstantTokenNone.
This is an important base class in LLVM.
bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
const Constant * stripPointerCasts() const
unsigned arg_size() const
arg_size - Return the number of funcletpad arguments.
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th funcletpad argument.
FunctionPass class - This class is used to implement most global optimizations.
const BasicBlock & getEntryBlock() const
const DataLayout & getDataLayout() const
Get the data layout of the module this function belongs to.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
bool hasPersonalityFn() const
Check whether this function has a personality function.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
Module * getParent()
Get the module that this global value is contained inside of...
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
LLVM_ABI void removeFromParent()
This method unlinks 'this' from the containing basic block, but does not delete it.
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
bool isEHPad() const
Return true if the instruction is a variety of EH-block.
bool isTerminator() const
iterator_range< user_iterator > users()
LLVM_ABI InstListType::iterator insertInto(BasicBlock *ParentBB, InstListType::iterator It)
Inserts an unlinked instruction into ParentBB at position It and returns the iterator of the inserted...
This is an important class for using LLVM in a threaded context.
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
An instruction for reading from memory.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
A Module instance is used to store all the information related to an LLVM module.
Metadata * getModuleFlag(StringRef Key) const
Return the corresponding value if Key appears in module flags, otherwise return null.
LLVM_ABI void removeIncomingValueIf(function_ref< bool(unsigned)> Predicate, bool DeletePHIIfEmpty=true)
Remove all incoming values for which the predicate returns true.
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
unsigned getNumIncomingValues() const
Return the number of incoming edges.
static PointerType * getUnqual(LLVMContext &C)
This constructs an opaque pointer to an object in the default address space (address space zero).
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
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.
Helper class for SSA formation on a set of values defined in multiple blocks.
LLVM_ABI void RewriteUseAfterInsertions(Use &U)
Rewrite a use like RewriteUse but handling in-block definitions.
LLVM_ABI void Initialize(Type *Ty, StringRef Name)
Reset this object to get ready for a new set of SSA updates with type 'Ty'.
LLVM_ABI void AddAvailableValue(BasicBlock *BB, Value *V)
Indicate that a rewritten value is available in the specified block with the specified value.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
void push_back(EltTy NewVal)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
Unconditional Branch instruction.
void setSuccessor(BasicBlock *NewSucc)
A Use represents the edge between a Value definition and its users.
std::pair< const Value *, WeakTrackingVH > value_type
iterator find(const KeyT &Val)
ValueMapIteratorImpl< MapT, const Value *, false > iterator
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
LLVMContext & getContext() const
All values hold a context through their type.
iterator_range< use_iterator > uses()
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
const ParentTy * getParent() const
self_iterator getIterator()
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI FunctionPass * createWinEHPass()
createWinEHPass - Prepares personality functions used by MSVC on Windows, in addition to the Itanium ...
LLVM_ABI bool ConstantFoldTerminator(BasicBlock *BB, bool DeleteDeadConditions=false, const TargetLibraryInfo *TLI=nullptr, DomTreeUpdater *DTU=nullptr)
If a terminator instruction is predicated on a constant value, convert it into an unconditional branc...
LLVM_ABI BasicBlock * CloneBasicBlock(const BasicBlock *BB, ValueToValueMapTy &VMap, const Twine &NameSuffix="", Function *F=nullptr, ClonedCodeInfo *CodeInfo=nullptr, bool MapAtoms=true)
Return a copy of the specified basic block, but without embedding the block into a particular functio...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool verifyFunction(const Function &F, raw_ostream *OS=nullptr)
Check a function for errors, useful for use when debugging a pass.
auto successors(const MachineBasicBlock *BB)
@ Load
The value being inserted comes from a load (InsertElement only).
LLVM_ABI DenseMap< BasicBlock *, ColorVector > colorEHFunclets(Function &F)
If an EH funclet personality is in use (see isFuncletEHPersonality), this will recompute which blocks...
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...
LLVM_ABI bool SimplifyInstructionsInBlock(BasicBlock *BB, const TargetLibraryInfo *TLI=nullptr)
Scan the specified basic block and try to simplify any instructions in it and recursively delete dead...
LLVM_ABI void calculateWinCXXEHStateNumbers(const Function *ParentFn, WinEHFuncInfo &FuncInfo)
Analyze the IR in ParentFn and it's handlers to build WinEHFuncInfo, which describes the state number...
bool isScopedEHPersonality(EHPersonality Pers)
Returns true if this personality uses scope-style EH IR instructions: catchswitch,...
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
LLVM_ABI bool removeUnreachableBlocks(Function &F, DomTreeUpdater *DTU=nullptr, MemorySSAUpdater *MSSAU=nullptr, bool FoldInstsToUnreachable=true)
Remove all blocks that can not be reached from the function's entry.
auto dyn_cast_or_null(const Y &Val)
void erase(Container &C, ValueType V)
Wrapper function to remove a value from a container:
auto reverse(ContainerTy &&C)
@ RF_IgnoreMissingLocals
If this flag is set, the remapper ignores missing function-local entries (Argument,...
@ RF_NoModuleLevelChanges
If this flag is set, the remapper knows that only local values within a function (such as an instruct...
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
LLVM_ABI Instruction * removeUnwindEdge(BasicBlock *BB, DomTreeUpdater *DTU=nullptr)
Replace 'BB's terminator with one that does not have an unwind successor block.
LLVM_ABI void calculateSEHStateForAsynchEH(const BasicBlock *BB, int State, WinEHFuncInfo &FuncInfo)
LLVM_ABI EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI unsigned changeToUnreachable(Instruction *I, bool PreserveLCSSA=false, DomTreeUpdater *DTU=nullptr, MemorySSAUpdater *MSSAU=nullptr)
Insert an unreachable instruction before the specified instruction, making it and the rest of the cod...
LLVM_ABI void calculateCXXStateForAsynchEH(const BasicBlock *BB, int State, WinEHFuncInfo &FuncInfo)
bool isFuncletEHPersonality(EHPersonality Pers)
Returns true if this is a personality function that invokes handler funclets (which must return to it...
LLVM_ABI void calculateSEHStateNumbers(const Function *ParentFn, WinEHFuncInfo &FuncInfo)
LLVM_ABI bool MergeBlockIntoPredecessor(BasicBlock *BB, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, MemoryDependenceResults *MemDep=nullptr, bool PredecessorWithTwoSuccessors=false, DominatorTree *DT=nullptr)
Attempts to merge a block into its predecessor, if possible.
void RemapInstruction(Instruction *I, ValueToValueMapTy &VM, RemapFlags Flags=RF_None, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr, const MetadataPredicate *IdentityMD=nullptr)
Convert the instruction operands from referencing the current values into those specified by VM.
ValueMap< const Value *, WeakTrackingVH > ValueToValueMapTy
TinyPtrVector< BasicBlock * > ColorVector
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
auto predecessors(const MachineBasicBlock *BB)
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
LLVM_ABI BasicBlock * SplitEdge(BasicBlock *From, BasicBlock *To, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, const Twine &BBName="")
Split the edge connecting the specified blocks, and return the newly created basic block between From...
const CodeGenOptions & getCodeGenOptions(const LLVMContext &C)
LLVM_ABI void calculateClrEHStateNumbers(const Function *Fn, WinEHFuncInfo &FuncInfo)
WorkItem(const BasicBlock *BB, int St)
int HandlerParentState
Outer handler enclosing this entry's handler.
Similar to CxxUnwindMapEntry, but supports SEH filters.
int ToState
If unwinding continues through this handler, transition to the handler at this state.
LLVM_ABI void addIPToStateRange(const InvokeInst *II, MCSymbol *InvokeBegin, MCSymbol *InvokeEnd)
SmallVector< SEHUnwindMapEntry, 4 > SEHUnwindMap
SmallVector< ClrEHUnwindMapEntry, 4 > ClrEHUnwindMap
DenseMap< const FuncletPadInst *, int > FuncletBaseStateMap
DenseMap< const BasicBlock *, int > BlockToStateMap
DenseMap< const InvokeInst *, int > InvokeStateMap
SmallVector< WinEHTryBlockMapEntry, 4 > TryBlockMap
DenseMap< const Instruction *, int > EHPadStateMap
DenseMap< MCSymbol *, std::pair< int, MCSymbol * > > LabelToStateMap
SmallVector< CxxUnwindMapEntry, 4 > CxxUnwindMap
int getLastStateNumber() const
GlobalVariable * TypeDescriptor
union llvm::WinEHHandlerType::@246205307012256373115155017221207221353102114334 CatchObj
The CatchObj starts out life as an LLVM alloca and is eventually turned frame index.
const AllocaInst * Alloca
SmallVector< WinEHHandlerType, 1 > HandlerArray