[PATCH] D153855: [StructuralHash] Ignore global variable declarations
Mikael Holmén via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 28 22:53:33 PDT 2023
This revision was automatically updated to reflect the committed changes.
uabelho marked an inline comment as done.
Closed by commit rGd2640f596c47: [StructuralHash] Ignore global variable declarations (authored by uabelho).
Changed prior to commit:
https://reviews.llvm.org/D153855?vs=535236&id=535631#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153855/new/
https://reviews.llvm.org/D153855
Files:
llvm/lib/IR/StructuralHash.cpp
llvm/test/Transforms/StripDeadPrototypes/remove-global-variable-declaration.ll
Index: llvm/test/Transforms/StripDeadPrototypes/remove-global-variable-declaration.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/StripDeadPrototypes/remove-global-variable-declaration.ll
@@ -0,0 +1,9 @@
+; RUN: opt -passes=strip-dead-prototypes -S -verify-analysis-invalidation < %s | FileCheck %s
+
+; The declaration of the unused global variable @.str should be removed without
+; getting any error from -verify-analysis-invalidation.
+
+; CHECK-NOT: @.str
+
+ at .str = external constant [15 x i16]
+
Index: llvm/lib/IR/StructuralHash.cpp
===================================================================
--- llvm/lib/IR/StructuralHash.cpp
+++ llvm/lib/IR/StructuralHash.cpp
@@ -58,9 +58,10 @@
}
void update(const GlobalVariable &GV) {
- // used/compiler.used don't affect analyses.
+ // Declarations and used/compiler.used don't affect analyses.
// Same for llvm.embedded.object, which is always a metadata section.
- if (GV.getName() == "llvm.compiler.used" || GV.getName() == "llvm.used" ||
+ if (GV.isDeclaration() ||
+ GV.getName() == "llvm.compiler.used" || GV.getName() == "llvm.used" ||
GV.getName() == "llvm.embedded.object")
return;
hash(23456); // Global header
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153855.535631.patch
Type: text/x-patch
Size: 1293 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230629/25c6fcb8/attachment.bin>
More information about the llvm-commits
mailing list