[PATCH] D136929: [Statepoint] Use default attributes for some GC intrinsics
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 28 02:27:39 PDT 2022
nikic created this revision.
nikic added reviewers: reames, mkazantsev, skatkov.
Herald added a project: All.
nikic requested review of this revision.
Herald added subscribers: llvm-commits, jdoerfert.
Herald added a project: LLVM.
This adds the default intrinsic attributes (nosync, nofree, nocallback, willreturn) to the gc.result, gc.relocate, gc.pointer.base and gc.pointer.offset intrinsics. As far as I understand, all of these are supposed to be pure. Some quotes from LangRef:
> A gc.result is modeled as a ‘readnone’ pure function. It has no side effects since it is just a projection of the return value of the previous call represented by the gc.statepoint.
> A gc.relocate is modeled as a readnone pure function. It has no side effects since it is just a way to extract information about work done during the actual call modeled by the gc.statepoint.
Having willreturn in particular will be important to avoid optimization regressions in the future.
https://reviews.llvm.org/D136929
Files:
llvm/include/llvm/IR/Intrinsics.td
llvm/test/Transforms/RewriteStatepointsForGC/statepoint-attrs.ll
Index: llvm/test/Transforms/RewriteStatepointsForGC/statepoint-attrs.ll
===================================================================
--- llvm/test/Transforms/RewriteStatepointsForGC/statepoint-attrs.ll
+++ llvm/test/Transforms/RewriteStatepointsForGC/statepoint-attrs.ll
@@ -20,6 +20,6 @@
attributes #1 = { norecurse noimplicitfloat }
;.
-; CHECK: attributes #[[ATTR0:[0-9]+]] = { nounwind readnone }
+; CHECK: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind readnone willreturn }
; CHECK: attributes #[[ATTR1]] = { noimplicitfloat norecurse }
;.
Index: llvm/include/llvm/IR/Intrinsics.td
===================================================================
--- llvm/include/llvm/IR/Intrinsics.td
+++ llvm/include/llvm/IR/Intrinsics.td
@@ -1248,21 +1248,20 @@
ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<3>>,
ImmArg<ArgIndex<4>>]>;
-def int_experimental_gc_result : Intrinsic<[llvm_any_ty], [llvm_token_ty],
- [IntrNoMem]>;
-def int_experimental_gc_relocate : Intrinsic<[llvm_any_ty],
- [llvm_token_ty, llvm_i32_ty,
- llvm_i32_ty],
- [IntrNoMem, ImmArg<ArgIndex<1>>,
- ImmArg<ArgIndex<2>>]>;
-
-def int_experimental_gc_get_pointer_base : Intrinsic<[llvm_anyptr_ty],
- [llvm_anyptr_ty], [IntrNoMem, IntrWillReturn,
- ReadNone<ArgIndex<0>>, NoCapture<ArgIndex<0>>]>;
-
-def int_experimental_gc_get_pointer_offset : Intrinsic<[llvm_i64_ty],
- [llvm_anyptr_ty], [IntrNoMem, IntrWillReturn,
- ReadNone<ArgIndex<0>>, NoCapture<ArgIndex<0>>]>;
+def int_experimental_gc_result : DefaultAttrsIntrinsic<
+ [llvm_any_ty], [llvm_token_ty], [IntrNoMem]>;
+
+def int_experimental_gc_relocate : DefaultAttrsIntrinsic<
+ [llvm_any_ty], [llvm_token_ty, llvm_i32_ty, llvm_i32_ty],
+ [IntrNoMem, ImmArg<ArgIndex<1>>, ImmArg<ArgIndex<2>>]>;
+
+def int_experimental_gc_get_pointer_base : DefaultAttrsIntrinsic<
+ [llvm_anyptr_ty], [llvm_anyptr_ty],
+ [IntrNoMem, IntrWillReturn, ReadNone<ArgIndex<0>>, NoCapture<ArgIndex<0>>]>;
+
+def int_experimental_gc_get_pointer_offset : DefaultAttrsIntrinsic<
+ [llvm_i64_ty], [llvm_anyptr_ty],
+ [IntrNoMem, IntrWillReturn, ReadNone<ArgIndex<0>>, NoCapture<ArgIndex<0>>]>;
//===------------------------ Coroutine Intrinsics ---------------===//
// These are documented in docs/Coroutines.rst
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136929.471454.patch
Type: text/x-patch
Size: 2616 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221028/4805f3d0/attachment.bin>
More information about the llvm-commits
mailing list