[llvm] r264559 - [Coverage] Fix the way we load "<unknown>:func" records

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 27 21:45:50 PDT 2016


On Sun, Mar 27, 2016 at 6:16 PM, Vedant Kumar via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: vedantk
> Date: Sun Mar 27 20:16:12 2016
> New Revision: 264559
>
> URL: http://llvm.org/viewvc/llvm-project?rev=264559&view=rev
> Log:
> [Coverage] Fix the way we load "<unknown>:func" records
>
> When emitting coverage mappings for functions with local linkage and an
> unknown filename, we use "<unknown>:func" for the PGO function name. The
> problem is that we don't strip "<unknown>" from the name when loading
> coverage data, like we do for other file names. Fix that and add a test.
>
> Modified:
>     llvm/trunk/lib/ProfileData/InstrProf.cpp
>     llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp
>
> Modified: llvm/trunk/lib/ProfileData/InstrProf.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProf.cpp?rev=264559&r1=264558&r2=264559&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/ProfileData/InstrProf.cpp (original)
> +++ llvm/trunk/lib/ProfileData/InstrProf.cpp Sun Mar 27 20:16:12 2016
> @@ -90,7 +90,7 @@ std::string getPGOFuncName(const Functio
>
>  StringRef getFuncNameWithoutPrefix(StringRef PGOFuncName, StringRef
> FileName) {
>    if (FileName.empty())
> -    return PGOFuncName;
> +    FileName = "<unknown>";
>

How about making getFuncNameWithoutPrefix take a default FileName parameter
with "<unknown>" value?

David


>    // Drop the file name including ':'. See also getPGOFuncName.
>    if (PGOFuncName.startswith(FileName))
>      PGOFuncName = PGOFuncName.drop_front(FileName.size() + 1);
>
> Modified: llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp?rev=264559&r1=264558&r2=264559&view=diff
>
> ==============================================================================
> --- llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp (original)
> +++ llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp Sun Mar 27
> 20:16:12 2016
> @@ -304,6 +304,21 @@ TEST_P(MaybeSparseCoverageMappingTest, s
>    ASSERT_EQ("func", Names[0]);
>  }
>
> +TEST_P(MaybeSparseCoverageMappingTest, strip_unknown_filename_prefix) {
> +  InstrProfRecord Record("<unknown>:func", 0x1234, {0});
> +  ProfileWriter.addRecord(std::move(Record));
> +  readProfCounts();
> +
> +  addCMR(Counter::getCounter(0), "", 1, 1, 9, 9);
> +  loadCoverageMapping("<unknown>:func", 0x1234);
> +
> +  std::vector<std::string> Names;
> +  for (const auto &Func : LoadedCoverage->getCoveredFunctions())
> +    Names.push_back(Func.Name);
> +  ASSERT_EQ(1U, Names.size());
> +  ASSERT_EQ("func", Names[0]);
> +}
> +
>  INSTANTIATE_TEST_CASE_P(MaybeSparse, MaybeSparseCoverageMappingTest,
>                          ::testing::Bool());
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160327/12cee729/attachment.html>


More information about the llvm-commits mailing list