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: not test -e %t3 30 31; Ensure gold generates an index as well as a binary with save-temps in ThinLTO mode. 32; First force single-threaded mode 33; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \ 34; RUN: -m elf_x86_64 \ 35; RUN: --plugin-opt=save-temps \ 36; RUN: --plugin-opt=thinlto \ 37; RUN: --plugin-opt=jobs=1 \ 38; RUN: -shared %t.o %t2.o -o %t4 39; RUN: llvm-bcanalyzer -dump %t4.index.bc | FileCheck %s --check-prefix=COMBINED 40; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM 41 42; Check with --no-map-whole-files 43; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \ 44; RUN: -m elf_x86_64 \ 45; RUN: --plugin-opt=save-temps \ 46; RUN: --plugin-opt=thinlto \ 47; RUN: --plugin-opt=jobs=1 \ 48; RUN: --no-map-whole-files \ 49; RUN: -shared %t.o %t2.o -o %t4 50; RUN: llvm-bcanalyzer -dump %t4.index.bc | FileCheck %s --check-prefix=COMBINED 51; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM 52 53; Next force multi-threaded mode 54; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \ 55; RUN: -m elf_x86_64 \ 56; RUN: --plugin-opt=save-temps \ 57; RUN: --plugin-opt=thinlto \ 58; RUN: --plugin-opt=jobs=2 \ 59; RUN: -shared %t.o %t2.o -o %t4 60; RUN: llvm-bcanalyzer -dump %t4.index.bc | FileCheck %s --check-prefix=COMBINED 61; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM 62 63; Test --plugin-opt=obj-path to ensure unique object files generated. 64; RUN: rm -f %t5.o %t5.o1 65; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \ 66; RUN: -m elf_x86_64 \ 67; RUN: --plugin-opt=thinlto \ 68; RUN: --plugin-opt=jobs=2 \ 69; RUN: --plugin-opt=obj-path=%t5.o \ 70; RUN: -shared %t.o %t2.o -o %t4 71; RUN: llvm-nm %t5.o1 | FileCheck %s --check-prefix=NM2 72; RUN: llvm-nm %t5.o2 | FileCheck %s --check-prefix=NM2 73 74; Test to ensure that thinlto-index-only with obj-path creates the file. 75; RUN: rm -f %t5.o %t5.o1 76; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \ 77; RUN: -m elf_x86_64 \ 78; RUN: --plugin-opt=thinlto \ 79; RUN: --plugin-opt=jobs=2 \ 80; RUN: --plugin-opt=thinlto-index-only \ 81; RUN: --plugin-opt=obj-path=%t5.o \ 82; RUN: -shared %t.o %t2.o -o %t4 83; RUN: llvm-readobj -h %t5.o | FileCheck %s --check-prefix=FORMAT 84; RUN: llvm-nm %t5.o | count 0 85 86; NM: T f 87; NM2: T {{f|g}} 88; FORMAT: Format: ELF64-x86-64 89 90; The backend index for this module contains summaries from itself and 91; Inputs/thinlto.ll, as it imports from the latter. 92; BACKEND1: <MODULE_STRTAB_BLOCK 93; BACKEND1-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o' 94; BACKEND1-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o' 95; BACKEND1-NEXT: </MODULE_STRTAB_BLOCK 96; BACKEND1-NEXT: <GLOBALVAL_SUMMARY_BLOCK 97; BACKEND1-NEXT: <VERSION 98; BACKEND1-NEXT: <FLAGS 99; BACKEND1-NEXT: <VALUE_GUID op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}} 100; BACKEND1-NEXT: <VALUE_GUID op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}} 101; BACKEND1-NEXT: <COMBINED 102; BACKEND1-NEXT: <COMBINED 103; BACKEND1-NEXT: </GLOBALVAL_SUMMARY_BLOCK 104 105; The backend index for Input/thinlto.ll contains summaries from itself only, 106; as it does not import anything. 107; BACKEND2: <MODULE_STRTAB_BLOCK 108; BACKEND2-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp2.o' 109; BACKEND2-NEXT: </MODULE_STRTAB_BLOCK 110; BACKEND2-NEXT: <GLOBALVAL_SUMMARY_BLOCK 111; BACKEND2-NEXT: <VERSION 112; BACKEND2-NEXT: <FLAGS 113; BACKEND2-NEXT: <VALUE_GUID op0=1 op1=-5300342847281564238 114; BACKEND2-NEXT: <COMBINED 115; BACKEND2-NEXT: </GLOBALVAL_SUMMARY_BLOCK 116 117; COMBINED: <MODULE_STRTAB_BLOCK 118; COMBINED-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o' 119; COMBINED-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o' 120; COMBINED-NEXT: </MODULE_STRTAB_BLOCK 121; COMBINED-NEXT: <GLOBALVAL_SUMMARY_BLOCK 122; COMBINED-NEXT: <VERSION 123; COMBINED-NEXT: <FLAGS 124; COMBINED-NEXT: <VALUE_GUID op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}} 125; COMBINED-NEXT: <VALUE_GUID op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}} 126; COMBINED-NEXT: <COMBINED 127; COMBINED-NEXT: <COMBINED 128; COMBINED-NEXT: </GLOBALVAL_SUMMARY_BLOCK 129 130target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 131target triple = "x86_64-unknown-linux-gnu" 132 133declare void @g(...) 134 135define void @f() { 136entry: 137 call void (...) @g() 138 ret void 139} 140