[PATCH] D94463: [Driver] Fix assertion failure when -fprofile-generate -fcs-profile-generate are used together
Fangrui Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 12 14:02:52 PST 2021
MaskRay updated this revision to Diff 316233.
MaskRay retitled this revision from "[Driver] Make -fcs-profile-generate require -fprofile-use" to "[Driver] Fix assertion failure when -fprofile-generate -fcs-profile-generate are used together".
MaskRay edited the summary of this revision.
MaskRay added a comment.
.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94463/new/
https://reviews.llvm.org/D94463
Files:
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/fcs-profile-generate.c
Index: clang/test/Driver/fcs-profile-generate.c
===================================================================
--- /dev/null
+++ clang/test/Driver/fcs-profile-generate.c
@@ -0,0 +1,13 @@
+// RUN: %clang -### -c -fprofile-use=a.profdata -fcs-profile-generate %s 2>&1 | FileCheck %s
+// CHECK: "-fprofile-instrument=csllvm" "-fprofile-instrument-use-path=a.profdata"
+
+// RUN: %clang -### -c -fprofile-use=a.profdata -fcs-profile-generate=dir %s 2>&1 | FileCheck %s --check-prefix=CHECK1
+// CHECK1: "-fprofile-instrument=csllvm" "-fprofile-instrument-path=dir/default_%m.profraw" "-fprofile-instrument-use-path=a.profdata"
+
+/// Degradation case. This usage does not make much sense.
+// RUN: %clang -### -c -fcs-profile-generate %s 2>&1 | FileCheck %s --check-prefix=NOUSE
+// NOUSE: "-fprofile-instrument=csllvm"
+// NOUSE-NOT: "-fprofile-instrument-path=
+
+// RUN: %clang -### -c -fprofile-generate -fcs-profile-generate %s 2>&1 | FileCheck %s --check-prefix=CONFLICT
+// CONFLICT: error: invalid argument '-fcs-profile-generate' not allowed with '-fprofile-generate'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -766,9 +766,11 @@
D.Diag(diag::err_drv_argument_not_allowed_with)
<< ProfileGenerateArg->getSpelling() << ProfileUseArg->getSpelling();
- if (CSPGOGenerateArg && PGOGenerateArg)
+ if (CSPGOGenerateArg && PGOGenerateArg) {
D.Diag(diag::err_drv_argument_not_allowed_with)
<< CSPGOGenerateArg->getSpelling() << PGOGenerateArg->getSpelling();
+ PGOGenerateArg = nullptr;
+ }
if (ProfileGenerateArg) {
if (ProfileGenerateArg->getOption().matches(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94463.316233.patch
Type: text/x-patch
Size: 1771 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210112/555846ef/attachment.bin>
More information about the cfe-commits
mailing list