[PATCH] D76149: [AssumeBundles] Use assume bundles in isKnownNonZero
Johannes Doerfert via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 13 21:02:15 PDT 2020
jdoerfert added inline comments.
================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:679
+ }
+
for (auto &AssumeVH : Q.AC->assumptionsFor(V)) {
----------------
jdoerfert wrote:
> I feel we need to move some/all of this complexity into `KnowledgeRetention`.
> Ideally, one (or at least I) would like something along the lines of:
>
> ```
> if (Q.DT && Q.CtxI) {
> SmallVector<AttributeKind, 2> AttrKinds;
> AttrKinds.append(Attribute::NonNull);
> if (llvm::NullPointerIsDefined(Q.CtxI->getFunction(), V->getType()->getPointerAddressSpace()))
> AttrKinds.append(Attribute::Dereferenceable);
> if (hasKnownAttributeDominatingInst(*V, AttrKinds, *Q.DT, *Q.CtxI))
> return true;
> }
> ```
>
> The impl of `hasKnownAttributeDominatingInst` does the required steps, thus looking at the uses. Actually all the steps should be in `getKnownNonNullAndDerefBytesForUse` which lives in Attributor.cpp. It does actually more, e.g., use in a call site or and recursive queries via the Attributor, but we should somehow share this logic.
>
> My suggestion:
> 1) Something similar to the above interface in KnowledgeRetention
> 2) Make Attributor etc. in `getKnownNonNullAndDerefBytesForUse` optional.
> 3) Teach `getKnownNonNullAndDerefBytesForUse` about assume uses.
> 3) Make the `getKnownNonNullAndDerefBytesForUse` logic public and invoke it if we have an attribute kind NonNull or Dereferenceable[_or_null].
>
> WDYT?
Maybe `hasKnownAttributeDominatingInst` should not need to look for `deref` at all as we derive it from `deref` in the Attributor. Otherwise we could make a helper to encapsulate the `NullPointerIsDefined` stuff.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76149/new/
https://reviews.llvm.org/D76149
More information about the llvm-commits
mailing list