enumerate BB's separately from other function values.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36467 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2007-04-26 04:42:16 +00:00
parent 0e72512a6c
commit c59c0afd7d
2 changed files with 16 additions and 4 deletions

View File

@ -178,11 +178,12 @@ void ValueEnumerator::incorporateFunction(const Function &F) {
isa<InlineAsm>(*OI)) isa<InlineAsm>(*OI))
EnumerateValue(*OI); EnumerateValue(*OI);
} }
ValueMap[BB] = BasicBlocks.size();
BasicBlocks.push_back(BB);
} }
// Add all of the instructions. // Add all of the instructions.
for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB) { for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
EnumerateValue(BB);
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; ++I) { for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; ++I) {
if (I->getType() != Type::VoidTy) if (I->getType() != Type::VoidTy)
EnumerateValue(I); EnumerateValue(I);
@ -194,6 +195,10 @@ void ValueEnumerator::purgeFunction() {
/// Remove purged values from the ValueMap. /// Remove purged values from the ValueMap.
for (unsigned i = ModuleLevel, e = Values.size(); i != e; ++i) for (unsigned i = ModuleLevel, e = Values.size(); i != e; ++i)
ValueMap.erase(Values[i].first); ValueMap.erase(Values[i].first);
for (unsigned i = 0, e = BasicBlocks.size(); i != e; ++i)
ValueMap.erase(BasicBlocks[i]);
Values.resize(ModuleLevel); Values.resize(ModuleLevel);
BasicBlocks.clear();
} }

View File

@ -19,13 +19,13 @@
namespace llvm { namespace llvm {
class Value;
class Type; class Type;
class Module; class Value;
class BasicBlock;
class Function; class Function;
class Module;
class TypeSymbolTable; class TypeSymbolTable;
class ValueSymbolTable; class ValueSymbolTable;
class ConstantArray;
class ValueEnumerator { class ValueEnumerator {
public: public:
@ -43,6 +43,10 @@ private:
ValueMapType ValueMap; ValueMapType ValueMap;
ValueList Values; ValueList Values;
/// BasicBlocks - This contains all the basic blocks for the currently
/// incorporated function. Their reverse mapping is stored in ValueMap.
std::vector<const BasicBlock*> BasicBlocks;
/// When a function is incorporated, this is the size of the Values list /// When a function is incorporated, this is the size of the Values list
/// before incorporation. /// before incorporation.
unsigned ModuleLevel; unsigned ModuleLevel;
@ -66,6 +70,9 @@ public:
const ValueList &getValues() const { return Values; } const ValueList &getValues() const { return Values; }
const TypeList &getTypes() const { return Types; } const TypeList &getTypes() const { return Types; }
const std::vector<const BasicBlock*> &getBasicBlocks() const {
return BasicBlocks;
}
/// PurgeAggregateValues - If there are any aggregate values at the end of the /// PurgeAggregateValues - If there are any aggregate values at the end of the
/// value list, remove them and return the count of the remaining values. If /// value list, remove them and return the count of the remaining values. If