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.so \ 6; RUN: --plugin-opt=thinlto \ 7; RUN: --plugin-opt=thinlto-index-only \ 8; RUN: -shared %t.o %t2.o -o %t3 9; RUN: not test -e %t3 10; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ 11; RUN: --plugin-opt=thinlto \ 12; RUN: -shared %t.o %t2.o -o %t4 13; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM 14 15; Next generate summary sections and test gold handling. 16; RUN: opt -module-summary %s -o %t.o 17; RUN: opt -module-summary %p/Inputs/thinlto.ll -o %t2.o 18 19; Ensure gold generates an index and not a binary if requested. 20; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ 21; RUN: --plugin-opt=thinlto \ 22; RUN: --plugin-opt=thinlto-index-only \ 23; RUN: -shared %t.o %t2.o -o %t3 24; RUN: llvm-bcanalyzer -dump %t.o.thinlto.bc | FileCheck %s --check-prefix=BACKEND1 25; RUN: llvm-bcanalyzer -dump %t2.o.thinlto.bc | FileCheck %s --check-prefix=BACKEND2 26; RUN: not test -e %t3 27 28; Ensure gold generates an index as well as a binary with save-temps in ThinLTO mode. 29; First force single-threaded mode 30; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ 31; RUN: --plugin-opt=save-temps \ 32; RUN: --plugin-opt=thinlto \ 33; RUN: --plugin-opt=jobs=1 \ 34; RUN: -shared %t.o %t2.o -o %t4 35; RUN: llvm-bcanalyzer -dump %t4.index.bc | FileCheck %s --check-prefix=COMBINED 36; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM 37 38; Check with --no-map-whole-files 39; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ 40; RUN: --plugin-opt=save-temps \ 41; RUN: --plugin-opt=thinlto \ 42; RUN: --plugin-opt=jobs=1 \ 43; RUN: --no-map-whole-files \ 44; RUN: -shared %t.o %t2.o -o %t4 45; RUN: llvm-bcanalyzer -dump %t4.index.bc | FileCheck %s --check-prefix=COMBINED 46; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM 47 48; Next force multi-threaded mode 49; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ 50; RUN: --plugin-opt=save-temps \ 51; RUN: --plugin-opt=thinlto \ 52; RUN: --plugin-opt=jobs=2 \ 53; RUN: -shared %t.o %t2.o -o %t4 54; RUN: llvm-bcanalyzer -dump %t4.index.bc | FileCheck %s --check-prefix=COMBINED 55; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM 56 57; Test --plugin-opt=obj-path to ensure unique object files generated. 58; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ 59; RUN: --plugin-opt=thinlto \ 60; RUN: --plugin-opt=jobs=2 \ 61; RUN: --plugin-opt=obj-path=%t5.o \ 62; RUN: -shared %t.o %t2.o -o %t4 63; RUN: llvm-nm %t5.o0 | FileCheck %s --check-prefix=NM2 64; RUN: llvm-nm %t5.o1 | FileCheck %s --check-prefix=NM2 65 66; NM: T f 67; NM2: T {{f|g}} 68 69; The backend index for this module contains summaries from itself and 70; Inputs/thinlto.ll, as it imports from the latter. 71; BACKEND1: <MODULE_STRTAB_BLOCK 72; BACKEND1-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o' 73; BACKEND1-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o' 74; BACKEND1-NEXT: </MODULE_STRTAB_BLOCK 75; BACKEND1-NEXT: <GLOBALVAL_SUMMARY_BLOCK 76; BACKEND1-NEXT: <VERSION 77; BACKEND1-NEXT: <COMBINED 78; BACKEND1-NEXT: <COMBINED 79; BACKEND1-NEXT: </GLOBALVAL_SUMMARY_BLOCK 80; BACKEND1-NEXT: <VALUE_SYMTAB 81; Check that the format is: op0=valueid, op1=offset, op2=funcguid, 82; where funcguid is the lower 64 bits of the function name MD5. 83; BACKEND1-NEXT: <COMBINED_ENTRY abbrevid={{[0-9]+}} op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}} 84; BACKEND1-NEXT: <COMBINED_ENTRY abbrevid={{[0-9]+}} op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}} 85; BACKEND1-NEXT: </VALUE_SYMTAB 86 87; The backend index for Input/thinlto.ll contains summaries from itself only, 88; as it does not import anything. 89; BACKEND2: <MODULE_STRTAB_BLOCK 90; BACKEND2-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp2.o' 91; BACKEND2-NEXT: </MODULE_STRTAB_BLOCK 92; BACKEND2-NEXT: <GLOBALVAL_SUMMARY_BLOCK 93; BACKEND2-NEXT: <VERSION 94; BACKEND2-NEXT: <COMBINED 95; BACKEND2-NEXT: </GLOBALVAL_SUMMARY_BLOCK 96; BACKEND2-NEXT: <VALUE_SYMTAB 97; Check that the format is: op0=valueid, op1=offset, op2=funcguid, 98; where funcguid is the lower 64 bits of the function name MD5. 99; BACKEND2-NEXT: <COMBINED_ENTRY abbrevid={{[0-9]+}} op0=1 op1=-5300342847281564238 100; BACKEND2-NEXT: </VALUE_SYMTAB 101 102; COMBINED: <MODULE_STRTAB_BLOCK 103; COMBINED-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o' 104; COMBINED-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o' 105; COMBINED-NEXT: </MODULE_STRTAB_BLOCK 106; COMBINED-NEXT: <GLOBALVAL_SUMMARY_BLOCK 107; COMBINED-NEXT: <VERSION 108; COMBINED-NEXT: <COMBINED 109; COMBINED-NEXT: <COMBINED 110; COMBINED-NEXT: </GLOBALVAL_SUMMARY_BLOCK 111; COMBINED-NEXT: <VALUE_SYMTAB 112; Check that the format is: op0=valueid, op1=offset, op2=funcguid, 113; where funcguid is the lower 64 bits of the function name MD5. 114; COMBINED-NEXT: <COMBINED_ENTRY abbrevid={{[0-9]+}} op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}} 115; COMBINED-NEXT: <COMBINED_ENTRY abbrevid={{[0-9]+}} op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}} 116; COMBINED-NEXT: </VALUE_SYMTAB 117 118declare void @g(...) 119 120define void @f() { 121entry: 122 call void (...) @g() 123 ret void 124} 125