This is an archive of the discontinued LLVM Phabricator instance.

Guard print() functions only used by dump() functions.
ClosedPublic

Authored by fhahn on Jul 27 2017, 10:03 AM.

Details

Summary

Since r293359, most dump() function are only defined when
!defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) holds. print() functions
only used by dump() functions are now unused in release builds,
generating lots of warnings. This patch only defines some print()
functions if they are used.

Diff Detail

Event Timeline

fhahn created this revision.Jul 27 2017, 10:03 AM

This patch also adds guards for a few functions not used by dump(), but only inside DEBUG(). I could split them off if that's preferred.

MatzeB edited edge metadata.Jul 27 2017, 10:17 AM

So I guess those print() functions are not publicly accessible (I guess we wouldn't warn about them otherwise). If the print functions aren't used otherwise, then why not merge them into the dump() functions?

MatzeB accepted this revision.Jul 27 2017, 1:22 PM

So I guess those print() functions are not publicly accessible (I guess we wouldn't warn about them otherwise). If the print functions aren't used otherwise, then why not merge them into the dump() functions?

Ah that makes sense. Go ahead then for those cases.

This revision is now accepted and ready to land.Jul 27 2017, 1:22 PM
fhahn added a comment.Jul 27 2017, 1:29 PM

I think it shouldn't be to hard to fold the print() functions into the dump() functions in most cases. I could update the patch. The only benefit of having those print functions would be debugging, in the rare case someone wants to print to a different stream then stderr.

fhahn closed this revision.Jul 31 2017, 3:08 AM
fhahn added a comment.Jul 31 2017, 3:09 AM

Thanks for having a look. Committed as is because some print functions are used in implementations of
raw_ostream &operator<<(raw_ostream &OS, const X &X), which in turn are used in DEBUG()

hintonda added inline comments.
lib/CodeGen/LiveDebugVariables.cpp
354

Since this is only called when NDEBUG is not defined, #ifndef NDEBUG should be moved here to fix buildbot failures.

fhahn added inline comments.Jul 31 2017, 8:55 AM
lib/CodeGen/LiveDebugVariables.cpp
354

I'll fix that, thanks