This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by ddcc on Dec 16 2019, 5:03 PM.

Details

Summary

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

Diff Detail

Event Timeline

ddcc created this revision.Dec 16 2019, 5:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 16 2019, 5:03 PM

Maybe this should depend on linkage?

ddcc added a comment.EditedDec 16 2019, 9:54 PM

Which linkage types specifically? hasUniqueInitializer() checks !isExternallyInitialized() and isStrongDefinitionForLinker(), which expands to !isDeclarationForLinker() (!hasAvailableExternallyLinkage() && !isDeclaration()) and !isWeakForLinker()), which I believe limits the variable to private and internal linkages.

No, that's not true; something with External linkage would not trip any of those conditions normally. ("Externally initialized" in particular is basically unrelated to linkage.) I think you want a condition something like L->getName() == R->getName() || (L->hasLocalLinkage() && R->hasLocalLinkage()).

ddcc updated this revision to Diff 234217.Dec 16 2019, 11:14 PM

Check linkages

This revision is now accepted and ready to land.Dec 17 2019, 11:09 AM
This revision was automatically updated to reflect the committed changes.