Skip to content

Commit e3028dc

Browse files
authored
[SYCL][ESIMD] Decorate dump methods according to LLVM guideline. (#20269)
LLVM uses `if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)` for decoration of dumping methods. Dumping is used for debugging but not for testing. Therefore, its usage is removed.
1 parent 506c1a9 commit e3028dc

File tree

3 files changed

+64
-72
lines changed

3 files changed

+64
-72
lines changed

llvm/include/llvm/SYCLPostLink/ModuleSplitter.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "llvm/IR/Function.h"
1919
#include "llvm/IR/Module.h"
2020
#include "llvm/SYCLLowerIR/SYCLDeviceRequirements.h"
21+
#include "llvm/Support/Compiler.h"
2122
#include "llvm/Support/Error.h"
2223
#include "llvm/Support/PropertySetIO.h"
2324

@@ -238,8 +239,11 @@ class ModuleDesc {
238239

239240
#ifndef NDEBUG
240241
void verifyESIMDProperty() const;
241-
void dump() const;
242242
#endif // NDEBUG
243+
244+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
245+
LLVM_DUMP_METHOD void dump() const;
246+
#endif
243247
};
244248

245249
// Module split support interface.
@@ -303,11 +307,13 @@ getDeviceCodeSplitter(ModuleDesc &&MD, IRSplitMode Mode, bool IROutputOnly,
303307
bool EmitOnlyKernelsAsEntryPoints,
304308
bool AllowDeviceImageDependencies);
305309

306-
#ifndef NDEBUG
307-
void dumpEntryPoints(const EntryPointSet &C, const char *Msg = "", int Tab = 0);
308-
void dumpEntryPoints(const Module &M, bool OnlyKernelsAreEntryPoints = false,
309-
const char *Msg = "", int Tab = 0);
310-
#endif // NDEBUG
310+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
311+
LLVM_DUMP_METHOD void dumpEntryPoints(const EntryPointSet &C,
312+
const char *Msg = "", int Tab = 0);
313+
LLVM_DUMP_METHOD void dumpEntryPoints(const Module &M,
314+
bool OnlyKernelsAreEntryPoints = false,
315+
const char *Msg = "", int Tab = 0);
316+
#endif
311317

312318
struct SplitModule {
313319
std::string ModuleFilePath;

llvm/lib/SYCLPostLink/ESIMDPostSplitProcessing.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,6 @@
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-
4130
using namespace llvm;
4231
using namespace llvm::module_split;
4332

@@ -134,11 +123,9 @@ llvm::sycl::handleESIMD(ModuleDesc MDesc,
134123

135124
SplitOccurred |= Result.size() > 1;
136125

137-
for (ModuleDesc &MD : Result) {
138-
DUMP_ENTRY_POINTS(MD.entries(), MD.Name.c_str(), 4);
126+
for (ModuleDesc &MD : Result)
139127
if (Options.LowerESIMD && MD.isESIMD())
140128
Modified |= lowerESIMDConstructs(MD, Options);
141-
}
142129

143130
if (Options.SplitESIMD || Result.size() == 1)
144131
return std::move(Result);
@@ -164,7 +151,6 @@ llvm::sycl::handleESIMD(ModuleDesc MDesc,
164151
Linked.rebuildEntryPoints(Names);
165152
Result.clear();
166153
Result.emplace_back(std::move(Linked));
167-
DUMP_ENTRY_POINTS(Result.back().entries(), Result.back().Name.c_str(), 4);
168154
Modified = true;
169155

170156
return std::move(Result);

llvm/lib/SYCLPostLink/ModuleSplitter.cpp

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -561,55 +561,6 @@ Error ModuleSplitterBase::verifyNoCrossModuleDeviceGlobalUsage() {
561561
return Error::success();
562562
}
563563

564-
#ifndef NDEBUG
565-
566-
const char *toString(SyclEsimdSplitStatus S) {
567-
switch (S) {
568-
case SyclEsimdSplitStatus::ESIMD_ONLY:
569-
return "ESIMD_ONLY";
570-
case SyclEsimdSplitStatus::SYCL_ONLY:
571-
return "SYCL_ONLY";
572-
case SyclEsimdSplitStatus::SYCL_AND_ESIMD:
573-
return "SYCL_AND_ESIMD";
574-
}
575-
return "<UNKNOWN_STATUS>";
576-
}
577-
578-
void tab(int N) {
579-
for (int I = 0; I < N; ++I) {
580-
llvm::errs() << " ";
581-
}
582-
}
583-
584-
void dumpEntryPoints(const EntryPointSet &C, const char *msg, int Tab) {
585-
tab(Tab);
586-
llvm::errs() << "ENTRY POINTS"
587-
<< " " << msg << " {\n";
588-
for (const Function *F : C) {
589-
tab(Tab);
590-
llvm::errs() << " " << F->getName() << "\n";
591-
}
592-
tab(Tab);
593-
llvm::errs() << "}\n";
594-
}
595-
596-
void dumpEntryPoints(const Module &M, bool OnlyKernelsAreEntryPoints,
597-
const char *msg, int Tab) {
598-
tab(Tab);
599-
llvm::errs() << "ENTRY POINTS (Module)"
600-
<< " " << msg << " {\n";
601-
for (const auto &F : M) {
602-
if (isEntryPoint(F, OnlyKernelsAreEntryPoints)) {
603-
tab(Tab);
604-
llvm::errs() << " " << F.getName() << "\n";
605-
}
606-
}
607-
tab(Tab);
608-
llvm::errs() << "}\n";
609-
}
610-
611-
#endif // NDEBUG
612-
613564
void ModuleDesc::assignMergedProperties(const ModuleDesc &MD1,
614565
const ModuleDesc &MD2) {
615566
EntryPoints.Props = MD1.EntryPoints.Props.merge(MD2.EntryPoints.Props);
@@ -847,16 +798,65 @@ void ModuleDesc::verifyESIMDProperty() const {
847798
// }
848799
//}
849800
}
801+
#endif // NDEBUG
802+
803+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
804+
LLVM_DUMP_METHOD const char *toString(SyclEsimdSplitStatus S) {
805+
switch (S) {
806+
case SyclEsimdSplitStatus::ESIMD_ONLY:
807+
return "ESIMD_ONLY";
808+
case SyclEsimdSplitStatus::SYCL_ONLY:
809+
return "SYCL_ONLY";
810+
case SyclEsimdSplitStatus::SYCL_AND_ESIMD:
811+
return "SYCL_AND_ESIMD";
812+
}
813+
return "<UNKNOWN_STATUS>";
814+
}
850815

851-
void ModuleDesc::dump() const {
816+
LLVM_DUMP_METHOD void tab(int N) {
817+
for (int I = 0; I < N; ++I) {
818+
llvm::errs() << " ";
819+
}
820+
}
821+
822+
LLVM_DUMP_METHOD void dumpEntryPoints(const EntryPointSet &C, const char *msg,
823+
int Tab) {
824+
tab(Tab);
825+
llvm::errs() << "ENTRY POINTS"
826+
<< " " << msg << " {\n";
827+
for (const Function *F : C) {
828+
tab(Tab);
829+
llvm::errs() << " " << F->getName() << "\n";
830+
}
831+
tab(Tab);
832+
llvm::errs() << "}\n";
833+
}
834+
835+
LLVM_DUMP_METHOD void dumpEntryPoints(const Module &M,
836+
bool OnlyKernelsAreEntryPoints,
837+
const char *msg, int Tab) {
838+
tab(Tab);
839+
llvm::errs() << "ENTRY POINTS (Module)"
840+
<< " " << msg << " {\n";
841+
for (const auto &F : M) {
842+
if (isEntryPoint(F, OnlyKernelsAreEntryPoints)) {
843+
tab(Tab);
844+
llvm::errs() << " " << F.getName() << "\n";
845+
}
846+
}
847+
tab(Tab);
848+
llvm::errs() << "}\n";
849+
}
850+
851+
LLVM_DUMP_METHOD void ModuleDesc::dump() const {
852852
llvm::errs() << "split_module::ModuleDesc[" << Name << "] {\n";
853853
llvm::errs() << " ESIMD:" << toString(EntryPoints.Props.HasESIMD)
854854
<< ", SpecConstMet:" << (Props.SpecConstsMet ? "YES" : "NO")
855855
<< "\n";
856856
dumpEntryPoints(entries(), EntryPoints.GroupId.c_str(), 1);
857857
llvm::errs() << "}\n";
858858
}
859-
#endif // NDEBUG
859+
#endif
860860

861861
void ModuleDesc::saveSplitInformationAsMetadata() {
862862
// Add metadata to the module so we can identify what kind of SYCL/ESIMD split

0 commit comments

Comments
 (0)