File: thinlto_embed_bitcode.ll

package info (click to toggle)
llvm-toolchain-13 1%3A13.0.1-11
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,418,840 kB
  • sloc: cpp: 5,290,826; ansic: 996,570; asm: 544,593; python: 188,212; objc: 72,027; lisp: 30,291; f90: 25,395; sh: 24,898; javascript: 9,780; pascal: 9,398; perl: 7,484; ml: 5,432; awk: 3,523; makefile: 2,913; xml: 953; cs: 573; fortran: 539
file content (48 lines) | stat: -rw-r--r-- 2,754 bytes parent folder | download | duplicates (18)
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
; REQUIRES: x86-registered-target

; check the -lto-embed-bitcode=post-thinlto-merge does not perform optimizations
; we expect 't1' - i.e start-lib1.ll's products - have both foo and bar defined,
; but the bar call is still made from foo.
; RUN: opt -module-summary %p/Inputs/start-lib1.ll -o %t1.bc
; RUN: opt -module-summary %p/Inputs/start-lib2.ll -o %t2.bc
; RUN: llvm-lto -thinlto -o %t.o %t1.bc %t2.bc

; For the optimized case, we expect the inlining of foo into bar to happen.
; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t-opt.o -x ir %t1.bc -c -fthinlto-index=%t.o.thinlto.bc -mllvm -lto-embed-bitcode=optimized
; RUN: llvm-readelf -S %t-opt.o | FileCheck %s --check-prefixes=CHECK-ELF,CHECK-ELF-NO-CMD
; RUN: llvm-objcopy --dump-section=.llvmbc=%t-embedded.bc %t-opt.o /dev/null
; RUN: llvm-dis %t-embedded.bc -o - | FileCheck %s --check-prefixes=CHECK,CHECK-OPT

; For the post-merge case, perform the embedded bitcode extraction, then
; round-trip through compilation and ensure the objects are the same.
; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t.o -x ir %t1.bc -c -fthinlto-index=%t.o.thinlto.bc -mllvm -lto-embed-bitcode=post-merge-pre-opt
; RUN: llvm-readelf -S %t.o | FileCheck %s --check-prefixes=CHECK-ELF,CHECK-ELF-CMD
; RUN: llvm-objcopy --dump-section=.llvmcmd=%t-embedded.cmd %t.o /dev/null
; RUN: FileCheck %s --check-prefixes=CHECK-EMBEDDED-CMD <%t-embedded.cmd
; RUN: llvm-objcopy --dump-section=.llvmbc=%t-embedded.bc %t.o /dev/null
; RUN: llvm-dis %t-embedded.bc -o - | FileCheck %s --check-prefixes=CHECK,CHECK-NOOPT
; We should only need the index and the post-thinlto merged module to generate 
; the exact same .o as we originally did.
; RUN: rm %t1.bc %t2.bc
; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t-redo.o -x ir %t-embedded.bc -c -fthinlto-index=%t.o.thinlto.bc -mllvm -lto-embed-bitcode=post-merge-pre-opt -mllvm -thinlto-assume-merged
;
; The resulting .o is almost the same, but the .llvmcmd section would be
; different because of the extra -thinlto-assume-merged.
; A simple, meaningful comparison is to just compare the stripped objects.
; RUN: llvm-strip --strip-all %t-redo.o 
; RUN: llvm-strip --strip-all %t.o 
; RUN: diff %t-redo.o %t.o

; CHECK-ELF:      .text   PROGBITS 0000000000000000 [[#%x,OFF:]] [[#%x,SIZE:]] 00 AX 0
; CHECK-ELF-NEXT: .llvmbc PROGBITS 0000000000000000 [[#%x,OFF:]] [[#%x,SIZE:]] 00    0
; CHECK-ELF-CMD:  .llvmcmd
; CHECK-ELF-NO-CMD-NOT: .llvmcmd

; CHECK:          define void @foo() 
; CHECK-OPT-NEXT:   ret void
; CHECK-NOOPT-NEXT: call void @bar()
; CHECK-NOOPT: define available_externally void @bar()
; CHECK-NOOPT-NEXT: ret void

; CHECK-EMBEDDED-CMD: x86_64-unknown-linux-gnu{{.*$}}
; CHECK-EMBEDDED-CMD-NOT: x86_64-unknown-linux-gnu