[PATCH] D71582: llvm-diff: Perform structural comparison on GlobalVariables, if possible
Dominic Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 16 23:22:11 PST 2019
ddcc updated this revision to Diff 234217.
ddcc added a comment.
Check linkages
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.234217.patch
Type: text/x-patch
Size: 779 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191217/d7a9b16f/attachment.bin>
More information about the llvm-commits
mailing list