Index: COFF/Driver.cpp =================================================================== --- COFF/Driver.cpp +++ COFF/Driver.cpp @@ -1028,8 +1028,9 @@ Config->Implib = Arg->getValue(); // Handle /opt. - bool DoGC = !Args.hasArg(OPT_debug); - unsigned ICFLevel = 1; // 0: off, 1: limited, 2: on + bool DoGC = !Args.hasArg(OPT_debug) || Args.hasArg(OPT_profile); + unsigned ICFLevel = + Args.hasArg(OPT_profile) ? 0 : 1; // 0: off, 1: limited, 2: on for (auto *Arg : Args.filtered(OPT_opt)) { std::string Str = StringRef(Arg->getValue()).lower(); SmallVector Vec; @@ -1144,7 +1145,8 @@ Args.hasFlag(OPT_allowisolation, OPT_allowisolation_no, true); Config->Incremental = Args.hasFlag(OPT_incremental, OPT_incremental_no, - !Config->DoGC && !Config->DoICF && !Args.hasArg(OPT_order)); + !Config->DoGC && !Config->DoICF && !Args.hasArg(OPT_order) && + !Args.hasArg(OPT_profile)); Config->NxCompat = Args.hasFlag(OPT_nxcompat, OPT_nxcompat_no, true); Config->TerminalServerAware = Args.hasFlag(OPT_tsaware, OPT_tsaware_no, true); Config->DebugDwarf = Args.hasArg(OPT_debug_dwarf); @@ -1152,6 +1154,16 @@ Config->MapFile = getMapFile(Args); + if (Config->Incremental && Args.hasArg(OPT_profile)) { + warn("ignoring '/incremental' due to '/profile' specification"); + Config->Incremental = false; + } + + if (Config->Incremental && Args.hasArg(OPT_order)) { + warn("ignoring '/incremental' due to '/order' specification"); + Config->Incremental = false; + } + if (Config->Incremental && Config->DoGC) { warn("ignoring '/incremental' because REF is enabled; use '/opt:noref' to " "disable"); @@ -1164,11 +1176,6 @@ Config->Incremental = false; } - if (Config->Incremental && Args.hasArg(OPT_order)) { - warn("ignoring '/INCREMENTAL' due to '/ORDER' specification"); - Config->Incremental = false; - } - if (errorCount()) return; Index: test/COFF/icf-simple.test =================================================================== --- test/COFF/icf-simple.test +++ test/COFF/icf-simple.test @@ -23,6 +23,11 @@ # RUN: /include:bar /verbose %t.obj > %t.log 2>&1 # RUN: FileCheck -check-prefix=NOICF %s < %t.log +# /profile disables ICF. +# RUN: lld-link /profile /entry:foo /out:%t.exe /subsystem:console \ +# RUN: /include:bar /verbose %t.obj > %t.log 2>&1 +# RUN: FileCheck -check-prefix=NOICF %s < %t.log + # /opt:noref disables ICF. # RUN: lld-link /opt:noref /entry:foo /out:%t.exe /subsystem:console \ # RUN: /include:bar /verbose %t.obj > %t.log 2>&1 Index: test/COFF/incremental.test =================================================================== --- test/COFF/incremental.test +++ test/COFF/incremental.test @@ -1,4 +1,5 @@ # RUN: yaml2obj < %p/Inputs/export.yaml > %t.obj + # RUN: lld-link -out:%t.dll -dll %t.obj 2>&1 \ # RUN: | FileCheck -allow-empty -check-prefix=NOWARN %s # RUN: touch -t 198002011200.00 %t.lib @@ -11,6 +12,12 @@ # RUN: lld-link -out:%t.dll -dll -incremental %t.obj # RUN: ls -l %t.lib | FileCheck -check-prefix=NOKEEP %s +# RUN: lld-link -out:%t.dll -dll -incremental -opt:noref,noicf %t.obj 2>&1 \ +# RUN: | FileCheck -allow-empty -check-prefix=NOWARN %s +# RUN: touch -t 198002011200.00 %t.lib +# RUN: lld-link -out:%t.dll -dll -incremental -opt:noref,noicf %t.obj +# RUN: ls -l %t.lib | FileCheck -check-prefix=KEEP %s + # RUN: lld-link -out:%t.dll -dll -debug %t.obj 2>&1 \ # RUN: | FileCheck -allow-empty -check-prefix=NOWARN %s # RUN: touch -t 198002011200.00 %t.lib @@ -53,6 +60,31 @@ # RUN: lld-link -out:%t.dll -dll -incremental -opt:ref %t.obj # RUN: ls -l %t.lib | FileCheck -check-prefix=NOKEEP %s +# RUN: touch %t.order +# RUN: lld-link -out:%t.dll -dll -incremental -opt:noref,noicf %t.obj \ +# RUN: -order:@%t.order 2>&1 | FileCheck -check-prefix=WARN-ORDER %s +# RUN: touch -t 198002011200.00 %t.lib +# RUN: lld-link -out:%t.dll -dll -incremental -opt:noref,noicf -order:@%t.order %t.obj +# RUN: ls -l %t.lib | FileCheck -check-prefix=NOKEEP %s + +# RUN: lld-link -out:%t.dll -dll -opt:noref,noicf %t.obj \ +# RUN: -order:@%t.order 2>&1 | FileCheck -allow-empty -check-prefix=NOWARN %s +# RUN: touch -t 198002011200.00 %t.lib +# RUN: lld-link -out:%t.dll -dll -opt:noref,noicf -order:@%t.order %t.obj +# RUN: ls -l %t.lib | FileCheck -check-prefix=NOKEEP %s + +# RUN: lld-link -out:%t.dll -dll -incremental -opt:noref,noicf %t.obj \ +# RUN: -profile 2>&1 | FileCheck -check-prefix=WARN-PROFILE %s +# RUN: touch -t 198002011200.00 %t.lib +# RUN: lld-link -out:%t.dll -dll -incremental -opt:noref,noicf -profile %t.obj +# RUN: ls -l %t.lib | FileCheck -check-prefix=NOKEEP %s + +# RUN: lld-link -out:%t.dll -dll -opt:noref,noicf %t.obj \ +# RUN: -profile 2>&1 | FileCheck -allow-empty -check-prefix=NOWARN %s +# RUN: touch -t 198002011200.00 %t.lib +# RUN: lld-link -out:%t.dll -dll -opt:noref,noicf -profile %t.obj +# RUN: ls -l %t.lib | FileCheck -check-prefix=NOKEEP %s + # RUN: lld-link -out:%t.dll -dll -debug -opt:ref %t.obj 2>&1 \ # RUN: | FileCheck -allow-empty -check-prefix=NOWARN %s # RUN: touch -t 198002011200.00 %t.lib @@ -62,5 +94,7 @@ # NOWARN-NOT: ignoring '/incremental' # WARN-ICF: ignoring '/incremental' because ICF is enabled; use '/opt:noicf' to disable # WARN-REF: ignoring '/incremental' because REF is enabled; use '/opt:noref' to disable +# WARN-ORDER: ignoring '/incremental' due to '/order' specification +# WARN-PROFILE: ignoring '/incremental' due to '/profile' specification # KEEP: {{Feb 1 1980|1980-02-01}} # NOKEEP-NOT: {{Feb 1 1980|1980-02-01}} Index: test/COFF/opt.test =================================================================== --- test/COFF/opt.test +++ test/COFF/opt.test @@ -1,13 +1,24 @@ # RUN: yaml2obj < %s > %t.obj # RUN: lld-link /out:%t.exe /entry:main %t.obj \ -# RUN: /verbose 2>&1 | FileCheck -check-prefix=CHECK1 %s +# RUN: /verbose 2>&1 | FileCheck -check-prefix=REF %s + +# /debug disables the /opt:ref default... +# RUN: lld-link /out:%t.exe /debug /entry:main %t.obj \ +# RUN: /verbose 2>&1 | FileCheck -check-prefix=NOREF %s + +# ...unless /profile is passed as well. +# RUN: lld-link /out:%t.exe /profile /debug /entry:main %t.obj \ +# RUN: /verbose 2>&1 | FileCheck -check-prefix=REF %s + +# RUN: lld-link /out:%t.exe /opt:ref /debug /entry:main %t.obj \ +# RUN: /verbose 2>&1 | FileCheck -check-prefix=REF %s # RUN: lld-link /out:%t.exe /entry:main %t.obj \ -# RUN: /verbose /opt:noref 2>&1 | FileCheck -check-prefix=CHECK2 %s +# RUN: /verbose /opt:noref /profile 2>&1 | FileCheck -check-prefix=NOREF %s -# CHECK1: Discarded unused -# CHECK2-NOT: Discarded unused +# REF: Discarded unused +# NOREF-NOT: Discarded unused --- !COFF header: