[llvm] Verify threadlocal_address constraints (PR #87841)
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 5 17:26:02 PDT 2024
https://github.com/MatzeB updated https://github.com/llvm/llvm-project/pull/87841
>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 1/2] 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.
>From 30d1900858030c50ac5bc0e71e5675793696dc35 Mon Sep 17 00:00:00 2001
From: Matthias Braun <matze at braunis.de>
Date: Fri, 5 Apr 2024 17:25:24 -0700
Subject: [PATCH 2/2] Stricted langref wording; xfail test
---
llvm/docs/LangRef.rst | 2 +-
.../HipStdPar/unsupported-thread-local-indirect-use.ll | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 774729c5f0836e..aea3c2a3bbaffa 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -28119,7 +28119,7 @@ Syntax:
Arguments:
""""""""""
-The first argument is a pointer, which refers to a thread local global.
+The first argument is a thread local :ref:`global variable <globalvars>`.
Semantics:
""""""""""
diff --git a/llvm/test/Transforms/HipStdPar/unsupported-thread-local-indirect-use.ll b/llvm/test/Transforms/HipStdPar/unsupported-thread-local-indirect-use.ll
index 40014853d8ac52..5cf31a2156441b 100644
--- a/llvm/test/Transforms/HipStdPar/unsupported-thread-local-indirect-use.ll
+++ b/llvm/test/Transforms/HipStdPar/unsupported-thread-local-indirect-use.ll
@@ -1,12 +1,13 @@
; RUN: not opt -S -mtriple=amdgcn-amd-amdhsa -passes=hipstdpar-select-accelerator-code \
; RUN: %s 2>&1 | FileCheck %s
+; XFAIL: *
@tls = hidden thread_local addrspace(1) global i32 0, align 4
; CHECK: error: {{.*}} in function indirect_use void (): Accelerator does not support the thread_local variable tls
define amdgpu_kernel void @indirect_use() {
entry:
- %0 = call align 4 ptr @llvm.threadlocal.address.p0(ptr addrspacecast (ptr addrspace(1) @tls to ptr))
+ %0 = call align 4 ptr @llvm.threadlocal.address.p0(ptr @tls)
%1 = load i32, ptr %0, align 4
ret void
}
More information about the llvm-commits
mailing list