[llvm] [DirectX] Implement DXILResourceImplicitBinding pass (PR #138043)
Helena Kotas via llvm-commits
llvm-commits at lists.llvm.org
Mon May 12 11:05:37 PDT 2025
================
@@ -0,0 +1,181 @@
+//===- DXILResourceImplicitBinding.cpp -----------------------------------===//
+//
+// 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 "DXILResourceImplicitBinding.h"
+#include "DirectX.h"
+#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Analysis/DXILResource.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/DiagnosticInfo.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/Instructions.h"
+#include "llvm/IR/IntrinsicsDirectX.h"
+#include "llvm/IR/Module.h"
+#include "llvm/InitializePasses.h"
+#include <cstdint>
+
+#define DEBUG_TYPE "dxil-resource-implicit-binding"
+
+using namespace llvm;
+using namespace llvm::dxil;
+
+namespace {
+
+static void diagnoseImplicitBindingNotFound(CallInst *ImplBindingCall) {
+ Function *F = ImplBindingCall->getFunction();
+ LLVMContext &Context = F->getParent()->getContext();
+ // FIXME: include the name of the resource in the error message
+ // (llvm/llvm-project#137868)
+ Context.diagnose(
----------------
hekota wrote:
I thought about it and in this case, I think it is better to issue the diagnostic right here. I know we agreed that the diagnostic reporting should happen in the `DXILPostOptimizationValidation` pass, especially if it requires extra work that would slow down the main non-error path. However, in this case we have all the information we need (except the resource name which will come be added soon). And when we report it here, the compiler stops and subsequent passes do not have to handle the case where we have a resource handle without a corresponding `createhandlefrombinding` call and associated `ResourceInfo`.
https://github.com/llvm/llvm-project/pull/138043
More information about the llvm-commits
mailing list