[TableGen] Use SmallMapVector to simplify some code that was trying to keep a vector...
authorCraig Topper <craig.topper@intel.com>
Wed, 21 Mar 2018 02:48:34 +0000 (02:48 +0000)
committerCraig Topper <craig.topper@intel.com>
Wed, 21 Mar 2018 02:48:34 +0000 (02:48 +0000)
commitf19eacfe0bc7a5746f8bb92f6ef27b9437bb716e
tree7dfc4dcc6ff34c81865afbdf1ce86dbaaf313002
parent98c1aefdffa8d0300a8723e17903adc17631601f
[TableGen] Use SmallMapVector to simplify some code that was trying to keep a vector unique

Summary:
This code previously had a SmallVector of std::pairs containing an unsigned and another SmallVector. The outer vector was using the unsigned effectively as a key to decide which SmallVector to add into. So each time something new needed to be added the out vector needed to be scanned. If it wasn't found a new entry needed to be added to be added. This sounds very much like a map, but the next loop iterates over the outer vector to get a deterministic order.

We can simplify this code greatly if use SmallMapVector instead. This uses more stack space since we now have a vector and a map, but the searching and creating new entries all happens behind the scenes. It should also make the search more efficient though usually there are only a few entries so that doesn't matter much.

We could probably get determinism by just using std::map which would iterate over the unsigned key, but that would generate different output from what we get with the current implementation.

Reviewers: RKSimon, dblaikie

Reviewed By: dblaikie

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D44711

llvm-svn: 328070
llvm/utils/TableGen/CodeGenSchedule.cpp