@@ -58,19 +58,6 @@ static cl::opt<unsigned> MaxDeoptOrUnreachableSuccessorCheckDepth(
58
58
" is followed by a block that either has a terminating "
59
59
" deoptimizing call or is terminated with an unreachable" ));
60
60
61
- static void replaceFuncletPadsRetWithUnreachable (Instruction &I) {
62
- assert (isa<FuncletPadInst>(I) && " Instruction must be a funclet pad!" );
63
- for (User *User : make_early_inc_range (I.users ())) {
64
- Instruction *ReturnInstr = dyn_cast<Instruction>(User);
65
- if (isa<CatchReturnInst>(ReturnInstr) ||
66
- isa<CleanupReturnInst>(ReturnInstr)) {
67
- BasicBlock *ReturnInstrBB = ReturnInstr->getParent ();
68
- ReturnInstr->eraseFromParent ();
69
- new UnreachableInst (ReturnInstrBB->getContext (), ReturnInstrBB);
70
- }
71
- }
72
- }
73
-
74
61
void llvm::detachDeadBlocks (
75
62
ArrayRef<BasicBlock *> BBs,
76
63
SmallVectorImpl<DominatorTree::UpdateType> *Updates,
@@ -88,36 +75,7 @@ void llvm::detachDeadBlocks(
88
75
// Zap all the instructions in the block.
89
76
while (!BB->empty ()) {
90
77
Instruction &I = BB->back ();
91
- // Exception handling funclets need to be explicitly addressed.
92
- // These funclets must begin with cleanuppad or catchpad and end with
93
- // cleanupred or catchret. The return instructions can be in different
94
- // basic blocks than the pad instruction. If we would only delete the
95
- // first block, the we would have possible cleanupret and catchret
96
- // instructions with poison arguments, which wouldn't be valid.
97
- if (isa<FuncletPadInst>(I))
98
- replaceFuncletPadsRetWithUnreachable (I);
99
-
100
- // Catchswitch instructions have handlers, that must be catchpads and
101
- // an unwind label, that is either a catchpad or catchswitch.
102
- if (CatchSwitchInst *CSI = dyn_cast<CatchSwitchInst>(&I)) {
103
- // Iterating over the handlers and the unwind basic block and processing
104
- // catchpads. If the unwind label is a catchswitch, we just replace the
105
- // label with poison later on.
106
- for (unsigned I = 0 ; I < CSI->getNumSuccessors (); I++) {
107
- BasicBlock *SucBlock = CSI->getSuccessor (I);
108
- Instruction &SucFstInst = *(SucBlock->getFirstNonPHIIt ());
109
- if (isa<FuncletPadInst>(SucFstInst)) {
110
- replaceFuncletPadsRetWithUnreachable (SucFstInst);
111
- // There may be catchswitch instructions using the catchpad.
112
- // Just replace those with poison.
113
- if (!SucFstInst.use_empty ())
114
- SucFstInst.replaceAllUsesWith (
115
- PoisonValue::get (SucFstInst.getType ()));
116
- SucFstInst.eraseFromParent ();
117
- }
118
- }
119
- }
120
-
78
+ // If this instruction is used, replace uses with an arbitrary value.
121
79
// Because control flow can't get here, we don't care what we replace the
122
80
// value with. Note that since this block is unreachable, and all values
123
81
// contained within it must dominate their uses, that all uses will
0 commit comments