LLVM 20.0.0git
StructuralHash.cpp
Go to the documentation of this file.
1//===- StructuralHash.cpp - Function Hash Printing ------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the StructuralHashPrinterPass which is used to show
10// the structural hash of all functions in a module and the module itself.
11//
12//===----------------------------------------------------------------------===//
13
15#include "llvm/IR/Module.h"
17#include "llvm/Support/Format.h"
18
19using namespace llvm;
20
23 OS << "Module Hash: "
24 << format("%016" PRIx64, StructuralHash(M, EnableDetailedStructuralHash))
25 << "\n";
26 for (Function &F : M) {
27 if (F.isDeclaration())
28 continue;
29 OS << "Function " << F.getName() << " Hash: "
30 << format("%016" PRIx64, StructuralHash(F, EnableDetailedStructuralHash))
31 << "\n";
32 }
34}
#define F(x, y, z)
Definition: MD5.cpp:55
Module.h This file contains the declarations for the Module class.
ModuleAnalysisManager MAM
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:253
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:111
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: Analysis.h:117
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
IRHash StructuralHash(const Function &F, bool DetailedHash=false)
Returns a hash of the function F.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
Definition: Format.h:125