[PATCH] D18066: Add some shortcuts in Value Propagation for alloca
David Li via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 11 16:09:33 PST 2016
davidxl added inline comments.
================
Comment at: lib/Transforms/Scalar/CorrelatedValuePropagation.cpp:322
@@ -318,1 +321,3 @@
+ // For pointer defined by AllocaInst, we know it is non-null.
if (Type && !CS.paramHasAttr(ArgNo + 1, Attribute::NonNull) &&
+ !isa<Constant>(V) &&
----------------
Maybe add a helper function to make this more readable:
if (mayHaveNullValue(...) && ...
================
Comment at: lib/Transforms/Scalar/CorrelatedValuePropagation.cpp:324
@@ +323,3 @@
+ !isa<Constant>(V) &&
+ (dyn_cast<AllocaInst>(V) ||
+ LVI->getPredicateAt(ICmpInst::ICMP_EQ, V,
----------------
Have a helper function like:
bool isValueNonNull(V) -- which does simple checks.
So the combined check becomes:
if (mayHaveNullValue(...) && (isValueNonNull(V) || LVI ....)) {
}
Note that isValueNonNull can also handle simple cases with gep:
foo() {
int a[10];
...
bar(&a[5]);
...
}
we know &a[5] can not be null.
================
Comment at: test/Transforms/CorrelatedValuePropagation/alloca.ll:4
@@ +3,3 @@
+; Shortcut in Correlated Value Propagation ensures not to take Lazy Value Info
+; analysis for %a.i because %a.i is defined by alloca and we know it is not-constant.
+; CHECK-NOT: LVI Getting block end value %a.i = alloca i64, align 8 at 'for.body'
----------------
not constant --> not null.
Repository:
rL LLVM
http://reviews.llvm.org/D18066
More information about the llvm-commits
mailing list