[PATCH] D87984: [BuildLibCalls] Add noundef to the returned pointers of allocators and argument of free

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 26 17:04:27 PDT 2020


aqjune added a comment.

If it is desirable to clarify the behavior of malloc and free in LangRef as well, I'm willing to do it.

The definition of malloc that is consistent with this patch is:

- If an undefined value is given to malloc, it allocates a heap with one of possible values nondeterministically chosen. For example, `malloc(16 + (undef & 4))` allocates a heap whose size is one of 16 ~ 19.
- If a poison value is given to malloc, it raises UB.

The definition of free is as follows:

- If an undefined value or poison is given to free, it is UB.

I remember that malloc also had an issue about when it is returning null. This issue is orthogonal with this patch, but if needed I'm happy to discuss it as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87984/new/

https://reviews.llvm.org/D87984



More information about the llvm-commits mailing list