[PATCH] D92857: [clang][cli] Don't always emit -f[no-]experimental-new-pass-manager
Jan Svoboda via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 11 05:45:32 PST 2020
jansvoboda11 updated this revision to Diff 311190.
jansvoboda11 added a comment.
Rebase
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D92857/new/
https://reviews.llvm.org/D92857
Files:
clang/unittests/Frontend/CompilerInvocationTest.cpp
llvm/include/llvm/Option/OptParser.td
Index: llvm/include/llvm/Option/OptParser.td
===================================================================
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -173,7 +173,6 @@
class MarshallingInfoBooleanFlag<code keypath, code defaultvalue, code neg_name, string neg_spelling>
: MarshallingInfoFlag<keypath, defaultvalue> {
- bit ShouldAlwaysEmit = 1;
code Normalizer = "makeBooleanFlagNormalizer(OPT_"#neg_name#")";
code Denormalizer = "makeBooleanFlagDenormalizer(\""#neg_spelling#"\")";
}
Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===================================================================
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -177,6 +177,14 @@
// The flag with positive spelling can set the keypath to true.
// The flag with negative spelling can set the keypath to false.
+static constexpr const char *PassManagerResetByFlag =
+ LLVM_ENABLE_NEW_PASS_MANAGER ? "-fno-legacy-pass-manager"
+ : "-flegacy-pass-manager";
+
+static constexpr const char *PassManagerChangedByFlag =
+ LLVM_ENABLE_NEW_PASS_MANAGER ? "-flegacy-pass-manager"
+ : "-fno-legacy-pass-manager";
+
TEST_F(CommandLineTest, BoolOptionDefaultArbitraryTwoFlagsPresentNone) {
const char *Args = {""};
@@ -188,40 +196,32 @@
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
- const char *ResetByFlag = LLVM_ENABLE_NEW_PASS_MANAGER
- ? "-fno-legacy-pass-manager"
- : "-flegacy-pass-manager";
-
- const char *ChangedByFlag = LLVM_ENABLE_NEW_PASS_MANAGER
- ? "-flegacy-pass-manager"
- : "-fno-legacy-pass-manager";
-
- ASSERT_THAT(GeneratedArgs, Contains(StrEq(ResetByFlag)));
- ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq(ChangedByFlag))));
+ ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq(PassManagerResetByFlag))));
+ ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq(PassManagerChangedByFlag))));
}
-TEST_F(CommandLineTest, BoolOptionDefaultArbitraryTwoFlagsPresentPos) {
- const char *Args[] = {"-flegacy-pass-manager"};
+TEST_F(CommandLineTest, BoolOptionDefaultArbitraryTwoFlagsPresentChange) {
+ const char *Args[] = {PassManagerChangedByFlag};
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_TRUE(Invocation.getCodeGenOpts().LegacyPassManager);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
- ASSERT_THAT(GeneratedArgs, Contains(StrEq("-flegacy-pass-manager")));
- ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-legacy-pass-manager"))));
+ ASSERT_THAT(GeneratedArgs, Contains(StrEq(PassManagerChangedByFlag)));
+ ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq(PassManagerResetByFlag))));
}
-TEST_F(CommandLineTest, BoolOptionDefaultArbitraryTwoFlagsPresentNeg) {
- const char *Args[] = {"-fno-legacy-pass-manager"};
+TEST_F(CommandLineTest, BoolOptionDefaultArbitraryTwoFlagsPresentReset) {
+ const char *Args[] = {PassManagerResetByFlag};
CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags);
ASSERT_FALSE(Diags->hasErrorOccurred());
ASSERT_FALSE(Invocation.getCodeGenOpts().LegacyPassManager);
Invocation.generateCC1CommandLine(GeneratedArgs, *this);
- ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fno-legacy-pass-manager")));
- ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-flegacy-pass-manager"))));
+ ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq(PassManagerChangedByFlag))));
+ ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq(PassManagerResetByFlag))));
}
TEST_F(CommandLineTest, CanGenerateCC1CommandLineFlag) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92857.311190.patch
Type: text/x-patch
Size: 3807 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201211/e147f679/attachment.bin>
More information about the llvm-commits
mailing list