Skip to content

Conversation

fmayer
Copy link
Contributor

@fmayer fmayer commented Aug 29, 2025

This is consistent with the normal trap. This will allow more
optimizations to work on it (e.g. it can be reordered more
freely).

This will also allow #155901 to avoid
hardcoding the ubsan trap.

Created using spr 1.3.4
@llvmbot
Copy link
Member

llvmbot commented Aug 29, 2025

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-llvm-ir

Author: Florian Mayer (fmayer)

Changes

This is consistent with the normal trap. This will allow more
optimizations to work on it (e.g. it can be reordered more
freely).


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

1 Files Affected:

  • (modified) llvm/include/llvm/IR/Intrinsics.td (+2-1)
diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td
index e0ee12391b31d..ca8bf6d7b912e 100644
--- a/llvm/include/llvm/IR/Intrinsics.td
+++ b/llvm/include/llvm/IR/Intrinsics.td
@@ -1834,7 +1834,8 @@ def int_trap : Intrinsic<[], [], [IntrNoReturn, IntrCold, IntrInaccessibleMemOnl
 def int_debugtrap : Intrinsic<[]>,
                     ClangBuiltin<"__builtin_debugtrap">;
 def int_ubsantrap : Intrinsic<[], [llvm_i8_ty],
-                              [IntrNoReturn, IntrCold, ImmArg<ArgIndex<0>>]>;
+                              [IntrNoReturn, IntrCold, ImmArg<ArgIndex<0>>,
+                               IntrInaccessibleMemOnly, IntrWriteMem]>;
 
 // Return true if ubsan check is allowed.
 def int_allow_ubsan_check : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_i8_ty],

@fmayer fmayer marked this pull request as draft August 29, 2025 20:31
Created using spr 1.3.4
@fmayer fmayer requested review from nikic and pcc August 29, 2025 21:32
@fmayer fmayer marked this pull request as ready for review August 29, 2025 21:33
@fmayer fmayer changed the title [UBSan] make ubsantrap IntrInaccessibleMemOnly [UBSan] make ubsantrap inaccessiblemem: write Aug 29, 2025
Created using spr 1.3.4
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Aug 29, 2025
Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, assuming the intended usage model for these does not include introspection of memory at the time of trap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category llvm:ir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants