llvm-project/llvm/test/Analysis/ValueTracking
Juneyoung Lee 4479c0c2c0 Allow nonnull/align attribute to accept poison
Currently LLVM is relying on ValueTracking's `isKnownNonZero` to attach `nonnull`, which can return true when the value is poison.
To make the semantics of `nonnull` consistent with the behavior of `isKnownNonZero`, this makes the semantics of `nonnull` to accept poison, and return poison if the input pointer isn't null.
This makes many transformations like below legal:

```
%p = gep inbounds %x, 1 ; % p is non-null pointer or poison
call void @f(%p)        ; instcombine converts this to call void @f(nonnull %p)
```

Instead, this semantics makes propagation of `nonnull` to caller illegal.
The reason is that, passing poison to `nonnull` does not immediately raise UB anymore, so such program is still well defined, if the callee does not use the argument.
Having `noundef` attribute there re-allows this.

```
define void @f(i8* %p) {       ; functionattr cannot mark %p nonnull here anymore
  call void @g(i8* nonnull %p) ; .. because @g never raises UB if it never uses %p.
  ret void
}
```

Another attribute that needs to be updated is `align`. This patch updates the semantics of align to accept poison as well.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D90529
2021-01-20 11:31:23 +09:00
..
aarch64.irg.ll
assume-queries-counter.ll [ValueTacking] assume-queries-counter.ll - remove unused check prefix 2020-11-10 14:31:03 +00:00
assume.ll [IR] Convert null-pointer-is-valid into an enum attribute 2020-05-15 19:41:07 +02:00
deref-bitcast-of-gep.ll Infer alignment of unmarked loads in IR/bitcode parsing. 2020-05-14 13:03:50 -07:00
dereferenceable-and-aligned.ll
func-ptr-lsb.ll
gep-negative-issue.ll
get-pointer-base-with-const-off.ll
invariant.group.ll
known-bits-from-operator-constexpr.ll [ValueTracking] Avoid blind cast from Operator to Instruction 2020-03-22 14:45:31 +01:00
known-bits-from-range-md.ll
known-non-equal.ll [ValueTracking] Fix isKnownNonEqual() with constexpr mul 2020-12-28 18:32:57 +01:00
known-nonnull-at.ll Allow nonnull/align attribute to accept poison 2021-01-20 11:31:23 +09:00
known-power-of-two.ll
knownzero-addrspacecast.ll
knownzero-shift.ll Reapply [InstSimplify] Remove known bits constant folding 2020-05-08 10:24:53 +02:00
memory-dereferenceable.ll Port -print-memderefs to NPM 2020-11-23 11:56:22 -08:00
monotonic-phi.ll
non-negative-phi-bits.ll
numsignbits-from-assume.ll
pr23011.ll
select-pattern.ll
signbits-extract-elt.ll