-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[llvm-lto2] Added llvm-lto2 -unified-lto descriptions (revised) #155462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-lto Author: Faith Rivera (fnriv) ChangesThis is a revised PR of #148309 (closed due to some git issues). The changes do the following:
Full diff: https://github.com/llvm/llvm-project/pull/155462.diff 2 Files Affected:
diff --git a/llvm/test/LTO/Resolution/X86/unified-lto-check.ll b/llvm/test/LTO/Resolution/X86/unified-lto-check.ll
index cf1e5693165e3..e1a93e5665702 100644
--- a/llvm/test/LTO/Resolution/X86/unified-lto-check.ll
+++ b/llvm/test/LTO/Resolution/X86/unified-lto-check.ll
@@ -38,6 +38,16 @@
; 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: invalid LTO mode
+
; UNIFIEDERR: unified LTO compilation must use compatible bitcode modules
; NOUNIFIEDERR-NOT: unified LTO compilation must use compatible bitcode modules
@@ -54,3 +64,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"
+
diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp b/llvm/tools/llvm-lto2/llvm-lto2.cpp
index fbde66666a596..00021c9a32fa3 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -198,9 +198,18 @@ 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. The default mode")
+ ),
+ cl::value_desc("mode"), cl::init(LTO::LTOK_Default));
static cl::opt<bool> EnableFreestanding(
"lto-freestanding",
@@ -404,18 +413,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);
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
Narrowing down the CI failure,
I guess that's the correct behaviour, in that an error is produced if the wrong argument is given, it's just not quite the same error text as what you're' checking for? |
Digging through the windows-bot failure,
That's a Windows issue where llvm-lto2 has ".exe" on the end if on Windows, and doesn't on Linux. I suppose that's solveable through using an optional regex for ".exe", or just not checking for the binary name and only the error message. |
@fnriv Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
I see LTO test failures on macOS llvm.org bot: https://green.lab.llvm.org/job/llvm.org/job/clang-stage2-cmake-RgSan/1057/ Can you check if this change might have affected it? |
Alas we don't have any mac environments to test in; a speculative revert and then reapplication if it doesn't fix anything would be alright, this a user-facing options fix. By my reading the relevant error message on green-dragon is the preloaded "libclang_rt.asan_osx_dynamic.dylib: command not found" message; it seems unlikely that this options change would manage to change something and propagate that far into a build without causing some other error. (I know nothing about green dragon though!) |
Hi, I had a mac machine when developing this and currently do not have access to a Windows/Linux machine. An alternative approach I can change could be to revert it to string checking rather than clEnumValN checking (as was done before)? I had changed it to clEnumValN due to precedence of that type of check (you can see conversation about this in #148309) |
This is a revised PR of #148309 (closed due to some git issues). The changes do the following:
-unified-lto=mode
optionunified-lto
descriptions from string to cEnumValN for continuity of description formattingunified-lto-check.ll