[llvm-commits] [llvm] r119865 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp
Owen Anderson
resistor at mac.com
Fri Nov 19 14:48:40 PST 2010
Author: resistor
Date: Fri Nov 19 16:48:40 2010
New Revision: 119865
URL: http://llvm.org/viewvc/llvm-project?rev=119865&view=rev
Log:
Document the new GVN number table structure.
Modified:
llvm/trunk/lib/Transforms/Scalar/GVN.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=119865&r1=119864&r2=119865&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Fri Nov 19 16:48:40 2010
@@ -677,8 +677,13 @@
ValueTable VN;
+ /// NumberTable - A mapping from value numers to lists of Value*'s that
+ /// have that value number. Use lookupNumber to query it.
DenseMap<uint32_t, std::pair<Value*, void*> > NumberTable;
BumpPtrAllocator TableAllocator;
+
+ /// insert_table - Push a new Value to the NumberTable onto the list for
+ /// its value number.
void insert_table(uint32_t N, Value *V) {
std::pair<Value*, void*>& Curr = NumberTable[N];
if (!Curr.first) {
@@ -693,6 +698,8 @@
Curr.second = Node;
}
+ /// erase_table - Scan the list of values corresponding to a given value
+ /// number, and remove the given value if encountered.
void erase_table(uint32_t N, Value *V) {
std::pair<Value*, void*>* Prev = 0;
std::pair<Value*, void*>* Curr = &NumberTable[N];
@@ -1886,6 +1893,11 @@
return false;
}
+// lookupNumber - In order to find a leader for a given value number at a
+// specific basic block, we first obtain the list of all Values for that number,
+// and then scan the list to find one whose block dominates the block in
+// question. This is fast because dominator tree queries consist of only
+// a few comparisons of DFS numbers.
Value *GVN::lookupNumber(BasicBlock *BB, uint32_t num) {
std::pair<Value*, void*> Vals = NumberTable[num];
if (!Vals.first) return 0;
More information about the llvm-commits
mailing list