mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-07 14:33:15 +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
|
||||
: public InstVisitor<ObjectSizeOffsetVisitor, SizeOffsetType> {
|
||||
|
||||
typedef DenseMap<const Value*, SizeOffsetType> CacheMapTy;
|
||||
|
||||
const DataLayout *TD;
|
||||
const TargetLibraryInfo *TLI;
|
||||
bool RoundToAlign;
|
||||
unsigned IntTyBits;
|
||||
APInt Zero;
|
||||
SmallPtrSet<Value*, 8> SeenInsts;
|
||||
CacheMapTy CacheMap;
|
||||
|
||||
APInt align(APInt Size, uint64_t Align);
|
||||
|
||||
|
@ -387,17 +387,19 @@ SizeOffsetType ObjectSizeOffsetVisitor::compute(Value *V) {
|
||||
V = V->stripPointerCasts();
|
||||
|
||||
if (isa<Instruction>(V) || isa<GEPOperator>(V)) {
|
||||
// If we have already seen this instruction, bail out.
|
||||
if (!SeenInsts.insert(V))
|
||||
return unknown();
|
||||
// return cached value or insert unknown in cache if size of V was not
|
||||
// computed yet in order to avoid recursions in PHis
|
||||
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))
|
||||
Ret = visitGEPOperator(*GEP);
|
||||
Result = visitGEPOperator(*GEP);
|
||||
else
|
||||
Ret = visit(cast<Instruction>(*V));
|
||||
SeenInsts.erase(V);
|
||||
return Ret;
|
||||
Result = visit(cast<Instruction>(*V));
|
||||
return CacheMap[V] = Result;
|
||||
}
|
||||
|
||||
if (Argument *A = dyn_cast<Argument>(V))
|
||||
|
Loading…
x
Reference in New Issue
Block a user