Skip to content

Commit 1b05b81

Browse files
authored
[SYCL][NFCI] Rework spec constants metadata used for split (#15346)
Addressing review feedback from #15271 Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
1 parent 783d2b9 commit 1b05b81

File tree

4 files changed

+12
-16
lines changed

4 files changed

+12
-16
lines changed

llvm/include/llvm/SYCLLowerIR/SpecConstants.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,6 @@ class SpecConstantsPass : public PassInfoMixin<SpecConstantsPass> {
7272
collectSpecConstantDefaultValuesMetadata(const Module &M,
7373
std::vector<char> &DefaultValues);
7474

75-
// Name of the metadata which holds a list of all specialization constants
76-
// (with associated information) encountered in the module
77-
static constexpr char SPEC_CONST_MD_STRING[] =
78-
"sycl.specialization-constants";
79-
8075
// Name of the metadata which indicates this module was proccessed with the
8176
// default values handing mode.
8277
static constexpr char SPEC_CONST_DEFAULT_VAL_MODULE_MD_STRING[] =

llvm/lib/SYCLLowerIR/ComputeModuleRuntimeInfo.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,11 @@ PropSetRegTy computeModuleProperties(const Module &M,
150150
PropSet.add(PropSetRegTy::SYCL_DEVICE_REQUIREMENTS,
151151
computeDeviceRequirements(M, EntryPoints).asMap());
152152
}
153-
auto *SpecConstsMD =
154-
M.getNamedMetadata(SpecConstantsPass::SPEC_CONST_MD_STRING);
155-
bool SpecConstsMet =
156-
SpecConstsMD != nullptr && SpecConstsMD->getNumOperands() != 0;
157-
if (SpecConstsMet) {
158-
// extract spec constant maps per each module
159-
SpecIDMapTy TmpSpecIDMap;
160-
SpecConstantsPass::collectSpecConstantMetadata(M, TmpSpecIDMap);
153+
154+
// extract spec constant maps per each module
155+
SpecIDMapTy TmpSpecIDMap;
156+
SpecConstantsPass::collectSpecConstantMetadata(M, TmpSpecIDMap);
157+
if (!TmpSpecIDMap.empty()) {
161158
PropSet.add(PropSetRegTy::SYCL_SPECIALIZATION_CONSTANTS, TmpSpecIDMap);
162159

163160
// Add property with the default values of spec constants

llvm/lib/SYCLLowerIR/SpecConstants.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ constexpr char SPIRV_GET_SPEC_CONST_VAL[] = "__spirv_SpecConstant";
4747
constexpr char SPIRV_GET_SPEC_CONST_COMPOSITE[] =
4848
"__spirv_SpecConstantComposite";
4949

50+
// Name of the metadata which holds a list of all specialization constants (with
51+
// associated information) encountered in the module
52+
constexpr char SPEC_CONST_MD_STRING[] = "sycl.specialization-constants";
5053
// Name of the metadata which holds a default value list of all specialization
5154
// constants encountered in the module
5255
constexpr char SPEC_CONST_DEFAULT_VAL_MD_STRING[] =
@@ -1026,9 +1029,6 @@ PreservedAnalyses SpecConstantsPass::run(Module &M,
10261029
for (const auto &P : DefaultsMetadata)
10271030
MDDefaults->addOperand(P);
10281031

1029-
if (Mode == HandlingMode::default_values)
1030-
M.getOrInsertNamedMetadata(SPEC_CONST_DEFAULT_VAL_MODULE_MD_STRING);
1031-
10321032
return IRModified ? PreservedAnalyses::none() : PreservedAnalyses::all();
10331033
}
10341034

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,10 @@ processSpecConstantsWithDefaultValues(const module_split::ModuleDesc &MD) {
509509
assert(NewModuleDesc->Props.SpecConstsMet &&
510510
"This property should be true since the presence of SpecConsts "
511511
"has been checked before the run of the pass");
512+
// Add metadata to the module so we can identify it as the default value split
513+
// later.
514+
NewModuleDesc->getModule().getOrInsertNamedMetadata(
515+
SpecConstantsPass::SPEC_CONST_DEFAULT_VAL_MODULE_MD_STRING);
512516
NewModuleDesc->rebuildEntryPoints();
513517
return NewModuleDesc;
514518
}

0 commit comments

Comments
 (0)