[PATCH] D20776: [CFLAA] Teach cfl-aa to understand heap memory allocation

George Burgess IV via llvm-commits llvm-commits at lists.llvm.org
Mon May 30 12:48:30 PDT 2016


george.burgess.iv added a comment.

We treat values that don't exist in StratifiedSets conservatively because the IR can be modified after we run CFLAA on it. Imagine that we started with:

  define void @foo() {
    %1 = alloca [2 x i32], align 8
    ; some code here
    ret void
  }

CFLAA ran, etc. and a later pass introduced a GEP of %1, like so:

  define void @foo() {
    %1 = alloca [2 x i32], align 8
    %2 = GEP %1, i32 0, i32 0
    ; some code here
    ret void
  }

...And a later pass queries CFLAA for whether %1 and %2 alias for whatever reason. Because %2 wasn't there at build-time, we can't offer an accurate answer without doing extra work, so we always answer conservatively.

As for why we don't add unused pointers, probably bugs. If you can find a case where we're not adding pointers, please say so. :)


================
Comment at: lib/Analysis/CFLAliasAnalysis.cpp:392
@@ +391,3 @@
+      return;
+    } else if (isFreeCall(&Inst, &TLI)) {
+      return;
----------------
I think we need to do the same edge hack with `free` calls, as well :)

Consider:

```
@g = ; some global ptr
define void @foo() {
  %a = alloca i32
  ; code that only uses %a
  call void @free(i8* @g)
}
```

If we don't, `@g` won't be in the sets, so we'll consider it to alias anything, which is too conservative.


http://reviews.llvm.org/D20776





More information about the llvm-commits mailing list