LLVM 19.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"
18
19using namespace llvm;
20
23 OS << "Module Hash: "
24 << Twine::utohexstr(StructuralHash(M, EnableDetailedStructuralHash))
25 << "\n";
26 for (Function &F : M) {
27 if (F.isDeclaration())
28 continue;
29 OS << "Function " << F.getName() << " Hash: "
30 << Twine::utohexstr(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)
static Twine utohexstr(const uint64_t &Val)
Definition: Twine.h:416
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.