[PATCH] D20890: [CFLAA] Improving the precision of cfl-aa for inttoptr and ptrtoint

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 1 17:34:52 PDT 2016


eli.friedman added a subscriber: eli.friedman.

================
Comment at: test/Analysis/CFLAliasAnalysis/int_ptr_cast.ll:13
@@ +12,3 @@
+  %qint2 = add nsw i64 %qint, %n
+  %qcast = inttoptr i64 %qint2 to i64*
+  ret void
----------------
Consider the following testcase:

```
  %q = alloca i64, align 8
  %qint = ptrtoint i64* %q to i64
  %qint2 = add i64 %n, %qint
  %qint2 = sub i64 %n, %qint
  %qcast = inttoptr i64 %qint2 to i64*
```

Suppose the function is then called with p==n.  Then %qcast == %p.

Also, it's possible to propagate a dependency through comparison instructions; consider, for example:
```
void f(unsigned * p, unsigned n) {
  int q;
  int qint = (unsigned )&q;
  while (qint != n) ++qint;
  *(unsigned*)qint = 3; // modifies *p
}
```


http://reviews.llvm.org/D20890





More information about the llvm-commits mailing list