mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
Make sure ... arguments are casted to sbyte* where needed.
llvm-svn: 22162
This commit is contained in:
parent
0a43070283
commit
5161c39bfe
@ -1237,6 +1237,16 @@ public:
|
|||||||
}
|
}
|
||||||
} PowOptimizer;
|
} PowOptimizer;
|
||||||
|
|
||||||
|
/// CastToCStr - Return V if it is an sbyte*, otherwise cast it to sbyte*,
|
||||||
|
/// inserting the cast before IP, and return the cast.
|
||||||
|
/// @brief Cast a value to a "C" string.
|
||||||
|
static Value *CastToCStr(Value *V, Instruction &IP) {
|
||||||
|
const Type *SBPTy = PointerType::get(Type::SByteTy);
|
||||||
|
if (V->getType() != SBPTy)
|
||||||
|
return new CastInst(V, SBPTy, V->getName(), &IP);
|
||||||
|
return V;
|
||||||
|
}
|
||||||
|
|
||||||
/// This LibCallOptimization will simplify calls to the "fprintf" library
|
/// This LibCallOptimization will simplify calls to the "fprintf" library
|
||||||
/// function. It looks for cases where the result of fprintf is not used and the
|
/// function. It looks for cases where the result of fprintf is not used and the
|
||||||
/// operation can be reduced to something simpler.
|
/// operation can be reduced to something simpler.
|
||||||
@ -1292,7 +1302,7 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fprintf(file,fmt) -> fwrite(fmt,strlen(fmt),1file)
|
// fprintf(file,fmt) -> fwrite(fmt,strlen(fmt),file)
|
||||||
const Type* FILEptr_type = ci->getOperand(1)->getType();
|
const Type* FILEptr_type = ci->getOperand(1)->getType();
|
||||||
Function* fwrite_func = SLC.get_fwrite(FILEptr_type);
|
Function* fwrite_func = SLC.get_fwrite(FILEptr_type);
|
||||||
if (!fwrite_func)
|
if (!fwrite_func)
|
||||||
@ -1335,7 +1345,7 @@ public:
|
|||||||
if (!fwrite_func)
|
if (!fwrite_func)
|
||||||
return false;
|
return false;
|
||||||
std::vector<Value*> args;
|
std::vector<Value*> args;
|
||||||
args.push_back(ci->getOperand(3));
|
args.push_back(CastToCStr(ci->getOperand(3), *ci));
|
||||||
args.push_back(ConstantUInt::get(SLC.getIntPtrType(),len));
|
args.push_back(ConstantUInt::get(SLC.getIntPtrType(),len));
|
||||||
args.push_back(ConstantUInt::get(SLC.getIntPtrType(),1));
|
args.push_back(ConstantUInt::get(SLC.getIntPtrType(),1));
|
||||||
args.push_back(ci->getOperand(1));
|
args.push_back(ci->getOperand(1));
|
||||||
@ -1366,17 +1376,6 @@ public:
|
|||||||
}
|
}
|
||||||
} FPrintFOptimizer;
|
} FPrintFOptimizer;
|
||||||
|
|
||||||
/// CastToCStr - Return V if it is an sbyte*, otherwise cast it to sbyte*,
|
|
||||||
/// inserting the cast before IP, and return the cast.
|
|
||||||
/// @brief Cast a value to a "C" string.
|
|
||||||
static Value *CastToCStr(Value *V, Instruction &IP) {
|
|
||||||
const Type *SBPTy = PointerType::get(Type::SByteTy);
|
|
||||||
if (V->getType() != SBPTy)
|
|
||||||
return new CastInst(V, SBPTy, V->getName(), &IP);
|
|
||||||
return V;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// This LibCallOptimization will simplify calls to the "sprintf" library
|
/// This LibCallOptimization will simplify calls to the "sprintf" library
|
||||||
/// function. It looks for cases where the result of sprintf is not used and the
|
/// function. It looks for cases where the result of sprintf is not used and the
|
||||||
/// operation can be reduced to something simpler.
|
/// operation can be reduced to something simpler.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user