@@ -5193,8 +5193,7 @@ bool CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::assignFunctions() {
51935193
51945194// Compute a SHA1 hash of the callsite and alloc version information of clone I
51955195// in the summary, to use in detection of duplicate clones.
5196- std::string ComputeHash (StringMap<Function *> &HashToFunc, FunctionSummary *FS,
5197- unsigned I) {
5196+ uint64_t ComputeHash (const FunctionSummary *FS, unsigned I) {
51985197 SHA1 Hasher;
51995198 // Update hash with any callsites that call non-default (non-zero) callee
52005199 // versions.
@@ -5207,7 +5206,7 @@ std::string ComputeHash(StringMap<Function *> &HashToFunc, FunctionSummary *FS,
52075206 " Callsite summary has fewer entries than other summaries in function" );
52085207 if (SN.Clones .size () <= I || !SN.Clones [I])
52095208 continue ;
5210- uint8_t Data[4 ];
5209+ uint8_t Data[sizeof (SN. Clones [I]) ];
52115210 support::endian::write32le (Data, SN.Clones [I]);
52125211 Hasher.update (Data);
52135212 }
@@ -5223,7 +5222,7 @@ std::string ComputeHash(StringMap<Function *> &HashToFunc, FunctionSummary *FS,
52235222 continue ;
52245223 Hasher.update (ArrayRef<uint8_t >(&AN.Versions [I], 1 ));
52255224 }
5226- return toHex (Hasher.result ());
5225+ return support::endian::read64le (Hasher.result (). data ());
52275226}
52285227
52295228static SmallVector<std::unique_ptr<ValueToValueMapTy>, 4 > createFunctionClones (
@@ -5274,16 +5273,15 @@ static SmallVector<std::unique_ptr<ValueToValueMapTy>, 4> createFunctionClones(
52745273 // (except for available_externally which are made declarations as they would
52755274 // be aliases in the prevailing module, and available_externally aliases are
52765275 // not well supported right now).
5277- StringMap< Function *> HashToFunc;
5276+ DenseMap< uint64_t , Function *> HashToFunc;
52785277
52795278 // Save the hash of the original function version.
5280- auto Hash = ComputeHash (HashToFunc, FS, 0 );
5281- HashToFunc[Hash] = &F;
5279+ HashToFunc[ComputeHash (FS, 0 )] = &F;
52825280
52835281 for (unsigned I = 1 ; I < NumClones; I++) {
52845282 VMaps.emplace_back (std::make_unique<ValueToValueMapTy>());
52855283 std::string Name = getMemProfFuncName (F.getName (), I);
5286- auto Hash = ComputeHash (HashToFunc, FS, I);
5284+ auto Hash = ComputeHash (FS, I);
52875285 // If this clone would duplicate a previously seen clone, don't generate the
52885286 // duplicate clone body, just make an alias to satisfy any (potentially
52895287 // cross-module) references.
@@ -5540,6 +5538,8 @@ bool MemProfContextDisambiguation::applyImport(Module &M) {
55405538 // below.
55415539 auto CalleeOrigName = CalledFunction->getName ();
55425540 for (unsigned J = 0 ; J < StackNode.Clones .size (); J++) {
5541+ // If the VMap is empty, this clone was a duplicate of another and was
5542+ // created as an alias or a declaration.
55435543 if (J > 0 && VMaps[J - 1 ]->empty ())
55445544 continue ;
55455545 // Do nothing if this version calls the original version of its
@@ -5718,6 +5718,8 @@ bool MemProfContextDisambiguation::applyImport(Module &M) {
57185718
57195719 // Update the allocation types per the summary info.
57205720 for (unsigned J = 0 ; J < AllocNode.Versions .size (); J++) {
5721+ // If the VMap is empty, this clone was a duplicate of another and
5722+ // was created as an alias or a declaration.
57215723 if (J > 0 && VMaps[J - 1 ]->empty ())
57225724 continue ;
57235725 // Ignore any that didn't get an assigned allocation type.
@@ -5943,6 +5945,8 @@ void MemProfContextDisambiguation::performICP(
59435945 // check.
59445946 CallBase *CBClone = CB;
59455947 for (unsigned J = 0 ; J < NumClones; J++) {
5948+ // If the VMap is empty, this clone was a duplicate of another and was
5949+ // created as an alias or a declaration.
59465950 if (J > 0 && VMaps[J - 1 ]->empty ())
59475951 continue ;
59485952 // Copy 0 is the original function.
@@ -5990,6 +5994,8 @@ void MemProfContextDisambiguation::performICP(
59905994 // TotalCount and the number promoted.
59915995 CallBase *CBClone = CB;
59925996 for (unsigned J = 0 ; J < NumClones; J++) {
5997+ // If the VMap is empty, this clone was a duplicate of another and was
5998+ // created as an alias or a declaration.
59935999 if (J > 0 && VMaps[J - 1 ]->empty ())
59946000 continue ;
59956001 // Copy 0 is the original function.
0 commit comments