llvm.org GIT mirror llvm / 0fc052c
For PR645: Remove the Function::renameLocalSymbols function as it is no longer needed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33522 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Spencer 13 years ago
3 changed file(s) with 0 addition(s) and 49 deletion(s). Raw diff Collapse all Expand all
109109 /// calling conventions are defined in CallingConv.h.
110110 unsigned getCallingConv() const { return CallingConvention; }
111111 void setCallingConv(unsigned CC) { CallingConvention = CC; }
112
113 /// renameLocalSymbols - This method goes through the Function's symbol table
114 /// and renames any symbols that conflict with symbols at global scope. This
115 /// is required before printing out to a textual form, to ensure that there is
116 /// no ambiguity when parsing.
117 void renameLocalSymbols();
118
119112
120113 /// deleteBody - This method deletes the body of the function, and converts
121114 /// the linkage to external.
9797
9898 // Output all floating point constants that cannot be printed accurately.
9999 printFloatingPointConstants(F);
100
101 // Ensure that no local symbols conflict with global symbols.
102 F.renameLocalSymbols();
103100
104101 printFunction(F);
105102 FPConstantMap.clear();
135135
136136 void Function::eraseFromParent() {
137137 getParent()->getFunctionList().erase(this);
138 }
139
140
141 /// renameLocalSymbols - This method goes through the Function's symbol table
142 /// and renames any symbols that conflict with symbols at global scope. This is
143 /// required before printing out to a textual form, to ensure that there is no
144 /// ambiguity when parsing.
145 void Function::renameLocalSymbols() {
146 SymbolTable &LST = getValueSymbolTable(); // Local Symtab
147 SymbolTable &GST = getParent()->getValueSymbolTable(); // Global Symtab
148
149 for (SymbolTable::plane_iterator LPI = LST.plane_begin(), E = LST.plane_end();
150 LPI != E; ++LPI)
151 // All global symbols are of pointer type, ignore any non-pointer planes.
152 if (isa(LPI->first)) {
153 // Only check if the global plane has any symbols of this type.
154 SymbolTable::plane_iterator GPI = GST.find(LPI->first);
155 if (GPI != GST.plane_end()) {
156 SymbolTable::ValueMap &LVM = LPI->second;
157 const SymbolTable::ValueMap &GVM = GPI->second;
158
159 // Loop over all local symbols, renaming those that are in the global
160 // symbol table already.
161 for (SymbolTable::value_iterator VI = LVM.begin(), E = LVM.end();
162 VI != E;) {
163 Value *V = VI->second;
164 const std::string &Name = VI->first;
165 ++VI;
166 if (GVM.count(Name)) {
167 static unsigned UniqueNum = 0;
168 // Find a name that does not conflict!
169 while (GVM.count(Name + "_" + utostr(++UniqueNum)) ||
170 LVM.count(Name + "_" + utostr(UniqueNum)))
171 /* scan for UniqueNum that works */;
172 V->setName(Name + "_" + utostr(UniqueNum));
173 }
174 }
175 }
176 }
177138 }
178139
179140