forked from OSchip/llvm-project
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:
parent
a4e1819c16
commit
79b4c897b8
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue