mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-26 12:20:42 +00:00
Handle addrspacecast when looking at memcpys from globals
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207054 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -31,10 +31,13 @@ STATISTIC(NumGlobalCopies, "Number of allocas copied from constant global");
|
||||
static bool pointsToConstantGlobal(Value *V) {
|
||||
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V))
|
||||
return GV->isConstant();
|
||||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
|
||||
|
||||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) {
|
||||
if (CE->getOpcode() == Instruction::BitCast ||
|
||||
CE->getOpcode() == Instruction::AddrSpaceCast ||
|
||||
CE->getOpcode() == Instruction::GetElementPtr)
|
||||
return pointsToConstantGlobal(CE->getOperand(0));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -62,9 +65,9 @@ isOnlyCopiedFromConstantGlobal(Value *V, MemTransferInst *&TheCopy,
|
||||
continue;
|
||||
}
|
||||
|
||||
if (BitCastInst *BCI = dyn_cast<BitCastInst>(I)) {
|
||||
if (isa<BitCastInst>(I) || isa<AddrSpaceCastInst>(I)) {
|
||||
// If uses of the bitcast are ok, we are ok.
|
||||
if (!isOnlyCopiedFromConstantGlobal(BCI, TheCopy, ToDelete, IsOffset))
|
||||
if (!isOnlyCopiedFromConstantGlobal(I, TheCopy, ToDelete, IsOffset))
|
||||
return false;
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user