[PATCH] D39885: Disable GC and ICF when /debug is present
Reid Kleckner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 10 13:23:05 PST 2017
rnk updated this revision to Diff 122515.
rnk added a comment.
- make opt:ref imply ICF unless it's explicitly disabled
https://reviews.llvm.org/D39885
Files:
lld/COFF/Driver.cpp
lld/test/COFF/icf-associative.test
lld/test/COFF/icf-simple.test
lld/test/COFF/pdb-global-gc.yaml
lld/test/COFF/pdb-import-gc.yaml
Index: lld/test/COFF/pdb-import-gc.yaml
===================================================================
--- lld/test/COFF/pdb-import-gc.yaml
+++ lld/test/COFF/pdb-import-gc.yaml
@@ -1,6 +1,6 @@
# RUN: yaml2obj %s -o %t.obj
# RUN: lld-link %t.obj %S/Inputs/pdb-import-gc.lib -debug -entry:main \
-# RUN: -nodefaultlib -debug -out:%t.exe -pdb:%t.pdb
+# RUN: -nodefaultlib -opt:ref -out:%t.exe -pdb:%t.pdb
# RUN: llvm-pdbutil dump -globals -symbols %t.pdb | FileCheck %s
# This tests the case where an __imp_ chunk is discarded by linker GC. The debug
Index: lld/test/COFF/pdb-global-gc.yaml
===================================================================
--- lld/test/COFF/pdb-global-gc.yaml
+++ lld/test/COFF/pdb-global-gc.yaml
@@ -1,7 +1,7 @@
# RUN: yaml2obj %s -o %t.obj
# RUN: llvm-mc %S/Inputs/pdb-global-gc.s -triple x86_64-windows-msvc -filetype=obj -o %t2.obj
# RUN: lld-link %t.obj %t2.obj -debug -entry:main \
-# RUN: -nodefaultlib -debug -out:%t.exe -pdb:%t.pdb -verbose
+# RUN: -nodefaultlib -opt:ref -out:%t.exe -pdb:%t.pdb -verbose
# RUN: llvm-pdbutil dump -symbols -globals %t.pdb | FileCheck %s
# This tests the case where an __imp_ chunk is discarded by linker GC. The debug
Index: lld/test/COFF/icf-simple.test
===================================================================
--- lld/test/COFF/icf-simple.test
+++ lld/test/COFF/icf-simple.test
@@ -1,5 +1,5 @@
# RUN: yaml2obj < %s > %t.obj
-# RUN: lld-link /entry:foo /out:%t.exe /subsystem:console /include:bar \
+# RUN: lld-link /opt:icf /entry:foo /out:%t.exe /subsystem:console /include:bar \
# RUN: /verbose %t.obj > %t.log 2>&1
# RUN: FileCheck -check-prefix=ICF %s < %t.log
Index: lld/test/COFF/icf-associative.test
===================================================================
--- lld/test/COFF/icf-associative.test
+++ lld/test/COFF/icf-associative.test
@@ -1,5 +1,5 @@
# RUN: yaml2obj < %s > %t.obj
-# RUN: lld-link /entry:foo /out:%t.exe /subsystem:console /include:bar \
+# RUN: lld-link /opt:icf /entry:foo /out:%t.exe /subsystem:console /include:bar \
# RUN: /debug /verbose %t.obj > %t.log 2>&1
# RUN: FileCheck %s < %t.log
Index: lld/COFF/Driver.cpp
===================================================================
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -896,7 +896,13 @@
if (auto *Arg = Args.getLastArg(OPT_implib))
Config->Implib = Arg->getValue();
- // Handle /opt
+ // Handle /opt. Disable GC and ICF if /debug is specified and no /opt flag is
+ // specified.
+ if (Args.hasArg(OPT_debug)) {
+ Config->DoGC = false;
+ Config->DoICF = false;
+ }
+ bool HaveNoICF = false;
for (auto *Arg : Args.filtered(OPT_opt)) {
std::string Str = StringRef(Arg->getValue()).lower();
SmallVector<StringRef, 1> Vec;
@@ -907,11 +913,20 @@
Config->DoICF = false;
continue;
}
+ if (S == "ref") {
+ // /opt:ref enables both GC and ICF unless /opt:noicf came first.
+ Config->DoGC = true;
+ if (!HaveNoICF)
+ Config->DoICF = true;
+ continue;
+ }
if (S == "icf" || S.startswith("icf=")) {
+ Config->DoGC = true;
Config->DoICF = true;
continue;
}
if (S == "noicf") {
+ HaveNoICF = true;
Config->DoICF = false;
continue;
}
@@ -935,7 +950,7 @@
error("/opt:lldltopartitions: invalid partition count: " + N);
continue;
}
- if (S != "ref" && S != "lbr" && S != "nolbr")
+ if (S != "lbr" && S != "nolbr")
error("/opt: unknown option: " + S);
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39885.122515.patch
Type: text/x-patch
Size: 3637 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171110/8edc8f5c/attachment.bin>
More information about the llvm-commits
mailing list