llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

CFL-AA doesn't understand internal global values properly

Open jmolloy opened this issue 11 years ago • 4 comments

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.

jmolloy avatar Mar 05 '15 12:03 jmolloy

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].

gburgessiv avatar Mar 06 '15 04:03 gburgessiv

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

  1. 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
  2. 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?

llvmbot avatar Mar 05 '15 12:03 llvmbot

assigned to @gburgessiv

jmolloy avatar Mar 05 '15 12:03 jmolloy

CFL AA was removed from LLVM. So, closing this.

nunoplopes avatar Dec 12 '22 09:12 nunoplopes