[llvm] Verify threadlocal_address constraints (PR #87841)

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 5 16:31:03 PDT 2024


https://github.com/MatzeB created https://github.com/llvm/llvm-project/pull/87841

Check invariants for `llvm.threadlocal.address` intrinsic in IR Verifier.

>From be8299b04210edae9f1aa562f49ee1b994f668aa Mon Sep 17 00:00:00 2001
From: Matthias Braun <matze at braunis.de>
Date: Fri, 5 Apr 2024 16:14:48 -0700
Subject: [PATCH] Verify threadlocal_address constraints

Check invariants for `llvm.threadlocal.address` intrinsic in IR
Verifier.
---
 llvm/lib/IR/Verifier.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 64c59914cf2fc2..ac3d13f3d2b057 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -6223,6 +6223,14 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
           &Call);
     break;
   }
+  case Intrinsic::threadlocal_address: {
+    const Value &Arg0 = *Call.getArgOperand(0);
+    Check(isa<GlobalVariable>(Arg0),
+          "llvm.threadlocal.address first argument must be a GlobalVariable");
+    Check(cast<GlobalVariable>(Arg0).isThreadLocal(),
+          "llvm.threadlocal.address operand isThreadLocal() must no be false");
+    break;
+  }
   };
 
   // Verify that there aren't any unmediated control transfers between funclets.



More information about the llvm-commits mailing list