1; REQUIRES: x86 2; RUN: rm -rf %t; split-file %s %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 %t/f.ll -o %t/1.o 7; RUN: llvm-as %t/g.ll -o %t/2.o 8; RUN: %lld --thinlto-index-only -dylib %t/1.o %t/2.o -o %t/3 9; RUN: ls %t/2.o.thinlto.bc 10; RUN: not test -e %t/3 11; RUN: %lld -dylib %t/1.o %t/2.o -o %t/3 12; RUN: llvm-nm %t/3 | FileCheck %s --check-prefix=NM 13 14;; Basic ThinLTO tests. 15; RUN: opt -module-summary %t/f.ll -o %t/1.o 16; RUN: opt -module-summary %t/g.ll -o %t/2.o 17; RUN: opt -module-summary %t/empty.ll -o %t/3.o 18 19;; Ensure lld doesn't generates index files when thinlto-index-only is not enabled. 20; RUN: rm -f %t/1.o.thinlto.bc %t/2.o.thinlto.bc %t/3.o.thinlto.bc 21; RUN: %lld -dylib %t/1.o %t/2.o %t/3.o -o %t/5 22; RUN: not ls %t/1.o.thinlto.bc 23; RUN: not ls %t/2.o.thinlto.bc 24; RUN: not ls %t/3.o.thinlto.bc 25 26;; Ensure lld generates an index and not a binary if requested. 27; RUN: %lld --thinlto-index-only -dylib %t/1.o %t/2.o -o %t/4 28; RUN: llvm-bcanalyzer -dump %t/1.o.thinlto.bc | FileCheck %s -DP1=%t/1.o -DP2=%t/2.o --check-prefix=BACKEND1 29; RUN: llvm-bcanalyzer -dump %t/2.o.thinlto.bc | FileCheck %s -DP2=%t/2.o --check-prefix=BACKEND2 30; RUN: not test -e %t/4 31 32;; Ensure lld generates an index even if the file is wrapped in --start-lib/--end-lib. 33; RUN: rm -f %t/2.o.thinlto.bc %t/4 34; RUN: %lld --thinlto-index-only -dylib %t/1.o %t/3.o --start-lib %t/2.o --end-lib -o %t/4 35; RUN: llvm-dis < %t/2.o.thinlto.bc | grep -q '\^0 = module:' 36; RUN: not test -e %t/4 37 38;; Test that LLD generates an empty index even for lazy object file that is not added to link. 39;; Test LLD generates empty imports file either because of thinlto-emit-imports-files option. 40; RUN: rm -f %t/1.o.thinlto.bc %t/1.o.imports 41; RUN: %lld --thinlto-index-only -dylib %t/2.o --start-lib %t/1.o --end-lib \ 42; RUN: --thinlto-emit-imports-files -o %t/3 43; RUN: ls %t/1.o.thinlto.bc 44; RUN: ls %t/1.o.imports 45 46;; Ensure LLD generates an empty index for each bitcode file even if all bitcode files are lazy. 47; RUN: rm -f %t/dummy.o %t/1.o.thinlto.bc 48; RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin /dev/null -o %t/dummy.o 49; RUN: %lld --thinlto-index-only -dylib %t/dummy.o --start-lib %t/1.o --end-lib -o /dev/null 50; RUN: ls %t/1.o.thinlto.bc 51 52;; Ensure when the same bitcode object is given as both lazy and non-lazy, 53;; LLD does not generate an empty index for the lazy object. 54; RUN: rm -f %t/2.o.thinlto.bc 55; RUN: %lld --thinlto-index-only -dylib %t/1.o %t/2.o --start-lib %t/2.o --end-lib -o /dev/null 56; RUN: llvm-dis < %t/2.o.thinlto.bc | grep -q '\^0 = module:' 57; RUN: rm -f %t/2.o.thinlto.bc 58; RUN: %lld --thinlto-index-only -dylib --start-lib %t/2.o --end-lib %t/2.o %t/1.o -o /dev/null 59; RUN: llvm-dis < %t/2.o.thinlto.bc | grep -q '\^0 = module:' 60 61;; Ensure when the same lazy bitcode object is given multiple times, 62;; no empty index file is generated if one of the copies is linked. 63; RUN: rm -f %t/2.o.thinlto.bc 64; RUN: %lld --thinlto-index-only -dylib %t/1.o --start-lib %t/2.o --end-lib --start-lib %t/2.o --end-lib -o /dev/null 65; RUN: llvm-dis < %t/2.o.thinlto.bc | grep -q '\^0 = module:' 66 67; NM: T _f 68 69;; The backend index for this module contains summaries from itself and 70;; g.ll, as it imports from the latter. 71; BACKEND1: <MODULE_STRTAB_BLOCK 72; BACKEND1-NEXT: <ENTRY {{.*}} record string = '[[P1]]' 73; BACKEND1-NEXT: <ENTRY {{.*}} record string = '[[P2]]' 74; BACKEND1-NEXT: </MODULE_STRTAB_BLOCK 75; BACKEND1: <GLOBALVAL_SUMMARY_BLOCK 76; BACKEND1: <VERSION 77; BACKEND1: <FLAGS 78; BACKEND1: <VALUE_GUID {{.*}} op0={{1|2}} {{op1=3060885059 op2=1207956914|op1=3432075125 op2=3712786831}} 79; BACKEND1: <VALUE_GUID {{.*}} op0={{1|2}} {{op1=3060885059 op2=1207956914|op1=3432075125 op2=3712786831}} 80; BACKEND1: <COMBINED 81; BACKEND1: <COMBINED 82; BACKEND1: </GLOBALVAL_SUMMARY_BLOCK 83 84;; The backend index for g.ll contains summaries from itself only, 85;; as it does not import anything. 86; BACKEND2: <MODULE_STRTAB_BLOCK 87; BACKEND2-NEXT: <ENTRY {{.*}} record string = '[[P2]]' 88; BACKEND2-NEXT: </MODULE_STRTAB_BLOCK 89; BACKEND2-NEXT: <GLOBALVAL_SUMMARY_BLOCK 90; BACKEND2-NEXT: <VERSION 91; BACKEND2-NEXT: <FLAGS 92; BACKEND2-NEXT: <VALUE_GUID {{.*}} op0=1 op1=3060885059 op2=1207956914 93; BACKEND2-NEXT: <COMBINED 94; BACKEND2-NEXT: </GLOBALVAL_SUMMARY_BLOCK 95 96;--- f.ll 97target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 98target triple = "x86_64-apple-darwin" 99 100declare void @g(...) 101 102define void @f() { 103entry: 104 call void (...) @g() 105 ret void 106} 107 108;--- g.ll 109target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 110target triple = "x86_64-apple-darwin" 111 112define void @g() { 113entry: 114 ret void 115} 116 117;--- empty.ll 118target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 119target triple = "x86_64-apple-darwin" 120