File: reloc-2.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,696 kB
  • sloc: cpp: 7,438,781; ansic: 1,393,871; asm: 1,012,926; python: 241,771; f90: 86,635; objc: 75,411; lisp: 42,144; pascal: 17,286; sh: 8,596; ml: 5,082; perl: 4,730; makefile: 3,591; awk: 3,523; javascript: 2,251; xml: 892; fortran: 672
file content (60 lines) | stat: -rw-r--r-- 2,120 bytes parent folder | download | duplicates (5)
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
; RUN: llc -mtriple=bpfel -mcpu=v1 -filetype=obj -o %t.el < %s
; RUN: llvm-objdump -r %t.el | FileCheck --check-prefix=RELOC %s
; RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t.el | FileCheck --check-prefix=DUMP %s
; RUN: llc -mtriple=bpfeb -mcpu=v1 -filetype=obj -o %t.eb < %s
; RUN: llvm-objdump -r %t.eb | FileCheck --check-prefix=RELOC %s
; RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t.eb | FileCheck --check-prefix=DUMP %s

; source code:
;   static __attribute__((noinline)) __attribute__((section("sec1")))
;   int add(int a, int b) {
;     return a + b;
;   }
;   static __attribute__((noinline))
;   int sub(int a, int b) {
;     return a - b;
;   }
;   int test(int a, int b) {
;     return add(a, b) + sub(a, b);
;   }
; compilation flag:
;   clang -target bpf -O2 -emit-llvm -S test.c

define dso_local i32 @test(i32 %a, i32 %b) local_unnamed_addr #0 {
entry:
  %call = tail call fastcc i32 @add(i32 %a, i32 %b)
  %call1 = tail call fastcc i32 @sub(i32 %a, i32 %b)
  %add = add nsw i32 %call1, %call
  ret i32 %add
}

define internal fastcc i32 @add(i32 %a, i32 %b) unnamed_addr #1 section "sec1" {
entry:
  %add = add nsw i32 %b, %a
  ret i32 %add
}

; Function Attrs: nofree noinline norecurse nosync nounwind readnone willreturn mustprogress
define internal fastcc i32 @sub(i32 %a, i32 %b) unnamed_addr #1 {
entry:
  %sub = sub nsw i32 %a, %b
  ret i32 %sub
}

; DUMP:       .text:
; DUMP-EMPTY:
; DUMP-NEXT:  <test>
; DUMP-NEXT:  r[[#]] = r[[#]]
; DUMP-NEXT:  r[[#]] = r[[#]]
; DUMP-NEXT:  call -1

; DUMP:       sec1:
; DUMP-EMPTY:
; DUMP-NEXT:  <add>

; RELOC:      RELOCATION RECORDS FOR [.text]:
; RELOC:      R_BPF_64_32            sec1
; RELOC-NOT:  R_BPF_64_32

attributes #0 = { nofree norecurse nosync nounwind readnone willreturn mustprogress "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
attributes #1 = { nofree noinline norecurse nosync nounwind readnone willreturn mustprogress "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }