161fc10d6SMircea Trofin; REQUIRES: x86-registered-target 261fc10d6SMircea Trofin 361fc10d6SMircea Trofin; check the -lto-embed-bitcode=post-thinlto-merge does not perform optimizations 461fc10d6SMircea Trofin; we expect 't1' - i.e start-lib1.ll's products - have both foo and bar defined, 561fc10d6SMircea Trofin; but the bar call is still made from foo. 661fc10d6SMircea Trofin; RUN: opt -module-summary %p/Inputs/start-lib1.ll -o %t1.bc 761fc10d6SMircea Trofin; RUN: opt -module-summary %p/Inputs/start-lib2.ll -o %t2.bc 861fc10d6SMircea Trofin; RUN: llvm-lto -thinlto -o %t.o %t1.bc %t2.bc 961fc10d6SMircea Trofin 10cf112382SMircea Trofin; For the optimized case, we expect the inlining of foo into bar to happen. 11cf112382SMircea Trofin; 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 12735ab4beSMircea Trofin; RUN: llvm-readelf -S %t-opt.o | FileCheck %s --check-prefixes=CHECK-ELF,CHECK-ELF-NO-CMD 13cf112382SMircea Trofin; RUN: llvm-objcopy --dump-section=.llvmbc=%t-embedded.bc %t-opt.o /dev/null 14cf112382SMircea Trofin; RUN: llvm-dis %t-embedded.bc -o - | FileCheck %s --check-prefixes=CHECK,CHECK-OPT 15cf112382SMircea Trofin 16cf112382SMircea Trofin; For the post-merge case, perform the embedded bitcode extraction, then 17cf112382SMircea Trofin; round-trip through compilation and ensure the objects are the same. 1861fc10d6SMircea Trofin; 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 19735ab4beSMircea Trofin; RUN: llvm-readelf -S %t.o | FileCheck %s --check-prefixes=CHECK-ELF,CHECK-ELF-CMD 2013aee94bSMircea Trofin; RUN: llvm-objcopy --dump-section=.llvmcmd=%t-embedded.cmd %t.o /dev/null 21*44174b3dSHubert Tong; RUN: FileCheck %s --check-prefixes=CHECK-EMBEDDED-CMD <%t-embedded.cmd 2261fc10d6SMircea Trofin; RUN: llvm-objcopy --dump-section=.llvmbc=%t-embedded.bc %t.o /dev/null 2361fc10d6SMircea Trofin; RUN: llvm-dis %t-embedded.bc -o - | FileCheck %s --check-prefixes=CHECK,CHECK-NOOPT 24cf112382SMircea Trofin; We should only need the index and the post-thinlto merged module to generate 25cf112382SMircea Trofin; the exact same .o as we originally did. 26cf112382SMircea Trofin; RUN: rm %t1.bc %t2.bc 27cf112382SMircea Trofin; 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 2813aee94bSMircea Trofin; 2913aee94bSMircea Trofin; The resulting .o is almost the same, but the .llvmcmd section would be 3013aee94bSMircea Trofin; different because of the extra -thinlto-assume-merged. 3113aee94bSMircea Trofin; A simple, meaningful comparison is to just compare the stripped objects. 3213aee94bSMircea Trofin; RUN: llvm-strip --strip-all %t-redo.o 3313aee94bSMircea Trofin; RUN: llvm-strip --strip-all %t.o 34cf112382SMircea Trofin; RUN: diff %t-redo.o %t.o 3561fc10d6SMircea Trofin 3661fc10d6SMircea Trofin; CHECK-ELF: .text PROGBITS 0000000000000000 [[#%x,OFF:]] [[#%x,SIZE:]] 00 AX 0 3761fc10d6SMircea Trofin; CHECK-ELF-NEXT: .llvmbc PROGBITS 0000000000000000 [[#%x,OFF:]] [[#%x,SIZE:]] 00 0 3861fc10d6SMircea Trofin; CHECK-ELF-CMD: .llvmcmd 3961fc10d6SMircea Trofin; CHECK-ELF-NO-CMD-NOT: .llvmcmd 4061fc10d6SMircea Trofin 4161fc10d6SMircea Trofin; CHECK: define void @foo() 4261fc10d6SMircea Trofin; CHECK-OPT-NEXT: ret void 4361fc10d6SMircea Trofin; CHECK-NOOPT-NEXT: call void @bar() 448ea7ef8eSMircea Trofin; CHECK-NOOPT: define available_externally void @bar() 4561fc10d6SMircea Trofin; CHECK-NOOPT-NEXT: ret void 46*44174b3dSHubert Tong 47*44174b3dSHubert Tong; CHECK-EMBEDDED-CMD: x86_64-unknown-linux-gnu{{.*$}} 48*44174b3dSHubert Tong; CHECK-EMBEDDED-CMD-NOT: x86_64-unknown-linux-gnu 49