mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-03 14:31:10 +00:00
Update obsolete comments
Fix iterator invalidation problems which was causing -mstrip to miss some entries, and read free'd memory. This shrinks the symbol table of 254.gap from 333 to 284 bytes! :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10751 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
737d3cd719
commit
2cacc0a306
@ -10,9 +10,9 @@
|
|||||||
// This file implements stripping symbols out of symbol tables.
|
// This file implements stripping symbols out of symbol tables.
|
||||||
//
|
//
|
||||||
// Specifically, this allows you to strip all of the symbols out of:
|
// Specifically, this allows you to strip all of the symbols out of:
|
||||||
// * A function
|
|
||||||
// * All functions in a module
|
// * All functions in a module
|
||||||
// * All symbols in a module (all function symbols + all module scope symbols)
|
// * All non-essential symbols in a module (all function symbols + all module
|
||||||
|
// scope symbols)
|
||||||
//
|
//
|
||||||
// Notice that:
|
// Notice that:
|
||||||
// * This pass makes code much less readable, so it should only be used in
|
// * This pass makes code much less readable, so it should only be used in
|
||||||
@ -30,12 +30,15 @@ using namespace llvm;
|
|||||||
static bool StripSymbolTable(SymbolTable &SymTab) {
|
static bool StripSymbolTable(SymbolTable &SymTab) {
|
||||||
bool RemovedSymbol = false;
|
bool RemovedSymbol = false;
|
||||||
|
|
||||||
for (SymbolTable::iterator I = SymTab.begin(); I != SymTab.end(); ++I) {
|
for (SymbolTable::iterator I = SymTab.begin(); I != SymTab.end();) {
|
||||||
std::map<const std::string, Value *> &Plane = I->second;
|
// Removing items from the plane can cause the plane itself to get deleted.
|
||||||
|
// If this happens, make sure we incremented our plane iterator already!
|
||||||
|
std::map<const std::string, Value *> &Plane = (I++)->second;
|
||||||
|
|
||||||
SymbolTable::type_iterator B = Plane.begin();
|
SymbolTable::type_iterator B = Plane.begin(), Bend = Plane.end();
|
||||||
while (B != Plane.end()) { // Found nonempty type plane!
|
while (B != Bend) { // Found nonempty type plane!
|
||||||
Value *V = B->second;
|
Value *V = B->second;
|
||||||
|
|
||||||
if (isa<Constant>(V) || isa<Type>(V)) {
|
if (isa<Constant>(V) || isa<Type>(V)) {
|
||||||
SymTab.type_remove(B++);
|
SymTab.type_remove(B++);
|
||||||
RemovedSymbol = true;
|
RemovedSymbol = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user