[PATCH] D99457: [llvm-profdata] Make sure to consume Error on the error path of setIsIRLevelProfile

Markus Böck via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 29 10:50:35 PDT 2021


zero9178 updated this revision to Diff 333928.
zero9178 added a comment.

Thanks a lot for the help.
I have now added tests that reproduce the issue and also ensure the error is emitted.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99457/new/

https://reviews.llvm.org/D99457

Files:
  llvm/test/tools/llvm-profdata/Inputs/fe-basic.proftext
  llvm/test/tools/llvm-profdata/Inputs/ir-basic.proftext
  llvm/test/tools/llvm-profdata/merge-incompatible.test
  llvm/tools/llvm-profdata/llvm-profdata.cpp


Index: llvm/tools/llvm-profdata/llvm-profdata.cpp
===================================================================
--- llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -251,7 +251,8 @@
   auto Reader = std::move(ReaderOrErr.get());
   bool IsIRProfile = Reader->isIRLevelProfile();
   bool HasCSIRProfile = Reader->hasCSIRLevelProfile();
-  if (WC->Writer.setIsIRLevelProfile(IsIRProfile, HasCSIRProfile)) {
+  if (Error E = WC->Writer.setIsIRLevelProfile(IsIRProfile, HasCSIRProfile)) {
+    consumeError(std::move(E));
     WC->Errors.emplace_back(
         make_error<StringError>(
             "Merge IR generated profile with Clang generated profile.",
Index: llvm/test/tools/llvm-profdata/merge-incompatible.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-profdata/merge-incompatible.test
@@ -0,0 +1,2 @@
+RUN: not llvm-profdata merge %p/Inputs/fe-basic.proftext %p/Inputs/ir-basic.proftext -o /dev/null 2>&1 | FileCheck %s
+CHECK: ir-basic.proftext: Merge IR generated profile with Clang generated profile.
Index: llvm/test/tools/llvm-profdata/Inputs/ir-basic.proftext
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-profdata/Inputs/ir-basic.proftext
@@ -0,0 +1,6 @@
+:ir
+foo2
+29667547796
+2
+100
+90
Index: llvm/test/tools/llvm-profdata/Inputs/fe-basic.proftext
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-profdata/Inputs/fe-basic.proftext
@@ -0,0 +1,6 @@
+:fe
+foo
+29667547796
+2
+100
+90


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99457.333928.patch
Type: text/x-patch
Size: 1634 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210329/c23eda8b/attachment.bin>


More information about the llvm-commits mailing list