1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

llvm-diff: Perform structural comparison on GlobalVariables, if possible

Summary: Names of GlobalVariables may not be preserved depending on compilation options, so prefer a structural diff

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D71582
This commit is contained in:
Dominic Chen 2019-12-16 19:01:26 -05:00
parent d10f996d89
commit 11fda9871d

View File

@ -732,5 +732,14 @@ void DifferenceEngine::diff(Module *L, Module *R) {
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();
}