[llvm] [LLVM][Verifier] Improve diagnostic messages for Intrinsics in Verifier (PR #185641)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 12 09:35:25 PDT 2026
================
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// Registers a diagnostics provider that appends detailed information to error
+// messages for NVVM intrinsic signature mismatches.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/IR/NVVMIntrinsicDiagnostics.h"
+#include "llvm/IR/DerivedTypes.h"
+#include "llvm/IR/IntrinsicDiagnostics.h"
+#include "llvm/IR/Intrinsics.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace llvm;
+
+static bool isNVVMIntrinsic(StringRef Name) {
+ return Name.starts_with("llvm.nvvm.");
+}
+
+/// Returns the canonical FunctionType for a non-overloaded intrinsic, or null.
+static FunctionType *getCanonicalType(StringRef Name, LLVMContext &Ctx) {
+ Intrinsic::ID ID = Intrinsic::lookupIntrinsicID(Name);
+ if (ID == Intrinsic::not_intrinsic || Intrinsic::isOverloaded(ID))
+ return nullptr;
+ SmallVector<Type *, 4> OverloadTys;
+ return Intrinsic::getType(Ctx, ID, OverloadTys);
+}
+
+namespace {
+
+class NVVMIntrinsicDiagnosticsProvider : public IntrinsicDiagnosticsProvider {
+public:
+ void getSignatureMismatch(StringRef Name, FunctionType *DeclFTy,
----------------
jurahul wrote:
At the point where this is called from the verifier, it seems we already have checks that the number of params for the call and they types match the function being called. So it seems there is no need to repeat those checks again?
https://github.com/llvm/llvm-project/pull/185641
More information about the llvm-commits
mailing list