File: musttail.ll

package info (click to toggle)
llvm-toolchain-7 1%3A7.0.1-8%2Bdeb10u2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 734,616 kB
  • sloc: cpp: 3,776,926; ansic: 633,271; asm: 350,301; python: 142,716; objc: 107,612; sh: 22,626; lisp: 11,056; perl: 7,999; pascal: 6,742; ml: 5,537; awk: 3,536; makefile: 2,557; cs: 2,027; xml: 841; javascript: 518; ruby: 156
file content (45 lines) | stat: -rw-r--r-- 1,119 bytes parent folder | download | duplicates (6)
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
; RUN: opt < %s -argpromotion -S | FileCheck %s
; PR36543

; Don't promote arguments of musttail callee

%T = type { i32, i32, i32, i32 }

; CHECK-LABEL: define internal i32 @test(%T* %p)
define internal i32 @test(%T* %p) {
  %a.gep = getelementptr %T, %T* %p, i64 0, i32 3
  %b.gep = getelementptr %T, %T* %p, i64 0, i32 2
  %a = load i32, i32* %a.gep
  %b = load i32, i32* %b.gep
  %v = add i32 %a, %b
  ret i32 %v
}

; CHECK-LABEL: define i32 @caller(%T* %p)
define i32 @caller(%T* %p) {
  %v = musttail call i32 @test(%T* %p)
  ret i32 %v
}

; Don't promote arguments of musttail caller

define i32 @foo(%T* %p, i32 %v) {
  ret i32 0
}

; CHECK-LABEL: define internal i32 @test2(%T* %p, i32 %p2)
define internal i32 @test2(%T* %p, i32 %p2) {
  %a.gep = getelementptr %T, %T* %p, i64 0, i32 3
  %b.gep = getelementptr %T, %T* %p, i64 0, i32 2
  %a = load i32, i32* %a.gep
  %b = load i32, i32* %b.gep
  %v = add i32 %a, %b
  %ca = musttail call i32 @foo(%T* undef, i32 %v)
  ret i32 %ca
}

; CHECK-LABEL: define i32 @caller2(%T* %g)
define i32 @caller2(%T* %g) {
  %v = call i32 @test2(%T* %g, i32 0)
  ret i32 %v
}