[lld] [LLD][COFF] allow saving intermediate files with /lldsavetemps (PR #115131)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 6 01:00:01 PST 2024


================
@@ -0,0 +1,58 @@
+; REQUIRES: x86
+; RUN: rm -fr %T/savetemps-eq
+; RUN: mkdir %T/savetemps-eq
+; RUN: opt -thinlto-bc -o %T/savetemps-eq/savetemps.obj %s
+; RUN: opt -thinlto-bc -o %T/savetemps-eq/thin1.obj %S/Inputs/thinlto.ll
+
+;; Check preopt
+; RUN: lld-link /lldsavetemps:preopt /out:%T/savetemps-eq/savetemps.exe /entry:main \
+; RUN:     /subsystem:console %T/savetemps-eq/savetemps.obj %T/savetemps-eq/thin1.obj
+; RUN: ls %T/savetemps-eq/*.obj.*.preopt.bc | count 2
+
+;; Check promote
+; RUN: lld-link /lldsavetemps:promote /out:%T/savetemps-eq/savetemps.exe /entry:main \
+; RUN:     /subsystem:console %T/savetemps-eq/savetemps.obj %T/savetemps-eq/thin1.obj
+; RUN: ls %T/savetemps-eq/*.obj.*.promote.bc | count 2
+
+;; Check internalize
+; RUN: lld-link /lldsavetemps:internalize /out:%T/savetemps-eq/savetemps.exe /entry:main \
+; RUN:     /subsystem:console %T/savetemps-eq/savetemps.obj %T/savetemps-eq/thin1.obj
+; RUN: ls %T/savetemps-eq/*.obj.*.internalize.bc | count 2
+
+;; Check import
+; RUN: lld-link /lldsavetemps:import /out:%T/savetemps-eq/savetemps.exe /entry:main \
+; RUN:     /subsystem:console %T/savetemps-eq/savetemps.obj %T/savetemps-eq/thin1.obj
+; RUN: ls %T/savetemps-eq/*.obj.*.import.bc | count 2
+
+;; Check opt
+;; Not supported on Windows due to difficulty with escaping "opt" across platforms.
+
+;; Check precodegen
+; RUN: lld-link /lldsavetemps:precodegen /out:%T/savetemps-eq/savetemps.exe /entry:main \
+; RUN:     /subsystem:console %T/savetemps-eq/savetemps.obj %T/savetemps-eq/thin1.obj
+; RUN: ls %T/savetemps-eq/*.obj.*.precodegen.bc | count 2
+
+;; Check combinedindex
+; RUN: lld-link /lldsavetemps:combinedindex /out:%T/savetemps-eq/savetemps.exe /entry:main \
+; RUN:     /subsystem:console %T/savetemps-eq/savetemps.obj %T/savetemps-eq/thin1.obj
+; RUN: ls %T/savetemps-eq/*.exe.index.bc | count 1
+
+;; Check prelink
+; RUN: lld-link /lldsavetemps:prelink /out:%T/savetemps-eq/savetemps.exe /entry:main \
+; RUN:     /subsystem:console %T/savetemps-eq/savetemps.obj %T/savetemps-eq/thin1.obj
+; RUN: ls %T/savetemps-eq/*.exe.lto.*.obj | count 2
+
+;; Check resolution
+; RUN: lld-link /lldsavetemps:resolution /out:%T/savetemps-eq/savetemps.exe /entry:main \
+; RUN:     /subsystem:console %T/savetemps-eq/savetemps.obj %T/savetemps-eq/thin1.obj
+; RUN: ls %T/savetemps-eq/*.resolution.txt | count 1
+
----------------
mstorsjo wrote:

While checking all the allowed values, I think it would be valuable to also check the error message when passing an invalid value. For that, you'll need to do something like `not lld-link ... 2>&1 | FileCheck %s`, possibly wrapped in a setting like `env LLD_IN_TEST=1 not lld-link ...` (which may be needed for getting the error output checked).

https://github.com/llvm/llvm-project/pull/115131


More information about the llvm-commits mailing list