[llvm-commits] CVS: llvm/lib/Bitcode/Writer/ValueEnumerator.cpp ValueEnumerator.h
Chris Lattner
sabre at nondot.org
Wed Apr 25 21:42:34 PDT 2007
Changes in directory llvm/lib/Bitcode/Writer:
ValueEnumerator.cpp updated: 1.5 -> 1.6
ValueEnumerator.h updated: 1.5 -> 1.6
---
Log message:
enumerate BB's separately from other function values.
---
Diffs of the changes: (+16 -4)
ValueEnumerator.cpp | 7 ++++++-
ValueEnumerator.h | 13 ++++++++++---
2 files changed, 16 insertions(+), 4 deletions(-)
Index: llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
diff -u llvm/lib/Bitcode/Writer/ValueEnumerator.cpp:1.5 llvm/lib/Bitcode/Writer/ValueEnumerator.cpp:1.6
--- llvm/lib/Bitcode/Writer/ValueEnumerator.cpp:1.5 Wed Apr 25 22:50:57 2007
+++ llvm/lib/Bitcode/Writer/ValueEnumerator.cpp Wed Apr 25 23:42:16 2007
@@ -178,11 +178,12 @@
isa<InlineAsm>(*OI))
EnumerateValue(*OI);
}
+ ValueMap[BB] = BasicBlocks.size();
+ BasicBlocks.push_back(BB);
}
// Add all of the instructions.
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) {
if (I->getType() != Type::VoidTy)
EnumerateValue(I);
@@ -194,6 +195,10 @@
/// Remove purged values from the ValueMap.
for (unsigned i = ModuleLevel, e = Values.size(); i != e; ++i)
ValueMap.erase(Values[i].first);
+ for (unsigned i = 0, e = BasicBlocks.size(); i != e; ++i)
+ ValueMap.erase(BasicBlocks[i]);
+
Values.resize(ModuleLevel);
+ BasicBlocks.clear();
}
Index: llvm/lib/Bitcode/Writer/ValueEnumerator.h
diff -u llvm/lib/Bitcode/Writer/ValueEnumerator.h:1.5 llvm/lib/Bitcode/Writer/ValueEnumerator.h:1.6
--- llvm/lib/Bitcode/Writer/ValueEnumerator.h:1.5 Wed Apr 25 22:50:57 2007
+++ llvm/lib/Bitcode/Writer/ValueEnumerator.h Wed Apr 25 23:42:16 2007
@@ -19,13 +19,13 @@
namespace llvm {
-class Value;
class Type;
-class Module;
+class Value;
+class BasicBlock;
class Function;
+class Module;
class TypeSymbolTable;
class ValueSymbolTable;
-class ConstantArray;
class ValueEnumerator {
public:
@@ -43,6 +43,10 @@
ValueMapType ValueMap;
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
/// before incorporation.
unsigned ModuleLevel;
@@ -66,6 +70,9 @@
const ValueList &getValues() const { return Values; }
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
/// value list, remove them and return the count of the remaining values. If
More information about the llvm-commits
mailing list