diff --git a/llvm/lib/CodeGen/MachineLICM.cpp b/llvm/lib/CodeGen/MachineLICM.cpp --- a/llvm/lib/CodeGen/MachineLICM.cpp +++ b/llvm/lib/CodeGen/MachineLICM.cpp @@ -525,6 +525,10 @@ // Walk the entire region, count number of defs for each register, and // collect potential LICM candidates. for (MachineBasicBlock *BB : CurLoop->getBlocks()) { + // We can't hoist instructions out of a funclet, so if the region + // contains a funclet (i.e. the loop contains a try-catch) we give up + if (BB->isEHFuncletEntry()) + return; // If the header of the loop containing this basic block is a landing pad, // then don't try to hoist instructions out of this loop. const MachineLoop *ML = MLI->getLoopFor(BB);