Skip to content

[NFC][Lanai][Hexagon] Define DEBUG_TYPE after including Debug.h. #125440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 12, 2025

Conversation

nvjle
Copy link
Contributor

@nvjle nvjle commented Feb 2, 2025

This patch fixes some warnings/errors that occur with certain compilers-- due to existing code not following the idiom mentioned in Debug.h:

// LLVM_DEBUG() requires the DEBUG_TYPE macro to be defined. Set it to "foo"
// specify that your debug code belongs to class "foo". **Be careful that you only
// do this after including Debug.h and not around any #include of headers.**

This fixes some warnings/errors that occur with certain compilers.
Copy link

github-actions bot commented Feb 2, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@nvjle nvjle marked this pull request as ready for review February 3, 2025 00:13
@llvmbot
Copy link
Member

llvmbot commented Feb 3, 2025

@llvm/pr-subscribers-backend-hexagon

Author: Jason Eckhardt (nvjle)

Changes

This fixes some warnings/errors that occur with certain compilers.


Full diff: https://github.com/llvm/llvm-project/pull/125440.diff

3 Files Affected:

  • (modified) llvm/lib/Target/Hexagon/HexagonLoopAlign.cpp (+2-2)
  • (modified) llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp (+3)
  • (modified) llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.h (-2)
diff --git a/llvm/lib/Target/Hexagon/HexagonLoopAlign.cpp b/llvm/lib/Target/Hexagon/HexagonLoopAlign.cpp
index 7d4c9eacbabfbf5..4a6e8a165457e1c 100644
--- a/llvm/lib/Target/Hexagon/HexagonLoopAlign.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonLoopAlign.cpp
@@ -9,13 +9,13 @@
 // number of instructions, set the prefLoopAlignment to 32 bytes (5).
 //===----------------------------------------------------------------------===//
 
-#define DEBUG_TYPE "hexagon-loop-align"
-
 #include "HexagonTargetMachine.h"
 #include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
 #include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
 #include "llvm/Support/Debug.h"
 
+#define DEBUG_TYPE "hexagon-loop-align"
+
 using namespace llvm;
 
 static cl::opt<bool>
diff --git a/llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp b/llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp
index e9fecef4ac5b915..2720e1d9a6a6440 100644
--- a/llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp
+++ b/llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp
@@ -20,8 +20,11 @@
 #include "llvm/MC/MCInst.h"
 #include "llvm/MC/MCSubtargetInfo.h"
 #include "llvm/MC/TargetRegistry.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/MathExtras.h"
 
+#define DEBUG_TYPE "lanai-disassembler"
+
 using namespace llvm;
 
 typedef MCDisassembler::DecodeStatus DecodeStatus;
diff --git a/llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.h b/llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.h
index 8aa28417896dc1b..04aeb3f27a3da98 100644
--- a/llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.h
+++ b/llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.h
@@ -15,8 +15,6 @@
 
 #include "llvm/MC/MCDisassembler/MCDisassembler.h"
 
-#define DEBUG_TYPE "lanai-disassembler"
-
 namespace llvm {
 
 class LanaiDisassembler : public MCDisassembler {

@kazutakahirata
Copy link
Contributor

This fixes some warnings/errors that occur with certain compilers.

Could you elaborate on what kinds of warnings and errors your PR fixes?

@nvjle
Copy link
Contributor Author

nvjle commented Feb 4, 2025

This fixes some warnings/errors that occur with certain compilers.

Could you elaborate on what kinds of warnings and errors your PR fixes?

Yes, with gcc13 on linux:

llvm/include/llvm/Support/Debug.h:106:41: error: ‘DEBUG_TYPE’ was not declared in this scope; did you mean ‘DEBUG_WITH_TYPE’?
  106 | #define LLVM_DEBUG(...) DEBUG_WITH_TYPE(DEBUG_TYPE, __VA_ARGS__)
      |                                         ^~~~~~~~~~
llvm/include/llvm/Support/Debug.h:66:57: note: in definition of macro ‘DEBUG_WITH_TYPE’
   66 |     if (::llvm::DebugFlag && ::llvm::isCurrentDebugType(TYPE)) {               \
      |                                                         ^~~~
llvm/lib/Target/Hexagon/HexagonLoopAlign.cpp:115:3: note: in expansion of macro ‘LLVM_DEBUG’
  115 |   LLVM_DEBUG({
      |   ^~~~~~~~~~

The change is LLVM-idiomatic (excerpt from Debug.h):

// LLVM_DEBUG() requires the DEBUG_TYPE macro to be defined. Set it to "foo"
// specify that your debug code belongs to class "foo". Be careful that you only
// do this after including Debug.h and not around any #include of headers.

@nvjle
Copy link
Contributor Author

nvjle commented Feb 7, 2025

Any other comment? This is NFC, but I still prefer to get the rubber-stamp before merging...

@nvjle nvjle merged commit 96ce8ca into llvm:main Feb 12, 2025
8 checks passed
flovent pushed a commit to flovent/llvm-project that referenced this pull request Feb 13, 2025
…m#125440)

This patch fixes some warnings/errors that occur with certain
compilers-- due to existing code not following the idiom mentioned in
`Debug.h`:

```
// LLVM_DEBUG() requires the DEBUG_TYPE macro to be defined. Set it to "foo"
// specify that your debug code belongs to class "foo". **Be careful that you only
// do this after including Debug.h and not around any #include of headers.**
```
joaosaffran pushed a commit to joaosaffran/llvm-project that referenced this pull request Feb 14, 2025
…m#125440)

This patch fixes some warnings/errors that occur with certain
compilers-- due to existing code not following the idiom mentioned in
`Debug.h`:

```
// LLVM_DEBUG() requires the DEBUG_TYPE macro to be defined. Set it to "foo"
// specify that your debug code belongs to class "foo". **Be careful that you only
// do this after including Debug.h and not around any #include of headers.**
```
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Feb 24, 2025
…m#125440)

This patch fixes some warnings/errors that occur with certain
compilers-- due to existing code not following the idiom mentioned in
`Debug.h`:

```
// LLVM_DEBUG() requires the DEBUG_TYPE macro to be defined. Set it to "foo"
// specify that your debug code belongs to class "foo". **Be careful that you only
// do this after including Debug.h and not around any #include of headers.**
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants