[PATCH] D70789: [Attributor] Remove dereferenceable_or_null when nonull is present
Hideto Ueno via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 27 22:48:33 PST 2019
uenoku updated this revision to Diff 231351.
uenoku added a comment.
Remove fixme
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70789/new/
https://reviews.llvm.org/D70789
Files:
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/test/Transforms/FunctionAttrs/dereferenceable.ll
Index: llvm/test/Transforms/FunctionAttrs/dereferenceable.ll
===================================================================
--- llvm/test/Transforms/FunctionAttrs/dereferenceable.ll
+++ llvm/test/Transforms/FunctionAttrs/dereferenceable.ll
@@ -30,8 +30,7 @@
}
define i32* @test3_2(i32* dereferenceable_or_null(32) %0) local_unnamed_addr {
-; FIXME: We should not have both deref(x) and deref_or_null(y) with x >= y.
-; ATTRIBUTOR: define nonnull dereferenceable(16) i32* @test3_2(i32* nofree nonnull readnone dereferenceable(32) dereferenceable_or_null(32) "no-capture-maybe-returned" %0)
+; ATTRIBUTOR: define nonnull dereferenceable(16) i32* @test3_2(i32* nofree nonnull readnone dereferenceable(32) "no-capture-maybe-returned" %0)
%ret = getelementptr inbounds i32, i32* %0, i64 4
ret i32* %ret
}
@@ -202,3 +201,9 @@
store i32 1, i32* %q
ret i32* %q
}
+
+define void @deref_or_null_and_nonnull(i32* dereferenceable_or_null(100) %0) {
+; ATTRIBUTOR: define void @deref_or_null_and_nonnull(i32* nocapture nofree nonnull writeonly dereferenceable(100) %0)
+ store i32 1, i32* %0
+ ret void
+}
Index: llvm/lib/Transforms/IPO/Attributor.cpp
===================================================================
--- llvm/lib/Transforms/IPO/Attributor.cpp
+++ llvm/lib/Transforms/IPO/Attributor.cpp
@@ -2971,6 +2971,16 @@
return TrackUse;
}
+ /// See AbstractAttribute::manifest(...).
+ ChangeStatus manifest(Attributor &A) override {
+ ChangeStatus Change = AADereferenceable::manifest(A);
+ if (isAssumedNonNull() && hasAttr(Attribute::DereferenceableOrNull)) {
+ removeAttrs({Attribute::DereferenceableOrNull});
+ return ChangeStatus::CHANGED;
+ }
+ return Change;
+ }
+
void getDeducedAttributes(LLVMContext &Ctx,
SmallVectorImpl<Attribute> &Attrs) const override {
// TODO: Add *_globally support
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70789.231351.patch
Type: text/x-patch
Size: 1893 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191128/a7cc339c/attachment.bin>
More information about the llvm-commits
mailing list