File: const-expr-gep.ll

package info (click to toggle)
llvm-toolchain-15 1%3A15.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,554,644 kB
  • sloc: cpp: 5,922,452; ansic: 1,012,136; asm: 674,362; python: 191,568; objc: 73,855; f90: 42,327; lisp: 31,913; pascal: 11,973; javascript: 10,144; sh: 9,421; perl: 7,447; ml: 5,527; awk: 3,523; makefile: 2,520; xml: 885; cs: 573; fortran: 567
file content (65 lines) | stat: -rw-r--r-- 2,045 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
; This testcase consists of alias relations which should be completely
; resolvable by cfl-steens-aa, but require analysis of getelementptr constant exprs.
; Derived from BasicAA/2003-12-11-ConstExprGEP.ll

; RUN: opt < %s -aa-pipeline=cfl-steens-aa -passes=aa-eval -print-may-aliases -disable-output 2>&1 | FileCheck %s

%T = type { i32, [10 x i8] }

@G = external global %T
@G2 = external global %T

; TODO: Quite a few of these are MayAlias because we don't yet consider
; constant offsets in CFLSteensAA. If we start doing so, then we'll need to
; change these test cases

; CHECK:     Function: test
; CHECK:     MayAlias: i32* %D, i32* %F
; CHECK:     MayAlias: i32* %D, i8* %X
; CHECK:     MayAlias: i32* %F, i8* %X
define void @test() {
  %D = getelementptr %T, %T* @G, i64 0, i32 0
  %F = getelementptr i32, i32* getelementptr (%T, %T* @G, i64 0, i32 0), i64 0
  %X = getelementptr [10 x i8], [10 x i8]* getelementptr (%T, %T* @G, i64 0, i32 1), i64 0, i64 5
  load i32, i32* %D
  load i32, i32* %F
  load i8, i8* %X

  ret void
}

; CHECK:     Function: simplecheck
; CHECK:     MayAlias: i32* %F, i32* %arg0
; CHECK:     MayAlias: i32* %H, i32* %arg0
; CHECK:     MayAlias: i32* %F, i32* %H
define void @simplecheck(i32* %arg0) {
  %F = getelementptr i32, i32* getelementptr (%T, %T* @G, i64 0, i32 0), i64 0
  %H = getelementptr %T, %T* @G2, i64 0, i32 0
  load i32, i32* %arg0
  load i32, i32* %F
  load i32, i32* %H

  ret void
}

; Ensure that CFLSteensAA properly identifies and handles escaping variables (i.e.
; globals) in nested ConstantExprs

; CHECK:      Function: checkNesting
; CHECK:      MayAlias: i32* %A, i32* %arg0

%NestedT = type { [1 x [1 x i32]] }
@NT = external global %NestedT

define void @checkNesting(i32* %arg0) {
  %A = getelementptr [1 x i32],
         [1 x i32]* getelementptr
           ([1 x [1 x i32]], [1 x [1 x i32]]* getelementptr (%NestedT, %NestedT* @NT, i64 0, i32 0),
           i64 0,
           i32 0),
         i64 0,
         i32 0
  load i32, i32* %arg0
  load i32, i32* %A
  ret void
}