mirror of
https://github.com/intel/llvm.git
synced 2026-01-23 07:58:23 +08:00
[StructuralHash] Track global variables
Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D149209
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user