[PATCH] D127835: [SCEV] recognize llvm.annotation intrinsic

ChenZheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 29 02:26:16 PDT 2022


shchenz updated this revision to Diff 440904.
shchenz added a comment.
Herald added a subscriber: jdoerfert.

address @nikic comment:

- explicitly doc the behavior for annotation intrinsics
- handle llvm.ptr.annotation too


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127835/new/

https://reviews.llvm.org/D127835

Files:
  llvm/docs/LangRef.rst
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/test/Analysis/ScalarEvolution/annotation-intrinsics.ll


Index: llvm/test/Analysis/ScalarEvolution/annotation-intrinsics.ll
===================================================================
--- llvm/test/Analysis/ScalarEvolution/annotation-intrinsics.ll
+++ llvm/test/Analysis/ScalarEvolution/annotation-intrinsics.ll
@@ -8,7 +8,7 @@
 ; CHECK-LABEL: 'annotatioin'
 ; CHECK-NEXT:  Classifying expressions for: @annotatioin
 ; CHECK-NEXT:    %1 = tail call i64 @llvm.annotation.i64(i64 %x, i8* null, i8* null, i32 0)
-; CHECK-NEXT:    --> %1 U: full-set S: full-set
+; CHECK-NEXT:    --> %x U: full-set S: full-set
 ; CHECK-NEXT:  Determining loop execution counts for: @annotatioin
 ;
   %1 = tail call i64 @llvm.annotation.i64(i64 %x, i8* null, i8* null, i32 0)
@@ -19,7 +19,7 @@
 ; CHECK-LABEL: 'ptr_annotatioin'
 ; CHECK-NEXT:  Classifying expressions for: @ptr_annotatioin
 ; CHECK-NEXT:    %1 = call i8* @llvm.ptr.annotation.p0i8(i8* %x, i8* null, i8* null, i32 0, i8* null)
-; CHECK-NEXT:    --> %1 U: full-set S: full-set
+; CHECK-NEXT:    --> %x U: full-set S: full-set
 ; CHECK-NEXT:  Determining loop execution counts for: @ptr_annotatioin
 ;
   %1 = call i8* @llvm.ptr.annotation.p0i8(i8* %x, i8* null, i8* null, i32 0, i8* null)
Index: llvm/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -7624,8 +7624,10 @@
         return getAddExpr(ClampedX, Y, SCEV::FlagNUW);
       }
       case Intrinsic::start_loop_iterations:
-        // A start_loop_iterations is just equivalent to the first operand for
-        // SCEV purposes.
+      case Intrinsic::annotation:
+      case Intrinsic::ptr_annotation:
+        // A start_loop_iterations or llvm.annotation or llvm.prt.annotation is
+        // just eqivalent to the first operand for SCEV purposes.
         return getSCEV(II->getArgOperand(0));
       default:
         break;
Index: llvm/docs/LangRef.rst
===================================================================
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -23575,8 +23575,9 @@
 
 This intrinsic allows annotation of a pointer to an integer with arbitrary
 strings. This can be useful for special purpose optimizations that want to look
-for these annotations. These have no other defined use; they are ignored by code
-generation and optimization.
+for these annotations. These have no other defined use; they are replaced with
+their first operand in instruction selection passes and in all other
+transformations and analysis.
 
 '``llvm.annotation.*``' Intrinsic
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -23614,7 +23615,8 @@
 This intrinsic allows annotations to be put on arbitrary expressions
 with arbitrary strings. This can be useful for special purpose
 optimizations that want to look for these annotations. These have no
-other defined use; they are ignored by code generation and optimization.
+other defined use; they are replaced with their first operand in instruction
+selection passes and in all other transformations and analysis.
 
 '``llvm.codeview.annotation``' Intrinsic
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127835.440904.patch
Type: text/x-patch
Size: 3152 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220629/68a813c6/attachment-0001.bin>


More information about the llvm-commits mailing list