summaryrefslogtreecommitdiff
path: root/test/Transforms/Inline/inline_returns_twice.ll
blob: f316c9152b8ffcdaaf38ef4f0591d8034ca51c7f (plain)
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 -inline -S | FileCheck %s

; Check that functions with "returns_twice" calls are only inlined,
; if they are themselve marked as such.

declare i32 @a() returns_twice
declare i32 @b() returns_twice

define i32 @f() {
entry:
  %call = call i32 @a() returns_twice
  %add = add nsw i32 1, %call
  ret i32 %add
}

define i32 @g() {
entry:
; CHECK-LABEL: define i32 @g(
; CHECK: call i32 @f()
; CHECK-NOT: call i32 @a()
  %call = call i32 @f()
  %add = add nsw i32 1, %call
  ret i32 %add
}

define i32 @h() returns_twice {
entry:
  %call = call i32 @b() returns_twice
  %add = add nsw i32 1, %call
  ret i32 %add
}

define i32 @i() {
entry:
; CHECK-LABEL: define i32 @i(
; CHECK: call i32 @b()
; CHECK-NOT: call i32 @h()
  %call = call i32 @h() returns_twice
  %add = add nsw i32 1, %call
  ret i32 %add
}