aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-10-18 20:05:30 +0000
committerChris Lattner <sabre@nondot.org>2001-10-18 20:05:30 +0000
commit399376b53b91e52d82cb993ecd4eb895fb8461d2 (patch)
tree21c2c0c8d9483932c75461f7a4880a86622e771f /include/llvm/Transforms
parent3923140a4d68ddc7ac34a2d973984da7be29ab55 (diff)
downloadexternal_llvm-399376b53b91e52d82cb993ecd4eb895fb8461d2.zip
external_llvm-399376b53b91e52d82cb993ecd4eb895fb8461d2.tar.gz
external_llvm-399376b53b91e52d82cb993ecd4eb895fb8461d2.tar.bz2
Initial Checkin
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@896 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Transforms')
-rw-r--r--include/llvm/Transforms/IPO/ConstantMerge.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/include/llvm/Transforms/IPO/ConstantMerge.h b/include/llvm/Transforms/IPO/ConstantMerge.h
new file mode 100644
index 0000000..e98e375
--- /dev/null
+++ b/include/llvm/Transforms/IPO/ConstantMerge.h
@@ -0,0 +1,58 @@
+//===- llvm/Transforms/ConstantMerge.h - Merge duplicate consts --*- C++ -*--=//
+//
+// This file defines the interface to a pass that merges duplicate global
+// constants together into a single constant that is shared. This is useful
+// because some passes (ie TraceValues) insert a lot of string constants into
+// the program, regardless of whether or not they duplicate an existing string.
+//
+// Algorithm: ConstantMerge is designed to build up a map of available constants
+// and elminate duplicates when it is initialized.
+//
+// The DynamicConstantMerge method is a superset of the ConstantMerge algorithm
+// that checks for each method to see if constants have been added to the
+// constant pool since it was last run... if so, it processes them.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_CONSTANTMERGE_H
+#define LLVM_TRANSFORMS_CONSTANTMERGE_H
+
+#include "llvm/Transforms/Pass.h"
+#include <map>
+class ConstPoolVal;
+class GlobalVariable;
+
+class ConstantMerge : public Pass {
+protected:
+ map<ConstPoolVal*, GlobalVariable*> Constants;
+ unsigned LastConstantSeen;
+public:
+ inline ConstantMerge() : LastConstantSeen(0) {}
+
+ // mergeDuplicateConstants - Static accessor for clients that don't want to
+ // deal with passes.
+ //
+ static bool mergeDuplicateConstants(Module *M);
+
+ // doPassInitialization - For this pass, process all of the globals in the
+ // module, eliminating duplicate constants.
+ //
+ bool doPassInitialization(Module *M);
+
+ // doPassFinalization - Clean up internal state for this module
+ //
+ bool doPassFinalization(Module *M) {
+ LastConstantSeen = 0;
+ Constants.clear();
+ return false;
+ }
+};
+
+struct DynamicConstantMerge : public ConstantMerge {
+ // doPerMethodWork - Check to see if any globals have been added to the
+ // global list for the module. If so, eliminate them.
+ //
+ bool doPerMethodWork(Method *M);
+};
+
+#endif