[jit][llvm] Track variable nullness separately from array length ranges/index ranges...
authorimhameed <imhameed@microsoft.com>
Fri, 6 Sep 2019 12:55:21 +0000 (05:55 -0700)
committerZoltan Varga <vargaz@gmail.com>
Fri, 6 Sep 2019 12:55:21 +0000 (08:55 -0400)
commitba46bd17120d350e42ac1460a495fd9e7d050513
tree95c340e703df7c35449f71a295b03d836994f9af
parentc3780f23a5e543e675894fc388e3bc6f4f48c8a3
[jit][llvm] Track variable nullness separately from array length ranges/index ranges in abcrem. (mono/mono#16499)

* [jit][llvm] Track variable nullness separately from array length ranges/index ranges in abcrem.

"Nullness" is tracked via a separate field that is stored adjacent
variable/array value ranges; values may be "maybe-null" or "not-null";
the intersection of maybe-null and not-null yields not-null, the union of
maybe-null and not-null yields maybe-null. The existing graph traversal logic
is reused as much as possible, which makes the implementation of this
null value approximation slightly more complicated than it would be
otherwise.

Fixes https://github.com/mono/mono/issues/16310, which was caused by
the use of non-empty array length ranges as a way to encode non-null
values.

This also allows null check elision for zero-sized arrays.

* Fix C++ compatibility. Fix a typo in a comment.

* Add symmetric nullness relations.

* Make ldlen imply that the source register is not-null, similar to CHECK_THIS or any other null check.

Commit migrated from https://github.com/mono/mono/commit/b4886817efcb1825b6dad38ef6cf3999563b3581
src/mono/mono/mini/abcremoval.c
src/mono/mono/mini/abcremoval.h
src/mono/mono/mini/method-to-ir.c