Index: llvm/lib/IR/StructuralHash.cpp =================================================================== --- llvm/lib/IR/StructuralHash.cpp +++ llvm/lib/IR/StructuralHash.cpp @@ -58,8 +58,9 @@ } void update(const GlobalVariable &GV) { - // used/compiler.used don't affect analyses. - if (GV.getName() == "llvm.compiler.used" || GV.getName() == "llvm.used") + // Declarations and used/compiler.used don't affect analyses. + if (GV.isDeclaration() || GV.getName() == "llvm.compiler.used" || + GV.getName() == "llvm.used") return; hash(23456); // Global header hash(GV.getValueType()->getTypeID()); 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 + +@.str = external constant [15 x i16] +