1 //===- llvm/IR/StructuralHash.h - IR Hashing --------------------*- C++ -*-===// 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 provides hashing of the LLVM IR structure to be used to check 10 // Passes modification status. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_IR_STRUCTURALHASH_H 15 #define LLVM_IR_STRUCTURALHASH_H 16 17 #include <cstdint> 18 19 namespace llvm { 20 21 class Function; 22 class Module; 23 24 using IRHash = uint64_t; 25 26 /// Returns a hash of the function \p F. 27 /// \param F The function to hash. 28 /// \param DetailedHash Whether or not to encode additional information in the 29 /// hash. The additional information added into the hash when this flag is set 30 /// to true includes instruction and operand type information. 31 IRHash StructuralHash(const Function &F, bool DetailedHash = false); 32 33 /// Returns a hash of the module \p M by hashing all functions and global 34 /// variables contained within. \param M The module to hash. \param DetailedHash 35 /// Whether or not to encode additional information in the function hashes that 36 /// composed the module hash. 37 IRHash StructuralHash(const Module &M, bool DetailedHash = false); 38 39 } // end namespace llvm 40 41 #endif 42