File: reloc-2.ll

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (60 lines) | stat: -rw-r--r-- 2,060 bytes parent folder | download | duplicates (7)
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 -march=bpfel -filetype=obj -o %t.el < %s
; RUN: llvm-objdump -r %t.el | FileCheck --check-prefix=RELOC %s
; RUN: llvm-objdump -d --no-show-raw-insn %t.el | FileCheck --check-prefix=DUMP %s
; RUN: llc -march=bpfeb -filetype=obj -o %t.eb < %s
; RUN: llvm-objdump -r %t.eb | FileCheck --check-prefix=RELOC %s
; RUN: llvm-objdump -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" }