1; UNSUPPORTED: system-windows 2;; Unsupported on Windows due to difficulty with escaping "opt" across platforms. 3;; lit substitutes 'opt' with /path/to/opt. 4 5; RUN: rm -rf %t && mkdir %t && cd %t 6 7;; Copy IR from import-constant.ll since it generates all the temps 8; RUN: opt -thinlto-bc %s -o 1.bc 9; RUN: opt -thinlto-bc %p/Inputs/import-constant.ll -o 2.bc 10 11;; Create the .all dir with save-temps saving everything, this will be used to compare 12;; with the output from individualized save-temps later 13; RUN: mkdir all all2 build subset subset2 14; RUN: llvm-lto2 run 1.bc 2.bc -o all/a.out \ 15; RUN: -import-constants-with-refs -r=1.bc,main,plx -r=1.bc,_Z6getObjv,l \ 16; RUN: -r=2.bc,_Z6getObjv,pl -r=2.bc,val,pl -r=2.bc,outer,pl \ 17; RUN: -save-temps 18 19;; The next 8 blocks follow this structure: 20;; for each option of save-temps= 21;; Run lto and generate files 22;; Make sure a.out exists and is correct (by diff-ing) 23;; this is the only file that should recur between runs 24;; (Also, for some stages, copy the generated files to subset2 to check composability later) 25;; Move files that were expected to be generated to all2 26;; Make sure there's no unexpected extra files 27;; After that, we'll diff all and all2 to make sure all contents are identical 28 29;; Check preopt 30; RUN: llvm-lto2 run 1.bc 2.bc -o build/a.out \ 31; RUN: -import-constants-with-refs -r=1.bc,main,plx -r=1.bc,_Z6getObjv,l \ 32; RUN: -r=2.bc,_Z6getObjv,pl -r=2.bc,val,pl -r=2.bc,outer,pl \ 33; RUN: -select-save-temps=preopt 34; RUN: cmp all/a.out.1 build/a.out.1 && rm -f build/a.out.1 35; RUN: cmp all/a.out.2 build/a.out.2 && rm -f build/a.out.2 36; RUN: cp build/*.0.preopt.* subset2 37; RUN: mv build/*.0.preopt.* all2 38; RUN: ls build | count 0 39 40;; Check promote 41; RUN: rm -f all2/*.1.promote* 42; RUN: llvm-lto2 run 1.bc 2.bc -o build/a.out \ 43; RUN: -import-constants-with-refs -r=1.bc,main,plx -r=1.bc,_Z6getObjv,l \ 44; RUN: -r=2.bc,_Z6getObjv,pl -r=2.bc,val,pl -r=2.bc,outer,pl \ 45; RUN: -select-save-temps=promote 46; RUN: cmp all/a.out.1 build/a.out.1 && rm -f build/a.out.1 47; RUN: cmp all/a.out.2 build/a.out.2 && rm -f build/a.out.2 48; RUN: mv build/*.1.promote* all2 49; RUN: ls build | count 0 50 51;; Check internalize 52; RUN: llvm-lto2 run 1.bc 2.bc -o build/a.out \ 53; RUN: -import-constants-with-refs -r=1.bc,main,plx -r=1.bc,_Z6getObjv,l \ 54; RUN: -r=2.bc,_Z6getObjv,pl -r=2.bc,val,pl -r=2.bc,outer,pl \ 55; RUN: -select-save-temps=internalize 56; RUN: cmp all/a.out.1 build/a.out.1 && rm -f build/a.out.1 57; RUN: cmp all/a.out.2 build/a.out.2 && rm -f build/a.out.2 58; RUN: mv build/*.2.internalize* all2 59; RUN: ls build | count 0 60 61;; Check import 62; RUN: llvm-lto2 run 1.bc 2.bc -o build/a.out \ 63; RUN: -import-constants-with-refs -r=1.bc,main,plx -r=1.bc,_Z6getObjv,l \ 64; RUN: -r=2.bc,_Z6getObjv,pl -r=2.bc,val,pl -r=2.bc,outer,pl \ 65; RUN: -select-save-temps=import 66; RUN: cmp all/a.out.1 build/a.out.1 && rm -f build/a.out.1 67; RUN: cmp all/a.out.2 build/a.out.2 && rm -f build/a.out.2 68; RUN: mv build/*.3.import* all2 69; RUN: ls build | count 0 70 71;; Check opt 72; RUN: llvm-lto2 run 1.bc 2.bc -o build/a.out \ 73; RUN: -import-constants-with-refs -r=1.bc,main,plx -r=1.bc,_Z6getObjv,l \ 74; RUN: -r=2.bc,_Z6getObjv,pl -r=2.bc,val,pl -r=2.bc,outer,pl \ 75; RUN: -select-save-temps=\opt 76; RUN: cmp all/a.out.1 build/a.out.1 && rm -f build/a.out.1 77; RUN: cmp all/a.out.2 build/a.out.2 && rm -f build/a.out.2 78; RUN: cp build/*.4.opt* subset2 79; RUN: mv build/*.4.opt* all2 80; RUN: ls build | count 0 81 82;; Check precodegen 83; RUN: llvm-lto2 run 1.bc 2.bc -o build/a.out \ 84; RUN: -import-constants-with-refs -r=1.bc,main,plx -r=1.bc,_Z6getObjv,l \ 85; RUN: -r=2.bc,_Z6getObjv,pl -r=2.bc,val,pl -r=2.bc,outer,pl \ 86; RUN: -select-save-temps=precodegen 87; RUN: cmp all/a.out.1 build/a.out.1 && rm -f build/a.out.1 88; RUN: cmp all/a.out.2 build/a.out.2 && rm -f build/a.out.2 89; RUN: mv build/*.5.precodegen* all2 90; RUN: ls build | count 0 91 92;; Check combinedindex 93; RUN: llvm-lto2 run 1.bc 2.bc -o build/a.out \ 94; RUN: -import-constants-with-refs -r=1.bc,main,plx -r=1.bc,_Z6getObjv,l \ 95; RUN: -r=2.bc,_Z6getObjv,pl -r=2.bc,val,pl -r=2.bc,outer,pl \ 96; RUN: -select-save-temps=combinedindex 97; RUN: cmp all/a.out.1 build/a.out.1 && rm -f build/a.out.1 98; RUN: cmp all/a.out.2 build/a.out.2 && rm -f build/a.out.2 99; RUN: cp build/*.index.bc subset2 100; RUN: cp build/*.index.dot subset2 101; RUN: mv build/*.index.bc all2 102; RUN: mv build/*.index.dot all2 103; RUN: ls build | count 0 104 105;; Check resolution 106; RUN: llvm-lto2 run 1.bc 2.bc -o build/a.out \ 107; RUN: -import-constants-with-refs -r=1.bc,main,plx -r=1.bc,_Z6getObjv,l \ 108; RUN: -r=2.bc,_Z6getObjv,pl -r=2.bc,val,pl -r=2.bc,outer,pl \ 109; RUN: -select-save-temps=resolution 110;; all2 needs at least 1 copy of a.out, move it over now since its the last block 111; RUN: mv build/a.out.1 build/a.out.2 all2 112; RUN: mv build/*.resolution.txt all2 113; RUN: ls build | count 0 114 115;; If no files were left out from individual stages, the .all2 dir should be identical to .all 116; RUN: diff -r all all2 117 118;; Check multi-stage composability 119;; Similar to the above, but do it with a subset instead. 120;; .all -> .subset, .all2 -> .subset2 121; RUN: llvm-lto2 run 1.bc 2.bc -o subset/a.out \ 122; RUN: -import-constants-with-refs -r=1.bc,main,plx -r=1.bc,_Z6getObjv,l \ 123; RUN: -r=2.bc,_Z6getObjv,pl -r=2.bc,val,pl -r=2.bc,outer,pl \ 124; RUN: -select-save-temps=preopt,combinedindex,\opt 125; RUN: cmp all/a.out.1 subset/a.out.1 && rm -f subset/a.out.1 126; RUN: cmp all/a.out.2 subset/a.out.2 && rm -f subset/a.out.2 127; RUN: diff -r subset subset2 128 129;; Check error messages 130; RUN: not llvm-lto2 run 1.bc 2.bc -o build/a.out \ 131; RUN: -import-constants-with-refs -r=1.bc,main,plx -r=1.bc,_Z6getObjv,l \ 132; RUN: -r=2.bc,_Z6getObjv,pl -r=2.bc,val,pl -r=2.bc,outer,pl \ 133; RUN: -select-save-temps=prelink 2>&1 \ 134; RUN: | FileCheck %s --check-prefix=ERR1 135; ERR1: invalid -select-save-temps argument: prelink 136 137; RUN: not llvm-lto2 run 1.bc 2.bc -o build/a.out \ 138; RUN: -import-constants-with-refs -r=1.bc,main,plx -r=1.bc,_Z6getObjv,l \ 139; RUN: -r=2.bc,_Z6getObjv,pl -r=2.bc,val,pl -r=2.bc,outer,pl \ 140; RUN: -select-save-temps=preopt -save-temps 2>&1 \ 141; RUN: | FileCheck %s --check-prefix=ERR2 142; ERR2: -save-temps cannot be specified with -select-save-temps 143 144target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 145target triple = "x86_64-unknown-linux-gnu" 146 147%struct.S = type { i32, i32, ptr } 148 149define dso_local i32 @main() local_unnamed_addr { 150entry: 151 %call = tail call ptr @_Z6getObjv() 152 %0 = load i32, ptr %call, align 8 153 %v = getelementptr inbounds %struct.S, ptr %call, i64 0, i32 1 154 %1 = load i32, ptr %v, align 4 155 %add = add nsw i32 %1, %0 156 ret i32 %add 157} 158 159declare dso_local ptr @_Z6getObjv() local_unnamed_addr 160