[clang] [Clang][CUDA] Replace inline asm in __trap() with intrinsic (PR #166152)
Weibo He via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 3 03:26:52 PST 2025
https://github.com/NewSigma created https://github.com/llvm/llvm-project/pull/166152
This patch proposes replacing the inline assembly with an intrinsic and adds the `noreturn` to avoid warnings when the caller is also `noreturn`.
>From 332e6d433fedc7da1ceb7d4df36366d534c7edf0 Mon Sep 17 00:00:00 2001
From: NewSigma <NewSigma at 163.com>
Date: Mon, 3 Nov 2025 12:07:24 +0800
Subject: [PATCH] [CUDA] Replace inline asm in __trap() with intrinsic
---
clang/lib/Headers/__clang_cuda_device_functions.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/Headers/__clang_cuda_device_functions.h b/clang/lib/Headers/__clang_cuda_device_functions.h
index 86123727a1bc3..0226fe95abab6 100644
--- a/clang/lib/Headers/__clang_cuda_device_functions.h
+++ b/clang/lib/Headers/__clang_cuda_device_functions.h
@@ -528,7 +528,7 @@ __DEVICE__ float __tanf(float __a) { return __nv_fast_tanf(__a); }
__DEVICE__ void __threadfence(void) { __nvvm_membar_gl(); }
__DEVICE__ void __threadfence_block(void) { __nvvm_membar_cta(); };
__DEVICE__ void __threadfence_system(void) { __nvvm_membar_sys(); };
-__DEVICE__ void __trap(void) { __asm__ __volatile__("trap;"); }
+__DEVICE__ __attribute__((noreturn)) void __trap(void) { __builtin_trap(); }
__DEVICE__ unsigned short
__usAtomicCAS(unsigned short *__p, unsigned short __cmp, unsigned short __v) {
return __nvvm_atom_cas_gen_us(__p, __cmp, __v);
More information about the cfe-commits
mailing list