Skip to content

Commit

Permalink
[SYCL][NFCI] Rework spec constants metadata used for split (#15346)
Browse files Browse the repository at this point in the history
Addressing review feedback from #15271

Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
  • Loading branch information
sarnex committed Sep 11, 2024
1 parent 783d2b9 commit 1b05b81
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
5 changes: 0 additions & 5 deletions llvm/include/llvm/SYCLLowerIR/SpecConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ class SpecConstantsPass : public PassInfoMixin<SpecConstantsPass> {
collectSpecConstantDefaultValuesMetadata(const Module &M,
std::vector<char> &DefaultValues);

// Name of the metadata which holds a list of all specialization constants
// (with associated information) encountered in the module
static constexpr char SPEC_CONST_MD_STRING[] =
"sycl.specialization-constants";

// Name of the metadata which indicates this module was proccessed with the
// default values handing mode.
static constexpr char SPEC_CONST_DEFAULT_VAL_MODULE_MD_STRING[] =
Expand Down
13 changes: 5 additions & 8 deletions llvm/lib/SYCLLowerIR/ComputeModuleRuntimeInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,11 @@ PropSetRegTy computeModuleProperties(const Module &M,
PropSet.add(PropSetRegTy::SYCL_DEVICE_REQUIREMENTS,
computeDeviceRequirements(M, EntryPoints).asMap());
}
auto *SpecConstsMD =
M.getNamedMetadata(SpecConstantsPass::SPEC_CONST_MD_STRING);
bool SpecConstsMet =
SpecConstsMD != nullptr && SpecConstsMD->getNumOperands() != 0;
if (SpecConstsMet) {
// extract spec constant maps per each module
SpecIDMapTy TmpSpecIDMap;
SpecConstantsPass::collectSpecConstantMetadata(M, TmpSpecIDMap);

// extract spec constant maps per each module
SpecIDMapTy TmpSpecIDMap;
SpecConstantsPass::collectSpecConstantMetadata(M, TmpSpecIDMap);
if (!TmpSpecIDMap.empty()) {
PropSet.add(PropSetRegTy::SYCL_SPECIALIZATION_CONSTANTS, TmpSpecIDMap);

// Add property with the default values of spec constants
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/SYCLLowerIR/SpecConstants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ constexpr char SPIRV_GET_SPEC_CONST_VAL[] = "__spirv_SpecConstant";
constexpr char SPIRV_GET_SPEC_CONST_COMPOSITE[] =
"__spirv_SpecConstantComposite";

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

if (Mode == HandlingMode::default_values)
M.getOrInsertNamedMetadata(SPEC_CONST_DEFAULT_VAL_MODULE_MD_STRING);

return IRModified ? PreservedAnalyses::none() : PreservedAnalyses::all();
}

Expand Down
4 changes: 4 additions & 0 deletions llvm/tools/sycl-post-link/sycl-post-link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,10 @@ processSpecConstantsWithDefaultValues(const module_split::ModuleDesc &MD) {
assert(NewModuleDesc->Props.SpecConstsMet &&
"This property should be true since the presence of SpecConsts "
"has been checked before the run of the pass");
// Add metadata to the module so we can identify it as the default value split
// later.
NewModuleDesc->getModule().getOrInsertNamedMetadata(
SpecConstantsPass::SPEC_CONST_DEFAULT_VAL_MODULE_MD_STRING);
NewModuleDesc->rebuildEntryPoints();
return NewModuleDesc;
}
Expand Down

0 comments on commit 1b05b81

Please sign in to comment.