| 
 | 1 | +;; Copied from ELF/lto/thinlto-index-only.ll  | 
 | 2 | +;; First ensure that the ThinLTO handling in lld handles  | 
 | 3 | +;; bitcode without summary sections gracefully and generates index file.  | 
 | 4 | +; RUN: rm -rf %t && mkdir %t && cd %t  | 
 | 5 | +; RUN: mkdir d  | 
 | 6 | +; RUN: llvm-as %s -o 1.o  | 
 | 7 | +; RUN: llvm-as %p/Inputs/thinlto.ll -o d/2.o  | 
 | 8 | +; RUN: wasm-ld --thinlto-emit-index-files -shared 1.o d/2.o -o 3  | 
 | 9 | +; RUN: ls d/2.o.thinlto.bc  | 
 | 10 | +; RUN: ls 3  | 
 | 11 | +; RUN: wasm-ld -shared 1.o d/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 d/2.o  | 
 | 17 | +; RUN: opt -module-summary %p/Inputs/thinlto_empty.ll -o 3.o  | 
 | 18 | +; RUN: cp 3.o 4.o  | 
 | 19 | + | 
 | 20 | +;; Ensure lld generates an index and also a binary if requested.  | 
 | 21 | +; RUN: wasm-ld --thinlto-emit-index-files -shared 1.o --start-lib d/2.o 3.o --end-lib 4.o -o 4  | 
 | 22 | +; RUN: ls 4  | 
 | 23 | +; RUN: llvm-bcanalyzer -dump 1.o.thinlto.bc | FileCheck %s --check-prefix=BACKEND1  | 
 | 24 | +; RUN: llvm-bcanalyzer -dump d/2.o.thinlto.bc | FileCheck %s --check-prefix=BACKEND2  | 
 | 25 | +; RUN: llvm-dis < 3.o.thinlto.bc | FileCheck %s --check-prefix=BACKEND3  | 
 | 26 | +; RUN: llvm-dis < 4.o.thinlto.bc | FileCheck %s --check-prefix=BACKEND4  | 
 | 27 | + | 
 | 28 | +; IMPORTS1: d/2.o  | 
 | 29 | + | 
 | 30 | +;; Ensure lld generates an index and not a binary if both emit-index and index-only are present.  | 
 | 31 | +; RUN: wasm-ld --thinlto-emit-index-files --thinlto-index-only -shared 1.o d/2.o -o 5  | 
 | 32 | +; RUN: not ls 5  | 
 | 33 | + | 
 | 34 | +;; Test that LLD generates an empty index even for lazy object file that is not added to link.  | 
 | 35 | +;; Test that LLD also generates empty imports file with the --thinlto-emit-imports-files option.  | 
 | 36 | +; RUN: rm -f 1.o.thinlto.bc 1.o.imports  | 
 | 37 | +; RUN: wasm-ld --thinlto-emit-index-files -shared d/2.o --start-lib 1.o --end-lib \  | 
 | 38 | +; RUN: --thinlto-emit-imports-files -o 7  | 
 | 39 | +; RUN: ls 7  | 
 | 40 | +; RUN: ls 1.o.thinlto.bc  | 
 | 41 | +; RUN: ls 1.o.imports  | 
 | 42 | + | 
 | 43 | +;; Ensure LLD generates an empty index for each bitcode file even if all bitcode files are lazy.  | 
 | 44 | +; RUN: rm -f 1.o.thinlto.bc  | 
 | 45 | +; RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-linux /dev/null -o dummy.o  | 
 | 46 | +; RUN: wasm-ld --thinlto-emit-index-files -shared dummy.o --start-lib 1.o --end-lib -o 8  | 
 | 47 | +; RUN: ls 8  | 
 | 48 | +; RUN: ls 1.o.thinlto.bc  | 
 | 49 | + | 
 | 50 | +;; Test that LLD errors out when run with suffix replacement, or prefix replacement  | 
 | 51 | +; RUN: not wasm-ld --thinlto-emit-index-files -shared d/2.o --start-lib 1.o --end-lib \  | 
 | 52 | +; RUN: --thinlto-prefix-replace="abc;xyz" 2>&1 | FileCheck %s --check-prefix=ERR1  | 
 | 53 | +; ERR1: --thinlto-prefix-replace is not supported with --thinlto-emit-index-files  | 
 | 54 | + | 
 | 55 | +; RUN: not wasm-ld --thinlto-emit-index-files -shared d/2.o --start-lib 1.o --end-lib \  | 
 | 56 | +; RUN: --thinlto-object-suffix-replace="abc;xyz" 2>&1 | FileCheck %s --check-prefix=ERR2  | 
 | 57 | +; ERR2: --thinlto-object-suffix-replace is not supported with --thinlto-emit-index-files  | 
 | 58 | + | 
 | 59 | +;; But not when passed with index only as well  | 
 | 60 | +; RUN: wasm-ld --thinlto-emit-index-files -shared d/2.o --start-lib 1.o --end-lib \  | 
 | 61 | +; RUN: --thinlto-prefix-replace="abc;xyz" --thinlto-index-only  | 
 | 62 | + | 
 | 63 | +; RUN: wasm-ld --thinlto-emit-index-files -shared d/2.o --start-lib 1.o --end-lib \  | 
 | 64 | +; RUN: --thinlto-object-suffix-replace="abc;xyz" --thinlto-index-only  | 
 | 65 | + | 
 | 66 | +; NM: T f  | 
 | 67 | + | 
 | 68 | +;; The backend index for this module contains summaries from itself and  | 
 | 69 | +;; Inputs/thinlto.ll, as it imports from the latter.  | 
 | 70 | +; BACKEND1: <MODULE_STRTAB_BLOCK  | 
 | 71 | +; BACKEND1-NEXT: <ENTRY {{.*}} record string = '1.o'  | 
 | 72 | +; BACKEND1-NEXT: <ENTRY {{.*}} record string = 'd/2.o'  | 
 | 73 | +; BACKEND1-NEXT: </MODULE_STRTAB_BLOCK  | 
 | 74 | +; BACKEND1: <GLOBALVAL_SUMMARY_BLOCK  | 
 | 75 | +; BACKEND1: <VERSION  | 
 | 76 | +; BACKEND1: <FLAGS  | 
 | 77 | +; BACKEND1: <VALUE_GUID {{.*}} op0={{1|2}} {{op1=3060885059 op2=1207956914|op1=3432075125 op2=3712786831}}  | 
 | 78 | +; BACKEND1: <VALUE_GUID {{.*}} op0={{1|2}} {{op1=3060885059 op2=1207956914|op1=3432075125 op2=3712786831}}  | 
 | 79 | +; BACKEND1: <COMBINED  | 
 | 80 | +; BACKEND1: <COMBINED  | 
 | 81 | +; BACKEND1: </GLOBALVAL_SUMMARY_BLOCK  | 
 | 82 | + | 
 | 83 | +;; The backend index for Input/thinlto.ll contains summaries from itself only,  | 
 | 84 | +;; as it does not import anything.  | 
 | 85 | +; BACKEND2: <MODULE_STRTAB_BLOCK  | 
 | 86 | +; BACKEND2-NEXT: <ENTRY {{.*}} record string = 'd/2.o'  | 
 | 87 | +; BACKEND2-NEXT: </MODULE_STRTAB_BLOCK  | 
 | 88 | +; BACKEND2-NEXT: <GLOBALVAL_SUMMARY_BLOCK  | 
 | 89 | +; BACKEND2-NEXT: <VERSION  | 
 | 90 | +; BACKEND2-NEXT: <FLAGS  | 
 | 91 | +; BACKEND2-NEXT: <VALUE_GUID {{.*}} op0=1 op1=3060885059 op2=1207956914  | 
 | 92 | +; BACKEND2-NEXT: <COMBINED  | 
 | 93 | +; BACKEND2-NEXT: </GLOBALVAL_SUMMARY_BLOCK  | 
 | 94 | + | 
 | 95 | +; BACKEND3: ^0 = flags:  | 
 | 96 | + | 
 | 97 | +; BACKEND4: ^0 = module: (path: "4.o", hash: (0, 0, 0, 0, 0))  | 
 | 98 | + | 
 | 99 | +target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20"  | 
 | 100 | +target triple = "wasm32-unknown-unknown"  | 
 | 101 | + | 
 | 102 | +declare void @g(...)  | 
 | 103 | + | 
 | 104 | +define void @f() {  | 
 | 105 | +entry:  | 
 | 106 | +  call void (...) @g()  | 
 | 107 | +  ret void  | 
 | 108 | +}  | 
0 commit comments