[OperandBundles] Have PruneEH work correct with operand bundles.
[oota-llvm.git] / lib / Transforms / IPO / PruneEH.cpp
index 714e1d6e42d29ccdd8caa8aecb5f93f20e4ec4be..c9c0b197eae666377a3eca5d9745bf9e83ea95b9 100644 (file)
@@ -191,9 +191,14 @@ bool PruneEH::SimplifyFunction(Function *F) {
   for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
     if (InvokeInst *II = dyn_cast<InvokeInst>(BB->getTerminator()))
       if (II->doesNotThrow() && canSimplifyInvokeNoUnwind(F)) {
-        SmallVector<Value*, 8> Args(II->op_begin(), II->op_end() - 3);
+        CallSite CS(II);
+        SmallVector<Value*, 8> Args(CS.arg_begin(), CS.arg_end());
+        SmallVector<OperandBundleDef, 1> OpBundles;
+        II->getOperandBundlesAsDefs(OpBundles);
+
         // Insert a call instruction before the invoke.
-        CallInst *Call = CallInst::Create(II->getCalledValue(), Args, "", II);
+        CallInst *Call = CallInst::Create(II->getCalledValue(), Args, OpBundles,
+                                          "", II);
         Call->takeName(II);
         Call->setCallingConv(II->getCallingConv());
         Call->setAttributes(II->getAttributes());