CFL-AA doesn't understand internal global values properly
| Bugzilla Link | 22801 |
| Version | trunk |
| OS | All |
| CC | @gburgessiv,@hfinkel |
Extended Description
In the following code:
static int g_1 = 0; int f3(int n, int * a) { int i; for (i = 0; i < n; ++i) { g_1 += a[i]; } return g_1; }
We know g_1 is internal and does not escape, therefore it cannot alias with a[i]. CFL cannot currently work this out.
Will look into fixing this.
Aside: Until we get the patch in for excluding non-pointers from set building, f3(int, int*) will report MayAlias between a and g_1 because of the line g_1 += a[i].
The bug here is that we treat all GlobalValues the same, even if they have local linkage.
For globals with local (isLocalLinkage()) linkage, we only have to treat them like regular globals if
- In non-IPA mode: We see a local function call (IE resolved to this module) || we see a non local function call and the address is taken and escapes
- In IPA mode: We see a non-local function call in IPA mode && the address is taken and escapes
For an approximation to address taken and escapes we already have something that computes which globals are address taken that we could start with.
#1 works because the local function call could modify the global, but a non-local function call cannot unless it is address taken and escapes (anywhere in the module) #2 works because in IPA mode, the local function calls can't do something we can't see. Additionally, it's only going to escape if we see it escape.
George, want to take a whack at this?
assigned to @gburgessiv
CFL AA was removed from LLVM. So, closing this.