[PATCH] D156476: [IR] Mark `llvm.trap` as `memory(inaccessiblemem: write)`

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 27 12:15:05 PDT 2023


jdoerfert created this revision.
jdoerfert added reviewers: nikic, nlopes, arsenm, fhahn.
Herald added subscribers: StephenFan, bollu.
Herald added a project: All.
jdoerfert requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

Traps will not read/write the program state but they need an effect for
preservation, similar to `llvm.assume`. We really want a new memory kind
for that (see TODO), but for now `inaccessiblemem: write` is better than
any possible effect.


https://reviews.llvm.org/D156476

Files:
  llvm/include/llvm/IR/Intrinsics.td


Index: llvm/include/llvm/IR/Intrinsics.td
===================================================================
--- llvm/include/llvm/IR/Intrinsics.td
+++ llvm/include/llvm/IR/Intrinsics.td
@@ -1670,8 +1670,10 @@
 
 ///===-------------------------- Other Intrinsics --------------------------===//
 //
-def int_trap : Intrinsic<[], [], [IntrNoReturn, IntrCold]>,
-               ClangBuiltin<"__builtin_trap">;
+// TODO: We should introduce a new memory kind fo traps (and other side effects 
+//       we only model to keep things alive).
+def int_trap : Intrinsic<[], [], [IntrNoReturn, IntrCold, IntrInaccessibleMemOnly,
+               WriteOnly]>, ClangBuiltin<"__builtin_trap">;
 def int_debugtrap : Intrinsic<[]>,
                     ClangBuiltin<"__builtin_debugtrap">;
 def int_ubsantrap : Intrinsic<[], [llvm_i8_ty],


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156476.544881.patch
Type: text/x-patch
Size: 826 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230727/8a18bb3c/attachment.bin>


More information about the llvm-commits mailing list