diff --git a/llvm/lib/IR/StructuralHash.cpp b/llvm/lib/IR/StructuralHash.cpp --- a/llvm/lib/IR/StructuralHash.cpp +++ b/llvm/lib/IR/StructuralHash.cpp @@ -8,6 +8,7 @@ #include "llvm/IR/StructuralHash.h" #include "llvm/IR/Function.h" +#include "llvm/IR/GlobalVariable.h" #include "llvm/IR/Module.h" using namespace llvm; @@ -27,9 +28,12 @@ StructuralHashImpl() : Hash(4) {} void update(const Function &F) { - if (F.empty()) + // Declarations don't affect analyses. + if (F.isDeclaration()) return; + hash(12345); // Function header + hash(F.isVarArg()); hash(F.arg_size()); @@ -53,7 +57,17 @@ } } + void update(const GlobalVariable &GV) { + // used/compiler.used don't affect analyses. + if (GV.getName() == "llvm.compiler.used" || GV.getName() == "llvm.used") + return; + hash(23456); // Global header + hash(GV.getValueType()->getTypeID()); + } + void update(const Module &M) { + for (const GlobalVariable &GV : M.globals()) + update(GV); for (const Function &F : M) update(F); }