[llvm] 142d522 - [llvm-profdata] Make sure to consume Error on the error path of setIsIRLevelProfile
Markus Böck via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 29 23:53:05 PDT 2021
Author: Markus Böck
Date: 2021-03-30T08:52:58+02:00
New Revision: 142d522dedbb06fdc5fdaa7650b322c479ddda45
URL: https://github.com/llvm/llvm-project/commit/142d522dedbb06fdc5fdaa7650b322c479ddda45
DIFF: https://github.com/llvm/llvm-project/commit/142d522dedbb06fdc5fdaa7650b322c479ddda45.diff
LOG: [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
Added:
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
Modified:
llvm/tools/llvm-profdata/llvm-profdata.cpp
Removed:
################################################################################
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 0000000000000..34aa036401769
--- /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 0000000000000..b177a624a7b50
--- /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 0000000000000..dad1c0ad5dbbe
--- /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 558d3e6ffd789..4f919b06ff20d 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.",
More information about the llvm-commits
mailing list