[llvm] [DirectX] Propagate shader flags mask of callees to callers (PR #118306)

Chris B via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 5 12:00:39 PST 2024


================
@@ -84,15 +145,22 @@ void ComputedShaderFlags::print(raw_ostream &OS) const {
 /// Return the shader flags mask of the specified function Func.
 const ComputedShaderFlags &
 ModuleShaderFlags::getFunctionFlags(const Function *Func) const {
-  const auto Iter = llvm::lower_bound(
-      FunctionFlags, Func,
-      [](const std::pair<const Function *, ComputedShaderFlags> FSM,
-         const Function *FindFunc) { return (FSM.first < FindFunc); });
+  auto Iter = FunctionFlags.find(Func);
   assert((Iter != FunctionFlags.end() && Iter->first == Func) &&
-         "No Shader Flags Mask exists for function");
+         "Get Shader Flags : No Shader Flags Mask exists for function");
   return Iter->second;
----------------
llvm-beanz wrote:

This would actually be safer to return `FunctionFlags[Func]` instead of using Find. Then if it fails, the returned result is a default initialized flags structure.

https://github.com/llvm/llvm-project/pull/118306


More information about the llvm-commits mailing list