mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-01 00:33:09 +00:00
Create constant expression casts instead of constant instructions if possible
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5968 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1fd95afab3
commit
95549281ec
@ -504,7 +504,17 @@ bool RPR::PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
|
|||||||
PointerType *NewPFunTy = PointerType::get(NewFT);
|
PointerType *NewPFunTy = PointerType::get(NewFT);
|
||||||
|
|
||||||
// Create a new cast, inserting it right before the function call...
|
// Create a new cast, inserting it right before the function call...
|
||||||
CastInst *NewCast = new CastInst(CI->getCalledValue(), NewPFunTy,
|
Value *NewCast;
|
||||||
|
Constant *ConstantCallSrc = 0;
|
||||||
|
if (Constant *CS = dyn_cast<Constant>(CI->getCalledValue()))
|
||||||
|
ConstantCallSrc = CS;
|
||||||
|
else if (GlobalValue *GV = dyn_cast<GlobalValue>(CI->getCalledValue()))
|
||||||
|
ConstantCallSrc = ConstantPointerRef::get(GV);
|
||||||
|
|
||||||
|
if (ConstantCallSrc)
|
||||||
|
NewCast = ConstantExpr::getCast(ConstantCallSrc, NewPFunTy);
|
||||||
|
else
|
||||||
|
NewCast = new CastInst(CI->getCalledValue(), NewPFunTy,
|
||||||
CI->getCalledValue()->getName()+"_c",CI);
|
CI->getCalledValue()->getName()+"_c",CI);
|
||||||
|
|
||||||
// Create a new call instruction...
|
// Create a new call instruction...
|
||||||
|
Loading…
Reference in New Issue
Block a user