[llvm] [SelectionDAG] Implement SDTCisPtrTy in SDNodeInfo::verifyNode. (PR #229270)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 5 17:01:44 PDT 2026


https://github.com/topperc created https://github.com/llvm/llvm-project/pull/229270

If the node is a MemSDNode, use it to get the pointer address space.

Disable checking for one NVPTX node that has pointer operands, but is not a MemSDNode.

Assisted-by: Claude

>From 6d3636b821c363bcfd90196ca06b1f3bc2964c54 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Mon, 5 Oct 2026 16:59:02 -0700
Subject: [PATCH] [SelectionDAG] Implement SDTCisPtrTy in
 SDNodeInfo::verifyNode.

If the node is a MemSDNode, use it to get the pointer address
space.

Disable checking for one NVPTX node that has pointer operands,
but is not a MemSDNode.

Assisted-by: Claude
---
 llvm/lib/CodeGen/SelectionDAG/SDNodeInfo.cpp    | 12 +++++++++++-
 llvm/lib/Target/NVPTX/NVPTXSelectionDAGInfo.cpp |  3 +++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/CodeGen/SelectionDAG/SDNodeInfo.cpp b/llvm/lib/CodeGen/SelectionDAG/SDNodeInfo.cpp
index 87fd7ed8543e0..031d2757ca406 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SDNodeInfo.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SDNodeInfo.cpp
@@ -203,8 +203,18 @@ void SDNodeInfo::verifyNode(const SelectionDAG &DAG, const SDNode *N) const {
       }
       break;
     }
-    case SDTCisPtrTy:
+    case SDTCisPtrTy: {
+      unsigned AS = 0;
+      if (const auto *MemSD = dyn_cast<MemSDNode>(N))
+        AS = MemSD->getAddressSpace();
+      EVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy(DAG.getDataLayout(), AS);
+      if (VT != PtrVT) {
+        SS << Val << " must have pointer type " << PtrVT << ", but has type "
+           << VT;
+        reportNodeError(DAG, N, SS.str());
+      }
       break;
+    }
     case SDTCisInt:
       if (!VT.isInteger()) {
         SS << Val << " must have integer type, but has type " << VT;
diff --git a/llvm/lib/Target/NVPTX/NVPTXSelectionDAGInfo.cpp b/llvm/lib/Target/NVPTX/NVPTXSelectionDAGInfo.cpp
index 710d063e75725..dac41465e1bdd 100644
--- a/llvm/lib/Target/NVPTX/NVPTXSelectionDAGInfo.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXSelectionDAGInfo.cpp
@@ -59,6 +59,9 @@ void NVPTXSelectionDAGInfo::verifyTargetNode(const SelectionDAG &DAG,
   switch (N->getOpcode()) {
   default:
     break;
+  case NVPTXISD::ST_ASYNC_MBARRIER_B128:
+    // invalid node: operand #4 must have pointer type i64, but has type i32
+    return;
   case NVPTXISD::ProxyReg:
     // invalid number of results; expected 2, got 1
     return;



More information about the llvm-commits mailing list