[PATCH] D89054: [WIP][IR] Make `llvm.assume` `readnone`

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 8 09:20:10 PDT 2020


jdoerfert created this revision.
jdoerfert added a reviewer: llvm-commits.
Herald added a subscriber: bollu.
Herald added a project: LLVM.
jdoerfert requested review of this revision.

Note: This is not a full commit. No tests were changed. Used for

  discussion

The `llvm.assume` intrinsic was historically not `readnone` because
control dependences need to be preserved. However, the intrinsic can
nowadays be represented as what it is, potentially UB if the condition
is false (or an operand bundle is violated). No effect but potentially
UB is `readnone` (in contrast to `speculatable`). While here we add
`nosync` and `nofree` to `llvm.assume`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89054

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
@@ -518,9 +518,13 @@
 
 def int_readcyclecounter : Intrinsic<[llvm_i64_ty]>;
 
-// The assume intrinsic is marked as arbitrarily writing so that proper
-// control dependencies will be maintained.
+// The assume intrinsic is *not* marked as speculatable but without memory
+// effects. Proper control dependencies will be maintained because weakening
+// them would potentially introduce UB on paths that did not contain it before.
 def int_assume        : Intrinsic<[], [llvm_i1_ty], [IntrWillReturn,
+                                                     IntrNoMem,
+                                                     IntrNoSync,
+                                                     IntrNoFree,
                                                      NoUndef<ArgIndex<0>>]>;
 
 // Stack Protector Intrinsic - The stackprotector intrinsic writes the stack


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89054.296993.patch
Type: text/x-patch
Size: 1045 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201008/31955fdb/attachment.bin>


More information about the llvm-commits mailing list