[PATCH] D71582: llvm-diff: Perform structural comparison on GlobalVariables, if possible

Dominic Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 17 11:26:23 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rG79b4c897b8ea: llvm-diff: Perform structural comparison on GlobalVariables, if possible (authored by ddcc).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71582/new/

https://reviews.llvm.org/D71582

Files:
  llvm/tools/llvm-diff/DifferenceEngine.cpp


Index: llvm/tools/llvm-diff/DifferenceEngine.cpp
===================================================================
--- llvm/tools/llvm-diff/DifferenceEngine.cpp
+++ llvm/tools/llvm-diff/DifferenceEngine.cpp
@@ -732,5 +732,14 @@
 
 bool DifferenceEngine::equivalentAsOperands(GlobalValue *L, GlobalValue *R) {
   if (globalValueOracle) return (*globalValueOracle)(L, R);
+
+  if (isa<GlobalVariable>(L) && isa<GlobalVariable>(R)) {
+    GlobalVariable *GVL = cast<GlobalVariable>(L);
+    GlobalVariable *GVR = cast<GlobalVariable>(R);
+    if (GVL->hasLocalLinkage() && GVL->hasUniqueInitializer() &&
+        GVR->hasLocalLinkage() && GVR->hasUniqueInitializer())
+      return GVL->getInitializer() == GVR->getInitializer();
+  }
+
   return L->getName() == R->getName();
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71582.234348.patch
Type: text/x-patch
Size: 779 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191217/ab72314a/attachment.bin>


More information about the llvm-commits mailing list