mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
Sink routine for replacing a operand bundle to CallBase [NFC]
We had equivalent code for both CallInst and InvokeInst, but never cared about the result type.
This commit is contained in:
parent
d2f05a31bd
commit
5c3ba57c9e
@ -1214,6 +1214,15 @@ public:
|
||||
static CallBase *Create(CallBase *CB, ArrayRef<OperandBundleDef> Bundles,
|
||||
Instruction *InsertPt = nullptr);
|
||||
|
||||
/// Create a clone of \p CB with the operand bundle with the tag matching
|
||||
/// \p Bundle's tag replaced with Bundle, and insert it before \p InsertPt.
|
||||
///
|
||||
/// The returned call instruction is identical \p CI in every way except that
|
||||
/// the specified operand bundle has been replaced.
|
||||
static CallBase *Create(CallBase *CB,
|
||||
OperandBundleDef Bundle,
|
||||
Instruction *InsertPt = nullptr);
|
||||
|
||||
static bool classof(const Instruction *I) {
|
||||
return I->getOpcode() == Instruction::Call ||
|
||||
I->getOpcode() == Instruction::Invoke ||
|
||||
|
@ -1585,16 +1585,6 @@ public:
|
||||
static CallInst *Create(CallInst *CI, ArrayRef<OperandBundleDef> Bundles,
|
||||
Instruction *InsertPt = nullptr);
|
||||
|
||||
/// Create a clone of \p CI with a different set of operand bundles and
|
||||
/// insert it before \p InsertPt.
|
||||
///
|
||||
/// The returned call instruction is identical \p CI in every way except that
|
||||
/// the operand bundle for the new instruction is set to the operand bundle
|
||||
/// in \p Bundle.
|
||||
static CallInst *CreateWithReplacedBundle(CallInst *CI,
|
||||
OperandBundleDef Bundle,
|
||||
Instruction *InsertPt = nullptr);
|
||||
|
||||
/// Generate the IR for a call to malloc:
|
||||
/// 1. Compute the malloc call's argument as the specified type's size,
|
||||
/// possibly multiplied by the array size if the array size is not
|
||||
@ -3824,16 +3814,6 @@ public:
|
||||
static InvokeInst *Create(InvokeInst *II, ArrayRef<OperandBundleDef> Bundles,
|
||||
Instruction *InsertPt = nullptr);
|
||||
|
||||
/// Create a clone of \p II with a different set of operand bundles and
|
||||
/// insert it before \p InsertPt.
|
||||
///
|
||||
/// The returned invoke instruction is identical to \p II in every way except
|
||||
/// that the operand bundle for the new instruction is set to the operand
|
||||
/// bundle in \p Bundle.
|
||||
static InvokeInst *CreateWithReplacedBundle(InvokeInst *II,
|
||||
OperandBundleDef Bundles,
|
||||
Instruction *InsertPt = nullptr);
|
||||
|
||||
// get*Dest - Return the destination basic blocks...
|
||||
BasicBlock *getNormalDest() const {
|
||||
return cast<BasicBlock>(Op<NormalDestOpEndIdx>());
|
||||
|
@ -262,6 +262,19 @@ CallBase *CallBase::Create(CallBase *CB, ArrayRef<OperandBundleDef> Bundles,
|
||||
}
|
||||
}
|
||||
|
||||
CallBase *CallBase::Create(CallBase *CI, OperandBundleDef OpB,
|
||||
Instruction *InsertPt) {
|
||||
SmallVector<OperandBundleDef, 2> OpDefs;
|
||||
for (unsigned i = 0, e = CI->getNumOperandBundles(); i < e; ++i) {
|
||||
auto ChildOB = CI->getOperandBundleAt(i);
|
||||
if (ChildOB.getTagName() != OpB.getTag())
|
||||
OpDefs.emplace_back(ChildOB);
|
||||
}
|
||||
OpDefs.emplace_back(OpB);
|
||||
return CallBase::Create(CI, OpDefs, InsertPt);
|
||||
}
|
||||
|
||||
|
||||
Function *CallBase::getCaller() { return getParent()->getParent(); }
|
||||
|
||||
unsigned CallBase::getNumSubclassExtraOperandsDynamic() const {
|
||||
@ -506,18 +519,6 @@ CallInst *CallInst::Create(CallInst *CI, ArrayRef<OperandBundleDef> OpB,
|
||||
return NewCI;
|
||||
}
|
||||
|
||||
CallInst *CallInst::CreateWithReplacedBundle(CallInst *CI, OperandBundleDef OpB,
|
||||
Instruction *InsertPt) {
|
||||
SmallVector<OperandBundleDef, 2> OpDefs;
|
||||
for (unsigned i = 0, e = CI->getNumOperandBundles(); i < e; ++i) {
|
||||
auto ChildOB = CI->getOperandBundleAt(i);
|
||||
if (ChildOB.getTagName() != OpB.getTag())
|
||||
OpDefs.emplace_back(ChildOB);
|
||||
}
|
||||
OpDefs.emplace_back(OpB);
|
||||
return CallInst::Create(CI, OpDefs, InsertPt);
|
||||
}
|
||||
|
||||
// Update profile weight for call instruction by scaling it using the ratio
|
||||
// of S/T. The meaning of "branch_weights" meta data for call instruction is
|
||||
// transfered to represent call count.
|
||||
@ -830,19 +831,6 @@ InvokeInst *InvokeInst::Create(InvokeInst *II, ArrayRef<OperandBundleDef> OpB,
|
||||
return NewII;
|
||||
}
|
||||
|
||||
InvokeInst *InvokeInst::CreateWithReplacedBundle(InvokeInst *II,
|
||||
OperandBundleDef OpB,
|
||||
Instruction *InsertPt) {
|
||||
SmallVector<OperandBundleDef, 2> OpDefs;
|
||||
for (unsigned i = 0, e = II->getNumOperandBundles(); i < e; ++i) {
|
||||
auto ChildOB = II->getOperandBundleAt(i);
|
||||
if (ChildOB.getTagName() != OpB.getTag())
|
||||
OpDefs.emplace_back(ChildOB);
|
||||
}
|
||||
OpDefs.emplace_back(OpB);
|
||||
return InvokeInst::Create(II, OpDefs, InsertPt);
|
||||
}
|
||||
|
||||
LandingPadInst *InvokeInst::getLandingPadInst() const {
|
||||
return cast<LandingPadInst>(getUnwindDest()->getFirstNonPHI());
|
||||
}
|
||||
|
@ -1763,12 +1763,7 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
|
||||
}
|
||||
// Create new statepoint instruction.
|
||||
OperandBundleDef NewBundle("gc-live", NewLiveGc);
|
||||
if (isa<CallInst>(II))
|
||||
return CallInst::CreateWithReplacedBundle(cast<CallInst>(II), NewBundle);
|
||||
else
|
||||
return InvokeInst::CreateWithReplacedBundle(cast<InvokeInst>(II),
|
||||
NewBundle);
|
||||
break;
|
||||
return CallBase::Create(II, NewBundle);
|
||||
}
|
||||
case Intrinsic::experimental_guard: {
|
||||
// Is this guard followed by another guard? We scan forward over a small
|
||||
|
Loading…
x
Reference in New Issue
Block a user