[InstCombine] Don't drop operand bundles
[oota-llvm.git] / lib / Transforms / InstCombine / InstCombineCalls.cpp
index cde26cc24c29d922656d14814582fd87fc5f05a0..c3fbaf2adfc04bcd950e64841fdcdcf74325e800 100644 (file)
@@ -2267,16 +2267,23 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
   const AttributeSet &NewCallerPAL = AttributeSet::get(Callee->getContext(),
                                                        attrVec);
 
+  SmallVector<OperandBundleDef, 1> OpBundles;
+
+  // Convert the operand bundle uses to operand bundle defs.  See InstrTypes.h
+  // for details on how these differ.
+  for (unsigned i = 0, e = CS.getNumOperandBundles(); i != e; ++i)
+    OpBundles.emplace_back(CS.getOperandBundleAt(i));
+
   Instruction *NC;
   if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) {
-    NC = Builder->CreateInvoke(Callee, II->getNormalDest(),
-                               II->getUnwindDest(), Args);
+    NC = Builder->CreateInvoke(Callee, II->getNormalDest(), II->getUnwindDest(),
+                               Args, OpBundles);
     NC->takeName(II);
     cast<InvokeInst>(NC)->setCallingConv(II->getCallingConv());
     cast<InvokeInst>(NC)->setAttributes(NewCallerPAL);
   } else {
     CallInst *CI = cast<CallInst>(Caller);
-    NC = Builder->CreateCall(Callee, Args);
+    NC = Builder->CreateCall(Callee, Args, OpBundles);
     NC->takeName(CI);
     if (CI->isTailCall())
       cast<CallInst>(NC)->setTailCall();