aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/SymbolTable.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-10-22 04:55:44 +0000
committerChris Lattner <sabre@nondot.org>2001-10-22 04:55:44 +0000
commit9245fc75a43a179422f88d7dd2b5b931a0b2972e (patch)
tree284c815df30d1166528dfe9356c54deb5b54fe39 /lib/VMCore/SymbolTable.cpp
parentc9a21b51a11d84443cb3f03787fd08a69fdd73cd (diff)
downloadexternal_llvm-9245fc75a43a179422f88d7dd2b5b931a0b2972e.zip
external_llvm-9245fc75a43a179422f88d7dd2b5b931a0b2972e.tar.gz
external_llvm-9245fc75a43a179422f88d7dd2b5b931a0b2972e.tar.bz2
Fix bug exposed by this testcase:
declare int "call_operand" (%rtx_def*, int) ;; Prototype for: call_operand declare int "restore_operand" (%rtx_def*, int) ;; Prototype for: restore_operand %rtx_def = type opaque %rtx_def = type int implementation git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@934 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/SymbolTable.cpp')
-rw-r--r--lib/VMCore/SymbolTable.cpp33
1 files changed, 27 insertions, 6 deletions
diff --git a/lib/VMCore/SymbolTable.cpp b/lib/VMCore/SymbolTable.cpp
index 4317968..8623416 100644
--- a/lib/VMCore/SymbolTable.cpp
+++ b/lib/VMCore/SymbolTable.cpp
@@ -119,9 +119,7 @@ Value *SymbolTable::type_remove(const type_iterator &It) {
// insertEntry - Insert a value into the symbol table with the specified
// name...
//
-void SymbolTable::insertEntry(const string &Name, Value *V) {
- const Type *VTy = V->getType();
-
+void SymbolTable::insertEntry(const string &Name, const Type *VTy, Value *V) {
// TODO: The typeverifier should catch this when its implemented
assert(lookup(VTy, Name) == 0 &&
"SymbolTable::insertEntry - Name already in symbol table!");
@@ -133,9 +131,16 @@ void SymbolTable::insertEntry(const string &Name, Value *V) {
iterator I = find(VTy);
if (I == end()) { // Not in collection yet... insert dummy entry
- (*this)[VTy] = VarMap();
- I = find(VTy);
+ // Insert a new empty element. I points to the new elements.
+ I = super::insert(make_pair(VTy, VarMap())).first;
assert(I != end() && "How did insert fail?");
+
+ // Check to see if the type is abstract. If so, it might be refined in the
+ // future, which would cause the plane of the old type to get merged into
+ // a new type plane.
+ //
+ if (VTy->isAbstract())
+ cast<DerivedType>(VTy)->addAbstractTypeUser(this);
}
I->second.insert(make_pair(Name, V));
@@ -153,7 +158,23 @@ void SymbolTable::refineAbstractType(const DerivedType *OldType,
const Type *NewType) {
if (OldType == NewType) return; // Noop, don't waste time dinking around
- iterator TPI = find(Type::TypeTy);
+ // Search to see if we have any values of the type oldtype. If so, we need to
+ // move them into the newtype plane...
+ iterator TPI = find(OldType);
+ if (TPI != end()) {
+ VarMap &OldPlane = TPI->second;
+ while (!OldPlane.empty()) {
+ pair<const string, Value*> V = *OldPlane.begin();
+ OldPlane.erase(OldPlane.begin());
+ insertEntry(V.first, NewType, V.second);
+ }
+
+ // Ok, now we are not referencing the type anymore... take me off your user
+ // list please!
+ OldType->removeAbstractTypeUser(this);
+ }
+
+ TPI = find(Type::TypeTy);
assert(TPI != end() &&"Type plane not in symbol table but we contain types!");
// Loop over all of the types in the symbol table, replacing any references to