1; REQUIRES: x86 2; RUN: rm -rf %t && mkdir %t && cd %t 3 4;; First ensure that the ThinLTO handling in lld handles 5;; bitcode without summary sections gracefully and generates index file. 6; RUN: llvm-as %s -o 1.o 7; RUN: llvm-as %p/Inputs/thinlto.ll -o 2.o 8; RUN: ld.lld --plugin-opt=thinlto-index-only -shared 1.o 2.o -o 3 9; RUN: ls 2.o.thinlto.bc 10; RUN: not test -e 3 11; RUN: ld.lld -shared 1.o 2.o -o 3 12; RUN: llvm-nm 3 | FileCheck %s --check-prefix=NM 13 14;; Basic ThinLTO tests. 15; RUN: opt -module-summary %s -o 1.o 16; RUN: opt -module-summary %p/Inputs/thinlto.ll -o 2.o 17; RUN: opt -module-summary %p/Inputs/thinlto_empty.ll -o 3.o 18 19;; Ensure lld generates an index and not a binary if requested. 20; RUN: ld.lld --plugin-opt=thinlto-index-only -shared 1.o 2.o -o 4 21; RUN: llvm-bcanalyzer -dump 1.o.thinlto.bc | FileCheck %s --check-prefix=BACKEND1 22; RUN: llvm-bcanalyzer -dump 2.o.thinlto.bc | FileCheck %s --check-prefix=BACKEND2 23; RUN: not test -e 4 24 25;; Ensure lld generates an index even if the file is wrapped in --start-lib/--end-lib 26; RUN: rm -f 2.o.thinlto.bc 4 27; RUN: ld.lld --plugin-opt=thinlto-index-only -shared 1.o 3.o --start-lib 2.o --end-lib -o 4 28; RUN: llvm-dis < 2.o.thinlto.bc | grep -q '\^0 = module:' 29; RUN: not test -e 4 30 31;; Test that LLD generates an empty index even for lazy object file that is not added to link. 32;; Test LLD generates empty imports file either because of thinlto-emit-imports-files option. 33; RUN: rm -f 1.o.thinlto.bc 1.o.imports 34; RUN: ld.lld --plugin-opt=thinlto-index-only -shared 2.o --start-lib 1.o --end-lib \ 35; RUN: --plugin-opt=thinlto-emit-imports-files -o 3 36; RUN: ls 1.o.thinlto.bc 37; RUN: ls 1.o.imports 38 39;; Ensure LLD generates an empty index for each bitcode file even if all bitcode files are lazy. 40; RUN: rm -f 1.o.thinlto.bc 41; RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux-gnu /dev/null -o dummy.o 42; RUN: ld.lld --plugin-opt=thinlto-index-only -shared dummy.o --start-lib 1.o --end-lib -o /dev/null 43; RUN: ls 1.o.thinlto.bc 44 45; NM: T f 46 47;; The backend index for this module contains summaries from itself and 48;; Inputs/thinlto.ll, as it imports from the latter. 49; BACKEND1: <MODULE_STRTAB_BLOCK 50; BACKEND1-NEXT: <ENTRY {{.*}} record string = '1.o' 51; BACKEND1-NEXT: <ENTRY {{.*}} record string = '2.o' 52; BACKEND1-NEXT: </MODULE_STRTAB_BLOCK 53; BACKEND1: <GLOBALVAL_SUMMARY_BLOCK 54; BACKEND1: <VERSION 55; BACKEND1: <FLAGS 56; BACKEND1: <VALUE_GUID op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}} 57; BACKEND1: <VALUE_GUID op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}} 58; BACKEND1: <COMBINED 59; BACKEND1: <COMBINED 60; BACKEND1: </GLOBALVAL_SUMMARY_BLOCK 61 62;; The backend index for Input/thinlto.ll contains summaries from itself only, 63;; as it does not import anything. 64; BACKEND2: <MODULE_STRTAB_BLOCK 65; BACKEND2-NEXT: <ENTRY {{.*}} record string = '2.o' 66; BACKEND2-NEXT: </MODULE_STRTAB_BLOCK 67; BACKEND2-NEXT: <GLOBALVAL_SUMMARY_BLOCK 68; BACKEND2-NEXT: <VERSION 69; BACKEND2-NEXT: <FLAGS 70; BACKEND2-NEXT: <VALUE_GUID op0=1 op1=-5300342847281564238 71; BACKEND2-NEXT: <COMBINED 72; BACKEND2-NEXT: <BLOCK_COUNT op0=2/> 73; BACKEND2-NEXT: </GLOBALVAL_SUMMARY_BLOCK 74 75target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 76target triple = "x86_64-unknown-linux-gnu" 77 78declare void @g(...) 79 80define void @f() { 81entry: 82 call void (...) @g() 83 ret void 84} 85