mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-16 07:38:43 +00:00
fix compile-time regression report by Joerg Sonnenberger:
cache result of Size/OffsetVisitor to speedup analysis of PHI nodes git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172363 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
135174deb8
commit
29eb2cc00c
@ -153,12 +153,14 @@ typedef std::pair<APInt, APInt> SizeOffsetType;
|
|||||||
class ObjectSizeOffsetVisitor
|
class ObjectSizeOffsetVisitor
|
||||||
: public InstVisitor<ObjectSizeOffsetVisitor, SizeOffsetType> {
|
: public InstVisitor<ObjectSizeOffsetVisitor, SizeOffsetType> {
|
||||||
|
|
||||||
|
typedef DenseMap<const Value*, SizeOffsetType> CacheMapTy;
|
||||||
|
|
||||||
const DataLayout *TD;
|
const DataLayout *TD;
|
||||||
const TargetLibraryInfo *TLI;
|
const TargetLibraryInfo *TLI;
|
||||||
bool RoundToAlign;
|
bool RoundToAlign;
|
||||||
unsigned IntTyBits;
|
unsigned IntTyBits;
|
||||||
APInt Zero;
|
APInt Zero;
|
||||||
SmallPtrSet<Value*, 8> SeenInsts;
|
CacheMapTy CacheMap;
|
||||||
|
|
||||||
APInt align(APInt Size, uint64_t Align);
|
APInt align(APInt Size, uint64_t Align);
|
||||||
|
|
||||||
|
@ -387,17 +387,19 @@ SizeOffsetType ObjectSizeOffsetVisitor::compute(Value *V) {
|
|||||||
V = V->stripPointerCasts();
|
V = V->stripPointerCasts();
|
||||||
|
|
||||||
if (isa<Instruction>(V) || isa<GEPOperator>(V)) {
|
if (isa<Instruction>(V) || isa<GEPOperator>(V)) {
|
||||||
// If we have already seen this instruction, bail out.
|
// return cached value or insert unknown in cache if size of V was not
|
||||||
if (!SeenInsts.insert(V))
|
// computed yet in order to avoid recursions in PHis
|
||||||
return unknown();
|
std::pair<CacheMapTy::iterator, bool> CacheVal =
|
||||||
|
CacheMap.insert(std::make_pair(V, unknown()));
|
||||||
|
if (!CacheVal.second)
|
||||||
|
return CacheVal.first->second;
|
||||||
|
|
||||||
SizeOffsetType Ret;
|
SizeOffsetType Result;
|
||||||
if (GEPOperator *GEP = dyn_cast<GEPOperator>(V))
|
if (GEPOperator *GEP = dyn_cast<GEPOperator>(V))
|
||||||
Ret = visitGEPOperator(*GEP);
|
Result = visitGEPOperator(*GEP);
|
||||||
else
|
else
|
||||||
Ret = visit(cast<Instruction>(*V));
|
Result = visit(cast<Instruction>(*V));
|
||||||
SeenInsts.erase(V);
|
return CacheMap[V] = Result;
|
||||||
return Ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Argument *A = dyn_cast<Argument>(V))
|
if (Argument *A = dyn_cast<Argument>(V))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user