[lld] r250728 - COFF: /OPT should accept comma-separated multiple arguments.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 19 12:40:44 PDT 2015
Author: ruiu
Date: Mon Oct 19 14:40:43 2015
New Revision: 250728
URL: http://llvm.org/viewvc/llvm-project?rev=250728&view=rev
Log:
COFF: /OPT should accept comma-separated multiple arguments.
/OPT:foo,bar is equivalent to /OPT:foo /OPT:bar.
Reported by alexchandel. https://llvm.org/bugs/show_bug.cgi?id=25228
Modified:
lld/trunk/COFF/Driver.cpp
lld/trunk/test/COFF/icf-simple.test
Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=250728&r1=250727&r2=250728&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Mon Oct 19 14:40:43 2015
@@ -361,35 +361,39 @@ void LinkerDriver::link(llvm::ArrayRef<c
// Handle /opt
for (auto *Arg : Args.filtered(OPT_opt)) {
- std::string S = StringRef(Arg->getValue()).lower();
- if (S == "noref") {
- Config->DoGC = false;
- Config->DoICF = false;
- continue;
+ std::string Str = StringRef(Arg->getValue()).lower();
+ SmallVector<StringRef, 1> Vec;
+ StringRef(Str).split(Vec, ',');
+ for (StringRef S : Vec) {
+ if (S == "noref") {
+ Config->DoGC = false;
+ Config->DoICF = false;
+ continue;
+ }
+ if (S == "icf" || StringRef(S).startswith("icf=")) {
+ Config->DoICF = true;
+ continue;
+ }
+ if (S == "noicf") {
+ Config->DoICF = false;
+ continue;
+ }
+ if (StringRef(S).startswith("lldlto=")) {
+ StringRef OptLevel = StringRef(S).substr(7);
+ if (OptLevel.getAsInteger(10, Config->LTOOptLevel) ||
+ Config->LTOOptLevel > 3)
+ error("/opt:lldlto: invalid optimization level: " + OptLevel);
+ continue;
+ }
+ if (StringRef(S).startswith("lldltojobs=")) {
+ StringRef Jobs = StringRef(S).substr(11);
+ if (Jobs.getAsInteger(10, Config->LTOJobs) || Config->LTOJobs == 0)
+ error("/opt:lldltojobs: invalid job count: " + Jobs);
+ continue;
+ }
+ if (S != "ref" && S != "lbr" && S != "nolbr")
+ error(Twine("/opt: unknown option: ") + S);
}
- if (S == "icf" || StringRef(S).startswith("icf=")) {
- Config->DoICF = true;
- continue;
- }
- if (S == "noicf") {
- Config->DoICF = false;
- continue;
- }
- if (StringRef(S).startswith("lldlto=")) {
- StringRef OptLevel = StringRef(S).substr(7);
- if (OptLevel.getAsInteger(10, Config->LTOOptLevel) ||
- Config->LTOOptLevel > 3)
- error("/opt:lldlto: invalid optimization level: " + OptLevel);
- continue;
- }
- if (StringRef(S).startswith("lldltojobs=")) {
- StringRef Jobs = StringRef(S).substr(11);
- if (Jobs.getAsInteger(10, Config->LTOJobs) || Config->LTOJobs == 0)
- error("/opt:lldltojobs: invalid job count: " + Jobs);
- continue;
- }
- if (S != "ref" && S != "lbr" && S != "nolbr")
- error(Twine("/opt: unknown option: ") + S);
}
// Handle /failifmismatch
Modified: lld/trunk/test/COFF/icf-simple.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/icf-simple.test?rev=250728&r1=250727&r2=250728&view=diff
==============================================================================
--- lld/trunk/test/COFF/icf-simple.test (original)
+++ lld/trunk/test/COFF/icf-simple.test Mon Oct 19 14:40:43 2015
@@ -9,6 +9,9 @@
# RUN: lld-link /entry:foo /out:%t.exe /subsystem:console /include:bar \
# RUN: /verbose /opt:noicf %t.obj > %t.log 2>&1
# RUN: FileCheck -check-prefix=NOICF %s < %t.log
+# RUN: lld-link /entry:foo /out:%t.exe /subsystem:console /include:bar \
+# RUN: /verbose /opt:noref,noicf %t.obj > %t.log 2>&1
+# RUN: FileCheck -check-prefix=NOICF %s < %t.log
# NOICF-NOT: Removed foo
# NOICF-NOT: Removed bar
More information about the llvm-commits
mailing list