[all-commits] [llvm/llvm-project] a15001: [SimplifyCFG] Optimize CFG when null is passed to ...

Dávid Bolvanský via All-commits all-commits at lists.llvm.org
Fri Jan 15 14:54:10 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a1500105ee6074f992f376c916dcfa3a54acb717
      https://github.com/llvm/llvm-project/commit/a1500105ee6074f992f376c916dcfa3a54acb717
  Author: Dávid Bolvanský <david.bolvansky at gmail.com>
  Date:   2021-01-15 (Fri, 15 Jan 2021)

  Changed paths:
    M llvm/lib/Transforms/Utils/SimplifyCFG.cpp
    M llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll

  Log Message:
  -----------
  [SimplifyCFG] Optimize CFG when null is passed to a function with nonnull argument

Example:

```
__attribute__((nonnull,noinline)) char * pinc(char *p)  {
  return ++p;
}

char * foo(bool b, char *a) {
       return pinc(b ? 0 : a);

}
```

optimize to

```
char * foo(bool b, char *a) {
       return pinc(a);

}
```

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D94180




More information about the All-commits mailing list