This is an archive of the discontinued LLVM Phabricator instance.

[Verifier] Avoid visiting DIGlobalVariables twice
ClosedPublic

Authored by davide on Aug 16 2017, 9:11 AM.

Details

Summary

We currently visit them twice.
Once, through visitMDNode() -> (the code generated by) ../include/llvm/IR/Metadata.def:109 -> visitDIGlobalVariable()
Then, through visitMDNode() -> visitDIGlobalVariableExpression() -> visitDIGlobalVariable()

This results in verification failures printed twice, e.g.:

$ ./opt -verify ../../test/DebugInfo/pr34186.ll
missing global variable type
!4 = distinct !DIGlobalVariable(name: "pat", scope: !0, file: !1, line: 27, isLocal: true, isDefinition: true)
missing global variable type
!4 = distinct !DIGlobalVariable(name: "pat", scope: !0, file: !1, line: 27, isLocal: true, isDefinition: true)
./opt: ../../test/DebugInfo/pr34186.ll: error: input module is broken!

The patch removes one call so we ensure each GV is visited exactly once.

Diff Detail

Repository
rL LLVM

Event Timeline

davide created this revision.Aug 16 2017, 9:11 AM
aprantl edited edge metadata.Aug 16 2017, 9:30 AM

Does this still catch the case where that variable is a nullptr? If yes, this LGTM.

This revision was automatically updated to reflect the committed changes.

Does this still catch the case where that variable is a nullptr? If yes, this LGTM.

Yes, it does from what I can see.