mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 21:29:20 +00:00
Fix the build, and fix the handling of pointer sizes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@38494 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6b278fc786
commit
7a616a1012
@ -15,6 +15,7 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/Analysis/MemoryDependenceAnalysis.h"
|
#include "llvm/Analysis/MemoryDependenceAnalysis.h"
|
||||||
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/Instructions.h"
|
#include "llvm/Instructions.h"
|
||||||
#include "llvm/Function.h"
|
#include "llvm/Function.h"
|
||||||
#include "llvm/Analysis/AliasAnalysis.h"
|
#include "llvm/Analysis/AliasAnalysis.h"
|
||||||
@ -67,22 +68,18 @@ Instruction* MemoryDependenceAnalysis::getDependency(Instruction* query,
|
|||||||
uint64_t dependeeSize = 0;
|
uint64_t dependeeSize = 0;
|
||||||
if (StoreInst* S = dyn_cast<StoreInst>(QI)) {
|
if (StoreInst* S = dyn_cast<StoreInst>(QI)) {
|
||||||
dependee = S->getPointerOperand();
|
dependee = S->getPointerOperand();
|
||||||
dependeeSize = TD.getTypeSize(dependee->getType());
|
dependeeSize = TD.getTypeSize(S->getOperand(0)->getType());
|
||||||
} else if (LoadInst* L = dyn_cast<LoadInst>(QI)) {
|
} else if (LoadInst* L = dyn_cast<LoadInst>(QI)) {
|
||||||
dependee = L->getPointerOperand();
|
dependee = L->getPointerOperand();
|
||||||
dependeeSize = TD.getTypeSize(dependee->getType());
|
dependeeSize = TD.getTypeSize(L->getType());
|
||||||
} else if (FreeInst* F = dyn_cast<FreeInst>(QI)) {
|
} else if (FreeInst* F = dyn_cast<FreeInst>(QI)) {
|
||||||
dependee = F->getPointerOperand();
|
dependee = F->getPointerOperand();
|
||||||
|
|
||||||
// FreeInsts erase the entire structure, not just a field
|
// FreeInsts erase the entire structure, not just a field
|
||||||
dependeeSize = ~0UL;
|
dependeeSize = ~0UL;
|
||||||
} else if (isa<AllocationInst>(query)) {
|
} else if (isa<AllocationInst>(query))
|
||||||
// Allocations don't depend on anything
|
|
||||||
depGraphLocal.insert(std::make_pair(query, std::make_pair(None,
|
|
||||||
true)));
|
|
||||||
reverseDep.insert(std::make_pair(None, query));
|
|
||||||
return None;
|
return None;
|
||||||
} else
|
else
|
||||||
// FIXME: Call/InvokeInsts need proper handling
|
// FIXME: Call/InvokeInsts need proper handling
|
||||||
return None;
|
return None;
|
||||||
|
|
||||||
@ -92,26 +89,19 @@ Instruction* MemoryDependenceAnalysis::getDependency(Instruction* query,
|
|||||||
while (QI != blockBegin) {
|
while (QI != blockBegin) {
|
||||||
--QI;
|
--QI;
|
||||||
|
|
||||||
// If we've reached the pointer's definition...
|
|
||||||
if (QI == dependee) {
|
|
||||||
depGraphLocal.insert(std::make_pair(query, std::make_pair(QI, true)));
|
|
||||||
reverseDep.insert(std::make_pair(QI, query));
|
|
||||||
return QI;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If this inst is a memory op, get the pointer it accessed
|
// If this inst is a memory op, get the pointer it accessed
|
||||||
Value* pointer = 0;
|
Value* pointer = 0;
|
||||||
uint64_t pointerSize = 0;
|
uint64_t pointerSize = 0;
|
||||||
if (StoreInst* S = dyn_cast<StoreInst>(QI)) {
|
if (StoreInst* S = dyn_cast<StoreInst>(QI)) {
|
||||||
pointer = S->getPointerOperand();
|
pointer = S->getPointerOperand();
|
||||||
pointerSize = TD.getTypeSize(pointer->getType());
|
pointerSize = TD.getTypeSize(S->getOperand(0)->getType());
|
||||||
} else if (LoadInst* L = dyn_cast<LoadInst>(QI)) {
|
} else if (LoadInst* L = dyn_cast<LoadInst>(QI)) {
|
||||||
pointer = L->getPointerOperand();
|
pointer = L->getPointerOperand();
|
||||||
pointerSize = TD.getTypeSize(pointer->getType());
|
pointerSize = TD.getTypeSize(L->getType());
|
||||||
} else if (AllocationInst* AI = dyn_cast<AllocationInst>(QI)) {
|
} else if (AllocationInst* AI = dyn_cast<AllocationInst>(QI)) {
|
||||||
pointer = AI;
|
pointer = AI;
|
||||||
if (isa<ConstantInt>(AI->getArraySize()))
|
if (ConstantInt* C = dyn_cast<ConstantInt>(AI->getArraySize()))
|
||||||
pointerSize = AI->getZExtValue();
|
pointerSize = C->getZExtValue();
|
||||||
else
|
else
|
||||||
pointerSize = ~0UL;
|
pointerSize = ~0UL;
|
||||||
} else if (FreeInst* F = dyn_cast<FreeInst>(QI)) {
|
} else if (FreeInst* F = dyn_cast<FreeInst>(QI)) {
|
||||||
@ -119,7 +109,7 @@ Instruction* MemoryDependenceAnalysis::getDependency(Instruction* query,
|
|||||||
|
|
||||||
// FreeInsts erase the entire structure
|
// FreeInsts erase the entire structure
|
||||||
pointerSize = ~0UL;
|
pointerSize = ~0UL;
|
||||||
} else if (CallSite* C = dyn_cast<CallSite>(QI)) {
|
} else if (CallInst* C = dyn_cast<CallInst>(QI)) {
|
||||||
// Call insts need special handling. Check is they can modify our pointer
|
// Call insts need special handling. Check is they can modify our pointer
|
||||||
if (AA.getModRefInfo(C, dependee, dependeeSize) != AliasAnalysis::NoModRef) {
|
if (AA.getModRefInfo(C, dependee, dependeeSize) != AliasAnalysis::NoModRef) {
|
||||||
depGraphLocal.insert(std::make_pair(query, std::make_pair(C, true)));
|
depGraphLocal.insert(std::make_pair(query, std::make_pair(C, true)));
|
||||||
@ -128,6 +118,15 @@ Instruction* MemoryDependenceAnalysis::getDependency(Instruction* query,
|
|||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
} else if (InvokeInst* I = dyn_cast<InvokeInst>(QI)) {
|
||||||
|
// Invoke insts need special handling. Check is they can modify our pointer
|
||||||
|
if (AA.getModRefInfo(I, dependee, dependeeSize) != AliasAnalysis::NoModRef) {
|
||||||
|
depGraphLocal.insert(std::make_pair(query, std::make_pair(I, true)));
|
||||||
|
reverseDep.insert(std::make_pair(I, query));
|
||||||
|
return I;
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we found a pointer, check if it could be the same as our pointer
|
// If we found a pointer, check if it could be the same as our pointer
|
||||||
|
Loading…
Reference in New Issue
Block a user