[llvm] [DSE] Update dereferenceable attributes when adjusting memintrinsic ptr (PR #125073)

Björn Pettersson via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 30 14:53:52 PST 2025


================
@@ -563,6 +563,22 @@ static void shortenAssignment(Instruction *Inst, Value *OriginalDest,
   for_each(LinkedDVRAssigns, InsertAssignForOverlap);
 }
 
+// Helper to trim or drop any dereferencable/dereferencable_or_null attributes
+// for a given argument, based on the new access being restricted to derefence
+// bytes in the range [Offset, Offset+Size).
+static void trimDereferencableAttrs(AnyMemIntrinsic *Intrinsic, unsigned Arg,
+                                    uint64_t Offset, uint64_t Size) {
+  uint64_t End = Offset + Size;
+  if (Intrinsic->getParamDereferenceableBytes(Arg) >= End)
+    Intrinsic->addDereferenceableParamAttr(Arg, Size);
----------------
bjope wrote:

Ok, thanks. I wasn't quite sure if dropping the attributes could have some downsides, but just dropping them is simpler so I like that solution. So I've updated the patch to just drop the attributes instead of trying to adjust them.

https://github.com/llvm/llvm-project/pull/125073


More information about the llvm-commits mailing list