================ @@ -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())) { ---------------- hekota wrote:
1. Yes, all resource infos in `DXILResourceMap` are sorted first by resource class and then by binding. The `uavs()`, `srvs()` etc. calls return iterator over the range of resources with the same class sorted by binding. This is where the `DXILResourceMap` is created: https://github.com/llvm/llvm-project/blob/20f1e351c79528f3bdf996baab03bca4e11704d1/llvm/lib/Analysis/DXILResource.cpp#L745 2. `overlapsWith` is not using `RecordID` or `std:tie`. The change in `operator==` that adds `Name` to the compare is to make sure resources with identical binding but different names are treated as different and not de-duplicated when the `DXILResourceMap` is populated. https://github.com/llvm/llvm-project/pull/140982 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits