mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-27 00:21:03 +00:00
[opaque pointer type] More IRBuilder::createGEP (non-inbounds) migrations: CodeGenPrepare and SimplifyLibCalls
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233596 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -222,7 +222,7 @@ Value *LibCallSimplifier::emitStrLenMemCpy(Value *Src, Value *Dst, uint64_t Len,
|
||||
// Now that we have the destination's length, we must index into the
|
||||
// destination's pointer to get the actual memcpy destination (end of
|
||||
// the string .. we're concatenating).
|
||||
Value *CpyDst = B.CreateGEP(Dst, DstLen, "endptr");
|
||||
Value *CpyDst = B.CreateGEP(B.getInt8Ty(), Dst, DstLen, "endptr");
|
||||
|
||||
// We have enough information to now generate the memcpy call to do the
|
||||
// concatenation for us. Make a memcpy to copy the nul byte with align = 1.
|
||||
@@ -303,7 +303,7 @@ Value *LibCallSimplifier::optimizeStrChr(CallInst *CI, IRBuilder<> &B) {
|
||||
StringRef Str;
|
||||
if (!getConstantStringInfo(SrcStr, Str)) {
|
||||
if (CharC->isZero()) // strchr(p, 0) -> p + strlen(p)
|
||||
return B.CreateGEP(SrcStr, EmitStrLen(SrcStr, B, DL, TLI), "strchr");
|
||||
return B.CreateGEP(B.getInt8Ty(), SrcStr, EmitStrLen(SrcStr, B, DL, TLI), "strchr");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ Value *LibCallSimplifier::optimizeStrChr(CallInst *CI, IRBuilder<> &B) {
|
||||
return Constant::getNullValue(CI->getType());
|
||||
|
||||
// strchr(s+n,c) -> gep(s+n+i,c)
|
||||
return B.CreateGEP(SrcStr, B.getInt64(I), "strchr");
|
||||
return B.CreateGEP(B.getInt8Ty(), SrcStr, B.getInt64(I), "strchr");
|
||||
}
|
||||
|
||||
Value *LibCallSimplifier::optimizeStrRChr(CallInst *CI, IRBuilder<> &B) {
|
||||
@@ -351,7 +351,7 @@ Value *LibCallSimplifier::optimizeStrRChr(CallInst *CI, IRBuilder<> &B) {
|
||||
return Constant::getNullValue(CI->getType());
|
||||
|
||||
// strrchr(s+n,c) -> gep(s+n+i,c)
|
||||
return B.CreateGEP(SrcStr, B.getInt64(I), "strrchr");
|
||||
return B.CreateGEP(B.getInt8Ty(), SrcStr, B.getInt64(I), "strrchr");
|
||||
}
|
||||
|
||||
Value *LibCallSimplifier::optimizeStrCmp(CallInst *CI, IRBuilder<> &B) {
|
||||
@@ -487,7 +487,7 @@ Value *LibCallSimplifier::optimizeStpCpy(CallInst *CI, IRBuilder<> &B) {
|
||||
Type *PT = FT->getParamType(0);
|
||||
Value *LenV = ConstantInt::get(DL.getIntPtrType(PT), Len);
|
||||
Value *DstEnd =
|
||||
B.CreateGEP(Dst, ConstantInt::get(DL.getIntPtrType(PT), Len - 1));
|
||||
B.CreateGEP(B.getInt8Ty(), Dst, ConstantInt::get(DL.getIntPtrType(PT), Len - 1));
|
||||
|
||||
// We have enough information to now generate the memcpy call to do the
|
||||
// copy for us. Make a memcpy to copy the nul byte with align = 1.
|
||||
@@ -597,7 +597,7 @@ Value *LibCallSimplifier::optimizeStrPBrk(CallInst *CI, IRBuilder<> &B) {
|
||||
if (I == StringRef::npos) // No match.
|
||||
return Constant::getNullValue(CI->getType());
|
||||
|
||||
return B.CreateGEP(CI->getArgOperand(0), B.getInt64(I), "strpbrk");
|
||||
return B.CreateGEP(B.getInt8Ty(), CI->getArgOperand(0), B.getInt64(I), "strpbrk");
|
||||
}
|
||||
|
||||
// strpbrk(s, "a") -> strchr(s, 'a')
|
||||
@@ -828,7 +828,7 @@ Value *LibCallSimplifier::optimizeMemChr(CallInst *CI, IRBuilder<> &B) {
|
||||
return Constant::getNullValue(CI->getType());
|
||||
|
||||
// memchr(s+n,c,l) -> gep(s+n+i,c)
|
||||
return B.CreateGEP(SrcStr, B.getInt64(I), "memchr");
|
||||
return B.CreateGEP(B.getInt8Ty(), SrcStr, B.getInt64(I), "memchr");
|
||||
}
|
||||
|
||||
Value *LibCallSimplifier::optimizeMemCmp(CallInst *CI, IRBuilder<> &B) {
|
||||
@@ -1671,7 +1671,7 @@ Value *LibCallSimplifier::optimizeSPrintFString(CallInst *CI, IRBuilder<> &B) {
|
||||
Value *V = B.CreateTrunc(CI->getArgOperand(2), B.getInt8Ty(), "char");
|
||||
Value *Ptr = CastToCStr(CI->getArgOperand(0), B);
|
||||
B.CreateStore(V, Ptr);
|
||||
Ptr = B.CreateGEP(Ptr, B.getInt32(1), "nul");
|
||||
Ptr = B.CreateGEP(B.getInt8Ty(), Ptr, B.getInt32(1), "nul");
|
||||
B.CreateStore(B.getInt8(0), Ptr);
|
||||
|
||||
return ConstantInt::get(CI->getType(), 1);
|
||||
@@ -2299,7 +2299,7 @@ Value *FortifiedLibCallSimplifier::optimizeStrpCpyChk(CallInst *CI,
|
||||
// If the function was an __stpcpy_chk, and we were able to fold it into
|
||||
// a __memcpy_chk, we still need to return the correct end pointer.
|
||||
if (Ret && Func == LibFunc::stpcpy_chk)
|
||||
return B.CreateGEP(Dst, ConstantInt::get(SizeTTy, Len - 1));
|
||||
return B.CreateGEP(B.getInt8Ty(), Dst, ConstantInt::get(SizeTTy, Len - 1));
|
||||
return Ret;
|
||||
}
|
||||
return nullptr;
|
||||
|
Reference in New Issue
Block a user