mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-26 23:24:34 +00:00
Fix PR422.
Ouch! Changes in the lazy initialization code caused each incorporated function to reprocess the entire function on every lookup of a value's slot number. This caused a horrible slowdown in all functions. This fix made llvm-dis go from "longer than I care to wait" (minutes) on a large test case to 0.53 seconds. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15818 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -92,7 +92,10 @@ public:
|
|||||||
public:
|
public:
|
||||||
/// If you'd like to deal with a function instead of just a module, use
|
/// If you'd like to deal with a function instead of just a module, use
|
||||||
/// this method to get its data into the SlotMachine.
|
/// this method to get its data into the SlotMachine.
|
||||||
void incorporateFunction(const Function *F) { TheFunction = F; }
|
void incorporateFunction(const Function *F) {
|
||||||
|
TheFunction = F;
|
||||||
|
FunctionProcessed = false;
|
||||||
|
}
|
||||||
|
|
||||||
/// After calling incorporateFunction, use this method to remove the
|
/// After calling incorporateFunction, use this method to remove the
|
||||||
/// most recently incorporated function from the SlotMachine. This
|
/// most recently incorporated function from the SlotMachine. This
|
||||||
@ -138,6 +141,7 @@ public:
|
|||||||
|
|
||||||
/// @brief The function for which we are holding slot numbers
|
/// @brief The function for which we are holding slot numbers
|
||||||
const Function* TheFunction;
|
const Function* TheFunction;
|
||||||
|
bool FunctionProcessed;
|
||||||
|
|
||||||
/// @brief The TypePlanes map for the module level data
|
/// @brief The TypePlanes map for the module level data
|
||||||
TypedPlanes mMap;
|
TypedPlanes mMap;
|
||||||
@ -1263,6 +1267,7 @@ CachedWriter& CachedWriter::operator<<(const Type &Ty) {
|
|||||||
SlotMachine::SlotMachine(const Module *M)
|
SlotMachine::SlotMachine(const Module *M)
|
||||||
: TheModule(M) ///< Saved for lazy initialization.
|
: TheModule(M) ///< Saved for lazy initialization.
|
||||||
, TheFunction(0)
|
, TheFunction(0)
|
||||||
|
, FunctionProcessed(false)
|
||||||
, mMap()
|
, mMap()
|
||||||
, mTypes()
|
, mTypes()
|
||||||
, fMap()
|
, fMap()
|
||||||
@ -1275,6 +1280,7 @@ SlotMachine::SlotMachine(const Module *M)
|
|||||||
SlotMachine::SlotMachine(const Function *F )
|
SlotMachine::SlotMachine(const Function *F )
|
||||||
: TheModule( F ? F->getParent() : 0 ) ///< Saved for lazy initialization
|
: TheModule( F ? F->getParent() : 0 ) ///< Saved for lazy initialization
|
||||||
, TheFunction(F) ///< Saved for lazy initialization
|
, TheFunction(F) ///< Saved for lazy initialization
|
||||||
|
, FunctionProcessed(false)
|
||||||
, mMap()
|
, mMap()
|
||||||
, mTypes()
|
, mTypes()
|
||||||
, fMap()
|
, fMap()
|
||||||
@ -1287,7 +1293,7 @@ inline void SlotMachine::initialize(void) {
|
|||||||
processModule();
|
processModule();
|
||||||
TheModule = 0; ///< Prevent re-processing next time we're called.
|
TheModule = 0; ///< Prevent re-processing next time we're called.
|
||||||
}
|
}
|
||||||
if ( TheFunction ) {
|
if ( TheFunction && ! FunctionProcessed) {
|
||||||
processFunction();
|
processFunction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1331,6 +1337,8 @@ void SlotMachine::processFunction() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FunctionProcessed = true;
|
||||||
|
|
||||||
SC_DEBUG("end processFunction!\n");
|
SC_DEBUG("end processFunction!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1343,6 +1351,7 @@ void SlotMachine::purgeFunction() {
|
|||||||
fMap.clear(); // Simply discard the function level map
|
fMap.clear(); // Simply discard the function level map
|
||||||
fTypes.clear();
|
fTypes.clear();
|
||||||
TheFunction = 0;
|
TheFunction = 0;
|
||||||
|
FunctionProcessed = false;
|
||||||
SC_DEBUG("end purgeFunction!\n");
|
SC_DEBUG("end purgeFunction!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user