aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/CodeGen/MachineConstantPool.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-10-23 16:29:12 +0000
committerChris Lattner <sabre@nondot.org>2003-10-23 16:29:12 +0000
commitd97487d1e0252a7b8fc27902b70562832d287e7d (patch)
treefbaeaff9affa958a9bf3cb2485954e83a6364032 /include/llvm/CodeGen/MachineConstantPool.h
parentc8893fcc7157a0c28de341b4322c31560ddd2a82 (diff)
downloadexternal_llvm-d97487d1e0252a7b8fc27902b70562832d287e7d.zip
external_llvm-d97487d1e0252a7b8fc27902b70562832d287e7d.tar.gz
external_llvm-d97487d1e0252a7b8fc27902b70562832d287e7d.tar.bz2
Actually share constants local to a function!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9417 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/MachineConstantPool.h')
-rw-r--r--include/llvm/CodeGen/MachineConstantPool.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/include/llvm/CodeGen/MachineConstantPool.h b/include/llvm/CodeGen/MachineConstantPool.h
index 74b7585..441a43a 100644
--- a/include/llvm/CodeGen/MachineConstantPool.h
+++ b/include/llvm/CodeGen/MachineConstantPool.h
@@ -30,10 +30,15 @@ class MachineConstantPool {
public:
/// getConstantPoolIndex - Create a new entry in the constant pool or return
- /// an existing one. This should eventually allow sharing of duplicate
- /// objects in the constant pool, but this is adequate for now.
+ /// an existing one.
///
unsigned getConstantPoolIndex(Constant *C) {
+ // Check to see if we already have this constant.
+ //
+ // FIXME, this could be made much more efficient for large constant pools.
+ for (unsigned i = 0, e = Constants.size(); i != e; ++i)
+ if (Constants[i] == C)
+ return i;
Constants.push_back(C);
return Constants.size()-1;
}