[llvm-commits] [dragonegg] r130302 - /dragonegg/trunk/src/Constants.cpp
Duncan Sands
baldrick at free.fr
Wed Apr 27 07:21:53 PDT 2011
Author: baldrick
Date: Wed Apr 27 09:21:53 2011
New Revision: 130302
URL: http://llvm.org/viewvc/llvm-project?rev=130302&view=rev
Log:
Initializers for global variables are typically converted at least twice.
Cache conversion results so that the work of conversion only needs to be
done once.
Modified:
dragonegg/trunk/src/Constants.cpp
Modified: dragonegg/trunk/src/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Constants.cpp?rev=130302&r1=130301&r2=130302&view=diff
==============================================================================
--- dragonegg/trunk/src/Constants.cpp (original)
+++ dragonegg/trunk/src/Constants.cpp Wed Apr 27 09:21:53 2011
@@ -26,6 +26,9 @@
#include "dragonegg/Trees.h"
#include "dragonegg/ADT/IntervalList.h"
#include "dragonegg/ADT/Range.h"
+extern "C" {
+#include "dragonegg/cache.h"
+}
// LLVM headers
#include "llvm/GlobalVariable.h"
@@ -1255,6 +1258,10 @@
/// initial value may exceed the alloc size of the LLVM memory type generated
/// for the GCC type (see ConvertType); it is never smaller than the alloc size.
Constant *ConvertInitializer(tree exp) {
+ // If we already converted the initializer then return the cached copy.
+ if (Constant *C = (Constant *)llvm_get_cached(exp))
+ return C;
+
Constant *Init;
switch (TREE_CODE(exp)) {
default:
@@ -1316,6 +1323,10 @@
DieAbjectly("Constant over aligned!", exp);
#endif
+ // Cache the result of converting the initializer since the same tree is often
+ // converted multiple times.
+ llvm_set_cached(exp, Init);
+
return Init;
}
More information about the llvm-commits
mailing list