diff --git a/llvm/lib/IR/StructuralHash.cpp b/llvm/lib/IR/StructuralHash.cpp
--- a/llvm/lib/IR/StructuralHash.cpp
+++ b/llvm/lib/IR/StructuralHash.cpp
@@ -59,10 +59,9 @@
 
   void update(const GlobalVariable &GV) {
     // Declarations and used/compiler.used don't affect analyses.
-    // Same for llvm.embedded.object, which is always a metadata section.
-    if (GV.isDeclaration() ||
-        GV.getName() == "llvm.compiler.used" || GV.getName() == "llvm.used" ||
-        GV.getName() == "llvm.embedded.object")
+    // Since there are several `llvm.*` metadata, like `llvm.embedded.object`,
+    // we ignore anything with the `.llvm` prefix
+    if (GV.isDeclaration() || GV.getName().starts_with("llvm."))
       return;
     hash(23456); // Global header
     hash(GV.getValueType()->getTypeID());
diff --git a/llvm/unittests/IR/StructuralHashTest.cpp b/llvm/unittests/IR/StructuralHashTest.cpp
--- a/llvm/unittests/IR/StructuralHashTest.cpp
+++ b/llvm/unittests/IR/StructuralHashTest.cpp
@@ -12,6 +12,8 @@
 #include "llvm/Support/SourceMgr.h"
 #include "gtest/gtest.h"
 
+#include <memory>
+
 using namespace llvm;
 
 namespace {
@@ -121,4 +123,21 @@
   EXPECT_EQ(StructuralHash(*M1), StructuralHash(*M2));
 }
 
+TEST(StructuralHashTest, IgnoredMetadata) {
+  LLVMContext Ctx;
+  std::unique_ptr<Module> M1 = parseIR(Ctx, "@a = global i32 1\n");
+  // clang-format off
+  std::unique_ptr<Module> M2 = parseIR(
+      Ctx, R"(
+        @a = global i32 1
+        @llvm.embedded.object = private constant [4 x i8] c"BC\C0\00", section ".llvm.lto", align 1, !exclude !0
+        @llvm.compiler.used = appending global [1 x ptr] [ptr @llvm.embedded.object], section "llvm.metadata"
+
+        !llvm.embedded.objects = !{!1}
+
+        !0 = !{}
+        !1 = !{ptr @llvm.embedded.object, !".llvm.lto"}
+        )");
+  EXPECT_EQ(StructuralHash(*M1), StructuralHash(*M2));
+}
 } // end anonymous namespace