forked from OSchip/llvm-project
[OperandBundles] Extract duplicated code into a helper function, NFC
llvm-svn: 254047
This commit is contained in:
parent
7629346193
commit
c521c7bea5
|
@ -390,6 +390,16 @@ public:
|
|||
#undef CALLSITE_DELEGATE_GETTER
|
||||
#undef CALLSITE_DELEGATE_SETTER
|
||||
|
||||
void getOperandBundlesAsDefs(SmallVectorImpl<OperandBundleDef> &Defs) const {
|
||||
const Instruction *II = getInstruction();
|
||||
// Since this is actually a getter that "looks like" a setter, don't use the
|
||||
// above macros to avoid confusion.
|
||||
if (isCall())
|
||||
cast<CallInst>(II)->getOperandBundlesAsDefs(Defs);
|
||||
else
|
||||
cast<InvokeInst>(II)->getOperandBundlesAsDefs(Defs);
|
||||
}
|
||||
|
||||
/// @brief Determine whether this data operand is not captured.
|
||||
bool doesNotCapture(unsigned OpNo) const {
|
||||
return dataOperandHasImpliedAttr(OpNo + 1, Attribute::NoCapture);
|
||||
|
|
|
@ -1325,6 +1325,18 @@ public:
|
|||
return None;
|
||||
}
|
||||
|
||||
/// \brief Return the list of operand bundles attached to this instruction as
|
||||
/// a vector of OperandBundleDefs.
|
||||
///
|
||||
/// This function copies the OperandBundeUse instances associated with this
|
||||
/// OperandBundleUser to a vector of OperandBundleDefs. Note:
|
||||
/// OperandBundeUses and OperandBundleDefs are non-trivially *different*
|
||||
/// representations of operand bundles (see documentation above).
|
||||
void getOperandBundlesAsDefs(SmallVectorImpl<OperandBundleDef> &Defs) const {
|
||||
for (unsigned i = 0, e = getNumOperandBundles(); i != e; ++i)
|
||||
Defs.emplace_back(getOperandBundleAt(i));
|
||||
}
|
||||
|
||||
/// \brief Return the operand bundle for the operand at index OpIdx.
|
||||
///
|
||||
/// It is an error to call this with an OpIdx that does not correspond to an
|
||||
|
|
|
@ -2268,11 +2268,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
|
|||
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)) {
|
||||
|
|
|
@ -210,11 +210,7 @@ HandleCallsInBlockInlinedThroughInvoke(BasicBlock *BB, BasicBlock *UnwindEdge) {
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue