[llvm] ce90dfc - [StructuralHash] Track global variables
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Mon May 15 17:05:10 PDT 2023
Author: Arthur Eubanks
Date: 2023-05-15T16:57:18-07:00
New Revision: ce90dfc74b9018dce0f4b2d5f5867297a0521e3c
URL: https://github.com/llvm/llvm-project/commit/ce90dfc74b9018dce0f4b2d5f5867297a0521e3c
DIFF: https://github.com/llvm/llvm-project/commit/ce90dfc74b9018dce0f4b2d5f5867297a0521e3c.diff
LOG: [StructuralHash] Track global variables
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D149209
Added:
Modified:
llvm/lib/IR/StructuralHash.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/StructuralHash.cpp b/llvm/lib/IR/StructuralHash.cpp
index 8fcd337c6a0d7..957e2124e9646 100644
--- 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 @@ class StructuralHashImpl {
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 @@ class StructuralHashImpl {
}
}
+ 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);
}
More information about the llvm-commits
mailing list