[llvm] [DirectX] Propagate shader flags mask of callees to callers (PR #118306)
S. Bharadwaj Yadavalli via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 3 16:52:40 PST 2024
================
@@ -81,16 +101,31 @@ void ComputedShaderFlags::print(raw_ostream &OS) const {
OS << ";\n";
}
-/// Return the shader flags mask of the specified function Func.
-const ComputedShaderFlags &
-ModuleShaderFlags::getFunctionFlags(const Function *Func) const {
+auto ModuleShaderFlags::getFunctionShaderFlagInfo(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); });
assert((Iter != FunctionFlags.end() && Iter->first == Func) &&
"No Shader Flags Mask exists for function");
- return Iter->second;
+ return Iter;
+}
+
+/// Merge mask NewSF to that of Func, if different.
+/// Return true if mask of Func is changed, else false.
+bool ModuleShaderFlags::mergeFunctionShaderFlags(
+ const Function *Func, const ComputedShaderFlags NewSF) {
+ const auto FuncSFInfo = getFunctionShaderFlagInfo(Func);
+ if ((FuncSFInfo->second & NewSF) != NewSF) {
+ const_cast<ComputedShaderFlags &>(FuncSFInfo->second).merge(NewSF);
----------------
bharadwajy wrote:
Changed `merge()` to operate on `ComputeShaderFlags` type thereby not relying on implicit cast to `uint64_t`.
Updated `mergeFunctionShaderFlags()` with the check for shader flag value change.
However, testing for equality still implicitly casts to `uint64_t`. Getting rid of implicit conversion operator requires changes to other access functions such as `getFeatureFlags()` etc., that use the conversion. I'll plan to delete implicit conversion operator in a follow-on PR. I think this implies that `operator==` would need to be implemented. Created an [issue](https://github.com/llvm/llvm-project/issues/118570) for this.
https://github.com/llvm/llvm-project/pull/118306
More information about the llvm-commits
mailing list