[PATCH] D20890: [CFLAA] Improving the precision of cfl-aa for inttoptr and ptrtoint
Jia Chen via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 2 07:26:50 PDT 2016
grievejia added inline comments.
================
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
----------------
eli.friedman wrote:
> 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
> }
> ```
Thank you so much for the comment!
Your first example might unveil a bug in the codes (and another bug in my test). I think the current algorithm cfl-aa uses should be able to handle that, but it didn't.
Your second example basically kills this patch. Control dependency is something that I failed to take into account. I'd like to argue that codes like that is very broken and should be fixed, but since this is permitted by the specification, for now it's not worth the pain to deal with it in any precise way.
http://reviews.llvm.org/D20890
More information about the llvm-commits
mailing list