summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ProfileData/InstrProfTest.cpp
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2017-06-20 01:38:56 +0000
committerVedant Kumar <vsk@apple.com>2017-06-20 01:38:56 +0000
commitb5794ca90c4e1e236eb98bf84b3e3be5e31edc32 (patch)
tree7d7fb893a3a2378d6547b904546f449d7f346fe5 /llvm/unittests/ProfileData/InstrProfTest.cpp
parent4f05b362855cd10b35608a36b18a04647920309c (diff)
downloadbcm5719-llvm-b5794ca90c4e1e236eb98bf84b3e3be5e31edc32.tar.gz
bcm5719-llvm-b5794ca90c4e1e236eb98bf84b3e3be5e31edc32.zip
[ProfileData] PR33517: Check for failure of symtab creation
With PR33517, it became apparent that symbol table creation can fail when presented with malformed inputs. This patch makes that sort of error detectable, so llvm-cov etc. can fail more gracefully. Specifically, we now check that function names within the symbol table aren't empty. Testing: check-{llvm,clang,profile}, some unit test updates. llvm-svn: 305765
Diffstat (limited to 'llvm/unittests/ProfileData/InstrProfTest.cpp')
-rw-r--r--llvm/unittests/ProfileData/InstrProfTest.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/llvm/unittests/ProfileData/InstrProfTest.cpp b/llvm/unittests/ProfileData/InstrProfTest.cpp
index b15029a0813..13436cc0d5b 100644
--- a/llvm/unittests/ProfileData/InstrProfTest.cpp
+++ b/llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -859,7 +859,7 @@ TEST_P(MaybeSparseInstrProfTest, instr_prof_symtab_test) {
FuncNames.push_back("bar2");
FuncNames.push_back("bar3");
InstrProfSymtab Symtab;
- Symtab.create(FuncNames);
+ NoError(Symtab.create(FuncNames));
StringRef R = Symtab.getFuncName(IndexedInstrProf::ComputeHash("func1"));
ASSERT_EQ(StringRef("func1"), R);
R = Symtab.getFuncName(IndexedInstrProf::ComputeHash("func2"));
@@ -880,9 +880,9 @@ TEST_P(MaybeSparseInstrProfTest, instr_prof_symtab_test) {
ASSERT_EQ(StringRef(), R);
// Now incrementally update the symtab
- Symtab.addFuncName("blah_1");
- Symtab.addFuncName("blah_2");
- Symtab.addFuncName("blah_3");
+ NoError(Symtab.addFuncName("blah_1"));
+ NoError(Symtab.addFuncName("blah_2"));
+ NoError(Symtab.addFuncName("blah_3"));
// Finalize it
Symtab.finalizeSymtab();
@@ -907,6 +907,12 @@ TEST_P(MaybeSparseInstrProfTest, instr_prof_symtab_test) {
ASSERT_EQ(StringRef("bar3"), R);
}
+// Test that we get an error when creating a bogus symtab.
+TEST_P(MaybeSparseInstrProfTest, instr_prof_bogus_symtab_empty_func_name) {
+ InstrProfSymtab Symtab;
+ ErrorEquals(instrprof_error::malformed, Symtab.addFuncName(""));
+}
+
// Testing symtab creator interface used by value profile transformer.
TEST_P(MaybeSparseInstrProfTest, instr_prof_symtab_module_test) {
LLVMContext Ctx;
@@ -927,7 +933,7 @@ TEST_P(MaybeSparseInstrProfTest, instr_prof_symtab_module_test) {
Function::Create(FTy, Function::WeakODRLinkage, "Wbar", M.get());
InstrProfSymtab ProfSymtab;
- ProfSymtab.create(*M);
+ NoError(ProfSymtab.create(*M));
StringRef Funcs[] = {"Gfoo", "Gblah", "Gbar", "Ifoo", "Iblah", "Ibar",
"Pfoo", "Pblah", "Pbar", "Wfoo", "Wblah", "Wbar"};
OpenPOWER on IntegriCloud