1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[TableGen] Fix D90844 introduced non-determinism due to iteration over a std::map over allocated object pointers

993eaf2d69d8beb97e4695cbd919b927ed1cfe86 (D90844) is still wrong.
The allocated const Record* pointers do not have an order guarantee
so switching from DenseMap to std::map does not help.

ProcModelMapTy = std::map<const Record*, unsigned>

Sort the values instead.
This commit is contained in:
Fangrui Song 2020-12-18 12:08:16 -08:00
parent 8ca3523a4f
commit b37b65492b
2 changed files with 4 additions and 1 deletions

View File

@ -1718,6 +1718,9 @@ std::vector<unsigned> CodeGenSchedModels::getAllProcIndices() const {
for (const auto &PM : ProcModelMap)
if (PM.second != 0)
ProcIdVec.push_back(PM.second);
// The order of the keys (Record pointers) of ProcModelMap are not stable.
// Sort to stabalize the values.
llvm::sort(ProcIdVec);
return ProcIdVec;
}

View File

@ -410,7 +410,7 @@ public:
ArrayRef<OpcodeGroup> getGroups() const { return Groups; }
};
using ProcModelMapTy = std::map<const Record*, unsigned>;
using ProcModelMapTy = DenseMap<const Record *, unsigned>;
/// Top level container for machine model data.
class CodeGenSchedModels {