diff options
author | Xinliang David Li <davidxl@google.com> | 2016-01-03 19:25:54 +0000 |
---|---|---|
committer | Xinliang David Li <davidxl@google.com> | 2016-01-03 19:25:54 +0000 |
commit | 20b188c09c4e22d8bd03bc466a3cc4c05d14196d (patch) | |
tree | ba4ff4baff485e1e7b85bccf870c8dee15969529 /clang/lib/CodeGen/CoverageMappingGen.cpp | |
parent | 6e69cbe342a5dee9f1383a3da4a5c407626a7a51 (diff) | |
download | bcm5719-llvm-20b188c09c4e22d8bd03bc466a3cc4c05d14196d.tar.gz bcm5719-llvm-20b188c09c4e22d8bd03bc466a3cc4c05d14196d.zip |
[PGO] Cleanup: Use covmap header definition in the template file
This is one last remaining instrumentatation related structure
that needs to be migrate to use the centralized template
definition. With this change, instrumentation code
related to coverage module header will be kept in sync
with the coverage mapping reader. The remaining code
which makes implicit assumption about covmap control
structure layout in the the lowering pass will cleaned
up in a different patch. This patch is not intended to
have no functional change.
llvm-svn: 256714
Diffstat (limited to 'clang/lib/CodeGen/CoverageMappingGen.cpp')
-rw-r--r-- | clang/lib/CodeGen/CoverageMappingGen.cpp | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index eb6edeac442..1d4d7099e19 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/lib/CodeGen/CoverageMappingGen.cpp @@ -993,24 +993,30 @@ void CoverageMappingModuleGen::emit() { llvm::ArrayType::get(FunctionRecordTy, FunctionRecords.size()); auto RecordsVal = llvm::ConstantArray::get(RecordsTy, FunctionRecords); + llvm::Type *CovDataHeaderTypes[] = { +#define COVMAP_HEADER(Type, LLVMType, Name, Init) LLVMType, +#include "llvm/ProfileData/InstrProfData.inc" + }; + auto CovDataHeaderTy = + llvm::StructType::get(Ctx, makeArrayRef(CovDataHeaderTypes)); + llvm::Constant *CovDataHeaderVals[] = { +#define COVMAP_HEADER(Type, LLVMType, Name, Init) Init, +#include "llvm/ProfileData/InstrProfData.inc" + }; + auto CovDataHeaderVal = llvm::ConstantStruct::get( + CovDataHeaderTy, makeArrayRef(CovDataHeaderVals)); + // Create the coverage data record - llvm::Type *CovDataTypes[] = {Int32Ty, Int32Ty, - Int32Ty, Int32Ty, - RecordsTy, FilenamesAndMappingsVal->getType()}; + llvm::Type *CovDataTypes[] = {CovDataHeaderTy, RecordsTy, + FilenamesAndMappingsVal->getType()}; auto CovDataTy = llvm::StructType::get(Ctx, makeArrayRef(CovDataTypes)); - llvm::Constant *TUDataVals[] = { - llvm::ConstantInt::get(Int32Ty, FunctionRecords.size()), - llvm::ConstantInt::get(Int32Ty, FilenamesSize), - llvm::ConstantInt::get(Int32Ty, CoverageMappingSize), - llvm::ConstantInt::get(Int32Ty, - /*Version=*/CoverageMappingVersion1), - RecordsVal, FilenamesAndMappingsVal}; + llvm::Constant *TUDataVals[] = {CovDataHeaderVal, RecordsVal, + FilenamesAndMappingsVal}; auto CovDataVal = llvm::ConstantStruct::get(CovDataTy, makeArrayRef(TUDataVals)); - auto CovData = new llvm::GlobalVariable(CGM.getModule(), CovDataTy, true, - llvm::GlobalValue::InternalLinkage, - CovDataVal, - llvm::getCoverageMappingVarName()); + auto CovData = new llvm::GlobalVariable( + CGM.getModule(), CovDataTy, true, llvm::GlobalValue::InternalLinkage, + CovDataVal, llvm::getCoverageMappingVarName()); CovData->setSection(getCoverageSection(CGM)); CovData->setAlignment(8); |