[llvm] [Target] Add target-independent TargetVerifier dispatcher (PR #205703)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 28 08:29:31 PDT 2026
================
@@ -0,0 +1,82 @@
+//===-- TargetVerifier.cpp - Target-dependent IR Verifier ------*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the target-independent dispatcher for target-dependent
+// IR verification. See llvm/Target/TargetVerifier.h for the design.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Target/TargetVerifier.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/Verifier.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace llvm;
+
+// The registry maps Triple::ArchType (stored as unsigned, since there is no
+// DenseMapInfo for the enum) to the factory that builds that target's
+// TargetVerify. It is populated by backends from LLVMInitialize<T>Target().
+static DenseMap<unsigned, TargetVerifyFactory> &getTargetVerifyRegistry() {
+ static DenseMap<unsigned, TargetVerifyFactory> Registry;
----------------
jofrn wrote:
We cannot remove the registration hook because TargetVerifier lives in LLVMTarget (llvm/lib/Target) (so it can be run from `opt -passes=target-verifier`), which doesn't link in where each backend lives (e.g. LLVMX86CodeGen (llvm/lib/Target/X86)). And so we cannot have a direct call from TargetVerifier into the backend.
The hook could be moved to TargetRegistry though.
https://github.com/llvm/llvm-project/pull/205703
More information about the llvm-commits
mailing list