[PATCH] D68497: [PATCH 08/26] [noalias] [CodeGen] Support lowering of noalias intrinsics
Jeroen Dobbelaere via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 14 03:17:23 PDT 2020
jeroen.dobbelaere updated this revision to Diff 277739.
jeroen.dobbelaere added a comment.
Rebased to c06b7e2ab5167ad031745a706204abed1aefd823 <https://reviews.llvm.org/rGc06b7e2ab5167ad031745a706204abed1aefd823> (July 14, 2020)
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68497/new/
https://reviews.llvm.org/D68497
Files:
llvm/lib/CodeGen/IntrinsicLowering.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/test/CodeGen/Generic/noalias.ll
llvm/test/CodeGen/Generic/provenance.noalias.ll
Index: llvm/test/CodeGen/Generic/provenance.noalias.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/Generic/provenance.noalias.ll
@@ -0,0 +1,15 @@
+; RUN: llc < %s
+
+define i32* @test(i32* %p) {
+ %p.decl = tail call i8* @llvm.noalias.decl.p0i8.p0p0i32.i32(i32** null, i32 0, metadata !0)
+ %p.provenance = tail call i32* @llvm.provenance.noalias.p0i32.p0i8.p0p0i32.p0p0i32.i32(i32* %p, i8* %p.decl, i32** null, i32** undef, i32 0, metadata !0)
+ %p.guard = call i32* @llvm.noalias.arg.guard.p0i32.p0i32(i32* %p, i32* %p.provenance)
+ ret i32* %p.guard
+}
+
+declare i8* @llvm.noalias.decl.p0i8.p0p0i32.i32(i32**, i32, metadata) argmemonly nounwind
+declare i32* @llvm.provenance.noalias.p0i32.p0i8.p0p0i32.p0p0i32.i32(i32*, i8*, i32**, i32**, i32, metadata) argmemonly nounwind speculatable
+declare i32* @llvm.noalias.arg.guard.p0i32.p0i32(i32*, i32*) nounwind readnone
+
+!0 = !{!0, !"some domain"}
+!1 = !{!1, !0, !"some scope"}
Index: llvm/test/CodeGen/Generic/noalias.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/Generic/noalias.ll
@@ -0,0 +1,13 @@
+; RUN: llc < %s
+
+define i32* @test(i32* %p) {
+ %p.decl = tail call i8* @llvm.noalias.decl.p0i8.p0p0i32.i32(i32** null, i32 0, metadata !0)
+ %v = call i32* @llvm.noalias.p0i32.p0i8.p0p0i32.i32(i32* %p, i8* %p.decl, i32** null, i32 0, metadata !0)
+ ret i32* %v
+}
+
+declare i8* @llvm.noalias.decl.p0i8.p0p0i32.i32(i32**, i32, metadata) argmemonly nounwind
+declare i32* @llvm.noalias.p0i32.p0i8.p0p0i32.i32(i32*, i8*, i32**, i32, metadata) argmemonly nounwind speculatable
+
+!0 = !{!0, !"some domain"}
+!1 = !{!1, !0, !"some scope"}
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -6464,11 +6464,21 @@
case Intrinsic::annotation:
case Intrinsic::ptr_annotation:
+ case Intrinsic::noalias:
case Intrinsic::launder_invariant_group:
case Intrinsic::strip_invariant_group:
+ case Intrinsic::provenance_noalias:
+ case Intrinsic::noalias_arg_guard:
+ case Intrinsic::noalias_copy_guard:
// Drop the intrinsic, but forward the value
setValue(&I, getValue(I.getOperand(0)));
return;
+ case Intrinsic::noalias_decl:
+ // Generate a dummy value - it will never be used and should get optimized
+ // away
+ setValue(&I, DAG.getUNDEF(TLI.getPointerTy(DAG.getDataLayout())));
+ return;
+
case Intrinsic::assume:
case Intrinsic::var_annotation:
case Intrinsic::sideeffect:
Index: llvm/lib/CodeGen/IntrinsicLowering.cpp
===================================================================
--- llvm/lib/CodeGen/IntrinsicLowering.cpp
+++ llvm/lib/CodeGen/IntrinsicLowering.cpp
@@ -332,6 +332,15 @@
case Intrinsic::var_annotation:
break; // Strip out these intrinsics
+ case Intrinsic::noalias_decl:
+ case Intrinsic::noalias:
+ case Intrinsic::provenance_noalias:
+ case Intrinsic::noalias_arg_guard:
+ case Intrinsic::noalias_copy_guard:
+ // Just forward the value
+ CI->replaceAllUsesWith(CI->getOperand(0));
+ break;
+
case Intrinsic::memcpy: {
Type *IntPtr = DL.getIntPtrType(Context);
Value *Size = Builder.CreateIntCast(CI->getArgOperand(2), IntPtr,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68497.277739.patch
Type: text/x-patch
Size: 3425 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200714/400f9cc0/attachment.bin>
More information about the llvm-commits
mailing list