Skip to content

Commit 9a56b8d

Browse files
committed
Changed unified-lto mode processing to use clEnumValN
1 parent b17f952 commit 9a56b8d

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

llvm/tools/llvm-lto2/llvm-lto2.cpp

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,18 @@ static cl::list<std::string>
198198
PassPlugins("load-pass-plugin",
199199
cl::desc("Load passes from plugin library"));
200200

201-
static cl::opt<std::string> UnifiedLTOMode(
201+
static cl::opt<LTO::LTOKind> UnifiedLTOMode(
202202
"unified-lto", cl::Optional,
203-
cl::desc("Set LTO mode with the following options:\n"
204-
" thin ThinLTO, with Unified LTO enabled.\n"
205-
" full Regular LTO, with Unified LTO enabled.\n"
206-
" default Any LTO mode without Unified LTO. The default mode."),
207-
cl::value_desc("mode"));
203+
cl::desc("Set LTO mode with the following options:"),
204+
cl::values(
205+
clEnumValN(LTO::LTOK_UnifiedThin, "thin",
206+
"ThinLTO with Unified LTO enabled"),
207+
clEnumValN(LTO::LTOK_UnifiedRegular, "full",
208+
"Regular LTO with Unified LTO enabled"),
209+
clEnumValN(LTO::LTOK_Default, "default",
210+
"Any LTO mode without Unified LTO. The default mode")
211+
),
212+
cl::value_desc("mode"), cl::init(LTO::LTOK_Default));
208213

209214
static cl::opt<bool> EnableFreestanding(
210215
"lto-freestanding",
@@ -408,18 +413,7 @@ static int run(int argc, char **argv) {
408413
HasErrors = true;
409414
};
410415

411-
LTO::LTOKind LTOMode = LTO::LTOK_Default;
412-
413-
if (UnifiedLTOMode == "full") {
414-
LTOMode = LTO::LTOK_UnifiedRegular;
415-
} else if (UnifiedLTOMode == "thin") {
416-
LTOMode = LTO::LTOK_UnifiedThin;
417-
} else if (UnifiedLTOMode == "default") {
418-
LTOMode = LTO::LTOK_Default;
419-
} else if (!UnifiedLTOMode.empty()) {
420-
llvm::errs() << "invalid LTO mode\n";
421-
return 1;
422-
}
416+
LTO::LTOKind LTOMode = UnifiedLTOMode;
423417

424418
LTO Lto(std::move(Conf), std::move(Backend), 1, LTOMode);
425419

0 commit comments

Comments
 (0)