diff options
author | Davide Italiano <davide@freebsd.org> | 2017-01-11 23:41:24 +0000 |
---|---|---|
committer | Davide Italiano <davide@freebsd.org> | 2017-01-11 23:41:24 +0000 |
commit | eac05f6b88017ea97119e0808f611c6bb3ae7063 (patch) | |
tree | 456159938508c2b0e3f326e8deb420fc7fcd5a7f /llvm/lib/Transforms | |
parent | 629cb7d8cc333c26f3b3b6b373c98221fcf54b28 (diff) | |
download | bcm5719-llvm-eac05f6b88017ea97119e0808f611c6bb3ae7063.tar.gz bcm5719-llvm-eac05f6b88017ea97119e0808f611c6bb3ae7063.zip |
[NewGVN] Fixup store count for the `initial` congruency class.
It was always zero. When we move a store from `initial` to its
own congruency class, we end up with a negative store count, which
is obviously wrong.
Also, while here, change StoreCount to be signed so that the assertions
actually fire.
Ack'ed by Daniel Berlin.
llvm-svn: 291725
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/NewGVN.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp index 06c3304afc8..e1b6741f31b 100644 --- a/llvm/lib/Transforms/Scalar/NewGVN.cpp +++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp @@ -137,7 +137,7 @@ struct CongruenceClass { // Number of stores in this congruence class. // This is used so we can detect store equivalence changes properly. - unsigned StoreCount = 0; + int StoreCount = 0; explicit CongruenceClass(unsigned ID) : ID(ID) {} CongruenceClass(unsigned ID, Value *Leader, const Expression *E) @@ -1066,7 +1066,7 @@ void NewGVN::moveValueToNewCongruenceClass(Value *V, CongruenceClass *OldClass, --OldClass->StoreCount; assert(OldClass->StoreCount >= 0); ++NewClass->StoreCount; - assert(NewClass->StoreCount >= 0); + assert(NewClass->StoreCount > 0); } ValueToClass[V] = NewClass; @@ -1337,9 +1337,12 @@ void NewGVN::initializeCongruenceClasses(Function &F) { // MemoryDef's for stores and all MemoryPhis to be equal. Right now, no // other expression can generate a memory equivalence. If we start // handling memcpy/etc, we can expand this. - if (isa<StoreInst>(&I)) + if (isa<StoreInst>(&I)) { MemoryAccessEquiv.insert( {MSSA->getMemoryAccess(&I), MSSA->getLiveOnEntryDef()}); + ++InitialClass->StoreCount; + assert(InitialClass->StoreCount > 0); + } } } InitialClass->Members.swap(InitialValues); |