[llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp
Reid Spencer
reid at x10sys.com
Mon Aug 16 00:46:44 PDT 2004
Changes in directory llvm/lib/VMCore:
AsmWriter.cpp updated: 1.153 -> 1.154
---
Log message:
Fix PR422: http://llvm.cs.uiuc.edu/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.
---
Diffs of the changes: (+11 -2)
Index: llvm/lib/VMCore/AsmWriter.cpp
diff -u llvm/lib/VMCore/AsmWriter.cpp:1.153 llvm/lib/VMCore/AsmWriter.cpp:1.154
--- llvm/lib/VMCore/AsmWriter.cpp:1.153 Thu Jul 29 11:53:53 2004
+++ llvm/lib/VMCore/AsmWriter.cpp Mon Aug 16 02:46:33 2004
@@ -92,7 +92,10 @@
public:
/// If you'd like to deal with a function instead of just a module, use
/// 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
/// most recently incorporated function from the SlotMachine. This
@@ -138,6 +141,7 @@
/// @brief The function for which we are holding slot numbers
const Function* TheFunction;
+ bool FunctionProcessed;
/// @brief The TypePlanes map for the module level data
TypedPlanes mMap;
@@ -1263,6 +1267,7 @@
SlotMachine::SlotMachine(const Module *M)
: TheModule(M) ///< Saved for lazy initialization.
, TheFunction(0)
+ , FunctionProcessed(false)
, mMap()
, mTypes()
, fMap()
@@ -1275,6 +1280,7 @@
SlotMachine::SlotMachine(const Function *F )
: TheModule( F ? F->getParent() : 0 ) ///< Saved for lazy initialization
, TheFunction(F) ///< Saved for lazy initialization
+ , FunctionProcessed(false)
, mMap()
, mTypes()
, fMap()
@@ -1287,7 +1293,7 @@
processModule();
TheModule = 0; ///< Prevent re-processing next time we're called.
}
- if ( TheFunction ) {
+ if ( TheFunction && ! FunctionProcessed) {
processFunction();
}
}
@@ -1331,6 +1337,8 @@
}
}
+ FunctionProcessed = true;
+
SC_DEBUG("end processFunction!\n");
}
@@ -1343,6 +1351,7 @@
fMap.clear(); // Simply discard the function level map
fTypes.clear();
TheFunction = 0;
+ FunctionProcessed = false;
SC_DEBUG("end purgeFunction!\n");
}
More information about the llvm-commits
mailing list