[PATCH] D153945: [ValueTracking] Guaranteed well-defined if parameter has a dereferecable_or_null attribute
luxufan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 28 00:51:18 PDT 2023
StephenFan created this revision.
StephenFan added a reviewer: nikic.
Herald added subscribers: okura, kuter, hiraditya.
Herald added a project: All.
StephenFan requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: sstefan1.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D153945
Files:
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/Attributor/nocapture-2.ll
Index: llvm/test/Transforms/Attributor/nocapture-2.ll
===================================================================
--- llvm/test/Transforms/Attributor/nocapture-2.ll
+++ llvm/test/Transforms/Attributor/nocapture-2.ll
@@ -174,9 +174,9 @@
; TUNIT-NEXT: [[TMP0:%.*]] = bitcast i32* [[A]] to i16*
; TUNIT-NEXT: [[CALL:%.*]] = call dereferenceable_or_null(4) i8* @scc_C(i16* noalias nofree noundef nonnull readnone dereferenceable(4) "no-capture-maybe-returned" [[TMP0]]) #[[ATTR9:[0-9]+]]
; TUNIT-NEXT: [[TMP1:%.*]] = bitcast i8* [[CALL]] to double*
-; TUNIT-NEXT: [[CALL1:%.*]] = call dereferenceable_or_null(4) i64* @scc_B(double* noalias nofree readnone dereferenceable_or_null(8) "no-capture-maybe-returned" [[TMP1]]) #[[ATTR9]]
+; TUNIT-NEXT: [[CALL1:%.*]] = call dereferenceable_or_null(4) i64* @scc_B(double* noalias nofree noundef readnone dereferenceable_or_null(8) "no-capture-maybe-returned" [[TMP1]]) #[[ATTR9]]
; TUNIT-NEXT: [[TMP2:%.*]] = bitcast i64* [[CALL1]] to i32*
-; TUNIT-NEXT: [[CALL2:%.*]] = call dereferenceable_or_null(4) float* @scc_A(i32* noalias nofree readnone dereferenceable_or_null(4) "no-capture-maybe-returned" [[TMP2]]) #[[ATTR9]]
+; TUNIT-NEXT: [[CALL2:%.*]] = call dereferenceable_or_null(4) float* @scc_A(i32* noalias nofree noundef readnone dereferenceable_or_null(4) "no-capture-maybe-returned" [[TMP2]]) #[[ATTR9]]
; TUNIT-NEXT: [[TMP3:%.*]] = bitcast float* [[CALL2]] to i32*
; TUNIT-NEXT: br label [[COND_END:%.*]]
; TUNIT: cond.false:
@@ -196,9 +196,9 @@
; CGSCC-NEXT: [[TMP0:%.*]] = bitcast i32* [[A]] to i16*
; CGSCC-NEXT: [[CALL:%.*]] = call dereferenceable_or_null(4) i8* @scc_C(i16* noalias nofree noundef nonnull readnone dereferenceable(4) "no-capture-maybe-returned" [[TMP0]]) #[[ATTR10:[0-9]+]]
; CGSCC-NEXT: [[TMP1:%.*]] = bitcast i8* [[CALL]] to double*
-; CGSCC-NEXT: [[CALL1:%.*]] = call dereferenceable_or_null(4) i64* @scc_B(double* noalias nofree readnone dereferenceable_or_null(8) "no-capture-maybe-returned" [[TMP1]]) #[[ATTR10]]
+; CGSCC-NEXT: [[CALL1:%.*]] = call dereferenceable_or_null(4) i64* @scc_B(double* noalias nofree noundef readnone dereferenceable_or_null(8) "no-capture-maybe-returned" [[TMP1]]) #[[ATTR10]]
; CGSCC-NEXT: [[TMP2:%.*]] = bitcast i64* [[CALL1]] to i32*
-; CGSCC-NEXT: [[CALL2:%.*]] = call dereferenceable_or_null(4) float* @scc_A(i32* noalias nofree readnone dereferenceable_or_null(4) "no-capture-maybe-returned" [[TMP2]]) #[[ATTR10]]
+; CGSCC-NEXT: [[CALL2:%.*]] = call dereferenceable_or_null(4) float* @scc_A(i32* noalias nofree noundef readnone dereferenceable_or_null(4) "no-capture-maybe-returned" [[TMP2]]) #[[ATTR10]]
; CGSCC-NEXT: [[TMP3:%.*]] = bitcast float* [[CALL2]] to i32*
; CGSCC-NEXT: br label [[COND_END:%.*]]
; CGSCC: cond.false:
@@ -243,9 +243,9 @@
; TUNIT-NEXT: [[TMP0:%.*]] = bitcast double* [[A]] to i32*
; TUNIT-NEXT: [[CALL:%.*]] = call dereferenceable_or_null(4) float* @scc_A(i32* noalias nofree noundef nonnull readnone dereferenceable(8) "no-capture-maybe-returned" [[TMP0]]) #[[ATTR9]]
; TUNIT-NEXT: [[TMP1:%.*]] = bitcast float* [[CALL]] to double*
-; TUNIT-NEXT: [[CALL1:%.*]] = call dereferenceable_or_null(4) i64* @scc_B(double* noalias nofree readnone dereferenceable_or_null(8) "no-capture-maybe-returned" [[TMP1]]) #[[ATTR9]]
+; TUNIT-NEXT: [[CALL1:%.*]] = call dereferenceable_or_null(4) i64* @scc_B(double* noalias nofree noundef readnone dereferenceable_or_null(8) "no-capture-maybe-returned" [[TMP1]]) #[[ATTR9]]
; TUNIT-NEXT: [[TMP2:%.*]] = bitcast i64* [[CALL1]] to i16*
-; TUNIT-NEXT: [[CALL2:%.*]] = call dereferenceable_or_null(4) i8* @scc_C(i16* noalias nofree readnone dereferenceable_or_null(4) "no-capture-maybe-returned" [[TMP2]]) #[[ATTR9]]
+; TUNIT-NEXT: [[CALL2:%.*]] = call dereferenceable_or_null(4) i8* @scc_C(i16* noalias nofree noundef readnone dereferenceable_or_null(4) "no-capture-maybe-returned" [[TMP2]]) #[[ATTR9]]
; TUNIT-NEXT: br label [[COND_END:%.*]]
; TUNIT: cond.false:
; TUNIT-NEXT: [[TMP3:%.*]] = bitcast double* [[A]] to i8*
@@ -265,9 +265,9 @@
; CGSCC-NEXT: [[TMP0:%.*]] = bitcast double* [[A]] to i32*
; CGSCC-NEXT: [[CALL:%.*]] = call dereferenceable_or_null(4) float* @scc_A(i32* noalias nofree noundef nonnull readnone dereferenceable(8) "no-capture-maybe-returned" [[TMP0]]) #[[ATTR10]]
; CGSCC-NEXT: [[TMP1:%.*]] = bitcast float* [[CALL]] to double*
-; CGSCC-NEXT: [[CALL1:%.*]] = call dereferenceable_or_null(4) i64* @scc_B(double* noalias nofree readnone dereferenceable_or_null(8) "no-capture-maybe-returned" [[TMP1]]) #[[ATTR10]]
+; CGSCC-NEXT: [[CALL1:%.*]] = call dereferenceable_or_null(4) i64* @scc_B(double* noalias nofree noundef readnone dereferenceable_or_null(8) "no-capture-maybe-returned" [[TMP1]]) #[[ATTR10]]
; CGSCC-NEXT: [[TMP2:%.*]] = bitcast i64* [[CALL1]] to i16*
-; CGSCC-NEXT: [[CALL2:%.*]] = call dereferenceable_or_null(4) i8* @scc_C(i16* noalias nofree readnone dereferenceable_or_null(4) "no-capture-maybe-returned" [[TMP2]]) #[[ATTR10]]
+; CGSCC-NEXT: [[CALL2:%.*]] = call dereferenceable_or_null(4) i8* @scc_C(i16* noalias nofree noundef readnone dereferenceable_or_null(4) "no-capture-maybe-returned" [[TMP2]]) #[[ATTR10]]
; CGSCC-NEXT: br label [[COND_END:%.*]]
; CGSCC: cond.false:
; CGSCC-NEXT: [[TMP3:%.*]] = bitcast double* [[A]] to i8*
@@ -321,7 +321,7 @@
; TUNIT: cond.end:
; TUNIT-NEXT: [[COND:%.*]] = phi i8* [ [[TMP1]], [[COND_TRUE]] ], [ [[CALL2]], [[COND_FALSE]] ]
; TUNIT-NEXT: [[TMP2:%.*]] = bitcast i8* [[COND]] to i32*
-; TUNIT-NEXT: [[CALL3:%.*]] = call dereferenceable_or_null(4) float* @scc_A(i32* noalias nofree readnone dereferenceable_or_null(4) "no-capture-maybe-returned" [[TMP2]]) #[[ATTR9]]
+; TUNIT-NEXT: [[CALL3:%.*]] = call dereferenceable_or_null(4) float* @scc_A(i32* noalias nofree noundef readnone dereferenceable_or_null(4) "no-capture-maybe-returned" [[TMP2]]) #[[ATTR9]]
; TUNIT-NEXT: [[TMP3:%.*]] = bitcast float* [[CALL3]] to i8*
; TUNIT-NEXT: ret i8* [[TMP3]]
;
@@ -345,7 +345,7 @@
; CGSCC: cond.end:
; CGSCC-NEXT: [[COND:%.*]] = phi i8* [ [[TMP1]], [[COND_TRUE]] ], [ [[CALL2]], [[COND_FALSE]] ]
; CGSCC-NEXT: [[TMP2:%.*]] = bitcast i8* [[COND]] to i32*
-; CGSCC-NEXT: [[CALL3:%.*]] = call dereferenceable_or_null(4) float* @scc_A(i32* noalias nofree readnone dereferenceable_or_null(4) "no-capture-maybe-returned" [[TMP2]]) #[[ATTR10]]
+; CGSCC-NEXT: [[CALL3:%.*]] = call dereferenceable_or_null(4) float* @scc_A(i32* noalias nofree noundef readnone dereferenceable_or_null(4) "no-capture-maybe-returned" [[TMP2]]) #[[ATTR10]]
; CGSCC-NEXT: [[TMP3:%.*]] = bitcast float* [[CALL3]] to i8*
; CGSCC-NEXT: ret i8* [[TMP3]]
;
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -6896,7 +6896,8 @@
Operands.push_back(CB->getCalledOperand());
for (unsigned i = 0; i < CB->arg_size(); ++i) {
if (CB->paramHasAttr(i, Attribute::NoUndef) ||
- CB->paramHasAttr(i, Attribute::Dereferenceable))
+ CB->paramHasAttr(i, Attribute::Dereferenceable) ||
+ CB->paramHasAttr(i, Attribute::DereferenceableOrNull))
Operands.push_back(CB->getArgOperand(i));
}
break;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153945.535267.patch
Type: text/x-patch
Size: 7449 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230628/e377370c/attachment.bin>
More information about the llvm-commits
mailing list