[llvm] r348203 - Adapt gcov to changes in CFE.
Adrian Prantl via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 4 09:11:18 PST 2018
Thanks for letting me know. I'll see if I can come up with an alternative implementation that retains this invariant.
-- adrian
> On Dec 4, 2018, at 7:40 AM, Ilya Biryukov <ibiryukov at google.com> wrote:
>
> Hi Adrian,
>
> After this change, the .gcno produced by clang store all the paths as absolute (adding the working directory).
> We rely on them being relative internally to produce code coverage.
>
> I'm afraid I'll have to revert this change (and prior changes that broke compiler-rt) to unbreak our integrate.
> Sorry for the inconvenience.
>
> On Mon, Dec 3, 2018 at 11:40 PM Adrian Prantl via llvm-commits <llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>> wrote:
> Author: adrian
> Date: Mon Dec 3 14:37:48 2018
> New Revision: 348203
>
> URL: http://llvm.org/viewvc/llvm-project?rev=348203&view=rev <http://llvm.org/viewvc/llvm-project?rev=348203&view=rev>
> Log:
> Adapt gcov to changes in CFE.
>
> The clang frontend no longer emits the current working directory for
> DIFiles containing an absolute path in the filename: and will move the
> common prefix between current working directory and the file into the
> directory: component.
>
> This fixes the GCOV tests in compiler-rt that were broken by the Clang
> change.
>
> Modified:
> llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp
>
> Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=348203&r1=348202&r2=348203&view=diff <http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=348203&r1=348202&r2=348203&view=diff>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original)
> +++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Mon Dec 3 14:37:48 2018
> @@ -180,6 +180,12 @@ static StringRef getFunctionName(const D
> return SP->getName();
> }
>
> +template<class DINode> SmallString<128> getFilename(const DINode *N) {
> + SmallString<128> Path;
> + sys::path::append(Path, N->getDirectory(), N->getFilename());
> + return Path;
> +}
> +
> namespace {
> class GCOVRecord {
> protected:
> @@ -256,7 +262,7 @@ namespace {
> }
>
> private:
> - StringRef Filename;
> + std::string Filename;
> SmallVector<uint32_t, 32> Lines;
> };
>
> @@ -377,8 +383,9 @@ namespace {
>
> void writeOut() {
> writeBytes(FunctionTag, 4);
> + SmallString<128> Filename = getFilename(SP);
> uint32_t BlockLen = 1 + 1 + 1 + lengthOfGCOVString(getFunctionName(SP)) +
> - 1 + lengthOfGCOVString(SP->getFilename()) + 1;
> + 1 + lengthOfGCOVString(Filename) + 1;
> if (UseCfgChecksum)
> ++BlockLen;
> write(BlockLen);
> @@ -387,7 +394,7 @@ namespace {
> if (UseCfgChecksum)
> write(CfgChecksum);
> writeGCOVString(getFunctionName(SP));
> - writeGCOVString(SP->getFilename());
> + writeGCOVString(Filename);
> write(SP->getLine());
>
> // Emit count of blocks.
> @@ -466,7 +473,7 @@ bool GCOVProfiler::isFunctionInstrumente
> if (FilterRe.empty() && ExcludeRe.empty()) {
> return true;
> }
> - const StringRef Filename = F.getSubprogram()->getFilename();
> + SmallString<128> Filename = getFilename(F.getSubprogram());
> auto It = InstrumentedFiles.find(Filename);
> if (It != InstrumentedFiles.end()) {
> return It->second;
> @@ -531,7 +538,7 @@ std::string GCOVProfiler::mangleName(con
> }
> }
>
> - SmallString<128> Filename = CU->getFilename();
> + SmallString<128> Filename = getFilename(CU);
> sys::path::replace_extension(Filename, Notes ? "gcno" : "gcda");
> StringRef FName = sys::path::filename(Filename);
> SmallString<128> CurPath;
> @@ -688,7 +695,8 @@ void GCOVProfiler::emitProfileNotes() {
> // Add the function line number to the lines of the entry block
> // to have a counter for the function definition.
> uint32_t Line = SP->getLine();
> - Func.getBlock(&EntryBlock).getFile(SP->getFilename()).addLine(Line);
> + auto Filename = getFilename(SP);
> + Func.getBlock(&EntryBlock).getFile(Filename).addLine(Line);
>
> for (auto &BB : F) {
> GCOVBlock &Block = Func.getBlock(&BB);
> @@ -719,7 +727,7 @@ void GCOVProfiler::emitProfileNotes() {
> if (SP != getDISubprogram(Loc.getScope()))
> continue;
>
> - GCOVLines &Lines = Block.getFile(SP->getFilename());
> + GCOVLines &Lines = Block.getFile(Filename);
> Lines.addLine(Loc.getLine());
> }
> Line = 0;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits <http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits>
>
>
> --
> Regards,
> Ilya Biryukov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181204/5d68ac3a/attachment.html>
More information about the llvm-commits
mailing list