Actually share constants local to a function!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9417 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-10-23 16:29:12 +00:00
parent c8893fcc71
commit d97487d1e0

View File

@ -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;
}