Skip to content

[StructuralHashPrinter] Always print 16-digit hash #101655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 2, 2024

Conversation

s-barannikov
Copy link
Contributor

The hash may contain less than 14 significant digits, which caused the test to fail.

The hash may contain less than 14 significant digits,
which caused the test to fail.
@llvmbot llvmbot added the llvm:analysis Includes value tracking, cost tables and constant folding label Aug 2, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 2, 2024

@llvm/pr-subscribers-llvm-analysis

Author: Sergei Barannikov (s-barannikov)

Changes

The hash may contain less than 14 significant digits, which caused the test to fail.


Full diff: https://github.com/llvm/llvm-project/pull/101655.diff

2 Files Affected:

  • (modified) llvm/lib/Analysis/StructuralHash.cpp (+3-3)
  • (modified) llvm/test/Analysis/StructuralHash/structural-hash-printer.ll (+5-6)
diff --git a/llvm/lib/Analysis/StructuralHash.cpp b/llvm/lib/Analysis/StructuralHash.cpp
index 24985f0a9d314..3a2341fe59ad9 100644
--- a/llvm/lib/Analysis/StructuralHash.cpp
+++ b/llvm/lib/Analysis/StructuralHash.cpp
@@ -14,20 +14,20 @@
 #include "llvm/Analysis/StructuralHash.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/StructuralHash.h"
-#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Format.h"
 
 using namespace llvm;
 
 PreservedAnalyses StructuralHashPrinterPass::run(Module &M,
                                                  ModuleAnalysisManager &MAM) {
   OS << "Module Hash: "
-     << Twine::utohexstr(StructuralHash(M, EnableDetailedStructuralHash))
+     << format("%016" PRIx64, StructuralHash(M, EnableDetailedStructuralHash))
      << "\n";
   for (Function &F : M) {
     if (F.isDeclaration())
       continue;
     OS << "Function " << F.getName() << " Hash: "
-       << Twine::utohexstr(StructuralHash(F, EnableDetailedStructuralHash))
+       << format("%016" PRIx64, StructuralHash(F, EnableDetailedStructuralHash))
        << "\n";
   }
   return PreservedAnalyses::all();
diff --git a/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll b/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll
index 569abae5567f7..5936199bf32f4 100644
--- a/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll
+++ b/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll
@@ -14,12 +14,11 @@ define i32 @f2(i32 %a) {
 	ret i32 %b
 }
 
-; CHECK: Module Hash: {{([a-z0-9]{14,})}}
-; CHECK-NEXT: Function f1 Hash: [[F1H:([a-z0-9]{14,})]]
+; CHECK: Module Hash: {{([a-f0-9]{16,})}}
+; CHECK-NEXT: Function f1 Hash: [[F1H:([a-f0-9]{16,})]]
 ; CHECK-NEXT: Function f2 Hash: [[F1H]]
 
-; DETAILED-HASH: Module Hash: {{([a-z0-9]{14,})}}
-; DETAILED-HASH-NEXT: Function f1 Hash: [[DF1H:([a-z0-9]{14,})]]
+; DETAILED-HASH: Module Hash: {{([a-f0-9]{16,})}}
+; DETAILED-HASH-NEXT: Function f1 Hash: [[DF1H:([a-f0-9]{16,})]]
 ; DETAILED-HASH-NOT: [[DF1H]]
-; DETAILED-HASH-NEXT: Function f2 Hash: {{([a-z0-9]{14,})}}
-
+; DETAILED-HASH-NEXT: Function f2 Hash: {{([a-f0-9]{16,})}}

Copy link
Contributor

@sparker-arm sparker-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cheers!

@s-barannikov s-barannikov merged commit 4a98f52 into llvm:main Aug 2, 2024
9 checks passed
@s-barannikov s-barannikov deleted the flacky-structural-hash branch August 2, 2024 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm:analysis Includes value tracking, cost tables and constant folding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants