Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions llvm/test/LTO/Resolution/X86/unified-lto-check.ll
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@
; RUN: llvm-lto2 run --debug-only=lto -o %t3 %t1 %t2 2>&1 | \
; RUN: FileCheck --allow-empty %s --check-prefix THIN

; Test invalid unified-lto mode causes an error message return.
; RUN: not llvm-lto2 run --unified-lto=foo -o %t3 %t1 %t2 2>&1 | \
; RUN: FileCheck %s --check-prefix INVALIDMODE
; RUN: not llvm-lto2 run --unified-lto="foo" -o %t3 %t1 %t2 2>&1 | \
; RUN: FileCheck %s --check-prefix INVALIDMODE
; RUN: not llvm-lto2 run --unified-lto=1 -o %t3 %t1 %t2 2>&1 | \
; RUN: FileCheck %s --check-prefix INVALIDMODE

; INVALIDMODE: for the --unified-lto option: Cannot find option named


; UNIFIEDERR: unified LTO compilation must use compatible bitcode modules
; NOUNIFIEDERR-NOT: unified LTO compilation must use compatible bitcode modules

Expand All @@ -54,3 +65,4 @@

target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

29 changes: 13 additions & 16 deletions llvm/tools/llvm-lto2/llvm-lto2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,16 @@ static cl::list<std::string>
PassPlugins("load-pass-plugin",
cl::desc("Load passes from plugin library"));

static cl::opt<std::string> UnifiedLTOMode("unified-lto", cl::Optional,
cl::desc("Set LTO mode"),
cl::value_desc("mode"));
static cl::opt<LTO::LTOKind> UnifiedLTOMode(
"unified-lto", cl::Optional,
cl::desc("Set LTO mode with the following options:"),
cl::values(clEnumValN(LTO::LTOK_UnifiedThin, "thin",
"ThinLTO with Unified LTO enabled"),
clEnumValN(LTO::LTOK_UnifiedRegular, "full",
"Regular LTO with Unified LTO enabled"),
clEnumValN(LTO::LTOK_Default, "default",
"Any LTO mode without Unified LTO")),
cl::value_desc("mode"), cl::init(LTO::LTOK_Default));

static cl::opt<bool> EnableFreestanding(
"lto-freestanding",
Expand Down Expand Up @@ -404,18 +411,7 @@ static int run(int argc, char **argv) {
HasErrors = true;
};

LTO::LTOKind LTOMode = LTO::LTOK_Default;

if (UnifiedLTOMode == "full") {
LTOMode = LTO::LTOK_UnifiedRegular;
} else if (UnifiedLTOMode == "thin") {
LTOMode = LTO::LTOK_UnifiedThin;
} else if (UnifiedLTOMode == "default") {
LTOMode = LTO::LTOK_Default;
} else if (!UnifiedLTOMode.empty()) {
llvm::errs() << "invalid LTO mode\n";
return 1;
}
LTO::LTOKind LTOMode = UnifiedLTOMode;

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

Expand Down Expand Up @@ -578,7 +574,8 @@ static int dumpSymtab(int argc, char **argv) {
}

if (TT.isOSBinFormatCOFF() && Sym.isWeak() && Sym.isIndirect())
outs() << " fallback " << Sym.getCOFFWeakExternalFallback() << '\n';
outs() << " fallback " << Sym.getCOFFWeakExternalFallback()
<< '\n';

if (!Sym.getSectionName().empty())
outs() << " section " << Sym.getSectionName() << "\n";
Expand Down