Skip to content

Commit d1f4a9d

Browse files
authored
[SYCL] Change _NDEBUG -> NDEBUG (the correct macro) in sycl-post-link. (#6262)
Also fix #ifndef _NDEBUG/#endif pairing bug. Signed-off-by: Konstantin S Bobrovsky <konstantin.s.bobrovsky@intel.com>
1 parent edd036d commit d1f4a9d

File tree

3 files changed

+21
-23
lines changed

3 files changed

+21
-23
lines changed

llvm/tools/sycl-post-link/ModuleSplitter.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ void ModuleSplitterBase::verifyNoCrossModuleDeviceGlobalUsage() {
425425
}
426426
}
427427

428-
#ifndef _NDEBUG
428+
#ifndef NDEBUG
429429

430430
const char *toString(SyclEsimdSplitStatus S) {
431431
switch (S) {
@@ -472,15 +472,17 @@ void dumpEntryPoints(const Module &M, bool OnlyKernelsAreEntryPoints,
472472
llvm::errs() << "}\n";
473473
}
474474

475+
#endif // NDEBUG
476+
475477
void ModuleDesc::renameDuplicatesOf(const Module &MA, StringRef Suff) {
476478
Module &MB = getModule();
477-
#ifndef _NDEBUG
479+
#ifndef NDEBUG
478480
DenseSet<StringRef> EntryNamesB;
479481
auto It0 = entries().cbegin();
480482
auto It1 = entries().cend();
481483
std::for_each(It0, It1,
482484
[&](const Function *F) { EntryNamesB.insert(F->getName()); });
483-
#endif // _NDEBUG
485+
#endif // NDEBUG
484486
for (const GlobalObject &GoA : MA.global_objects()) {
485487
if (GoA.isDeclaration()) {
486488
continue;
@@ -495,12 +497,12 @@ void ModuleDesc::renameDuplicatesOf(const Module &MA, StringRef Suff) {
495497
// function or variable is not shared or is a declaration in MB
496498
continue;
497499
}
498-
#ifndef _NDEBUG
500+
#ifndef NDEBUG
499501
if (F) {
500502
// this is a shared function, must not be an entry point:
501503
assert(!EntryNamesB.contains(Name));
502504
}
503-
#endif // _NDEBUG
505+
#endif // NDEBUG
504506
// rename the global object in MB:
505507
GoB->setName(Name + Suff);
506508
}
@@ -514,12 +516,12 @@ void ModuleDesc::assignESIMDProperty() {
514516
} else {
515517
Props.HasEsimd = SyclEsimdSplitStatus::SYCL_AND_ESIMD;
516518
}
517-
#ifndef _NDEBUG
519+
#ifndef NDEBUG
518520
verifyESIMDProperty();
519-
#endif // _NDEBUG
521+
#endif // NDEBUG
520522
}
521523

522-
#ifndef _NDEBUG
524+
#ifndef NDEBUG
523525
void ModuleDesc::verifyESIMDProperty() const {
524526
if (Props.HasEsimd == SyclEsimdSplitStatus::SYCL_AND_ESIMD) {
525527
return; // nothing to verify
@@ -550,7 +552,6 @@ void ModuleDesc::verifyESIMDProperty() const {
550552
// }
551553
//}
552554
}
553-
#endif // _NDEBUG
554555

555556
void ModuleDesc::dump() {
556557
llvm::errs() << "split_module::ModuleDesc[" << Name << "] {\n";
@@ -560,7 +561,7 @@ void ModuleDesc::dump() {
560561
dumpEntryPoints(entries(), EntryPoints.getId().str().c_str(), 1);
561562
llvm::errs() << "}\n";
562563
}
563-
#endif // _NDEBUG
564+
#endif // NDEBUG
564565

565566
bool EntryPointGroup::isEsimd() const { return GroupId == ESIMD_SCOPE_NAME; }
566567

llvm/tools/sycl-post-link/ModuleSplitter.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,10 @@ class ModuleDesc {
119119
// this module descriptor is a ESIMD/SYCL part of the ESIMD/SYCL module split.
120120
// Otherwise assumes the module has both SYCL and ESIMD.
121121
void assignESIMDProperty();
122-
#ifndef _NDEBUG
122+
#ifndef NDEBUG
123123
void verifyESIMDProperty() const;
124-
#endif // _NDEBUG
125-
126-
#ifndef _NDEBUG
127124
void dump();
128-
#endif // _NDEBUG
125+
#endif // NDEBUG
129126
};
130127

131128
// Module split support interface.
@@ -188,11 +185,11 @@ getSplitterByMode(std::unique_ptr<Module> M, IRSplitMode Mode,
188185
bool AutoSplitIsGlobalScope,
189186
bool EmitOnlyKernelsAsEntryPoints);
190187

191-
#ifndef _NDEBUG
188+
#ifndef NDEBUG
192189
void dumpEntryPoints(const EntryPointVec &C, const char *msg = "", int Tab = 0);
193190
void dumpEntryPoints(const Module &M, bool OnlyKernelsAreEntryPoints = false,
194191
const char *msg = "", int Tab = 0);
195-
#endif // _NDEBUG
192+
#endif // NDEBUG
196193

197194
} // namespace module_split
198195

llvm/tools/sycl-post-link/sycl-post-link.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ using string_vector = std::vector<std::string>;
6161

6262
namespace {
6363

64-
#ifdef _NDEBUG
64+
#ifdef NDEBUG
6565
#define DUMP_ENTRY_POINTS(args...)
6666
#else
6767
constexpr int DebugPostLink = 0;
@@ -70,7 +70,7 @@ constexpr int DebugPostLink = 0;
7070
if (DebugPostLink > 0) { \
7171
llvm::module_split::dumpEntryPoints(__VA_ARGS__); \
7272
}
73-
#endif
73+
#endif // NDEBUG
7474

7575
cl::OptionCategory PostLinkCat{"sycl-post-link options"};
7676

@@ -451,15 +451,15 @@ std::string saveModuleProperties(module_split::ModuleDesc &MD,
451451
// Saves specified collection of symbols to a file.
452452
std::string saveModuleSymbolTable(const module_split::EntryPointVec &Es, int I,
453453
StringRef Suffix) {
454-
#ifndef _NDEBUG
454+
#ifndef NDEBUG
455455
if (DebugPostLink > 0) {
456456
llvm::errs() << "ENTRY POINTS saving Sym table {\n";
457457
for (const auto *F : Es) {
458458
llvm::errs() << " " << F->getName() << "\n";
459459
}
460460
llvm::errs() << "}\n";
461461
}
462-
#endif
462+
#endif // NDEBUG
463463
// Concatenate names of the input entry points with "\n".
464464
std::string SymT;
465465

@@ -743,9 +743,9 @@ processInputModule(std::unique_ptr<Module> M) {
743743
MMs.emplace_back(std::move(MDesc1));
744744
}
745745
Modified |= MMs.size() > 1;
746-
#ifndef _NDEBUG
746+
#ifndef NDEBUG
747747
bool NoSplitOccurred = (MMs.size() == 1) && (Table->getNumRows() == 0);
748-
#endif // _NDEBUG
748+
#endif // NDEBUG
749749

750750
if (!SplitEsimd && (MMs.size() > 1)) {
751751
// SYCL/ESIMD splitting is not requested, link back into single module.

0 commit comments

Comments
 (0)