Value *LibCallSimplifier::optimizeStpCpy(CallInst *CI, IRBuilder<> &B) {
Function *Callee = CI->getCalledFunction();
- // Verify the "stpcpy" function prototype.
- FunctionType *FT = Callee->getFunctionType();
-
if (!checkStringCopyLibFuncSignature(Callee, LibFunc::stpcpy))
return nullptr;
if (Len == 0)
return nullptr;
- Type *PT = FT->getParamType(0);
+ Type *PT = Callee->getFunctionType()->getParamType(0);
Value *LenV = ConstantInt::get(DL.getIntPtrType(PT), Len);
Value *DstEnd =
B.CreateGEP(B.getInt8Ty(), Dst, ConstantInt::get(DL.getIntPtrType(PT), Len - 1));
Value *LibCallSimplifier::optimizeStrNCpy(CallInst *CI, IRBuilder<> &B) {
Function *Callee = CI->getCalledFunction();
- FunctionType *FT = Callee->getFunctionType();
-
if (!checkStringCopyLibFuncSignature(Callee, LibFunc::strncpy))
return nullptr;
if (Len > SrcLen + 1)
return nullptr;
- Type *PT = FT->getParamType(0);
+ Type *PT = Callee->getFunctionType()->getParamType(0);
// strncpy(x, s, c) -> memcpy(x, s, c, 1) [s and c are constant]
B.CreateMemCpy(Dst, Src, ConstantInt::get(DL.getIntPtrType(PT), Len), 1);