Moving this discussion here from the review thread.
RIght now, we have a few passes that prefix DEBUG message with various things, so folks using -debug can tell where the debug message came from.
But this is not consistent, and in fact, most passes don’t do it.
Worse, the prefixes used do not often match the DEBUG_TYPE of the pass.
It would be nice to fix this, and just have the DEBUG macros output the debug type in front of messages if that’s what folks want.
Of course, it turns out you can’t just make the DEBUG macro do something here, because people use it for more than just outputting messages.
My thought was to just bite the bullet and make a DEBUG_MSG macro that outputs the DEBUG_TYPE, and replace the appropriate existing uses of DEBUG(dbgs() <<) with it.
Something like
#define DEBUG_MSG_WITH_TYPE(t, x) DEBUG_WITH_TYPE(t, dbgs() << t <<“:” << x;)
#define DEBUG_MSG(x) DEBUG_MSG_WITH_TYPE(DEBUG_TYPE, x)
Suggestions, however, welcome!
To ask a basic question first: Why do we need prefixes at all? Are the messages that likely to be confused? As far as I understand this case it was only mentioned because of inconsistent prefix/no-prefix use, there was no indication that we should actually have them. So another possible solution would be to remove prefixes and avoiding the additional visual noise. Why add noise to every message just to improve upon the rare case of a messages origin being ambiguous?
- Matthias
From: "Matthias Braun via llvm-dev" <llvm-dev@lists.llvm.org>
To: "Daniel Berlin" <dberlin@dberlin.org>
Cc: "llvm-dev" <llvm-dev@lists.llvm.org>
Sent: Monday, November 2, 2015 1:16:18 PM
Subject: Re: [llvm-dev] Prefixing DEBUG messages with DEBUG_TYPE (was re: [PATCH] D13259: LLE 6/6: Add
LoopLoadElimination pass)
To ask a basic question first: Why do we need prefixes at all? Are
the messages that likely to be confused? As far as I understand this
case it was only mentioned because of inconsistent prefix/no-prefix
use, there was no indication that we should actually have them. So
another possible solution would be to remove prefixes and avoiding
the additional visual noise. Why add noise to every message just to
improve upon the rare case of a messages origin being ambiguous?
I generally find the prefixes convenient when searching the debug output for debug messages from a particular pass.
-Hal
Especially when you enable debug for all passes as well as print-after-all.
--renato
From: "Renato Golin" <renato.golin@linaro.org>
To: "Hal Finkel" <hfinkel@anl.gov>
Cc: "Matthias Braun" <mbraun@apple.com>, "llvm-dev" <llvm-dev@lists.llvm.org>
Sent: Monday, November 2, 2015 1:24:16 PM
Subject: Re: [llvm-dev] Prefixing DEBUG messages with DEBUG_TYPE (was re: [PATCH] D13259: LLE 6/6: Add
LoopLoadElimination pass)
> I generally find the prefixes convenient when searching the debug
> output for debug messages from a particular pass.
Especially when you enable debug for all passes as well as
print-after-all.
I'll add that this is particularly important when, for example, debug messages from different passes appear intermingled. This is common for lazy analysis passes (such as SCEV).
-Hal
On the other hand, I have only used -debug (output from all passes) once. I normally only use -debug-only, or #define DEBUG(x) to (x).
-Krzysztof
Well no strong opposition here, if the prefixes help you go ahead and introduce them. I just wanted to make sure we have considered the no-prefix option.
- Matthias