mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-04 18:38:05 +00:00
Fix several bugs in basic-aa
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5643 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ddd5b417c6
commit
a36635aba7
@ -142,8 +142,10 @@ BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size,
|
|||||||
std::swap(V1Size, V2Size);
|
std::swap(V1Size, V2Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(V1))
|
if (const GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(V1)) {
|
||||||
if (GEP->getOperand(0) == V2) {
|
AliasResult R = alias(GEP->getOperand(0), V1Size, V2, V2Size);
|
||||||
|
if (R == NoAlias) return NoAlias;
|
||||||
|
if (R == MustAlias) {
|
||||||
// If there is at least one non-zero constant index, we know they cannot
|
// If there is at least one non-zero constant index, we know they cannot
|
||||||
// alias.
|
// alias.
|
||||||
for (unsigned i = 1, e = GEP->getNumOperands(); i != e; ++i)
|
for (unsigned i = 1, e = GEP->getNumOperands(); i != e; ++i)
|
||||||
@ -151,6 +153,7 @@ BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size,
|
|||||||
if (!C->isNullValue())
|
if (!C->isNullValue())
|
||||||
return NoAlias;
|
return NoAlias;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return MayAlias;
|
return MayAlias;
|
||||||
}
|
}
|
||||||
@ -220,8 +223,10 @@ BasicAliasAnalysis::CheckGEPInstructions(GetElementPtrInst *GEP1, unsigned G1S,
|
|||||||
std::vector<Value*> Indices1;
|
std::vector<Value*> Indices1;
|
||||||
Indices1.reserve(NumGEPOperands-1);
|
Indices1.reserve(NumGEPOperands-1);
|
||||||
for (unsigned i = 1; i != FirstConstantOper; ++i)
|
for (unsigned i = 1; i != FirstConstantOper; ++i)
|
||||||
Indices1.push_back(Constant::getNullValue(GEP1->getOperand(i)
|
if (GEP1->getOperand(i)->getType() == Type::UByteTy)
|
||||||
->getType()));
|
Indices1.push_back(GEP1->getOperand(i));
|
||||||
|
else
|
||||||
|
Indices1.push_back(Constant::getNullValue(Type::LongTy));
|
||||||
std::vector<Value*> Indices2;
|
std::vector<Value*> Indices2;
|
||||||
Indices2.reserve(NumGEPOperands-1);
|
Indices2.reserve(NumGEPOperands-1);
|
||||||
Indices2 = Indices1; // Copy the zeros prefix...
|
Indices2 = Indices1; // Copy the zeros prefix...
|
||||||
@ -235,7 +240,7 @@ BasicAliasAnalysis::CheckGEPInstructions(GetElementPtrInst *GEP1, unsigned G1S,
|
|||||||
// Loop over the rest of the operands...
|
// Loop over the rest of the operands...
|
||||||
for (unsigned i = FirstConstantOper+1; i!=NumGEPOperands; ++i){
|
for (unsigned i = FirstConstantOper+1; i!=NumGEPOperands; ++i){
|
||||||
const Value *Op1 = GEP1->getOperand(i);
|
const Value *Op1 = GEP1->getOperand(i);
|
||||||
const Value *Op2 = GEP1->getOperand(i);
|
const Value *Op2 = GEP2->getOperand(i);
|
||||||
if (Op1 == Op2) { // If they are equal, use a zero index...
|
if (Op1 == Op2) { // If they are equal, use a zero index...
|
||||||
Indices1.push_back(Constant::getNullValue(Op1->getType()));
|
Indices1.push_back(Constant::getNullValue(Op1->getType()));
|
||||||
Indices2.push_back(Indices1.back());
|
Indices2.push_back(Indices1.back());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user