1; First ensure that the ThinLTO handling in the gold plugin handles 2; bitcode without summary sections gracefully. 3; RUN: llvm-as %s -o %t.o 4; RUN: llvm-as %p/Inputs/thinlto.ll -o %t2.o 5; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \ 6; RUN: -m elf_x86_64 \ 7; RUN: --plugin-opt=thinlto \ 8; RUN: --plugin-opt=thinlto-index-only \ 9; RUN: -shared %t.o %t2.o -o %t3 10; RUN: not test -e %t3 11; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \ 12; RUN: -m elf_x86_64 \ 13; RUN: --plugin-opt=thinlto \ 14; RUN: -shared %t.o %t2.o -o %t4 15; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM 16 17; Next generate summary sections and test gold handling. 18; RUN: opt -module-summary %s -o %t.o 19; RUN: opt -module-summary %p/Inputs/thinlto.ll -o %t2.o 20 21; Ensure gold generates an index and not a binary if requested. 22; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \ 23; RUN: -m elf_x86_64 \ 24; RUN: --plugin-opt=thinlto \ 25; RUN: --plugin-opt=thinlto-index-only \ 26; RUN: -shared %t.o %t2.o -o %t3 27; RUN: llvm-bcanalyzer -dump %t.o.thinlto.bc | FileCheck %s --check-prefix=BACKEND1 28; RUN: llvm-bcanalyzer -dump %t2.o.thinlto.bc | FileCheck %s --check-prefix=BACKEND2 29; RUN: llvm-dis %t.o.thinlto.bc -o - | FileCheck %s --check-prefix=DIS1 30; RUN: llvm-dis %t2.o.thinlto.bc -o - | FileCheck %s --check-prefix=DIS2 31; RUN: not test -e %t3 32 33; Ensure gold generates an index as well as a binary with save-temps in ThinLTO mode. 34; First force single-threaded mode 35; RUN: rm -f %t4* 36; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \ 37; RUN: -m elf_x86_64 \ 38; RUN: --plugin-opt=save-temps \ 39; RUN: --plugin-opt=thinlto \ 40; RUN: --plugin-opt=jobs=1 \ 41; RUN: -shared %t.o %t2.o -o %t4 42; RUN: llvm-bcanalyzer -dump %t4.index.bc | FileCheck %s --check-prefix=COMBINED 43; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM 44; Ensure ld does not emit empty combined module in default. 45; RUN: ls %t4.lto.o* | count 2 46 47; Check with --no-map-whole-files 48; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \ 49; RUN: -m elf_x86_64 \ 50; RUN: --plugin-opt=save-temps \ 51; RUN: --plugin-opt=thinlto \ 52; RUN: --plugin-opt=jobs=1 \ 53; RUN: --no-map-whole-files \ 54; RUN: -shared %t.o %t2.o -o %t4 55; RUN: llvm-bcanalyzer -dump %t4.index.bc | FileCheck %s --check-prefix=COMBINED 56; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM 57 58; Next force multi-threaded mode 59; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \ 60; RUN: -m elf_x86_64 \ 61; RUN: --plugin-opt=save-temps \ 62; RUN: --plugin-opt=thinlto \ 63; RUN: --plugin-opt=jobs=2 \ 64; RUN: -shared %t.o %t2.o -o %t4 65; RUN: llvm-bcanalyzer -dump %t4.index.bc | FileCheck %s --check-prefix=COMBINED 66; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM 67 68; Test --plugin-opt=obj-path to ensure unique object files generated. 69; RUN: rm -f %t5.o %t5.o1 70; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \ 71; RUN: -m elf_x86_64 \ 72; RUN: --plugin-opt=thinlto \ 73; RUN: --plugin-opt=jobs=2 \ 74; RUN: --plugin-opt=obj-path=%t5.o \ 75; RUN: -shared %t.o %t2.o -o %t4 76; RUN: llvm-nm %t5.o1 | FileCheck %s --check-prefix=NM2 77; RUN: llvm-nm %t5.o2 | FileCheck %s --check-prefix=NM2 78; Ensure ld emits empty combined module if specific obj-path. 79; RUN: ls %t5.o* | count 3 80 81; Test to ensure that thinlto-index-only with obj-path creates the file. 82; RUN: rm -f %t5.o %t5.o1 83; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \ 84; RUN: -m elf_x86_64 \ 85; RUN: --plugin-opt=thinlto \ 86; RUN: --plugin-opt=jobs=2 \ 87; RUN: --plugin-opt=thinlto-index-only \ 88; RUN: --plugin-opt=obj-path=%t5.o \ 89; RUN: -shared %t.o %t2.o -o %t4 90; RUN: llvm-readobj -h %t5.o | FileCheck %s --check-prefix=FORMAT 91; RUN: llvm-nm %t5.o 2>&1 | count 0 92 93; NM: T f 94; NM2: T {{f|g}} 95; FORMAT: Format: elf64-x86-64 96 97; The backend index for this module contains summaries from itself and 98; Inputs/thinlto.ll, as it imports from the latter. 99; BACKEND1: <MODULE_STRTAB_BLOCK 100; BACKEND1-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o' 101; BACKEND1-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o' 102; BACKEND1-NEXT: </MODULE_STRTAB_BLOCK 103; BACKEND1-NEXT: <GLOBALVAL_SUMMARY_BLOCK 104; BACKEND1-NEXT: <VERSION 105; BACKEND1-NEXT: <FLAGS 106; BACKEND1-NEXT: <VALUE_GUID op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}} 107; BACKEND1-NEXT: <VALUE_GUID op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}} 108; BACKEND1-NEXT: <COMBINED 109; BACKEND1-NEXT: <COMBINED 110; BACKEND1-NEXT: <BLOCK_COUNT 111; BACKEND1-NEXT: </GLOBALVAL_SUMMARY_BLOCK 112 113; The backend index for Input/thinlto.ll contains summaries from itself only, 114; as it does not import anything. 115; BACKEND2: <MODULE_STRTAB_BLOCK 116; BACKEND2-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp2.o' 117; BACKEND2-NEXT: </MODULE_STRTAB_BLOCK 118; BACKEND2-NEXT: <GLOBALVAL_SUMMARY_BLOCK 119; BACKEND2-NEXT: <VERSION 120; BACKEND2-NEXT: <FLAGS 121; BACKEND2-NEXT: <VALUE_GUID op0=1 op1=-5300342847281564238 122; BACKEND2-NEXT: <COMBINED 123; BACKEND2-NEXT: <BLOCK_COUNT 124; BACKEND2-NEXT: </GLOBALVAL_SUMMARY_BLOCK 125 126; DIS1: ^0 = module: (path: "{{.*}}thinlto.ll.tmp.o", hash: (0, 0, 0, 0, 0)) 127; DIS1: ^1 = module: (path: "{{.*}}thinlto.ll.tmp2.o", hash: (0, 0, 0, 0, 0)) 128; DIS1: ^2 = gv: (guid: 13146401226427987378, summaries: (function: (module: ^1, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 0, canAutoHide: 0), insts: 1))) 129; DIS1: ^3 = gv: (guid: 14740650423002898831, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 0, canAutoHide: 0), insts: 2, calls: ((callee: ^2))))) 130 131; DIS2: ^0 = module: (path: "{{.*}}thinlto.ll.tmp2.o", hash: (0, 0, 0, 0, 0)) 132; DIS2: ^1 = gv: (guid: 13146401226427987378, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 0, canAutoHide: 0), insts: 1))) 133 134; COMBINED: <MODULE_STRTAB_BLOCK 135; COMBINED-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o' 136; COMBINED-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o' 137; COMBINED-NEXT: </MODULE_STRTAB_BLOCK 138; COMBINED-NEXT: <GLOBALVAL_SUMMARY_BLOCK 139; COMBINED-NEXT: <VERSION 140; COMBINED-NEXT: <FLAGS 141; COMBINED-NEXT: <VALUE_GUID op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}} 142; COMBINED-NEXT: <VALUE_GUID op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}} 143; COMBINED-NEXT: <COMBINED 144; COMBINED-NEXT: <COMBINED 145; COMBINED-NEXT: <BLOCK_COUNT 146; COMBINED-NEXT: </GLOBALVAL_SUMMARY_BLOCK 147 148target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 149target triple = "x86_64-unknown-linux-gnu" 150 151declare void @g(...) 152 153define void @f() { 154entry: 155 call void (...) @g() 156 ret void 157} 158