diff --git a/llvm/include/llvm/Transforms/IPO/SampleContextTracker.h b/llvm/include/llvm/Transforms/IPO/SampleContextTracker.h --- a/llvm/include/llvm/Transforms/IPO/SampleContextTracker.h +++ b/llvm/include/llvm/Transforms/IPO/SampleContextTracker.h @@ -53,7 +53,7 @@ uint32_t ContextFramesToRemove, bool DeleteNode = true); void removeChildContext(const LineLocation &CallSite, StringRef ChildName); - std::map &getAllChildContext(); + std::map &getAllChildContext(); StringRef getFuncName() const; FunctionSamples *getFunctionSamples() const; void setFunctionSamples(FunctionSamples *FSamples); @@ -66,10 +66,10 @@ void dumpTree(); private: - static uint32_t nodeHash(StringRef ChildName, const LineLocation &Callsite); + static uint64_t nodeHash(StringRef ChildName, const LineLocation &Callsite); // Map line+discriminator location to child context - std::map AllChildContext; + std::map AllChildContext; // Link to parent context node ContextTrieNode *ParentContext; diff --git a/llvm/lib/Transforms/IPO/SampleContextTracker.cpp b/llvm/lib/Transforms/IPO/SampleContextTracker.cpp --- a/llvm/lib/Transforms/IPO/SampleContextTracker.cpp +++ b/llvm/lib/Transforms/IPO/SampleContextTracker.cpp @@ -32,7 +32,7 @@ if (CalleeName.empty()) return getHottestChildContext(CallSite); - uint32_t Hash = nodeHash(CalleeName, CallSite); + auto Hash = nodeHash(CalleeName, CallSite); auto It = AllChildContext.find(Hash); if (It != AllChildContext.end()) return &It->second; @@ -65,7 +65,7 @@ ContextTrieNode &ContextTrieNode::moveToChildContext( const LineLocation &CallSite, ContextTrieNode &&NodeToMove, uint32_t ContextFramesToRemove, bool DeleteNode) { - uint32_t Hash = nodeHash(NodeToMove.getFuncName(), CallSite); + auto Hash = nodeHash(NodeToMove.getFuncName(), CallSite); assert(!AllChildContext.count(Hash) && "Node to remove must exist"); LineLocation OldCallSite = NodeToMove.CallSiteLoc; ContextTrieNode &OldParentContext = *NodeToMove.getParentContext(); @@ -108,12 +108,12 @@ void ContextTrieNode::removeChildContext(const LineLocation &CallSite, StringRef CalleeName) { - uint32_t Hash = nodeHash(CalleeName, CallSite); + auto Hash = nodeHash(CalleeName, CallSite); // Note this essentially calls dtor and destroys that child context AllChildContext.erase(Hash); } -std::map &ContextTrieNode::getAllChildContext() { +std::map &ContextTrieNode::getAllChildContext() { return AllChildContext; } @@ -174,20 +174,20 @@ } } -uint32_t ContextTrieNode::nodeHash(StringRef ChildName, +uint64_t ContextTrieNode::nodeHash(StringRef ChildName, const LineLocation &Callsite) { // We still use child's name for child hash, this is // because for children of root node, we don't have // different line/discriminator, and we'll rely on name // to differentiate children. - uint32_t NameHash = std::hash{}(ChildName.str()); - uint32_t LocId = (Callsite.LineOffset << 16) | Callsite.Discriminator; + uint64_t NameHash = std::hash{}(ChildName.str()); + uint64_t LocId = (Callsite.LineOffset << 16) | Callsite.Discriminator; return NameHash + (LocId << 5) + LocId; } ContextTrieNode *ContextTrieNode::getOrCreateChildContext( const LineLocation &CallSite, StringRef CalleeName, bool AllowCreate) { - uint32_t Hash = nodeHash(CalleeName, CallSite); + auto Hash = nodeHash(CalleeName, CallSite); auto It = AllChildContext.find(Hash); if (It != AllChildContext.end()) { assert(It->second.getFuncName() == CalleeName &&