[llvm] [HLSL] Raise Diag for Invalid CounterDirection (PR #137697)
Ashley Coleman via llvm-commits
llvm-commits at lists.llvm.org
Mon May 5 10:43:52 PDT 2025
================
@@ -0,0 +1,119 @@
+//===- DXILPostOptimizationValidation.cpp - Opt DXIL validation ----------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "DXILPostOptimizationValidation.h"
+#include "DXILConstants.h"
+#include "DXILIntrinsicExpansion.h"
+#include "DXILOpBuilder.h"
+#include "DXILShaderFlags.h"
+#include "DirectX.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/Analysis/DXILMetadataAnalysis.h"
+#include "llvm/Analysis/DXILResource.h"
+#include "llvm/CodeGen/Passes.h"
+#include "llvm/IR/DiagnosticInfo.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/Instruction.h"
+#include "llvm/IR/Instructions.h"
+#include "llvm/IR/Intrinsics.h"
+#include "llvm/IR/IntrinsicsDirectX.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/PassManager.h"
+#include "llvm/InitializePasses.h"
+#include "llvm/Pass.h"
+#include "llvm/Support/ErrorHandling.h"
+#include <cstdio>
+
+#define DEBUG_TYPE "dxil-post-optimization-validation"
+
+using namespace llvm;
+using namespace llvm::dxil;
+
+namespace {
+class DXILValidator {
+ Module &M;
+ DXILResourceMap &DRM;
+
+public:
+ DXILValidator(Module &M, DXILResourceMap &DRM) : M(M), DRM(DRM) {}
+
+ void validate() {
+ for (const auto &UAV : DRM.uavs()) {
+ if (UAV.CounterDirection != ResourceCounterDirection::Invalid)
+ continue;
+
+ CallInst *ResourceHandle = nullptr;
+ for (CallInst *MaybeHandle : DRM.calls()) {
----------------
V-FEXrt wrote:
The inner loop does, but the outer loop checks for invalid direction first so the inner loop only runs once for each invalid direction uav
https://github.com/llvm/llvm-project/pull/137697
More information about the llvm-commits
mailing list