[llvm-dev] llvm 3.9 Alias Analysis result for function's by-ref arguments

Hayrapetyan, Anahit via llvm-dev llvm-dev at lists.llvm.org
Tue Mar 28 02:32:49 PDT 2017


Hi,


I'm writing an analysis pass which is supposed to find instructions in a function that modify function's by-ref arguments. For that I'm using llvm AliasAnalysis pass, particularly querying for ModRef info for instructions and function arguments, to see if a given instruction modifies a given argument. However, for functions with more than one by-ref argument, I get strange results. Instructions, which modify one of the arguments, are reported as modifying the others too - saying, ModRef info of those instructions is Mod for all arguments.

For this example

void function(int& n, int& m)

{

int tmp = m;

n = tmp;

}


Arguments n and m are marked as MayAlias, and storing tmp into n is reported to modify m too.


I found a few discussions about this problem. In one of them, it was suggested to use cfl-aa, I tried it and it did not solve the problem.

In another one they said that this happens on purpose. llvm Alias Analysis marks function's by-ref arguments MayAlias, as function may be called with arguments referencing the same variable.


So I would like to ask whether this is the case. And if it is, is there a way to make llvm ignore this consideration?


Thanks,

Anahit.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170328/a6aac6b6/attachment.html>


More information about the llvm-dev mailing list