[llvm] [DSE] Update dereferenceable attributes when adjusting memintrinsic ptr (PR #125073)
Björn Pettersson via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 31 01:33:37 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:
I see some alternatives:
1) Instead of having an explicit set of attributes to drop we could use prepare a set of attributes that is safe to keep. And then use that for the filtering. That would more future proof in case new attributes are added.
2) Another idea is to add some kind of support in Attributes.h (or similar). Such as a more centralized helper method to "filter attributes based on access being narrowed" (and then it might be easier to find and update that when adding new attributes). This could also just be an AttributeMask similar to getUBImplyingAttributes().
https://github.com/llvm/llvm-project/pull/125073
More information about the llvm-commits
mailing list