[llvm] [DirectX] Infrastructure to collect shader flags for each function (PR #112967)
Damyan Pepper via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 1 11:30:56 PDT 2024
================
@@ -63,17 +118,78 @@ void ComputedShaderFlags::print(raw_ostream &OS) const {
OS << ";\n";
}
+void DXILModuleShaderFlagsInfo::clear() {
+ ModuleFlags = ComputedShaderFlags{};
+ FunctionFlags.clear();
+}
+
+/// Insert the pair <Func, FlagMask> into the sorted vector
+/// FunctionFlags. The insertion is expected to be in-order and hence
+/// is done at the end of the already sorted list.
+[[nodiscard]] bool DXILModuleShaderFlagsInfo::insertInorderFunctionFlags(
+ const Function *Func, ComputedShaderFlags FlagMask) {
+ std::pair<Function const *, ComputedShaderFlags> V{Func, {}};
+ auto Iter = llvm::lower_bound(FunctionFlags, V);
+ if (Iter != FunctionFlags.end())
+ return false;
+
+ FunctionFlags.push_back({Func, FlagMask});
+ return true;
+}
----------------
damyanp wrote:
This all seems overly complicated. Why isn't it sufficient just to do a push_back from within `computeFlags`?
The only way I think this could go wrong would be if something the call to `llvm::sort(FuncList)` somehow didn't sort the list. But as some point I think we have to trust that that code works.
https://github.com/llvm/llvm-project/pull/112967
More information about the llvm-commits
mailing list