[llvm-branch-commits] [llvm] [HLSL] Diagnose overlapping resource bindings (PR #140982)
Finn Plummer via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon May 26 16:35:33 PDT 2025
================
@@ -50,15 +51,55 @@ static void reportInvalidDirection(Module &M, DXILResourceMap &DRM) {
}
}
-} // namespace
+static void reportOverlappingError(Module &M, ResourceInfo R1,
+ ResourceInfo R2) {
+ SmallString<64> Message;
+ raw_svector_ostream OS(Message);
+ OS << "resource " << R1.getName() << " at register "
+ << R1.getBinding().LowerBound << " overlaps with resource " << R2.getName()
+ << " at register " << R2.getBinding().LowerBound << ", space "
+ << R2.getBinding().Space;
+ M.getContext().diagnose(DiagnosticInfoGeneric(Message));
+}
-PreservedAnalyses
-DXILPostOptimizationValidation::run(Module &M, ModuleAnalysisManager &MAM) {
- DXILResourceMap &DRM = MAM.getResult<DXILResourceAnalysis>(M);
+static void reportOverlappingBinding(Module &M, DXILResourceMap &DRM) {
+ if (DRM.empty())
+ return;
+ for (auto ResList :
+ {DRM.srvs(), DRM.uavs(), DRM.cbuffers(), DRM.samplers()}) {
+ if (ResList.empty())
+ continue;
+ const ResourceInfo *PrevRI = &*ResList.begin();
+ for (auto *I = ResList.begin() + 1; I != ResList.end(); ++I) {
+ const ResourceInfo *RI = &*I;
+ if (PrevRI->getBinding().overlapsWith(RI->getBinding())) {
----------------
inbelic wrote:
The `overlapsWith` check requires that the `LHS.LowerBound < RHS.LowerBound`. So I want to check that:
1. these are sorted
2. the `std::tie` works as expected in the `<` comparison. Since `RecordID` is compared before `LowerBound` could it be possible that a binding has a lower `RecordID` but higher `LowerBound`.
https://github.com/llvm/llvm-project/pull/140982
More information about the llvm-branch-commits
mailing list