[StructuralHash] Track global variables

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D149209
This commit is contained in:
Arthur Eubanks
2023-05-15 16:57:10 -07:00
parent 45af0aa1fd
commit ce90dfc74b

View File

@@ -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 @@ public:
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 @@ public:
}
}
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);
}