125 lines · plain
1;; This test is similar to llvm/test/ThinLTO/X86/selective-save-temps.ll2 3; REQUIRES: x864; UNSUPPORTED: system-windows5;; Unsupported on Windows due to difficulty with escaping "opt" across platforms.6;; lit substitutes 'opt' with /path/to/opt.7 8; RUN: rm -rf %t && mkdir %t && cd %t9; RUN: mkdir all all2 all3 build subset subset2 && cd build10 11; RUN: opt -thinlto-bc -o main.o %s12; RUN: opt -thinlto-bc -o thin1.o %S/Inputs/thinlto.ll13 14;; Create the .all dir with save-temps saving everything, this will be used to compare15;; with the output from individualized save-temps later16; RUN: ld.lld main.o thin1.o --save-temps -o %t/all/a.out17; RUN: mv a.out.lto.* *.o.*.bc %t/all18;; Sanity check that everything got moved19; RUN: ls | count 220 21;; Check precedence if both --save-temps and --save-temps= are present22; RUN: ld.lld main.o thin1.o --save-temps=preopt --save-temps --save-temps=\opt -o %t/all2/a.out23; RUN: cmp %t/all2/a.out %t/all/a.out24; RUN: mv a.out.lto.* *.o.* %t/all225; RUN: ls | count 226; RUN: diff -r %t/all %t/all227 28;; The next 9 blocks follow this structure:29;; for each option of save-temps=30;; Run linker and generate files31;; Make sure a.out exists and is correct (by diff-ing)32;; this is the only file that should recur between runs33;; (Also, for some stages, copy the generated files to %t/subset2 to check composability later)34;; Move files that were expected to be generated to %t/all335;; Make sure there's no unexpected extra files36;; After that, we'll diff %t/all and %t/all3 to make sure all contents are identical37 38;; Check preopt39; RUN: ld.lld main.o thin1.o --save-temps=preopt40; RUN: cmp %t/all/a.out a.out && rm -f a.out41; RUN: cp *.0.preopt.* %t/subset242; RUN: mv *.0.preopt.* %t/all343; RUN: ls | count 244 45;; Check promote46; RUN: ld.lld main.o thin1.o --save-temps=promote47; RUN: cmp %t/all/a.out a.out && rm -f a.out48; RUN: mv *.1.promote* %t/all349; RUN: ls | count 250 51;; Check internalize52; RUN: ld.lld main.o thin1.o --save-temps=internalize53; RUN: cmp %t/all/a.out a.out && rm -f a.out54; RUN: mv *.2.internalize* %t/all355; RUN: ls | count 256 57;; Check import58; RUN: ld.lld main.o thin1.o --save-temps=import59; RUN: cmp %t/all/a.out a.out && rm -f a.out60; RUN: mv *.3.import* %t/all361; RUN: ls | count 262 63;; Check opt64; RUN: ld.lld main.o thin1.o --save-temps=\opt65; RUN: cmp %t/all/a.out a.out && rm -f a.out66; RUN: cp *.4.opt* %t/subset267; RUN: mv *.4.opt* %t/all368; RUN: ls | count 269 70;; Check precodegen71; RUN: ld.lld main.o thin1.o --save-temps=precodegen72; RUN: cmp %t/all/a.out a.out && rm -f a.out73; RUN: mv *.5.precodegen* %t/all374; RUN: ls | count 275 76;; Check combinedindex77; RUN: ld.lld main.o thin1.o --save-temps=combinedindex78; RUN: cmp %t/all/a.out a.out && rm -f a.out79; RUN: mv *.index.bc %t/all380; RUN: mv *.index.dot %t/all381; RUN: ls | count 282 83;; Check prelink84; RUN: ld.lld main.o thin1.o --save-temps=prelink85; RUN: cmp %t/all/a.out a.out && rm -f a.out86; RUN: cp a.out.lto.*.o %t/subset287; RUN: mv a.out.lto.*.o %t/all388; RUN: ls | count 289 90;; Check resolution91; RUN: ld.lld main.o thin1.o --save-temps=resolution92;; %t/all3 needs at least 1 copy of a.out, move it over now since its the last block93; RUN: mv a.out %t/all394; RUN: mv *.resolution.txt %t/all395; RUN: ls | count 296 97;; If no files were left out from individual stages, the .all3 dir should be identical to .all98; RUN: diff -r %t/all %t/all399 100;; Check multi-stage composability101;; Similar to the above, but do it with a subset instead.102;; .all -> .subset, .all3 -> .subset2103; RUN: ld.lld main.o thin1.o --save-temps=preopt --save-temps=prelink --save-temps=\opt104; RUN: cmp %t/all/a.out a.out && rm -f a.out105; RUN: mv *.0.preopt.* %t/subset106; RUN: mv *.4.opt* %t/subset107; RUN: mv a.out.lto.*.o %t/subset108; RUN: ls | count 2109; RUN: diff -r %t/subset2 %t/subset110 111;; Check error message112; RUN: not ld.lld --save-temps=prelink --save-temps=\opt --save-temps=notastage 2>&1 \113; RUN: | FileCheck %s114; CHECK: unknown --save-temps value: notastage115 116target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"117target triple = "x86_64-unknown-linux-gnu"118 119declare void @g()120 121define i32 @_start() {122 call void @g()123 ret i32 0124}125