DEBUG_TYPE

In include/llvm/ADT/Statistic.h, the identifier “DEBUG_TYPE” is never defined. I’ve noticed it’s defined as different things in a few other header files, including llvm/Analysis/BlockFrequencyInfoImpl.h, llvm/Analysis/RegionInfoImpl.h, llvm/Support/UnicodeCharRanges.h, llvm/Transforms/InstCombine/InstCombineWorkList.h, and llvm/Transforms/Utils/SSAUpdaterImpl.h. Should I edit Statistic.h so that it includes one of those? If so, which one? If not, what should I do?

Thanks,
Peter Finn

No. DEBUG_TYPE is used for grouping debug output and statistics. The DEBUG_TYPE belongs in the source file. The fact it's in the other headers is suspicious and might be worth checking on.

Philip

Okay then, how should I define it?

Peter

So far, nothing you've said sounds particularly problematic. Can you take a step back and spell out the problem you're trying to solve?

p.s. Look at any of the transform/scalar passes (along with many other places) for examples of usage.

Philip

No. DEBUG_TYPE is used for grouping debug output and statistics. The DEBUG_TYPE belongs in the source file. The fact it's in the other headers is suspicious and might be worth checking on.

Might be. I think it sometimes makes sense.

Philip

In include/llvm/ADT/Statistic.h, the identifier “DEBUG_TYPE” is never defined. I’ve noticed it’s defined as different things in a few other header files, including llvm/Analysis/BlockFrequencyInfoImpl.h,

FWIW, this one really is a BFI implementation file:

No. DEBUG_TYPE is used for grouping debug output and statistics. The DEBUG_TYPE belongs in the source file. The fact it's in the other headers is suspicious and might be worth checking on.

Might be. I think it sometimes makes sense.

Philip

In include/llvm/ADT/Statistic.h, the identifier “DEBUG_TYPE” is never defined. I’ve noticed it’s defined as different things in a few other header files, including llvm/Analysis/BlockFrequencyInfoImpl.h,

FWIW, this one really is a BFI implementation file:
--
$ git grep -l llvm/Analysis/BlockFrequencyInfoImpl.h
lib/Analysis/BlockFrequencyInfo.cpp
lib/Analysis/BlockFrequencyInfoImpl.cpp
lib/CodeGen/MachineBlockFrequencyInfo.cpp
--
(Maybe it should get moved to lib/Analysis, and MBFI can access it
via a relative path like `../Analysis/`? I'm not clear on the
tradeoffs.)

It has template functions that want `DEBUG()` statements, and all
three want to use `block-freq`.

Haven't looked at the others you mentioned, but they could be
similar.

I believe there's also a DEBUG_WITH_TYPE which allows a specific invocation of DEBUG() to use the given type. Perhaps headers should be required to use that and headers shouldn't be allowed to define DEBUG_TYPE?

Pete