[llvm] r269887 - [Coverage] Ensure that coverage mapping data has an expected alignment in 'covmapping' files.
Igor Kudrin via llvm-commits
llvm-commits at lists.llvm.org
Wed May 18 00:43:27 PDT 2016
Author: ikudrin
Date: Wed May 18 02:43:27 2016
New Revision: 269887
URL: http://llvm.org/viewvc/llvm-project?rev=269887&view=rev
Log:
[Coverage] Ensure that coverage mapping data has an expected alignment in 'covmapping' files.
Coverage mapping data is organized in a sequence of blocks, each of which is expected
to be aligned by 8 bytes. This feature is used when reading those blocks, see
VersionedCovMapFuncRecordReader::readFunctionRecords(). If a misaligned covearge
mapping data has more than one block, it causes llvm-cov to fail.
Differential Revision: http://reviews.llvm.org/D20285
Modified:
llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp
llvm/trunk/test/tools/llvm-cov/Inputs/combine_expansions.covmapping
llvm/trunk/test/tools/llvm-cov/Inputs/highlightedRanges.covmapping
llvm/trunk/test/tools/llvm-cov/Inputs/lineExecutionCounts.covmapping
llvm/trunk/test/tools/llvm-cov/Inputs/prevent_false_instantiations.covmapping
llvm/trunk/test/tools/llvm-cov/Inputs/regionMarkers.covmapping
llvm/trunk/test/tools/llvm-cov/Inputs/showExpansions.covmapping
llvm/trunk/test/tools/llvm-cov/Inputs/templateInstantiations.covmapping
llvm/trunk/tools/llvm-cov/TestingSupport.cpp
Modified: llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp?rev=269887&r1=269886&r2=269887&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp (original)
+++ llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp Wed May 18 02:43:27 2016
@@ -491,6 +491,13 @@ static std::error_code loadTestingFormat
return coveragemap_error::malformed;
ProfileNames.create(Data.substr(0, ProfileNamesSize), Address);
CoverageMapping = Data.substr(ProfileNamesSize);
+ // Skip the padding bytes because coverage map data has an alignment of 8.
+ if (CoverageMapping.size() < 1)
+ return coveragemap_error::truncated;
+ size_t Pad = alignmentAdjustment(CoverageMapping.data(), 8);
+ if (CoverageMapping.size() < Pad)
+ return coveragemap_error::malformed;
+ CoverageMapping = CoverageMapping.substr(Pad);
return std::error_code();
}
Modified: llvm/trunk/test/tools/llvm-cov/Inputs/combine_expansions.covmapping
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/Inputs/combine_expansions.covmapping?rev=269887&r1=269886&r2=269887&view=diff
==============================================================================
Binary files llvm/trunk/test/tools/llvm-cov/Inputs/combine_expansions.covmapping (original) and llvm/trunk/test/tools/llvm-cov/Inputs/combine_expansions.covmapping Wed May 18 02:43:27 2016 differ
Modified: llvm/trunk/test/tools/llvm-cov/Inputs/highlightedRanges.covmapping
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/Inputs/highlightedRanges.covmapping?rev=269887&r1=269886&r2=269887&view=diff
==============================================================================
Binary files - no diff available.
Modified: llvm/trunk/test/tools/llvm-cov/Inputs/lineExecutionCounts.covmapping
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/Inputs/lineExecutionCounts.covmapping?rev=269887&r1=269886&r2=269887&view=diff
==============================================================================
Binary files - no diff available.
Modified: llvm/trunk/test/tools/llvm-cov/Inputs/prevent_false_instantiations.covmapping
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/Inputs/prevent_false_instantiations.covmapping?rev=269887&r1=269886&r2=269887&view=diff
==============================================================================
Binary files llvm/trunk/test/tools/llvm-cov/Inputs/prevent_false_instantiations.covmapping (original) and llvm/trunk/test/tools/llvm-cov/Inputs/prevent_false_instantiations.covmapping Wed May 18 02:43:27 2016 differ
Modified: llvm/trunk/test/tools/llvm-cov/Inputs/regionMarkers.covmapping
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/Inputs/regionMarkers.covmapping?rev=269887&r1=269886&r2=269887&view=diff
==============================================================================
Binary files - no diff available.
Modified: llvm/trunk/test/tools/llvm-cov/Inputs/showExpansions.covmapping
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/Inputs/showExpansions.covmapping?rev=269887&r1=269886&r2=269887&view=diff
==============================================================================
Binary files llvm/trunk/test/tools/llvm-cov/Inputs/showExpansions.covmapping (original) and llvm/trunk/test/tools/llvm-cov/Inputs/showExpansions.covmapping Wed May 18 02:43:27 2016 differ
Modified: llvm/trunk/test/tools/llvm-cov/Inputs/templateInstantiations.covmapping
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/Inputs/templateInstantiations.covmapping?rev=269887&r1=269886&r2=269887&view=diff
==============================================================================
Binary files llvm/trunk/test/tools/llvm-cov/Inputs/templateInstantiations.covmapping (original) and llvm/trunk/test/tools/llvm-cov/Inputs/templateInstantiations.covmapping Wed May 18 02:43:27 2016 differ
Modified: llvm/trunk/tools/llvm-cov/TestingSupport.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/TestingSupport.cpp?rev=269887&r1=269886&r2=269887&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/TestingSupport.cpp (original)
+++ llvm/trunk/tools/llvm-cov/TestingSupport.cpp Wed May 18 02:43:27 2016
@@ -88,7 +88,11 @@ int convertForTestingMain(int argc, cons
OS << "llvmcovmtestdata";
encodeULEB128(ProfileNamesData.size(), OS);
encodeULEB128(ProfileNamesAddress, OS);
- OS << ProfileNamesData << CoverageMappingData;
+ OS << ProfileNamesData;
+ // Coverage mapping data is expected to have an alignment of 8.
+ for (unsigned Pad = OffsetToAlignment(OS.tell(), 8); Pad; --Pad)
+ OS.write(uint8_t(0));
+ OS << CoverageMappingData;
return 0;
}
More information about the llvm-commits
mailing list