Skip to content

Commit 4a98f52

Browse files
authored
[StructuralHashPrinter] Always print 16-digit hash (#101655)
The hash may contain less than 14 significant digits, which caused the test to fail.
1 parent d40fa2c commit 4a98f52

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

llvm/lib/Analysis/StructuralHash.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@
1414
#include "llvm/Analysis/StructuralHash.h"
1515
#include "llvm/IR/Module.h"
1616
#include "llvm/IR/StructuralHash.h"
17-
#include "llvm/Support/CommandLine.h"
17+
#include "llvm/Support/Format.h"
1818

1919
using namespace llvm;
2020

2121
PreservedAnalyses StructuralHashPrinterPass::run(Module &M,
2222
ModuleAnalysisManager &MAM) {
2323
OS << "Module Hash: "
24-
<< Twine::utohexstr(StructuralHash(M, EnableDetailedStructuralHash))
24+
<< format("%016" PRIx64, StructuralHash(M, EnableDetailedStructuralHash))
2525
<< "\n";
2626
for (Function &F : M) {
2727
if (F.isDeclaration())
2828
continue;
2929
OS << "Function " << F.getName() << " Hash: "
30-
<< Twine::utohexstr(StructuralHash(F, EnableDetailedStructuralHash))
30+
<< format("%016" PRIx64, StructuralHash(F, EnableDetailedStructuralHash))
3131
<< "\n";
3232
}
3333
return PreservedAnalyses::all();

llvm/test/Analysis/StructuralHash/structural-hash-printer.ll

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ define i32 @f2(i32 %a) {
1414
ret i32 %b
1515
}
1616

17-
; CHECK: Module Hash: {{([a-z0-9]{14,})}}
18-
; CHECK-NEXT: Function f1 Hash: [[F1H:([a-z0-9]{14,})]]
17+
; CHECK: Module Hash: {{([a-f0-9]{16,})}}
18+
; CHECK-NEXT: Function f1 Hash: [[F1H:([a-f0-9]{16,})]]
1919
; CHECK-NEXT: Function f2 Hash: [[F1H]]
2020

21-
; DETAILED-HASH: Module Hash: {{([a-z0-9]{14,})}}
22-
; DETAILED-HASH-NEXT: Function f1 Hash: [[DF1H:([a-z0-9]{14,})]]
21+
; DETAILED-HASH: Module Hash: {{([a-f0-9]{16,})}}
22+
; DETAILED-HASH-NEXT: Function f1 Hash: [[DF1H:([a-f0-9]{16,})]]
2323
; DETAILED-HASH-NOT: [[DF1H]]
24-
; DETAILED-HASH-NEXT: Function f2 Hash: {{([a-z0-9]{14,})}}
25-
24+
; DETAILED-HASH-NEXT: Function f2 Hash: {{([a-f0-9]{16,})}}

0 commit comments

Comments
 (0)