const-expr-gep.ll 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. ; This testcase consists of alias relations which should be completely
  2. ; resolvable by cfl-aa, but require analysis of getelementptr constant exprs.
  3. ; Derived from BasicAA/2003-12-11-ConstExprGEP.ll
  4. ; RUN: opt < %s -cfl-aa -aa-eval -print-may-aliases -disable-output 2>&1 | FileCheck %s
  5. %T = type { i32, [10 x i8] }
  6. @G = external global %T
  7. @G2 = external global %T
  8. ; TODO: Quite a few of these are MayAlias because we don't yet consider
  9. ; constant offsets in CFLAA. If we start doing so, then we'll need to
  10. ; change these test cases
  11. ; CHECK: Function: test
  12. ; CHECK: MayAlias: i32* %D, i32* %F
  13. ; CHECK: MayAlias: i32* %D, i8* %X
  14. ; CHECK: MayAlias: i32* %F, i8* %X
  15. define void @test() {
  16. %D = getelementptr %T, %T* @G, i64 0, i32 0
  17. %F = getelementptr i32, i32* getelementptr (%T, %T* @G, i64 0, i32 0), i64 0
  18. %X = getelementptr [10 x i8], [10 x i8]* getelementptr (%T, %T* @G, i64 0, i32 1), i64 0, i64 5
  19. ret void
  20. }
  21. ; CHECK: Function: simplecheck
  22. ; CHECK: MayAlias: i32* %F, i32* %arg0
  23. ; CHECK: MayAlias: i32* %H, i32* %arg0
  24. ; CHECK: MayAlias: i32* %F, i32* %H
  25. define void @simplecheck(i32* %arg0) {
  26. %F = getelementptr i32, i32* getelementptr (%T, %T* @G, i64 0, i32 0), i64 0
  27. %H = getelementptr %T, %T* @G2, i64 0, i32 0
  28. ret void
  29. }
  30. ; Ensure that CFLAA properly identifies and handles escaping variables (i.e.
  31. ; globals) in nested ConstantExprs
  32. ; CHECK: Function: checkNesting
  33. ; CHECK: MayAlias: i32* %A, i32* %arg0
  34. %NestedT = type { [1 x [1 x i32]] }
  35. @NT = external global %NestedT
  36. define void @checkNesting(i32* %arg0) {
  37. %A = getelementptr [1 x i32],
  38. [1 x i32]* getelementptr
  39. ([1 x [1 x i32]], [1 x [1 x i32]]* getelementptr (%NestedT, %NestedT* @NT, i64 0, i32 0),
  40. i64 0,
  41. i32 0),
  42. i64 0,
  43. i32 0
  44. ret void
  45. }