File: return-constants.ll

package info (click to toggle)
llvm-2.7 2.7-6
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 59,992 kB
  • ctags: 49,499
  • sloc: cpp: 373,792; ansic: 16,885; sh: 12,614; asm: 6,809; ada: 3,083; ml: 2,942; python: 2,671; perl: 2,404; makefile: 1,691; pascal: 1,235; exp: 399; objc: 291; lisp: 184; csh: 117; xml: 38; f90: 36
file content (41 lines) | stat: -rw-r--r-- 1,167 bytes parent folder | download | duplicates (2)
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
; RUN: opt < %s -ipconstprop -S > %t
;; Check that the 21 constants got propagated properly
; RUN: cat %t | grep {%M = add i32 21, 21}
;; Check that the second return values didn't get propagated
; RUN: cat %t | grep {%N = add i32 %B, %D}

define internal {i32, i32} @foo(i1 %Q) {
        br i1 %Q, label %T, label %F

T:              ; preds = %0
        ret i32 21, i32 22

F:              ; preds = %0
        ret i32 21, i32 23
}

define internal {i32, i32} @bar(i1 %Q) {
        %A = insertvalue { i32, i32 } undef, i32 21, 0
        br i1 %Q, label %T, label %F

T:              ; preds = %0
        %B = insertvalue { i32, i32 } %A, i32 22, 1
        ret { i32, i32 } %B

F:              ; preds = %0
        %C = insertvalue { i32, i32 } %A, i32 23, 1
        ret { i32, i32 } %C
}

define { i32, i32 } @caller(i1 %Q) {
        %X = call {i32, i32} @foo( i1 %Q )
        %A = getresult {i32, i32} %X, 0
        %B = getresult {i32, i32} %X, 1
        %Y = call {i32, i32} @bar( i1 %Q )
        %C = extractvalue {i32, i32} %Y, 0
        %D = extractvalue {i32, i32} %Y, 1
        %M = add i32 %A, %C
        %N = add i32 %B, %D
        ret { i32, i32 } %X
}