File: machine-outliner-loh.ll

package info (click to toggle)
llvm-toolchain-21 1%3A21.1.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 2,245,044 kB
  • sloc: cpp: 7,619,726; ansic: 1,434,018; asm: 1,058,748; python: 252,740; f90: 94,671; objc: 70,685; lisp: 42,813; pascal: 18,401; sh: 8,601; ml: 5,111; perl: 4,720; makefile: 3,666; awk: 3,523; javascript: 2,409; xml: 892; fortran: 770
file content (74 lines) | stat: -rw-r--r-- 2,336 bytes parent folder | download | duplicates (3)
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
69
70
71
72
73
74
; RUN: llc -verify-machineinstrs -mtriple=aarch64-apple-darwin < %s | FileCheck %s --implicit-check-not=.loh --check-prefixes=CHECK,LOH
; RUN: llc -verify-machineinstrs -mtriple=aarch64-apple-darwin -enable-machine-outliner < %s | FileCheck %s --implicit-check-not=.loh --check-prefixes=CHECK,OUTLINE

@A = global i32 0, align 4
@B = global i32 0, align 4

declare void @foo();
declare void @bar(ptr %a);
declare void @goo(ptr %a);

; CHECK-LABEL: _a0:
define void @a0(i32 %a) {

  ; This becomes AdrpAdd when outlining is disabled, otherwise it is outlined
  ; and there should be no LOH.
  %addr = getelementptr inbounds i32, ptr @A, i32 0
  %res = load i32, ptr %addr, align 4
  ; LOH:      [[L0:Lloh.+]]:
  ; LOH-NEXT:   adrp x19, _A@PAGE
  ; LOH-NEXT: [[L1:Lloh.+]]:
  ; LOH-NEXT:   add x19, x19, _A@PAGEOFF

  call void @foo()
  ; OUTLINE:      bl _OUTLINED_FUNCTION_0
  ; OUTLINE-NEXT: mov x0, x19
  ; OUTLINE-NEXT: bl _bar
  call void @bar(ptr %addr)

  ; This becomes AdrpAddStr.
  %addr2 = getelementptr inbounds i32, ptr @B, i32 4
  store i32 %res, ptr %addr2, align 4
  ; CHECK:      [[L2:Lloh.+]]:
  ; CHECK-NEXT:   adrp x8, _B@PAGE
  ; CHECK-NEXT: [[L3:Lloh.+]]:
  ; CHECK-NEXT:   add x8, x8, _B@PAGEOFF
  ; CHECK-NEXT: [[L4:Lloh.+]]:
  ; CHECK-NEXT:   str w20, [x8, #16]
  ret void

  ; LOH-DAG:   .loh AdrpAdd [[L0]], [[L1]]
  ; CHECK-DAG: .loh AdrpAddStr [[L2]], [[L3]], [[L4]]
  ; CHECK:     .cfi_endproc
}

; CHECK-LABEL: _a1:
define i32 @a1(i32 %a) {

  ; This becomes AdrpAdd when outlining is disabled, otherwise it is outlined
  ; and there should be no LOH.
  %addr = getelementptr inbounds i32, ptr @A, i32 0
  %res = load i32, ptr %addr, align 4
  ; LOH:      [[L5:Lloh.+]]:
  ; LOH-NEXT:   adrp x19, _A@PAGE
  ; LOH-NEXT: [[L6:Lloh.+]]:
  ; LOH-NEXT:   add x19, x19, _A@PAGEOFF

  call void @foo()
  ; OUTLINE:      bl _OUTLINED_FUNCTION_0
  ; OUTLINE-NEXT: mov x0, x19
  ; OUTLINE-NEXT: bl _goo
  call void @goo(ptr %addr)
  ret i32 %res

  ; LOH:   .loh AdrpAdd [[L5]], [[L6]]
  ; CHECK: .cfi_endproc
}

; Note: it is not safe to add LOHs to this function as outlined functions do not
; follow calling convention and thus x19 could be live across the call.
; OUTLINE: _OUTLINED_FUNCTION_0:
; OUTLINE:   adrp x19, _A@PAGE
; OUTLINE:   add x19, x19, _A@PAGEOFF
; OUTLINE:   ldr w20, [x19]
; OUTLINE:   b _foo