mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-29 10:25:12 +00:00
* Add new method localLookup
* SymbolTable::remove(Value *N) checks to see if we are internally inconsistent before looking for a type plane (caused a crash) * insertEntry now does a local lookup instead of a global lookup, which was causing an infinite loop in the renamer logic. * Added assertions to make sure stuff stays happy * Now the linker correctly links the SPECINT2000 mcf benchmark git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1840 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -54,6 +54,11 @@ public:
|
|||||||
// lookup - Returns null on failure...
|
// lookup - Returns null on failure...
|
||||||
Value *lookup(const Type *Ty, const std::string &name);
|
Value *lookup(const Type *Ty, const std::string &name);
|
||||||
|
|
||||||
|
// localLookup - Look in this symbol table without falling back on parent,
|
||||||
|
// if non-existing. Returns null on failure...
|
||||||
|
//
|
||||||
|
Value *localLookup(const Type *Ty, const std::string &name);
|
||||||
|
|
||||||
// insert - Add named definition to the symbol table...
|
// insert - Add named definition to the symbol table...
|
||||||
inline void insert(Value *N) {
|
inline void insert(Value *N) {
|
||||||
assert(N->hasName() && "Value must be named to go into symbol table!");
|
assert(N->hasName() && "Value must be named to go into symbol table!");
|
||||||
|
@@ -73,7 +73,7 @@ string SymbolTable::getUniqueName(const Type *Ty, const string &BaseName) {
|
|||||||
|
|
||||||
|
|
||||||
// lookup - Returns null on failure...
|
// lookup - Returns null on failure...
|
||||||
Value *SymbolTable::lookup(const Type *Ty, const string &Name) {
|
Value *SymbolTable::localLookup(const Type *Ty, const string &Name) {
|
||||||
iterator I = find(Ty);
|
iterator I = find(Ty);
|
||||||
if (I != end()) { // We have symbols in that plane...
|
if (I != end()) { // We have symbols in that plane...
|
||||||
type_iterator J = I->second.find(Name);
|
type_iterator J = I->second.find(Name);
|
||||||
@@ -81,13 +81,23 @@ Value *SymbolTable::lookup(const Type *Ty, const string &Name) {
|
|||||||
return J->second;
|
return J->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// lookup - Returns null on failure...
|
||||||
|
Value *SymbolTable::lookup(const Type *Ty, const string &Name) {
|
||||||
|
Value *LV = localLookup(Ty, Name);
|
||||||
|
if (LV) return LV;
|
||||||
return ParentSymTab ? ParentSymTab->lookup(Ty, Name) : 0;
|
return ParentSymTab ? ParentSymTab->lookup(Ty, Name) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SymbolTable::remove(Value *N) {
|
void SymbolTable::remove(Value *N) {
|
||||||
assert(N->hasName() && "Value doesn't have name!");
|
assert(N->hasName() && "Value doesn't have name!");
|
||||||
|
if (InternallyInconsistent) return;
|
||||||
|
|
||||||
iterator I = find(N->getType());
|
iterator I = find(N->getType());
|
||||||
|
assert(I != end() &&
|
||||||
|
"Trying to remove a type that doesn't have a plane yet!");
|
||||||
removeEntry(I, I->second.find(N->getName()));
|
removeEntry(I, I->second.find(N->getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,9 +152,11 @@ Value *SymbolTable::removeEntry(iterator Plane, type_iterator Entry) {
|
|||||||
// name...
|
// name...
|
||||||
//
|
//
|
||||||
void SymbolTable::insertEntry(const string &Name, const Type *VTy, Value *V) {
|
void SymbolTable::insertEntry(const string &Name, const Type *VTy, Value *V) {
|
||||||
|
|
||||||
// Check to see if there is a naming conflict. If so, rename this value!
|
// Check to see if there is a naming conflict. If so, rename this value!
|
||||||
if (lookup(VTy, Name)) {
|
if (localLookup(VTy, Name)) {
|
||||||
string UniqueName = getUniqueName(VTy, Name);
|
string UniqueName = getUniqueName(VTy, Name);
|
||||||
|
assert(InternallyInconsistent == false && "Infinite loop inserting entry!");
|
||||||
InternallyInconsistent = true;
|
InternallyInconsistent = true;
|
||||||
V->setName(UniqueName, this);
|
V->setName(UniqueName, this);
|
||||||
InternallyInconsistent = false;
|
InternallyInconsistent = false;
|
||||||
@@ -243,6 +255,8 @@ void SymbolTable::refineAbstractType(const DerivedType *OldType,
|
|||||||
// that turns remove into a noop. Thus the name will get null'd
|
// that turns remove into a noop. Thus the name will get null'd
|
||||||
// out, but the symbol table won't get upset.
|
// out, but the symbol table won't get upset.
|
||||||
//
|
//
|
||||||
|
assert(InternallyInconsistent == false &&
|
||||||
|
"Symbol table already inconsistent!");
|
||||||
InternallyInconsistent = true;
|
InternallyInconsistent = true;
|
||||||
|
|
||||||
// Remove newM from the symtab
|
// Remove newM from the symtab
|
||||||
|
Reference in New Issue
Block a user