Refactor creation of overflow result tuples in InstCombineCalls.

Extract the creation of overflow result tuples in a separate function. NFC.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224006 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Erik Eckstein
2014-12-11 08:02:30 +00:00
parent 3490558860
commit 1bf1224a06
2 changed files with 30 additions and 57 deletions

View File

@@ -331,6 +331,20 @@ public:
return &I;
}
/// Creates a result tuple for an overflow intrinsic \p II with a given
/// \p Result and a constant \p Overflow value. If \p ReUseName is true the
/// \p Result's name is taken from \p II.
Instruction *CreateOverflowTuple(IntrinsicInst *II, Value *Result,
bool Overflow, bool ReUseName = true) {
if (ReUseName)
Result->takeName(II);
Constant *V[] = { UndefValue::get(Result->getType()),
Overflow ? Builder->getTrue() : Builder->getFalse() };
StructType *ST = cast<StructType>(II->getType());
Constant *Struct = ConstantStruct::get(ST, V);
return InsertValueInst::Create(Struct, Result, 0);
}
// EraseInstFromFunction - When dealing with an instruction that has side
// effects or produces a void value, we can't rely on DCE to delete the
// instruction. Instead, visit methods should return the value returned by