[llvm] [DirectX] Infrastructure to collect shader flags for each function (PR #112967)
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 29 17:18:27 PDT 2024
================
@@ -318,22 +313,39 @@ static void translateMetadata(Module &M, const DXILResourceMap &DRM,
// See https://github.com/llvm/llvm-project/issues/57928
MDTuple *Signatures = nullptr;
- if (MMDI.ShaderProfile == Triple::EnvironmentType::Library)
+ if (MMDI.ShaderProfile == Triple::EnvironmentType::Library) {
+ // Create a consolidated shader flag mask of all functions in the library
+ // to be used as shader flags mask value associated with top-level library
+ // entry metadata.
+ uint64_t ConsolidatedMask = ShaderFlags.ModuleFlags;
+ for (const auto &FunFlags : ShaderFlags.FuncShaderFlagsVec) {
+ ConsolidatedMask |= FunFlags.second;
+ }
EntryFnMDNodes.emplace_back(
- emitTopLevelLibraryNode(M, ResourceMD, ShaderFlags));
- else if (MMDI.EntryPropertyVec.size() > 1) {
+ emitTopLevelLibraryNode(M, ResourceMD, ConsolidatedMask));
+ } else if (MMDI.EntryPropertyVec.size() > 1) {
M.getContext().diagnose(DiagnosticInfoTranslateMD(
M, "Non-library shader: One and only one entry expected"));
}
for (const EntryProperties &EntryProp : MMDI.EntryPropertyVec) {
- // FIXME: ShaderFlagsAnalysis pass needs to collect and provide
- // ShaderFlags for each entry function. For now, assume shader flags value
- // of entry functions being compiled for lib_* shader profile viz.,
- // EntryPro.Entry is 0.
- uint64_t EntryShaderFlags =
- (MMDI.ShaderProfile == Triple::EnvironmentType::Library) ? 0
- : ShaderFlags;
+ Expected<const ComputedShaderFlags &> ECSF =
+ ShaderFlags.getShaderFlagsMask(EntryProp.Entry);
+ if (Error E = ECSF.takeError()) {
+ M.getContext().diagnose(DiagnosticInfoTranslateMD(
+ M, "Shader Flags information of Function '" +
+ Twine(EntryProp.Entry->getName()) + "' not found"));
+ }
----------------
bogner wrote:
If we're going to completely ignore the error here it would make more sense to simply have `getShaderFlagsMask` return `nullptr` if it fails. Using `Expected` to return a string that says "not found" is kind of heavy handed anyways.
https://github.com/llvm/llvm-project/pull/112967
More information about the llvm-commits
mailing list