[PATCH] D107356: [Lowering] Support lowering of llvm.experimental.ptr.provenance.
Jeroen Dobbelaere via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 15 14:14:06 PST 2023
jeroen.dobbelaere updated this revision to Diff 497801.
jeroen.dobbelaere added a comment.
Rebased to: 8c7cfa357280dd93d33b10bbba0fe33797e27d63 <https://reviews.llvm.org/rG8c7cfa357280dd93d33b10bbba0fe33797e27d63> (Feb 14, 2023)
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D107356/new/
https://reviews.llvm.org/D107356
Files:
llvm/lib/CodeGen/IntrinsicLowering.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/test/CodeGen/Generic/ptr_provenance.ll
Index: llvm/test/CodeGen/Generic/ptr_provenance.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/Generic/ptr_provenance.ll
@@ -0,0 +1,8 @@
+; RUN: llc < %s
+
+define i32* @test(i32* %p, i32* %p.provenance) {
+ %p.joined = call i32* @llvm.experimental.ptr.provenance.p0i32.p0i32(i32* %p, i32* %p.provenance)
+ ret i32* %p.joined
+}
+
+declare i32* @llvm.experimental.ptr.provenance.p0i32.p0i32(i32*, i32*) nounwind readnone
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -4164,6 +4164,7 @@
SmallVector<SDValue, 4> Chains(std::min(MaxParallelChains, NumValues));
EVT PtrVT = Ptr.getValueType();
+ const auto *PtrProvenance = I.getOptionalPtrProvenance().value_or(nullptr);
unsigned ChainI = 0;
for (unsigned i = 0; i != NumValues; ++i, ++ChainI) {
// Serializing loads here may result in excessive register pressure, and
@@ -4184,9 +4185,10 @@
DAG.getConstant(Offsets[i], dl, PtrVT),
Flags);
- SDValue L = DAG.getLoad(MemVTs[i], dl, Root, A,
- MachinePointerInfo(SV, Offsets[i]), Alignment,
- MMOFlags, AAInfo, Ranges);
+ SDValue L =
+ DAG.getLoad(MemVTs[i], dl, Root, A,
+ MachinePointerInfo(SV, Offsets[i], 0, PtrProvenance),
+ Alignment, MMOFlags, AAInfo, Ranges);
Chains[ChainI] = L.getValue(1);
if (MemVTs[i] != ValueVTs[i])
@@ -4313,6 +4315,7 @@
SDNodeFlags Flags;
Flags.setNoUnsignedWrap(true);
+ const auto *PtrProvenance = I.getOptionalPtrProvenance().value_or(nullptr);
unsigned ChainI = 0;
for (unsigned i = 0; i != NumValues; ++i, ++ChainI) {
// See visitLoad comments.
@@ -4328,7 +4331,8 @@
if (MemVTs[i] != ValueVTs[i])
Val = DAG.getPtrExtOrTrunc(Val, dl, MemVTs[i]);
SDValue St =
- DAG.getStore(Root, dl, Val, Add, MachinePointerInfo(PtrV, Offsets[i]),
+ DAG.getStore(Root, dl, Val, Add,
+ MachinePointerInfo(PtrV, Offsets[i], 0, PtrProvenance),
Alignment, MMOFlags, AAInfo);
Chains[ChainI] = St;
}
@@ -6764,6 +6768,7 @@
case Intrinsic::ptr_annotation:
case Intrinsic::launder_invariant_group:
case Intrinsic::strip_invariant_group:
+ case Intrinsic::experimental_ptr_provenance:
// Drop the intrinsic, but forward the value
setValue(&I, getValue(I.getOperand(0)));
return;
Index: llvm/lib/CodeGen/IntrinsicLowering.cpp
===================================================================
--- llvm/lib/CodeGen/IntrinsicLowering.cpp
+++ llvm/lib/CodeGen/IntrinsicLowering.cpp
@@ -333,6 +333,11 @@
case Intrinsic::var_annotation:
break; // Strip out these intrinsics
+ case Intrinsic::experimental_ptr_provenance:
+ // Drop the provenance, but 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: D107356.497801.patch
Type: text/x-patch
Size: 3281 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230215/964dcf8b/attachment-0001.bin>
More information about the llvm-commits
mailing list