File: test-module.ll

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (68 lines) | stat: -rw-r--r-- 1,755 bytes parent folder | download | duplicates (9)
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
66
67
68
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-grtev4-linux-gnu"

declare void @external_fct(i32)

define dso_local i32 @top() {
  %a = call i32 @multiplier(i32 5)
  %b = call i32 @adder(i32 10)
  %ret = add nsw i32 %a, %b
  call void @external_fct(i32 %ret)
  ret i32 %ret
}

define internal dso_local i32 @adder(i32) {
  %2 = alloca i32, align 4
  store i32 %0, i32* %2, align 4
  %3 = load i32, i32* %2, align 4
  %4 = call i32 @multiplier(i32 %3)
  %5 = load i32, i32* %2, align 4
  %6 = call i32 @switcher(i32 1)
  %7 = add nsw i32 %4, %6
  ret i32 %7
}

define internal i32 @multiplier(i32) {
  %2 = alloca i32, align 4
  store i32 %0, i32* %2, align 4
  %3 = load i32, i32* %2, align 4
  %4 = load i32, i32* %2, align 4
  %5 = mul nsw i32 %3, %4
  ret i32 %5
}

define i32 @switcher(i32) {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  store i32 %0, i32* %3, align 4
  %4 = load i32, i32* %3, align 4
  switch i32 %4, label %11 [
    i32 1, label %5
    i32 2, label %6
  ]

; <label>:5:                                      ; preds = %1
  store i32 2, i32* %2, align 4
  br label %12

; <label>:6:                                      ; preds = %1
  %7 = load i32, i32* %3, align 4
  %8 = load i32, i32* %3, align 4
  %9 = call i32 @multiplier(i32 %8)
  %10 = add nsw i32 %7, %9
  store i32 %10, i32* %2, align 4
  br label %12

; <label>:11:                                     ; preds = %1
  %adder.result = call i32 @adder(i32 2)
  store i32 %adder.result, i32* %2, align 4
  br label %12

; <label>:12:                                     ; preds = %11, %6, %5
  %13 = load i32, i32* %2, align 4
  ret i32 %13
}

; CHECK-NOT: @adder
; DEFAULT-LABEL:        @adder
; DEFAULT-NEXT:         %2 = mul