49 lines · plain
1; REQUIRES: x86-registered-target2 3; check the -lto-embed-bitcode=post-thinlto-merge does not perform optimizations4; we expect 't1' - i.e start-lib1.ll's products - have both foo and bar defined,5; but the bar call is still made from foo.6; RUN: opt -module-summary %p/Inputs/start-lib1.ll -o %t1.bc7; RUN: opt -module-summary %p/Inputs/start-lib2.ll -o %t2.bc8; RUN: llvm-lto -thinlto -o %t.o %t1.bc %t2.bc9 10; For the optimized case, we expect the inlining of foo into bar to happen.11; 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=optimized12; RUN: llvm-readelf -S %t-opt.o | FileCheck %s --check-prefixes=CHECK-ELF,CHECK-ELF-NO-CMD13; RUN: llvm-objcopy --dump-section=.llvmbc=%t-embedded.bc %t-opt.o /dev/null14; RUN: llvm-dis %t-embedded.bc -o - | FileCheck %s --check-prefixes=CHECK,CHECK-OPT15 16; For the post-merge case, perform the embedded bitcode extraction, then17; round-trip through compilation and ensure the objects are the same.18; 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-opt19; RUN: llvm-readelf -S %t.o | FileCheck %s --check-prefixes=CHECK-ELF,CHECK-ELF-CMD20; RUN: llvm-objcopy --dump-section=.llvmcmd=%t-embedded.cmd %t.o /dev/null21; RUN: FileCheck %s --check-prefixes=CHECK-EMBEDDED-CMD <%t-embedded.cmd22; RUN: llvm-objcopy --dump-section=.llvmbc=%t-embedded.bc %t.o /dev/null23; RUN: llvm-dis %t-embedded.bc -o - | FileCheck %s --check-prefixes=CHECK,CHECK-NOOPT24; We should only need the index and the post-thinlto merged module to generate 25; the exact same .o as we originally did.26; RUN: rm %t1.bc %t2.bc27; 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-merged28;29; The resulting .o is almost the same, but the .llvmcmd section would be30; different because of the extra -thinlto-assume-merged.31; A simple, meaningful comparison is to just compare the stripped objects.32; RUN: llvm-strip --strip-all %t-redo.o 33; RUN: llvm-strip --strip-all %t.o 34; RUN: diff %t-redo.o %t.o35 36; CHECK-ELF: .text PROGBITS 0000000000000000 [[#%x,OFF:]] [[#%x,SIZE:]] 00 AX 037; CHECK-ELF-NEXT: .llvmbc PROGBITS 0000000000000000 [[#%x,OFF:]] [[#%x,SIZE:]] 00 038; CHECK-ELF-CMD: .llvmcmd39; CHECK-ELF-NO-CMD-NOT: .llvmcmd40 41; CHECK: define void @foo() 42; CHECK-OPT-NEXT: ret void43; CHECK-NOOPT-NEXT: call void @bar()44; CHECK-NOOPT: define available_externally void @bar()45; CHECK-NOOPT-NEXT: ret void46 47; CHECK-EMBEDDED-CMD: x86_64-unknown-linux-gnu{{.*$}}48; CHECK-EMBEDDED-CMD-NOT: x86_64-unknown-linux-gnu49