39 #define DEBUG_TYPE "winehprepare"
44 "Clone multicolor basic blocks but do not demote cross funclet values"),
49 cl::desc(
"Do not remove implausible terminators or other similar cleanups"),
59 bool runOnFunction(
Function &Fn)
override;
61 bool doFinalization(
Module &M)
override;
66 return "Windows exception handling preparation";
82 void removeImplausibleInstructions(
Function &
F);
83 void cleanupPreparedFunclets(
Function &
F);
100 return new WinEHPrepare(TM);
103 bool WinEHPrepare::runOnFunction(
Function &Fn) {
114 return prepareExplicitEH(Fn);
117 bool WinEHPrepare::doFinalization(
Module &M) {
return false; }
119 void WinEHPrepare::getAnalysisUsage(
AnalysisUsage &AU)
const {}
131 int TryHigh,
int CatchHigh,
140 Constant *TypeInfo = cast<Constant>(CPI->getArgOperand(0));
145 HT.
Adjectives = cast<ConstantInt>(CPI->getArgOperand(1))->getZExtValue();
148 dyn_cast<AllocaInst>(CPI->getArgOperand(2)->stripPointerCasts()))
158 for (
const User *U : CleanupPad->
users())
159 if (
const auto *CRI = dyn_cast<CleanupReturnInst>(U))
160 return CRI->getUnwindDest();
173 auto &BBColors = BlockColors[&BB];
174 assert(BBColors.size() == 1 &&
"multi-color BB not removed by preparation");
182 FuncletUnwindDest =
nullptr;
183 else if (
auto *CatchPad = dyn_cast<CatchPadInst>(FuncletPad))
184 FuncletUnwindDest = CatchPad->getCatchSwitch()->getUnwindDest();
185 else if (
auto *CleanupPad = dyn_cast<CleanupPadInst>(FuncletPad))
190 BasicBlock *InvokeUnwindDest = II->getUnwindDest();
192 if (FuncletUnwindDest == InvokeUnwindDest) {
195 BaseState = BaseStateI->second;
198 if (BaseState != -1) {
213 if (isa<InvokeInst>(TI))
215 if (
auto *CatchSwitch = dyn_cast<CatchSwitchInst>(TI)) {
216 if (CatchSwitch->getParentPad() != ParentPad)
221 auto *CleanupPad = cast<CleanupReturnInst>(TI)->getCleanupPad();
222 if (CleanupPad->getParentPad() != ParentPad)
224 return CleanupPad->getParent();
233 if (
auto *CatchSwitch = dyn_cast<CatchSwitchInst>(FirstNonPHI)) {
235 "shouldn't revist catch funclets!");
238 for (
const BasicBlock *CatchPadBB : CatchSwitch->handlers()) {
239 auto *CatchPad = cast<CatchPadInst>(CatchPadBB->getFirstNonPHI());
246 CatchSwitch->getParentPad())))
252 int TryHigh = CatchLow - 1;
253 for (
const auto *CatchPad : Handlers) {
255 for (
const User *U : CatchPad->
users()) {
256 const auto *UserI = cast<Instruction>(U);
257 if (
auto *InnerCatchSwitch = dyn_cast<CatchSwitchInst>(UserI)) {
258 BasicBlock *UnwindDest = InnerCatchSwitch->getUnwindDest();
259 if (!UnwindDest || UnwindDest == CatchSwitch->getUnwindDest())
262 if (
auto *InnerCleanupPad = dyn_cast<CleanupPadInst>(UserI)) {
267 if (!UnwindDest || UnwindDest == CatchSwitch->getUnwindDest())
279 auto *CleanupPad = cast<CleanupPadInst>(FirstNonPHI);
288 DEBUG(
dbgs() <<
"Assigning state #" << CleanupState <<
" to BB "
292 CleanupPad->getParentPad()))) {
297 for (
const User *U : CleanupPad->
users()) {
298 const auto *UserI = cast<Instruction>(U);
299 if (UserI->isEHPad())
301 "contain exceptional actions");
334 if (
auto *CatchSwitch = dyn_cast<CatchSwitchInst>(FirstNonPHI)) {
336 "shouldn't revist catch funclets!");
340 assert(CatchSwitch->getNumHandlers() == 1 &&
341 "SEH doesn't have multiple handlers per __try");
342 const auto *CatchPad =
343 cast<CatchPadInst>((*CatchSwitch->handler_begin())->getFirstNonPHI());
346 cast<Constant>(CatchPad->getArgOperand(0)->stripPointerCasts());
349 "unexpected filter value");
350 int TryState =
addSEHExcept(FuncInfo, ParentState, Filter, CatchPadBB);
354 DEBUG(
dbgs() <<
"Assigning state #" << TryState <<
" to BB "
355 << CatchPadBB->getName() <<
'\n');
358 CatchSwitch->getParentPad())))
364 for (
const User *U : CatchPad->
users()) {
365 const auto *UserI = cast<Instruction>(U);
366 if (
auto *InnerCatchSwitch = dyn_cast<CatchSwitchInst>(UserI)) {
367 BasicBlock *UnwindDest = InnerCatchSwitch->getUnwindDest();
368 if (!UnwindDest || UnwindDest == CatchSwitch->getUnwindDest())
371 if (
auto *InnerCleanupPad = dyn_cast<CleanupPadInst>(UserI)) {
376 if (!UnwindDest || UnwindDest == CatchSwitch->getUnwindDest())
381 auto *CleanupPad = cast<CleanupPadInst>(FirstNonPHI);
390 DEBUG(
dbgs() <<
"Assigning state #" << CleanupState <<
" to BB "
397 for (
const User *U : CleanupPad->
users()) {
398 const auto *UserI = cast<Instruction>(U);
399 if (UserI->isEHPad())
401 "contain exceptional actions");
407 if (
auto *CatchSwitch = dyn_cast<CatchSwitchInst>(EHPad))
408 return isa<ConstantTokenNone>(CatchSwitch->getParentPad()) &&
409 CatchSwitch->unwindsToCaller();
410 if (
auto *CleanupPad = dyn_cast<CleanupPadInst>(EHPad))
411 return isa<ConstantTokenNone>(CleanupPad->getParentPad()) &&
413 if (isa<CatchPadInst>(EHPad))
427 const Instruction *FirstNonPHI = BB.getFirstNonPHI();
445 const Instruction *FirstNonPHI = BB.getFirstNonPHI();
499 const Instruction *FirstNonPHI = BB.getFirstNonPHI();
500 const Value *ParentPad;
501 if (
const auto *CPI = dyn_cast<CleanupPadInst>(FirstNonPHI))
502 ParentPad = CPI->getParentPad();
503 else if (
const auto *CSI = dyn_cast<CatchSwitchInst>(FirstNonPHI))
504 ParentPad = CSI->getParentPad();
507 if (isa<ConstantTokenNone>(ParentPad))
517 while (!Worklist.
empty()) {
519 int HandlerParentState;
520 std::tie(Pad, HandlerParentState) = Worklist.
pop_back_val();
522 if (
const auto *Cleanup = dyn_cast<CleanupPadInst>(Pad)) {
532 if (
const auto *
I = dyn_cast<Instruction>(U))
540 const auto *CatchSwitch = cast<CatchSwitchInst>(Pad);
541 int CatchState = -1, FollowerState = -1;
543 for (
auto CBI = CatchBlocks.rbegin(), CBE = CatchBlocks.rend();
544 CBI != CBE; ++CBI, FollowerState = CatchState) {
550 cast<ConstantInt>(
Catch->getArgOperand(0))->getZExtValue());
556 if (
const auto *
I = dyn_cast<Instruction>(U))
563 assert(CatchSwitch->getNumHandlers());
573 Entry !=
End; ++Entry) {
575 Entry->Handler.get<
const BasicBlock *>()->getFirstNonPHI();
579 if (
const auto *
Catch = dyn_cast<CatchPadInst>(Pad)) {
585 if (Entry->TryParentState != -1)
588 UnwindDest =
Catch->getCatchSwitch()->getUnwindDest();
590 const auto *Cleanup = cast<CleanupPadInst>(Pad);
591 UnwindDest =
nullptr;
593 if (
auto *CleanupRet = dyn_cast<CleanupReturnInst>(U)) {
596 UnwindDest = CleanupRet->getUnwindDest();
602 if (
auto *Invoke = dyn_cast<InvokeInst>(U)) {
603 UserUnwindDest = Invoke->getUnwindDest();
604 }
else if (
auto *CatchSwitch = dyn_cast<CatchSwitchInst>(U)) {
605 UserUnwindDest = CatchSwitch->getUnwindDest();
606 }
else if (
auto *ChildCleanup = dyn_cast<CleanupPadInst>(U)) {
608 int UserUnwindState =
610 if (UserUnwindState != -1)
625 const Value *UserUnwindParent;
626 if (
auto *CSI = dyn_cast<CatchSwitchInst>(UserUnwindPad))
627 UserUnwindParent = CSI->getParentPad();
634 if (UserUnwindParent == Cleanup)
638 UnwindDest = UserUnwindDest;
657 UnwindDestState = -1;
662 Entry->TryParentState = UnwindDestState;
669 void WinEHPrepare::colorFunclets(
Function &
F) {
680 void WinEHPrepare::demotePHIsOnFunclets(
Function &F) {
694 AllocaInst *SpillSlot = insertPHILoads(PN, F);
696 insertPHIStores(PN, SpillSlot);
702 for (
auto *PN : PHINodes) {
705 PN->eraseFromParent();
709 void WinEHPrepare::cloneCommonBlocks(
Function &F) {
713 for (
auto &Funclets : FuncletBlocks) {
715 std::vector<BasicBlock *> &BlocksInFunclet = Funclets.second;
722 std::vector<std::pair<BasicBlock *, BasicBlock *>> Orig2Clone;
727 size_t NumColorsForBB = ColorsForBB.
size();
728 if (NumColorsForBB == 1)
733 <<
"\' for funclet \'" << FuncletPadBB->
getName()
747 Orig2Clone.emplace_back(BB, CBB);
751 if (Orig2Clone.empty())
756 for (
auto &BBMapping : Orig2Clone) {
760 BlocksInFunclet.push_back(NewBlock);
762 assert(NewColors.
empty() &&
"A new block should only have one color!");
766 dbgs() <<
" Assigned color \'" << FuncletPadBB->
getName()
767 <<
"\' to block \'" << NewBlock->
getName()
770 BlocksInFunclet.erase(
771 std::remove(BlocksInFunclet.begin(), BlocksInFunclet.end(), OldBlock),
772 BlocksInFunclet.end());
779 dbgs() <<
" Removed color \'" << FuncletPadBB->
getName()
780 <<
"\' from block \'" << OldBlock->
getName()
795 for (
auto &BBMapping : Orig2Clone) {
799 FixupCatchrets.
clear();
801 if (
auto *CatchRet = dyn_cast<CatchReturnInst>(Pred->getTerminator()))
802 if (CatchRet->getCatchSwitchParentPad() == FuncletToken)
806 CatchRet->setSuccessor(NewBlock);
809 auto UpdatePHIOnClonedBlock = [&](
PHINode *PN,
bool IsForOldBlock) {
811 for (
unsigned PredIdx = 0, PredEnd = NumPreds; PredIdx != PredEnd;
814 bool EdgeTargetsFunclet;
817 EdgeTargetsFunclet = (CRI->getCatchSwitchParentPad() == FuncletToken);
819 ColorVector &IncomingColors = BlockColors[IncomingBlock];
820 assert(!IncomingColors.
empty() &&
"Block not colored!");
824 return Color != FuncletPadBB;
826 "Cloning should leave this funclet's blocks monochromatic");
827 EdgeTargetsFunclet = (IncomingColors.
front() == FuncletPadBB);
829 if (IsForOldBlock != EdgeTargetsFunclet)
838 for (
auto &BBMapping : Orig2Clone) {
845 UpdatePHIOnClonedBlock(OldPN,
true);
851 UpdatePHIOnClonedBlock(NewPN,
false);
857 for (
auto &BBMapping : Orig2Clone) {
869 if (OldBlockIdx == -1)
871 Value *IV = SuccPN->getIncomingValue(OldBlockIdx);
874 if (
auto *Inst = dyn_cast<Instruction>(IV)) {
880 SuccPN->addIncoming(IV, NewBlock);
896 auto *NewI = cast<Instruction>(VT.second);
900 Instruction *UserI = cast<Instruction>(U.getUser());
902 ColorVector &ColorsForUserBB = BlockColors[UserBB];
904 if (ColorsForUserBB.
size() > 1 ||
905 *ColorsForUserBB.
begin() != FuncletPadBB)
906 UsesToRename.push_back(&U);
911 if (UsesToRename.empty())
918 SSAUpdate.
Initialize(OldI->getType(), OldI->getName());
922 while (!UsesToRename.empty())
928 void WinEHPrepare::removeImplausibleInstructions(
Function &F) {
930 for (
auto &Funclet : FuncletBlocks) {
932 std::vector<BasicBlock *> &BlocksInFunclet = Funclet.second;
935 auto *CatchPad = dyn_cast_or_null<CatchPadInst>(FuncletPad);
936 auto *CleanupPad = dyn_cast_or_null<CleanupPadInst>(FuncletPad);
944 Value *FuncletBundleOperand =
nullptr;
946 FuncletBundleOperand = BU->Inputs.front();
948 if (FuncletBundleOperand == FuncletPad)
954 if (CalledFn && ((CalledFn->isIntrinsic() &&
CS.doesNotThrow()) ||
964 std::prev(BB->getTerminator()->getIterator());
965 auto *CI = cast<CallInst>(&*CallI);
978 bool IsUnreachableRet = isa<ReturnInst>(TI) && FuncletPad;
980 bool IsUnreachableCatchret =
false;
981 if (
auto *CRI = dyn_cast<CatchReturnInst>(TI))
982 IsUnreachableCatchret = CRI->getCatchPad() != CatchPad;
984 bool IsUnreachableCleanupret =
false;
985 if (
auto *CRI = dyn_cast<CleanupReturnInst>(TI))
986 IsUnreachableCleanupret = CRI->getCleanupPad() != CleanupPad;
987 if (IsUnreachableRet || IsUnreachableCatchret ||
988 IsUnreachableCleanupret) {
990 }
else if (isa<InvokeInst>(TI)) {
1002 void WinEHPrepare::cleanupPreparedFunclets(
Function &F) {
1017 void WinEHPrepare::verifyPreparedFunclets(
Function &F) {
1019 size_t NumColors = BlockColors[&BB].size();
1020 assert(NumColors == 1 &&
"Expected monochromatic BB!");
1026 "EH Pad still has a PHI!");
1030 bool WinEHPrepare::prepareExplicitEH(
Function &F) {
1039 cloneCommonBlocks(F);
1042 demotePHIsOnFunclets(F);
1046 removeImplausibleInstructions(F);
1049 cleanupPreparedFunclets(F);
1052 DEBUG(verifyPreparedFunclets(F));
1054 DEBUG(colorFunclets(F));
1055 DEBUG(verifyPreparedFunclets(F));
1057 BlockColors.clear();
1058 FuncletBlocks.clear();
1070 if (!isa<TerminatorInst>(EHPad)) {
1088 auto *UsingInst = cast<Instruction>(U.
getUser());
1089 if (isa<PHINode>(UsingInst) && UsingInst->getParent()->isEHPad()) {
1094 replaceUseWithLoad(PN, U, SpillSlot, Loads, F);
1103 void WinEHPrepare::insertPHIStores(
PHINode *OriginalPHI,
1111 while (!Worklist.
empty()) {
1125 if (isa<UndefValue>(PredVal))
1134 insertPHIStore(PredBlock, InVal, SpillSlot, Worklist);
1140 void WinEHPrepare::insertPHIStore(
1147 Worklist.
push_back({PredBlock, PredVal});
1164 auto *UsingInst = cast<Instruction>(U.
getUser());
1165 if (
auto *UsingPHI = dyn_cast<PHINode>(UsingInst)) {
1175 BasicBlock *IncomingBlock = UsingPHI->getIncomingBlock(U);
1176 if (
auto *CatchRet =
1177 dyn_cast<CatchReturnInst>(IncomingBlock->
getTerminator())) {
1199 CatchRet->removeFromParent();
1203 CatchRet->setSuccessor(NewBlock);
1208 ColorVector &ColorsForNewBlock = BlockColors[NewBlock];
1209 ColorVector &ColorsForPHIBlock = BlockColors[PHIBlock];
1210 ColorsForNewBlock = ColorsForPHIBlock;
1211 for (
BasicBlock *FuncletPad : ColorsForPHIBlock)
1212 FuncletBlocks[FuncletPad].
push_back(NewBlock);
1214 IncomingBlock = NewBlock;
1235 "should get invoke with precomputed state");
void push_back(const T &Elt)
use_iterator_impl< Use > use_iterator
static Value * getParentPad(Value *EHPad)
iterator_range< use_iterator > uses()
SmallVector< WinEHHandlerType, 1 > HandlerArray
Helper class for SSA formation on a set of values defined in multiple blocks.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
DenseMap< MCSymbol *, std::pair< int, MCSymbol * > > LabelToStateMap
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
void Initialize(Type *Ty, StringRef Name)
Reset this object to get ready for a new set of SSA updates with type 'Ty'.
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. ...
SmallVector< SEHUnwindMapEntry, 4 > SEHUnwindMap
std::error_code remove(const Twine &path, bool IgnoreNonExisting=true)
Remove path.
void AddAvailableValue(BasicBlock *BB, Value *V)
Indicate that a rewritten value is available in the specified block with the specified value...
DenseMap< const FuncletPadInst *, int > FuncletBaseStateMap
const AllocaInst * Alloca
FunctionPass * createWinEHPass(const TargetMachine *TM)
createWinEHPass - Prepares personality functions used by MSVC on Windows, in addition to the Itanium ...
This class implements a map that also provides access to all stored values in a deterministic order...
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
bool isEHPad() const
Return true if this basic block is an exception handling block.
const Function * getParent() const
Return the enclosing method, or null if none.
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...
const Instruction & front() const
std::pair< const Value *, WeakVH > value_type
An instruction for reading from memory.
unsigned changeToUnreachable(Instruction *I, bool UseLLVMTrap, bool PreserveLCSSA=false)
Insert an unreachable instruction before the specified instruction, making it and the rest of the cod...
INITIALIZE_TM_PASS(WinEHPrepare,"winehprepare","Prepare Windows exceptions", false, false) FunctionPass *llvm
TinyPtrVector - This class is specialized for cases where there are normally 0 or 1 element in a vect...
static cl::opt< bool > DisableCleanups("disable-cleanups", cl::Hidden, cl::desc("Do not remove implausible terminators or other similar cleanups"), cl::init(false))
StringRef getName() const
Return a constant reference to the value's name.
iterator begin()
Instruction iterator methods.
MBBOrBasicBlock Handler
Holds the __except or __finally basic block.
#define DEBUG_WITH_TYPE(TYPE, X)
DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug information.
Value * removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty=true)
Remove an incoming value.
iterator erase(iterator I)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void calculateSEHStateNumbers(const Function *ParentFn, WinEHFuncInfo &FuncInfo)
A Use represents the edge between a Value definition and its users.
bool ConstantFoldTerminator(BasicBlock *BB, bool DeleteDeadConditions=false, const TargetLibraryInfo *TLI=nullptr)
If a terminator instruction is predicated on a constant value, convert it into an unconditional branc...
int TryParentState
Outer try region enclosing this entry's try region, treating later catches on same try as "outer"...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Instruction * getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
static BasicBlock * getCleanupRetUnwindDest(const CleanupPadInst *CleanupPad)
Constant * getPersonalityFn() const
Get the personality function associated with this function.
LLVM_NODISCARD bool empty() const
int ToState
If unwinding continues through this handler, transition to the handler at this state.
static int addUnwindMapEntry(WinEHFuncInfo &FuncInfo, int ToState, const BasicBlock *BB)
static void calculateStateNumbersForInvokes(const Function *Fn, WinEHFuncInfo &FuncInfo)
iterator find(const KeyT &Val)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
An instruction for storing to memory.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
If this flag is set, the remapper knows that only local values within a function (such as an instruct...
unsigned getNumIncomingValues() const
Return the number of incoming edges.
Similar to CxxUnwindMapEntry, but supports SEH filters.
initializer< Ty > init(const Ty &Val)
static cl::opt< bool > DisableDemotion("disable-demotion", cl::Hidden, cl::desc("Clone multicolor basic blocks but do not demote cross funclet values"), cl::init(false))
SmallVector< ClrEHUnwindMapEntry, 4 > ClrEHUnwindMap
Subclasses of this class are all able to terminate a basic block.
Constant * stripPointerCasts()
static int addSEHExcept(WinEHFuncInfo &FuncInfo, int ParentState, const Function *Filter, const BasicBlock *Handler)
LLVM Basic Block Representation.
void push_back(EltTy NewVal)
void RewriteUseAfterInsertions(Use &U)
Rewrite a use like RewriteUse but handling in-block definitions.
Conditional or Unconditional Branch instruction.
This is an important base class in LLVM.
bool hasPersonalityFn() const
Check whether this function has a personality function.
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
DenseMap< const Instruction *, int > EHPadStateMap
Represent the analysis usage information of a pass.
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
const InstListType & getInstList() const
Return the underlying instruction list container.
static const unsigned End
int getLastStateNumber() const
User * getUser() const
Returns the User that contains this Use.
FunctionPass class - This class is used to implement most global optimizations.
DenseMap< const InvokeInst *, int > InvokeStateMap
void calculateClrEHStateNumbers(const Function *Fn, WinEHFuncInfo &FuncInfo)
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
static bool isTopLevelPadForMSVC(const Instruction *EHPad)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void setSuccessor(unsigned idx, BasicBlock *NewSucc)
void calculateWinCXXEHStateNumbers(const Function *ParentFn, WinEHFuncInfo &FuncInfo)
Analyze the IR in ParentFn and it's handlers to build WinEHFuncInfo, which describes the state number...
SmallVector< CxxUnwindMapEntry, 4 > CxxUnwindMap
const Function * Filter
Holds the filter expression function.
Iterator for intrusive lists based on ilist_node.
Color
A "color", which is either even or odd.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
bool isFuncletEHPersonality(EHPersonality Pers)
Returns true if this is a personality function that invokes handler funclets (which must return to it...
bool removeUnreachableBlocks(Function &F, LazyValueInfo *LVI=nullptr)
Remove all blocks that can not be reached from the function's entry.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Type * getType() const
All values are typed, get the type of this value.
static void calculateCXXStateNumbers(WinEHFuncInfo &FuncInfo, const Instruction *FirstNonPHI, int ParentState)
int HandlerParentState
Outer handler enclosing this entry's handler.
LLVM_NODISCARD T pop_back_val()
static void addTryBlockMapEntry(WinEHFuncInfo &FuncInfo, int TryLow, int TryHigh, int CatchHigh, ArrayRef< const CatchPadInst * > Handlers)
void addIPToStateRange(const InvokeInst *II, MCSymbol *InvokeBegin, MCSymbol *InvokeEnd)
pred_range predecessors(BasicBlock *BB)
const BasicBlock & getEntryBlock() const
bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
SmallVector< WinEHTryBlockMapEntry, 4 > TryBlockMap
void push_back(pointer val)
iterator_range< user_iterator > users()
void RemapInstruction(Instruction *I, ValueToValueMapTy &VM, RemapFlags Flags=RF_None, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr)
Convert the instruction operands from referencing the current values into those specified by VM...
GlobalVariable * TypeDescriptor
void removeUnwindEdge(BasicBlock *BB)
Replace 'BB's terminator with one that does not have an unwind successor block.
If this flag is set, the remapper ignores missing function-local entries (Argument, Instruction, BasicBlock) that are not in the value map.
void removeFromParent()
This method unlinks 'this' from the containing basic block, but does not delete it.
bool isEHPad() const
Return true if the instruction is a variety of EH-block.
void emplace_back(ArgTypes &&...Args)
bool MergeBlockIntoPredecessor(BasicBlock *BB, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr, MemoryDependenceResults *MemDep=nullptr)
Attempts to merge a block into its predecessor, if possible.
static int addSEHFinally(WinEHFuncInfo &FuncInfo, int ParentState, const BasicBlock *Handler)
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
bool verifyFunction(const Function &F, raw_ostream *OS=nullptr)
Check a function for errors, useful for use when debugging a pass.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
static ConstantTokenNone * get(LLVMContext &Context)
Return the ConstantTokenNone.
union llvm::WinEHHandlerType::@61 CatchObj
The CatchObj starts out life as an LLVM alloca and is eventually turned frame index.
ClrHandlerType HandlerType
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static int addClrEHHandler(WinEHFuncInfo &FuncInfo, int HandlerParentState, int TryParentState, ClrHandlerType HandlerType, uint32_t TypeToken, const BasicBlock *Handler)
LLVM Value Representation.
succ_range successors(BasicBlock *BB)
BasicBlock * SplitEdge(BasicBlock *From, BasicBlock *To, DominatorTree *DT=nullptr, LoopInfo *LI=nullptr)
Split the edge connecting specified block.
Primary interface to the complete machine description for the target machine.
StringRef - Represent a constant reference to a string, i.e.
iterator getFirstInsertionPt()
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
DenseMap< BasicBlock *, ColorVector > colorEHFunclets(Function &F)
If an EH funclet personality is in use (see isFuncletEHPersonality), this will recompute which blocks...
static const BasicBlock * getEHPadFromPredecessor(const BasicBlock *BB, Value *ParentPad)
BasicBlock * CloneBasicBlock(const BasicBlock *BB, ValueToValueMapTy &VMap, const Twine &NameSuffix="", Function *F=nullptr, ClonedCodeInfo *CodeInfo=nullptr)
CloneBasicBlock - Return a copy of the specified basic block, but without embedding the block into a ...
int getBasicBlockIndex(const BasicBlock *BB) const
Return the first index of the specified basic block in the value list for this PHI.
const BasicBlock * getParent() const
an instruction to allocate memory on the stack