[OperandBundles] Extract duplicated code into a helper function, NFC

llvm-svn: 254047
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index c3fbaf2..26088bb 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -2268,11 +2268,7 @@
                                                        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));
+  CS.getOperandBundlesAsDefs(OpBundles);
 
   Instruction *NC;
   if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) {
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index dd8e5b3..aee84c0 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -210,11 +210,7 @@
     SmallVector<Value*, 8> InvokeArgs(CS.arg_begin(), CS.arg_end());
     SmallVector<OperandBundleDef, 1> OpBundles;
 
-    // Copy the OperandBundeUse instances to OperandBundleDefs.  These two are
-    // *different* representations of operand bundles: see the documentation in
-    // InstrTypes.h for more details.
-    for (unsigned i = 0, e = CS.getNumOperandBundles(); i != e; ++i)
-      OpBundles.emplace_back(CS.getOperandBundleAt(i));
+    CS.getOperandBundlesAsDefs(OpBundles);
 
     // Note: we're round tripping operand bundles through memory here, and that
     // can potentially be avoided with a cleverer API design that we do not have