xref: /llvm-project/lld/test/COFF/thinlto-object-suffix-replace.ll (revision 7b1d793713cf9ed9ab719f33b332f9c66a1fc5cc)
15011b832SBob Haarman; REQUIRES: x86
25011b832SBob Haarman
35011b832SBob Haarman; Test to make sure the thinlto-object-suffix-replace option is handled
45011b832SBob Haarman; correctly.
55011b832SBob Haarman
65011b832SBob Haarman; Generate bitcode file with summary, as well as a minimized bitcode without
75011b832SBob Haarman; the debug metadata for the thin link.
85011b832SBob Haarman; RUN: opt -thinlto-bc %s -thin-link-bitcode-file=%t1.thinlink.bc -o %t1.obj
95011b832SBob Haarman
105011b832SBob Haarman; First perform the thin link on the normal bitcode file, and save the
115011b832SBob Haarman; resulting index.
125011b832SBob Haarman; RUN: lld-link -thinlto-index-only -entry:main %t1.obj -out:%t3.exe
135011b832SBob Haarman; RUN: cp %t1.obj.thinlto.bc %t1.obj.thinlto.bc.orig
145011b832SBob Haarman
155011b832SBob Haarman; Next perform the thin link on the minimized bitcode file, and compare dump
165011b832SBob Haarman; of the resulting index to the above dump to ensure they are identical.
175011b832SBob Haarman; RUN: rm -f %t1.obj.thinlto.bc
185011b832SBob Haarman; Make sure it isn't inadvertently using the regular bitcode file.
195011b832SBob Haarman; RUN: rm -f %t1.obj
205011b832SBob Haarman; RUN: lld-link -entry:main -thinlto-index-only \
215011b832SBob Haarman; RUN:     -thinlto-object-suffix-replace:".thinlink.bc;.obj" \
225011b832SBob Haarman; RUN:     %t1.thinlink.bc -out:%t3.exe
235011b832SBob Haarman; RUN: diff %t1.obj.thinlto.bc.orig %t1.obj.thinlto.bc
245011b832SBob Haarman
255011b832SBob Haarman; Ensure lld generates error if suffix replace option not in 'old;new' format.
265011b832SBob Haarman; RUN: rm -f %t1.obj.thinlto.bc
275011b832SBob Haarman; RUN: not lld-link -entry:main -thinlto-index-only \
285011b832SBob Haarman; RUN: -thinlto-object-suffix-replace:"abc:def" %t1.thinlink.bc \
295011b832SBob Haarman; RUN: -out:%t3.exe 2>&1 | FileCheck %s --check-prefix=ERR1
305011b832SBob Haarman; ERR1: -thinlto-object-suffix-replace: expects 'old;new' format, but got abc:def
315011b832SBob Haarman
325011b832SBob Haarman; If filename does not end with old suffix, no suffix change should occur,
335011b832SBob Haarman; so ".thinlto.bc" will simply be appended to the input file name.
345011b832SBob Haarman; RUN: rm -f %t1.thinlink.bc.thinlto.bc
355011b832SBob Haarman; RUN: lld-link -entry:main -thinlto-index-only \
365011b832SBob Haarman; RUN: -thinlto-object-suffix-replace:".abc;.obj" %t1.thinlink.bc -out:%t3.exe
375011b832SBob Haarman; RUN: ls %t1.thinlink.bc.thinlto.bc
385011b832SBob Haarman
39*7b1d7937SAmy Huangtarget datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
405011b832SBob Haarmantarget triple = "x86_64-pc-windows-msvc19.0.24215"
415011b832SBob Haarman
425011b832SBob Haarmandefine void @main() {
435011b832SBob Haarmanentry:
445011b832SBob Haarman  ret void
455011b832SBob Haarman}
465011b832SBob Haarman
475011b832SBob Haarman!llvm.dbg.cu = !{}
485011b832SBob Haarman
495011b832SBob Haarman!1 = !{i32 2, !"Debug Info Version", i32 3}
505011b832SBob Haarman!llvm.module.flags = !{!1}
51