Skip to content

Commit f4a0b40

Browse files
authored
[SYCL][ESIMD] Don't always dump entry points if LLVM_ENABLE_DUMP=ON (#20150)
Starting from #18684 in debug/release with asserts builds entry points are always dumped in ESIMDPostSplitProcessing. This is meant to be a debugging tool, but now it is spamming build logs. #18684 is marked as NFC, so my assumption is that this was unintentional. Guard the dump with a variable (disabled by default) so that it can be enabled for debugging, the same way as it was in sycl-post-link.cpp prior to the code move. FYI: `LLVM_ENABLE_DUMP` is an option documented to > Enable dump functions even when assertions are disabled (from [llvm/CMakeLists.txt:698](https://github.com/llvm/llvm-project/blob/32b1f167fbee28debc7527b939a6764575c854a4/llvm/CMakeLists.txt#L698)) and its typical usage is to guard the definitions of dump functions, e.g.: ```cpp class Foo { // ... #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) void dump() const; #endif } ``` and not to guard **calls** to such functions.
1 parent 6b29cf1 commit f4a0b40

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

llvm/lib/SYCLPostLink/ESIMDPostSplitProcessing.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@
2727
#include <string>
2828
#include <vector>
2929

30+
#ifdef NDEBUG
31+
#define DUMP_ENTRY_POINTS(...)
32+
#else
33+
constexpr int DebugESIMDPostSplit = 0;
34+
35+
#define DUMP_ENTRY_POINTS(...) \
36+
if (DebugESIMDPostSplit > 0) { \
37+
llvm::module_split::dumpEntryPoints(__VA_ARGS__); \
38+
}
39+
#endif // NDEBUG
40+
3041
using namespace llvm;
3142
using namespace llvm::module_split;
3243

@@ -124,9 +135,7 @@ llvm::sycl::handleESIMD(ModuleDesc MDesc,
124135
SplitOccurred |= Result.size() > 1;
125136

126137
for (ModuleDesc &MD : Result) {
127-
#ifdef LLVM_ENABLE_DUMP
128-
dumpEntryPoints(MD.entries(), MD.Name.c_str(), 4);
129-
#endif // LLVM_ENABLE_DUMP
138+
DUMP_ENTRY_POINTS(MD.entries(), MD.Name.c_str(), 4);
130139
if (Options.LowerESIMD && MD.isESIMD())
131140
Modified |= lowerESIMDConstructs(MD, Options);
132141
}
@@ -155,9 +164,7 @@ llvm::sycl::handleESIMD(ModuleDesc MDesc,
155164
Linked.rebuildEntryPoints(Names);
156165
Result.clear();
157166
Result.emplace_back(std::move(Linked));
158-
#ifdef LLVM_ENABLE_DUMP
159-
dumpEntryPoints(Result.back().entries(), Result.back().Name.c_str(), 4);
160-
#endif // LLVM_ENABLE_DUMP
167+
DUMP_ENTRY_POINTS(Result.back().entries(), Result.back().Name.c_str(), 4);
161168
Modified = true;
162169

163170
return std::move(Result);

0 commit comments

Comments
 (0)