diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2004-08-26 22:32:00 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2004-08-26 22:32:00 +0000 |
commit | 07ea1917d00cb84474fc47a1050572d9c589501c (patch) | |
tree | 7bc3d4448b0f3f194e2c0479a9b916e77f9caa36 | |
parent | 22a2f6d5b05631a21b62e3e103aa1b9469ad0c5c (diff) | |
download | external_llvm-07ea1917d00cb84474fc47a1050572d9c589501c.zip external_llvm-07ea1917d00cb84474fc47a1050572d9c589501c.tar.gz external_llvm-07ea1917d00cb84474fc47a1050572d9c589501c.tar.bz2 |
Add the CompactionTableIsEmpty function so that we can determine if a
CompactionTable really needs to be emitted. This is not a straight forward
computation, hence the need for a member function here.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16062 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Bytecode/Writer/SlotCalculator.cpp | 26 | ||||
-rw-r--r-- | lib/Bytecode/Writer/SlotCalculator.h | 3 |
2 files changed, 29 insertions, 0 deletions
diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp index 75fb418..2656edd 100644 --- a/lib/Bytecode/Writer/SlotCalculator.cpp +++ b/lib/Bytecode/Writer/SlotCalculator.cpp @@ -622,6 +622,32 @@ void SlotCalculator::pruneCompactionTable() { } } +/// Determine if the compaction table is actually empty. Because the +/// compaction table always includes the primitive type planes, we +/// can't just check getCompactionTable().size() because it will never +/// be zero. Furthermore, the ModuleLevel factors into whether a given +/// plane is empty or not. This function does the necessary computation +/// to determine if its actually empty. +bool SlotCalculator::CompactionTableIsEmpty() const { + // Check a degenerate case, just in case. + if (CompactionTable.size() == 0) return true; + + // Check each plane + for (unsigned i = 0, e = CompactionTable.size(); i < e; ++i) { + // If the plane is not empty + if (!CompactionTable[i].empty()) { + // If the module level is non-zero then at least the + // first element of the plane is valid and therefore not empty. + unsigned End = getModuleLevel(i); + if (End != 0) + return false; + } + } + // All the compaction table planes are empty so the table is + // considered empty too. + return true; +} + int SlotCalculator::getSlot(const Value *V) const { // If there is a CompactionTable active... if (!CompactionNodeMap.empty()) { diff --git a/lib/Bytecode/Writer/SlotCalculator.h b/lib/Bytecode/Writer/SlotCalculator.h index 29b6906..a6d4286 100644 --- a/lib/Bytecode/Writer/SlotCalculator.h +++ b/lib/Bytecode/Writer/SlotCalculator.h @@ -138,6 +138,9 @@ public: const TypeList& getCompactionTypes() const { return CompactionTypes; } + /// @brief Determine if the compaction table (not types) is empty + bool CompactionTableIsEmpty() const; + private: // getOrCreateSlot - Values can be crammed into here at will... if // they haven't been inserted already, they get inserted, otherwise |