Author: Arthur Eubanks Date: 2021-09-21T14:35:56-07:00 New Revision: e1ed02181ffcfea7de952d252a5e25953c822251
URL: https://github.com/llvm/llvm-project/commit/e1ed02181ffcfea7de952d252a5e25953c822251 DIFF: https://github.com/llvm/llvm-project/commit/e1ed02181ffcfea7de952d252a5e25953c822251.diff LOG: [clang] Make -Rpass imply -Rpass=.* Previously with -Rpass (and friends) we'd have remarks "enabled", but without an actual regex. As seen in the test change to line numbers, this can give us better diagnostics by properly enabling NeedLocTracking with -Rpass. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D110201 Added: Modified: clang/lib/Frontend/CompilerInvocation.cpp clang/test/Frontend/optimization-remark-analysis.c clang/test/Frontend/optimization-remark.c Removed: ################################################################################ diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 38abcf91ab7d3..10b2e96e89578 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1174,8 +1174,9 @@ ParseOptimizationRemark(DiagnosticsEngine &Diags, ArgList &Args, OptSpecifier OptEQ, StringRef Name) { CodeGenOptions::OptRemark Result; - auto InitializeResultPattern = [&Diags, &Args, &Result](const Arg *A) { - Result.Pattern = A->getValue(); + auto InitializeResultPattern = [&Diags, &Args, &Result](const Arg *A, + StringRef Pattern) { + Result.Pattern = Pattern.str(); std::string RegexError; Result.Regex = std::make_shared<llvm::Regex>(Result.Pattern); @@ -1200,19 +1201,21 @@ ParseOptimizationRemark(DiagnosticsEngine &Diags, ArgList &Args, Result.Kind = CodeGenOptions::RK_Disabled; else if (Value == "no-everything") Result.Kind = CodeGenOptions::RK_DisabledEverything; + + if (Result.Kind == CodeGenOptions::RK_Disabled || + Result.Kind == CodeGenOptions::RK_DisabledEverything) { + Result.Pattern = ""; + Result.Regex = nullptr; + } else { + InitializeResultPattern(A, ".*"); + } } else if (A->getOption().matches(OptEQ)) { Result.Kind = CodeGenOptions::RK_WithPattern; - if (!InitializeResultPattern(A)) + if (!InitializeResultPattern(A, A->getValue())) return CodeGenOptions::OptRemark(); } } - if (Result.Kind == CodeGenOptions::RK_Disabled || - Result.Kind == CodeGenOptions::RK_DisabledEverything) { - Result.Pattern = ""; - Result.Regex = nullptr; - } - return Result; } diff --git a/clang/test/Frontend/optimization-remark-analysis.c b/clang/test/Frontend/optimization-remark-analysis.c index b396327976186..e43984942a6ef 100644 --- a/clang/test/Frontend/optimization-remark-analysis.c +++ b/clang/test/Frontend/optimization-remark-analysis.c @@ -1,8 +1,8 @@ // RUN: %clang -O1 -fvectorize -target x86_64-unknown-unknown -emit-llvm -Rpass-analysis -S %s -o - 2>&1 | FileCheck %s --check-prefix=RPASS // RUN: %clang -O1 -fvectorize -target x86_64-unknown-unknown -emit-llvm -S %s -o - 2>&1 | FileCheck %s -// RPASS: {{.*}}:7:8: remark: loop not vectorized: loop contains a switch statement -// CHECK-NOT: {{.*}}:7:8: remark: loop not vectorized: loop contains a switch statement +// RPASS: {{.*}}:12:5: remark: loop not vectorized: loop contains a switch statement +// CHECK-NOT: remark: loop not vectorized: loop contains a switch statement double foo(int N, int *Array) { double v = 0.0; diff --git a/clang/test/Frontend/optimization-remark.c b/clang/test/Frontend/optimization-remark.c index 2287693a45e40..d4cab0bdec0cb 100644 --- a/clang/test/Frontend/optimization-remark.c +++ b/clang/test/Frontend/optimization-remark.c @@ -26,11 +26,11 @@ // RUN: %clang_cc1 %s -Rpass=inline -fno-experimental-new-pass-manager -w -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS // RUN: %clang_cc1 %s -Rpass=inline -fexperimental-new-pass-manager -O1 -w -emit-llvm -mllvm -mandatory-inlining-first=false -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS // -// FIXME: -Reverything should imply -Rpass=.*. -// RUN: %clang_cc1 %s -Reverything -emit-llvm -o - 2>/dev/null | FileCheck %s --check-prefix=CHECK-NO-REMARKS +// -Reverything implies -Rpass=.*. +// RUN: %clang_cc1 %s -Reverything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS // -// FIXME: -Rpass should either imply -Rpass=.* or should be rejected. -// RUN: %clang_cc1 %s -Rpass -emit-llvm -o - 2>/dev/null | FileCheck %s --check-prefix=CHECK-NO-REMARKS +// -Rpass implies -Rpass=.* +// RUN: %clang_cc1 %s -Rpass -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS // CHECK-REMARKS: remark: // CHECK-NO-REMARKS-NOT: remark: _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits