summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Böck <markus.boeck02@gmail.com>2021-03-30 08:52:28 +0200
committerMarkus Böck <markus.boeck02@gmail.com>2021-03-30 08:52:58 +0200
commit142d522dedbb06fdc5fdaa7650b322c479ddda45 (patch)
treeaed799d39e6d0f163810b27caecaa0a245a44563
parentea08d4ba37362506ebd30957a9473467df6f00b9 (diff)
downloadllvm-142d522dedbb06fdc5fdaa7650b322c479ddda45.tar.gz
[llvm-profdata] Make sure to consume Error on the error path of setIsIRLevelProfile
Encountered a crash while running a debug build, where this code path would be taken due to a mismatch in profile coverage data versions. Without consuming the error, an assert would be triggered inside the destructor of Error. Differential Revision: https://reviews.llvm.org/D99457
-rw-r--r--llvm/test/tools/llvm-profdata/Inputs/fe-basic.proftext6
-rw-r--r--llvm/test/tools/llvm-profdata/Inputs/ir-basic.proftext6
-rw-r--r--llvm/test/tools/llvm-profdata/merge-incompatible.test2
-rw-r--r--llvm/tools/llvm-profdata/llvm-profdata.cpp3
4 files changed, 16 insertions, 1 deletions
diff --git a/llvm/test/tools/llvm-profdata/Inputs/fe-basic.proftext b/llvm/test/tools/llvm-profdata/Inputs/fe-basic.proftext
new file mode 100644
index 000000000000..34aa03640176
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/Inputs/fe-basic.proftext
@@ -0,0 +1,6 @@
+:fe
+foo
+29667547796
+2
+100
+90
diff --git a/llvm/test/tools/llvm-profdata/Inputs/ir-basic.proftext b/llvm/test/tools/llvm-profdata/Inputs/ir-basic.proftext
new file mode 100644
index 000000000000..b177a624a7b5
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/Inputs/ir-basic.proftext
@@ -0,0 +1,6 @@
+:ir
+foo2
+29667547796
+2
+100
+90
diff --git a/llvm/test/tools/llvm-profdata/merge-incompatible.test b/llvm/test/tools/llvm-profdata/merge-incompatible.test
new file mode 100644
index 000000000000..dad1c0ad5dbb
--- /dev/null
+++ b/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.
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 558d3e6ffd78..4f919b06ff20 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -251,7 +251,8 @@ static void loadInput(const WeightedFile &Input, SymbolRemapper *Remapper,
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.",