[PATCH] D68503: [PATCH 20/38] [noalias] D9386: llvm.noalias - CaptureTracking needs to look through them
Jeroen Dobbelaere via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 4 14:49:30 PDT 2019
jeroen.dobbelaere created this revision.
jeroen.dobbelaere added reviewers: hfinkel, jdoerfert.
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>.
Rebase of D9386 <https://reviews.llvm.org/D9386>
https://reviews.llvm.org/D68503
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
@@ -98,6 +98,22 @@
ret i32 %val
}
+; 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)
+ br label %l
+l:
+ %x = phi i32* [ %pa, %e ]
+ %y = phi i32* [ %q, %e ]
+ %tmp = bitcast i32* %x to i32* ; <i32*> [#uses=2]
+ %tmp2 = select i1 %b, i32* %tmp, i32* %y
+ %val = load i32, i32* %tmp2 ; <i32> [#uses=1]
+ store i32 0, i32* %tmp
+ 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:
@@ -323,3 +339,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
+
+!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
@@ -26,6 +26,7 @@
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
+#include "llvm/IR/Intrinsics.h"
using namespace llvm;
@@ -254,6 +255,12 @@
switch (I->getOpcode()) {
case Instruction::Call:
case Instruction::Invoke: {
+ if (auto *II = dyn_cast<IntrinsicInst>(I))
+ if (II->getIntrinsicID() == Intrinsic::noalias) {
+ AddUses(I);
+ break;
+ }
+
auto *Call = cast<CallBase>(I);
// Not captured if the callee is readonly, doesn't return a copy through
// its return value and doesn't unwind (a readonly function can leak bits
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68503.223306.patch
Type: text/x-patch
Size: 1994 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191004/10a29e6f/attachment.bin>
More information about the llvm-commits
mailing list