[PATCH] D149209: [StructuralHash] Track global variables
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 25 15:27:34 PDT 2023
aeubanks created this revision.
aeubanks added a reviewer: nikic.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D149209
Files:
llvm/lib/IR/StructuralHash.cpp
Index: llvm/lib/IR/StructuralHash.cpp
===================================================================
--- llvm/lib/IR/StructuralHash.cpp
+++ 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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149209.516958.patch
Type: text/x-patch
Size: 1110 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230425/79d44d84/attachment.bin>
More information about the llvm-commits
mailing list