[PATCH] D68504: [PATCH 21/38] [noalias] CaptureTracking: learn about new noalias intrinsics

Jeroen Dobbelaere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 4 14:50:43 PDT 2019


jeroen.dobbelaere created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

This is part of the series started by D68484 <https://reviews.llvm.org/D68484>.

Note: this is a stable point and tests should run fine with the patches applied up to this point.


https://reviews.llvm.org/D68504

Files:
  llvm/lib/Analysis/CaptureTracking.cpp
  llvm/test/Transforms/FunctionAttrs/nocapture.ll


Index: llvm/test/Transforms/FunctionAttrs/nocapture.ll
===================================================================
--- llvm/test/Transforms/FunctionAttrs/nocapture.ll
+++ llvm/test/Transforms/FunctionAttrs/nocapture.ll
@@ -101,7 +101,7 @@
 ; EITHER: define i32 @nc1a(i32* %q, i32* nocapture %p, i1 %b)
 define i32 @nc1a(i32* %q, i32* %p, i1 %b) {
 e:
-        %pa = call i32* @llvm.noalias.p0i32(i32* %p, metadata !1)
+        %pa = call i32* @llvm.noalias.p0i32.p0i8.p0p0i32.i32(i32* %p, i8* null, i32** null, i32 0, metadata !1)
 	br label %l
 l:
 	%x = phi i32* [ %pa, %e ]
@@ -114,6 +114,24 @@
 	ret i32 %val
 }
 
+; EITHER: define i32 @nc1b(i32* %q, i32* nocapture %p, i1 %b)
+define i32 @nc1b(i32* %q, i32* %p, i1 %b) {
+e:
+        %side.p = call i32* @llvm.side.noalias.p0i32.p0i8.p0p0i32.p0p0i32.i32(i32* %p, i8* null, i32** null, i32** null, i32 0, metadata !1)
+	br label %l
+l:
+	%x = phi i32* [ %p, %e ]
+	%side.x = phi i32* [ %side.p, %e ]
+	%y = phi i32* [ %q, %e ]
+	%tmp = bitcast i32* %x to i32*		; <i32*> [#uses=2]
+	%tmp2 = select i1 %b, i32* %tmp, i32* %y
+        %side.tmp2 = select i1 %b, i32* %side.x, i32* %y
+	%val = load i32, i32* %tmp2		; <i32> [#uses=1]
+	store i32 0, i32* %tmp, noalias_sidechannel i32* %side.tmp2
+	store i32* %y, i32** @g
+	ret i32 %val
+}
+
 ; EITHER: define i32 @nc1_addrspace(i32* %q, i32 addrspace(1)* nocapture %p, i1 %b)
 define i32 @nc1_addrspace(i32* %q, i32 addrspace(1)* %p, i1 %b) {
 e:
@@ -340,7 +358,8 @@
 declare i8* @llvm.launder.invariant.group.p0i8(i8*)
 declare i8* @llvm.strip.invariant.group.p0i8(i8*)
 
-declare i32* @llvm.noalias.p0i32(i32*, metadata) nounwind
+declare i32*  @llvm.noalias.p0i32.p0i8.p0p0i32.i32(i32*, i8*, i32**, i32, metadata ) nounwind
+declare i32*  @llvm.side.noalias.p0i32.p0i8.p0p0i32.p0p0i32.i32(i32*, i8*, i32**, i32**, i32, metadata ) nounwind
 
 !0 = !{!0, !"some domain"}
 !1 = !{!1, !0, !"some scope"}
Index: llvm/lib/Analysis/CaptureTracking.cpp
===================================================================
--- llvm/lib/Analysis/CaptureTracking.cpp
+++ llvm/lib/Analysis/CaptureTracking.cpp
@@ -256,7 +256,10 @@
     case Instruction::Call:
     case Instruction::Invoke: {
       if (auto *II = dyn_cast<IntrinsicInst>(I))
-        if (II->getIntrinsicID() == Intrinsic::noalias) {
+        if (II->getIntrinsicID() == Intrinsic::noalias ||
+            II->getIntrinsicID() == Intrinsic::side_noalias ||
+            II->getIntrinsicID() == Intrinsic::noalias_arg_guard ||
+            II->getIntrinsicID() == Intrinsic::noalias_copy_guard) {
           AddUses(I);
           break;
         }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68504.223307.patch
Type: text/x-patch
Size: 2615 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191004/9ba173e4/attachment.bin>


More information about the llvm-commits mailing list