1*2638aafeSHongtao Yu; REQUIRES: x86 2*2638aafeSHongtao Yu; RUN: rm -fr %t && mkdir %t && cd %t 3*2638aafeSHongtao Yu; RUN: opt -thinlto-bc -o main.o %s 4*2638aafeSHongtao Yu; RUN: opt -thinlto-bc -o thin1.o %S/Inputs/thin1.ll 5*2638aafeSHongtao Yu; RUN: opt -thinlto-bc -o thin2.o %S/Inputs/thin2.ll 6*2638aafeSHongtao Yu; RUN: llvm-ar qcT thin.a thin1.o thin2.o 7*2638aafeSHongtao Yu 8*2638aafeSHongtao Yu;; --thinlto-single-module=main.o should result in only main.o compiled, of which 9*2638aafeSHongtao Yu;; the object code is saved in single1.o1. Note that single1.o is always the dummy 10*2638aafeSHongtao Yu;; output, aka ld-temp.o. There should be no more object files generated. 11*2638aafeSHongtao Yu; RUN: ld.lld main.o thin.a --thinlto-single-module=main.o --lto-obj-path=single1.o 12*2638aafeSHongtao Yu; RUN: llvm-readelf -S -s single1.o | FileCheck %s --check-prefix=DEFAULT 13*2638aafeSHongtao Yu; RUN: llvm-readelf -S -s single1.o1 | FileCheck %s --check-prefix=MAIN 14*2638aafeSHongtao Yu; RUN: not ls single1.o2 15*2638aafeSHongtao Yu; RUN: not ls a.out 16*2638aafeSHongtao Yu 17*2638aafeSHongtao Yu; DEFAULT: Value Size Type Bind Vis Ndx Name 18*2638aafeSHongtao Yu; DEFAULT: 0000000000000000 0 FILE LOCAL DEFAULT ABS ld-temp.o 19*2638aafeSHongtao Yu; MAIN: Value Size Type Bind Vis Ndx Name 20*2638aafeSHongtao Yu; MAIN: 0000000000000000 0 FILE LOCAL DEFAULT ABS thinlto-single-module.ll 21*2638aafeSHongtao Yu; MAIN-NEXT: 0000000000000000 3 FUNC GLOBAL DEFAULT 3 _start 22*2638aafeSHongtao Yu 23*2638aafeSHongtao Yu;; --thinlto-single-module=thin.a should result in only thin1.o and thin2.o compiled. 24*2638aafeSHongtao Yu; RUN: ld.lld main.o thin.a --thinlto-single-module=thin.a --lto-obj-path=single2.o 25*2638aafeSHongtao Yu; RUN: llvm-readelf -S -s single2.o | FileCheck %s --check-prefix=DEFAULT 26*2638aafeSHongtao Yu; RUN: llvm-readelf -S -s single2.o1 | FileCheck %s --check-prefix=FOO 27*2638aafeSHongtao Yu; RUN: llvm-readelf -S -s single2.o2 | FileCheck %s --check-prefix=BLAH 28*2638aafeSHongtao Yu; RUN: not ls single1.o3 29*2638aafeSHongtao Yu 30*2638aafeSHongtao Yu;; Multiple --thinlto-single-module uses should result in a combination of inputs compiled. 31*2638aafeSHongtao Yu; RUN: ld.lld main.o thin.a --thinlto-single-module=main.o --thinlto-single-module=thin2.o --lto-obj-path=single4.o 32*2638aafeSHongtao Yu; RUN: llvm-readelf -S -s single4.o | FileCheck %s --check-prefix=DEFAULT 33*2638aafeSHongtao Yu; RUN: llvm-readelf -S -s single4.o1 | FileCheck %s --check-prefix=MAIN 34*2638aafeSHongtao Yu; RUN: llvm-readelf -S -s single4.o2 | FileCheck %s --check-prefix=BLAH 35*2638aafeSHongtao Yu; RUN: not ls single4.o3 36*2638aafeSHongtao Yu 37*2638aafeSHongtao Yu; FOO: Value Size Type Bind Vis Ndx Name 38*2638aafeSHongtao Yu; FOO: 0000000000000000 0 FILE LOCAL DEFAULT ABS thin1.ll 39*2638aafeSHongtao Yu; FOO-NEXT: 0000000000000000 6 FUNC GLOBAL DEFAULT 3 foo 40*2638aafeSHongtao Yu; BLAH: Value Size Type Bind Vis Ndx Name 41*2638aafeSHongtao Yu; BLAH: 0000000000000000 0 FILE LOCAL DEFAULT ABS thin2.ll 42*2638aafeSHongtao Yu; BLAH-NEXT: 0000000000000000 4 FUNC GLOBAL DEFAULT 3 blah 43*2638aafeSHongtao Yu 44*2638aafeSHongtao Yu;; Check only main.o is in the result thin index file. 45*2638aafeSHongtao Yu;; Also check a *.thinlto.bc file generated for main.o only. 46*2638aafeSHongtao Yu; RUN: ld.lld main.o thin.a --thinlto-single-module=main.o --thinlto-index-only=single5.idx 47*2638aafeSHongtao Yu; RUN: ls main.o.thinlto.bc 48*2638aafeSHongtao Yu; RUN: ls | FileCheck --implicit-check-not='thin.{{.*}}.thinlto.bc' /dev/null 49*2638aafeSHongtao Yu; RUN: FileCheck %s --check-prefix=IDX < single5.idx 50*2638aafeSHongtao Yu; RUN: count 1 < single5.idx 51*2638aafeSHongtao Yu 52*2638aafeSHongtao Yu; IDX: main.o 53*2638aafeSHongtao Yu 54*2638aafeSHongtao Yu;; Check temporary output generated for main.o only. 55*2638aafeSHongtao Yu; RUN: ld.lld main.o thin.a --thinlto-single-module=main.o --save-temps 56*2638aafeSHongtao Yu; RUN: ls main.o.0.preopt.bc 57*2638aafeSHongtao Yu; RUN: not ls thin.*.0.preopt.bc 58*2638aafeSHongtao Yu 59*2638aafeSHongtao Yutarget datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 60*2638aafeSHongtao Yutarget triple = "x86_64-scei-ps4" 61*2638aafeSHongtao Yu 62*2638aafeSHongtao Yudeclare i32 @blah(i32 %meh) 63*2638aafeSHongtao Yudeclare i32 @foo(i32 %goo) 64*2638aafeSHongtao Yu 65*2638aafeSHongtao Yudefine i32 @_start() { 66*2638aafeSHongtao Yu call i32 @foo(i32 0) 67*2638aafeSHongtao Yu call i32 @blah(i32 0) 68*2638aafeSHongtao Yu ret i32 0 69*2638aafeSHongtao Yu} 70