Skip to content

Commit ed0166e

Browse files
committed
Align variables names with the meaning and correct comments
1 parent fbd2413 commit ed0166e

File tree

1 file changed

+38
-37
lines changed

1 file changed

+38
-37
lines changed

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

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,9 @@ void writeToFile(const std::string &Filename, const std::string &Content) {
210210
OS.close();
211211
}
212212

213-
// Describes scope covered by each entry in the module-kernel map populated by
214-
// the collectKernelModuleMap function.
215-
enum KernelMapEntryScope {
213+
// Describes scope covered by each entry in the module-entry points map
214+
// populated by the collectEntryPointToModuleMap function.
215+
enum EntryPointsSplitScope {
216216
Scope_PerKernel, // one entry per kernel
217217
Scope_PerModule, // one entry per module
218218
Scope_Global // single entry in the map for all kernels
@@ -245,7 +245,7 @@ bool hasIndirectFunctionCalls(const Module &M) {
245245
return false;
246246
}
247247

248-
KernelMapEntryScope selectDeviceCodeSplitScope(const Module &M) {
248+
EntryPointsSplitScope selectDeviceCodeSplitScope(const Module &M) {
249249
bool DoSplit = SplitMode.getNumOccurrences() > 0;
250250
if (DoSplit) {
251251
switch (SplitMode) {
@@ -288,7 +288,7 @@ bool isSpirvSyclBuiltin(StringRef FName) {
288288
}
289289

290290
bool isEntryPoint(const Function &F) {
291-
// Skip declarations, if any: they should not be included into KernelModuleMap
291+
// Skip declarations, if any: they should not be included into EntryPointsMap
292292
// or otherwise we will end up with incorrectly generated list of symbols.
293293
if (F.isDeclaration())
294294
return false;
@@ -311,12 +311,12 @@ bool isEntryPoint(const Function &F) {
311311
// This function decides how entry points of the input module M will be
312312
// distributed ("split") into multiple modules based on the command options and
313313
// IR attributes. The decision is recorded in the output map parameter
314-
// ResKernelModuleMap which maps some key to a group of entry points. Each such
314+
// EntryPointsSplitMap which maps some key to a group of entry points. Each such
315315
// group along with IR it depends on (globals, functions from its call graph,
316316
// ...) will constitute a separate module.
317317
void collectEntryPointToModuleMap(const Module &M,
318-
EntryPointsMap &ResKernelModuleMap,
319-
KernelMapEntryScope EntryScope) {
318+
EntryPointsMap &EntryPointsSplitMap,
319+
EntryPointsSplitScope EntryScope) {
320320

321321
// Only process module entry points:
322322
for (const auto &F : M.functions()) {
@@ -325,7 +325,7 @@ void collectEntryPointToModuleMap(const Module &M,
325325

326326
switch (EntryScope) {
327327
case Scope_PerKernel:
328-
ResKernelModuleMap[F.getName()].push_back(&F);
328+
EntryPointsSplitMap[F.getName()].push_back(&F);
329329
break;
330330
case Scope_PerModule: {
331331
if (!F.hasFnAttribute(ATTR_SYCL_MODULE_ID))
@@ -338,12 +338,12 @@ void collectEntryPointToModuleMap(const Module &M,
338338

339339
Attribute Id = F.getFnAttribute(ATTR_SYCL_MODULE_ID);
340340
StringRef Val = Id.getValueAsString();
341-
ResKernelModuleMap[Val].push_back(&F);
341+
EntryPointsSplitMap[Val].push_back(&F);
342342
break;
343343
}
344344
case Scope_Global:
345345
// the map key is not significant here
346-
ResKernelModuleMap[GLOBAL_SCOPE_NAME].push_back(&F);
346+
EntryPointsSplitMap[GLOBAL_SCOPE_NAME].push_back(&F);
347347
break;
348348
}
349349
}
@@ -487,15 +487,15 @@ std::vector<uint32_t> getKernelReqdWorkGroupSizeMetadata(const Function &Func) {
487487
return {X, Y, Z};
488488
}
489489

490-
// Input parameter KernelModuleMap is a map containing groups of entry points
491-
// with same values of the sycl-module-id attribute. Return value is a vector
492-
// of entry points names lists. Each vector element is a string with entry point
493-
// names from the same module separated by \n.
490+
// Input parameter EntryPointsSplitMap contains a map of entry points or groups
491+
// of entry points with same values of the sycl-module-id attribute.
492+
// Return value is a vector of entry points names lists. Each vector element is
493+
// a string with entry point names from the same module separated by \n.
494494
// The function saves names of entry points from one group to a single
495495
// std::string and stores this string to the ResSymbolsLists vector.
496-
string_vector collectSymbolsLists(const EntryPointsMap &KernelModuleMap) {
496+
string_vector collectSymbolsLists(const EntryPointsMap &EntryPointsSplitMap) {
497497
string_vector ResSymbolsLists{};
498-
for (const auto &It : KernelModuleMap) {
498+
for (const auto &It : EntryPointsSplitMap) {
499499
std::string SymbolsList;
500500
for (const auto &F : It.second) {
501501
SymbolsList =
@@ -507,21 +507,21 @@ string_vector collectSymbolsLists(const EntryPointsMap &KernelModuleMap) {
507507
}
508508

509509
struct ResultModule {
510-
StringRef KernelModuleName;
510+
StringRef SplitModuleId;
511511
std::unique_ptr<Module> ModulePtr;
512512
};
513513

514-
// Input parameter KernelModuleMap is a map containing groups of entry points
515-
// with same values of the sycl-module-id attribute. For each group of entry
516-
// points a separate IR module will be produced.
517-
// ResModules is a vector of pairs of kernel module names and produced modules.
518-
// The function splits input LLVM IR module M into smaller ones and stores them
519-
// to the ResModules vector.
520-
std::vector<ResultModule> splitModule(const Module &M,
521-
const EntryPointsMap &KernelModuleMap) {
514+
// Input parameter EntryPointsSplitMap contains a map of entry points or groups
515+
// of entry points with same values of the sycl-module-id attribute.
516+
// For each group of entry points a separate IR module will be produced.
517+
// ResModules is a vector of pairs of split module identifiers and produced
518+
// modules. The function splits input LLVM IR module M into smaller ones and
519+
// stores them to the ResModules vector.
520+
std::vector<ResultModule>
521+
splitModule(const Module &M, const EntryPointsMap &EntryPointsSplitMap) {
522522
std::vector<ResultModule> ResModules{};
523523

524-
for (const auto &It : KernelModuleMap) {
524+
for (const auto &It : EntryPointsSplitMap) {
525525
// For each group of entry points collect all dependencies.
526526
SetVector<const GlobalValue *> GVs;
527527
std::vector<const Function *> Workqueue;
@@ -617,7 +617,7 @@ string_vector saveResultModules(const std::vector<ResultModule> &ResModules,
617617

618618
string_vector
619619
saveDeviceImageProperty(const std::vector<ResultModule> &ResultModules,
620-
const EntryPointsMap &KernelModuleMap,
620+
const EntryPointsMap &EntryPointsSplitMap,
621621
const ImagePropSaveInfo &ImgPSInfo) {
622622
using PropSetRegTy = llvm::util::PropertySetRegistry;
623623

@@ -682,8 +682,8 @@ saveDeviceImageProperty(const std::vector<ResultModule> &ResultModules,
682682
if (ImgPSInfo.EmitExportedSymbols) {
683683
// For each result module, extract the exported functions
684684
auto ModuleFunctionsIt =
685-
KernelModuleMap.find(ResultModules[I].KernelModuleName);
686-
if (ModuleFunctionsIt != KernelModuleMap.end()) {
685+
EntryPointsSplitMap.find(ResultModules[I].SplitModuleId);
686+
if (ModuleFunctionsIt != EntryPointsSplitMap.end()) {
687687
for (const auto &F : ModuleFunctionsIt->second) {
688688
if (F->getCallingConv() == CallingConv::SPIR_FUNC) {
689689
PropSet[PropSetRegTy::SYCL_EXPORTED_SYMBOLS].insert(
@@ -812,7 +812,7 @@ TableFiles processOneModule(std::unique_ptr<Module> M, bool IsEsimd,
812812
bool DoSplit = SplitMode.getNumOccurrences() > 0;
813813

814814
if (DoSplit || DoSymGen) {
815-
KernelMapEntryScope Scope = selectDeviceCodeSplitScope(*M);
815+
EntryPointsSplitScope Scope = selectDeviceCodeSplitScope(*M);
816816
collectEntryPointToModuleMap(*M, GlobalsSet, Scope);
817817
}
818818

@@ -920,13 +920,14 @@ ModulePair splitSyclEsimd(std::unique_ptr<Module> M) {
920920
if (SyclFunctions.empty())
921921
return std::make_pair(std::unique_ptr<Module>(nullptr), std::move(M));
922922

923-
// Key values in KernelModuleMap are not significant, but they define the
924-
// order, in which entry points are processed in the splitModule function. The
925-
// caller of the splitSyclEsimd function expects a pair of 1-Sycl and 2-Esimd
926-
// modules, hence the strings names below.
927-
EntryPointsMap KernelModuleMap(
923+
// Key values in SyclEsimdEntryPointsMap are not significant, but they define
924+
// the order, in which entry points are processed in the splitModule function.
925+
// The caller of the splitSyclEsimd function expects a pair of 1-Sycl and
926+
// 2-Esimd modules, hence the strings names below.
927+
EntryPointsMap SyclEsimdEntryPointsMap(
928928
{{"1-SYCL", SyclFunctions}, {"2-ESIMD", EsimdFunctions}});
929-
std::vector<ResultModule> ResultModules = splitModule(*M, KernelModuleMap);
929+
std::vector<ResultModule> ResultModules =
930+
splitModule(*M, SyclEsimdEntryPointsMap);
930931
assert(ResultModules.size() == 2);
931932
return std::make_pair(std::move(ResultModules[0].ModulePtr),
932933
std::move(ResultModules[1].ModulePtr));

0 commit comments

Comments
 (0)