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