[PATCH] D65402: [Attributor][MustExec] Deduce dereferenceable and nonnull attribute using MustBeExecutedContextExplorer

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 15 04:06:09 PDT 2019


xbolva00 added a comment.

Hello folks,

Yesterday I came up with idea to annonate allocation functions with deref_or_null.

malloc(40) -> annotate return value of malloc with deref_or_null(40) -> Good, I will work on this idea.

Now I present some ideas for Attributor (maybe following cases already work.. I didnt check them).

Use case 1:
p = malloc(40) //  deref_or_null(40)
p[1] = 100; // here, we can change  deref_or_null(40) to  deref(40) since if p was null, it is UB.

Use case 2:
p = malloc(40) //  deref_or_null(40)
if (p) {

  in this block p is now  deref(40)! cool.

}

Use case 3
p = malloc(40) //  deref_or_null(40)
if (someotherbool) {

  p[1] = 100; // here, we can change  deref_or_null(40) to  deref(40) since if p was null, it is UB.

}

What do you think? Can attributor does it? I think use case 1 is doable, 2 and 3 a bit harder ones.
Maybe @reames is interested too in this area? Please comment this idea :)

I think precise deref info can enable really neat things, see https://bugs.llvm.org/show_bug.cgi?id=43003.


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

https://reviews.llvm.org/D65402





More information about the llvm-commits mailing list