[PATCH] D64904: [FunctionAttrs] Annotate "willreturn" for floating point and bit manipulation intrinsics.

Hideto Ueno via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 17 23:31:06 PDT 2019


uenoku created this revision.
uenoku added a reviewer: jdoerfert.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
uenoku retitled this revision from "[FunctionAttrs] Annotate "willreturn for floating point and bit manipulation intrinsics." to "[FunctionAttrs] Annotate "willreturn" for floating point and bit manipulation intrinsics.".

In D62801 <https://reviews.llvm.org/D62801>, new function attribute `willreturn` was introduced. In short, a function with `willreturn` is guaranteed to come back to the call site(more precise definition is in LangRef).

In this patch, willreturn is annotated for some basic arithmetic intrinsics(`maximum, sin, pow, log, floor, bitshift, ctlz, etc..`). I think these intrinsic are `willreturn` apparently. If, in `Intrinsics.td` annotation, there is a function which doesn't terminate for some input, let me know.


https://reviews.llvm.org/D64904

Files:
  clang/test/CodeGen/libcalls.c
  llvm/include/llvm/IR/Intrinsics.td
  llvm/test/Feature/intrinsics.ll
  llvm/test/Transforms/SLPVectorizer/X86/call.ll


Index: llvm/test/Transforms/SLPVectorizer/X86/call.ll
===================================================================
--- llvm/test/Transforms/SLPVectorizer/X86/call.ll
+++ llvm/test/Transforms/SLPVectorizer/X86/call.ll
@@ -173,5 +173,5 @@
 ; CHECK: declare <2 x double> @llvm.pow.v2f64(<2 x double>, <2 x double>) [[ATTR0]]
 ; CHECK: declare <2 x double> @llvm.exp2.v2f64(<2 x double>) [[ATTR0]]
 
-; CHECK: attributes [[ATTR0]] = { nounwind readnone speculatable }
+; CHECK: attributes [[ATTR0]] = { nounwind readnone speculatable willreturn }
 
Index: llvm/test/Feature/intrinsics.ll
===================================================================
--- llvm/test/Feature/intrinsics.ll
+++ llvm/test/Feature/intrinsics.ll
@@ -69,5 +69,5 @@
   ret void
 }
 
-; CHECK: attributes #0 = { nounwind readnone speculatable }
+; CHECK: attributes #0 = { nounwind readnone speculatable willreturn }
 ; CHECK: attributes #1 = { cold noreturn nounwind }
Index: llvm/include/llvm/IR/Intrinsics.td
===================================================================
--- llvm/include/llvm/IR/Intrinsics.td
+++ llvm/include/llvm/IR/Intrinsics.td
@@ -509,7 +509,7 @@
 // FIXME: Add version of these floating point intrinsics which allow non-default
 // rounding modes and FP exception handling.
 
-let IntrProperties = [IntrNoMem, IntrSpeculatable] in {
+let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
   def int_fma  : Intrinsic<[llvm_anyfloat_ty],
                            [LLVMMatchType<0>, LLVMMatchType<0>,
                             LLVMMatchType<0>]>;
@@ -551,19 +551,19 @@
 
 def int_minnum : Intrinsic<[llvm_anyfloat_ty],
   [LLVMMatchType<0>, LLVMMatchType<0>],
-  [IntrNoMem, IntrSpeculatable, Commutative]
+  [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
 >;
 def int_maxnum : Intrinsic<[llvm_anyfloat_ty],
   [LLVMMatchType<0>, LLVMMatchType<0>],
-  [IntrNoMem, IntrSpeculatable, Commutative]
+  [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
 >;
 def int_minimum : Intrinsic<[llvm_anyfloat_ty],
   [LLVMMatchType<0>, LLVMMatchType<0>],
-  [IntrNoMem, IntrSpeculatable, Commutative]
+  [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
 >;
 def int_maximum : Intrinsic<[llvm_anyfloat_ty],
   [LLVMMatchType<0>, LLVMMatchType<0>],
-  [IntrNoMem, IntrSpeculatable, Commutative]
+  [IntrNoMem, IntrSpeculatable, IntrWillReturn, Commutative]
 >;
 
 // NOTE: these are internal interfaces.
@@ -717,7 +717,7 @@
 //
 
 // None of these intrinsics accesses memory at all.
-let IntrProperties = [IntrNoMem, IntrSpeculatable] in {
+let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn] in {
   def int_bswap: Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
   def int_ctpop: Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
   def int_bitreverse : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>]>;
@@ -727,7 +727,7 @@
       [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>]>;
 }
 
-let IntrProperties = [IntrNoMem, IntrSpeculatable, ImmArg<1>] in {
+let IntrProperties = [IntrNoMem, IntrSpeculatable, IntrWillReturn, ImmArg<1>] in {
   def int_ctlz : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>;
   def int_cttz : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>, llvm_i1_ty]>;
 }
Index: clang/test/CodeGen/libcalls.c
===================================================================
--- clang/test/CodeGen/libcalls.c
+++ clang/test/CodeGen/libcalls.c
@@ -124,4 +124,4 @@
 }
 
 // CHECK-NO-DAG: attributes [[NUW_RN]] = { nounwind readnone{{.*}} }
-// CHECK-NO-DAG: attributes [[NUW_RNI]] = { nounwind readnone speculatable }
+// CHECK-NO-DAG: attributes [[NUW_RNI]] = { nounwind readnone speculatable willreturn }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64904.210486.patch
Type: text/x-patch
Size: 3708 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190718/0ff2e6ee/attachment.bin>


More information about the llvm-commits mailing list