Skip to content

Conversation

@NewSigma
Copy link
Contributor

@NewSigma NewSigma commented Nov 3, 2025

This patch proposes replacing the inline assembly with an intrinsic and adds the noreturn to avoid warnings when the caller is also noreturn.

@NewSigma NewSigma requested a review from Artem-B November 3, 2025 11:26
@llvmbot llvmbot added clang Clang issues not falling into any other category backend:X86 clang:headers Headers provided by Clang, e.g. for intrinsics labels Nov 3, 2025
@llvmbot
Copy link
Member

llvmbot commented Nov 3, 2025

@llvm/pr-subscribers-clang

Author: Weibo He (NewSigma)

Changes

This patch proposes replacing the inline assembly with an intrinsic and adds the noreturn to avoid warnings when the caller is also noreturn.


Full diff: https://github.com/llvm/llvm-project/pull/166152.diff

1 Files Affected:

  • (modified) clang/lib/Headers/__clang_cuda_device_functions.h (+1-1)
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);

@llvmbot
Copy link
Member

llvmbot commented Nov 3, 2025

@llvm/pr-subscribers-backend-x86

Author: Weibo He (NewSigma)

Changes

This patch proposes replacing the inline assembly with an intrinsic and adds the noreturn to avoid warnings when the caller is also noreturn.


Full diff: https://github.com/llvm/llvm-project/pull/166152.diff

1 Files Affected:

  • (modified) clang/lib/Headers/__clang_cuda_device_functions.h (+1-1)
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);

@NewSigma NewSigma merged commit b440fb7 into llvm:main Nov 11, 2025
14 checks passed
@NewSigma NewSigma deleted the cuda-trap branch November 11, 2025 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:headers Headers provided by Clang, e.g. for intrinsics clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants