summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2015-09-08 23:28:38 +0000
committerReid Kleckner <rnk@google.com>2015-09-08 23:28:38 +0000
commit51189f0a1d0b8b6d1490a4e42df4971916fb9235 (patch)
tree804c110f1c9172e760631974831c8fd1dd52a950 /llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
parenta195adde001abe1b337a4455b8b8c80f340f8a2e (diff)
downloadbcm5719-llvm-51189f0a1d0b8b6d1490a4e42df4971916fb9235.tar.gz
bcm5719-llvm-51189f0a1d0b8b6d1490a4e42df4971916fb9235.zip
[WinEH] Avoid creating MBBs for LLVM BBs that cannot contain code
Typically these are catchpads, which hold data used to decide whether to catch the exception or continue unwinding. We also shouldn't create MBBs for catchendpads, cleanupendpads, or terminatepads, since no real code can live in them. This fixes a problem where MI passes (like the register allocator) would try to put code into catchpad blocks, which are not executed by the runtime. In the new world, blocks ending in invokes now have many possible successors. llvm-svn: 247102
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
index 3a51676bc9a..7bbb194ac19 100644
--- a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
@@ -212,6 +212,22 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf,
// also creates the initial PHI MachineInstrs, though none of the input
// operands are populated.
for (BB = Fn->begin(); BB != EB; ++BB) {
+ // Don't create MachineBasicBlocks for imaginary EH pad blocks. These blocks
+ // are really data, and no instructions can live here.
+ if (BB->isEHPad()) {
+ const Instruction *I = BB->getFirstNonPHI();
+ if (!isa<LandingPadInst>(I))
+ MMI.setHasEHFunclets(true);
+ if (isa<CatchPadInst>(I) || isa<CatchEndPadInst>(I) ||
+ isa<CleanupEndPadInst>(I)) {
+ assert(&*BB->begin() == I &&
+ "WinEHPrepare failed to remove PHIs from imaginary BBs");
+ continue;
+ } else if (!isa<LandingPadInst>(I)) {
+ llvm_unreachable("unhandled EH pad in MBB graph");
+ }
+ }
+
MachineBasicBlock *MBB = mf.CreateMachineBasicBlock(BB);
MBBMap[BB] = MBB;
MF->push_back(MBB);
@@ -252,9 +268,9 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf,
// Mark landing pad blocks.
SmallVector<const LandingPadInst *, 4> LPads;
for (BB = Fn->begin(); BB != EB; ++BB) {
- if (BB->isEHPad())
- MBBMap[BB]->setIsEHPad();
const Instruction *FNP = BB->getFirstNonPHI();
+ if (BB->isEHPad() && !isa<CatchPadInst>(FNP) && !isa<CatchEndPadInst>(FNP))
+ MBBMap[BB]->setIsEHPad();
if (const auto *LPI = dyn_cast<LandingPadInst>(FNP))
LPads.push_back(LPI);
}
OpenPOWER on IntegriCloud