diff options
| author | Alex Lorenz <arphaman@gmail.com> | 2014-08-21 19:25:27 +0000 |
|---|---|---|
| committer | Alex Lorenz <arphaman@gmail.com> | 2014-08-21 19:25:27 +0000 |
| commit | 1d45c5bc269cbefe36a43089abf81372ca142613 (patch) | |
| tree | 76c5f9a764bb32fefacef7d0453d09a465776824 | |
| parent | 936b99c94279db95ecd6da1615957488752043ca (diff) | |
| download | bcm5719-llvm-1d45c5bc269cbefe36a43089abf81372ca142613.tar.gz bcm5719-llvm-1d45c5bc269cbefe36a43089abf81372ca142613.zip | |
Coverage Mapping: store function's hash in coverage function records.
The profile data format was recently updated and the new indexing api
requires the code coverage tool to know the function's hash as well
as the function's name to get the execution counts for a function.
Differential Revision: http://reviews.llvm.org/D4995
llvm-svn: 216208
| -rw-r--r-- | clang/lib/CodeGen/CodeGenPGO.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CoverageMappingGen.cpp | 8 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CoverageMappingGen.h | 1 | ||||
| -rw-r--r-- | clang/test/CoverageMapping/ir.c | 2 |
4 files changed, 9 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp index 7fb64b85a05..d341baf523c 100644 --- a/clang/lib/CodeGen/CodeGenPGO.cpp +++ b/clang/lib/CodeGen/CodeGenPGO.cpp @@ -168,8 +168,8 @@ llvm::GlobalVariable *CodeGenPGO::buildDataVar() { // Create coverage mapping data variable. if (!CoverageMapping.empty()) - CGM.getCoverageMapping()->addFunctionMappingRecord(Name, - getFuncName(), + CGM.getCoverageMapping()->addFunctionMappingRecord(Name, getFuncName(), + FunctionHash, CoverageMapping); // Hide all these symbols so that we correctly get a copy for each diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index 86e2be8fbe2..1bfa7cda76d 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/lib/CodeGen/CoverageMappingGen.cpp @@ -1094,12 +1094,13 @@ static void dump(llvm::raw_ostream &OS, const CoverageMappingRecord &Function) { void CoverageMappingModuleGen::addFunctionMappingRecord( llvm::GlobalVariable *FunctionName, StringRef FunctionNameValue, - const std::string &CoverageMapping) { + uint64_t FunctionHash, const std::string &CoverageMapping) { llvm::LLVMContext &Ctx = CGM.getLLVMContext(); auto *Int32Ty = llvm::Type::getInt32Ty(Ctx); + auto *Int64Ty = llvm::Type::getInt64Ty(Ctx); auto *Int8PtrTy = llvm::Type::getInt8PtrTy(Ctx); if (!FunctionRecordTy) { - llvm::Type *FunctionRecordTypes[] = {Int8PtrTy, Int32Ty, Int32Ty}; + llvm::Type *FunctionRecordTypes[] = {Int8PtrTy, Int32Ty, Int32Ty, Int64Ty}; FunctionRecordTy = llvm::StructType::get(Ctx, makeArrayRef(FunctionRecordTypes)); } @@ -1107,7 +1108,8 @@ void CoverageMappingModuleGen::addFunctionMappingRecord( llvm::Constant *FunctionRecordVals[] = { llvm::ConstantExpr::getBitCast(FunctionName, Int8PtrTy), llvm::ConstantInt::get(Int32Ty, FunctionNameValue.size()), - llvm::ConstantInt::get(Int32Ty, CoverageMapping.size())}; + llvm::ConstantInt::get(Int32Ty, CoverageMapping.size()), + llvm::ConstantInt::get(Int64Ty, FunctionHash)}; FunctionRecords.push_back(llvm::ConstantStruct::get( FunctionRecordTy, makeArrayRef(FunctionRecordVals))); CoverageMappings += CoverageMapping; diff --git a/clang/lib/CodeGen/CoverageMappingGen.h b/clang/lib/CodeGen/CoverageMappingGen.h index 8f4d7456045..45e0db8bce3 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.h +++ b/clang/lib/CodeGen/CoverageMappingGen.h @@ -69,6 +69,7 @@ public: /// function mapping records. void addFunctionMappingRecord(llvm::GlobalVariable *FunctionName, StringRef FunctionNameValue, + uint64_t FunctionHash, const std::string &CoverageMapping); /// \brief Emit the coverage mapping data for a translation unit. diff --git a/clang/test/CoverageMapping/ir.c b/clang/test/CoverageMapping/ir.c index eb83959f1d2..a1cb57020f9 100644 --- a/clang/test/CoverageMapping/ir.c +++ b/clang/test/CoverageMapping/ir.c @@ -9,4 +9,4 @@ int main(void) { return 0; } -// CHECK: @__llvm_coverage_mapping = internal constant { i32, i32, i32, i32, [2 x { i8*, i32, i32 }], [{{[0-9]+}} x i8] } { i32 2, i32 {{[0-9]+}}, i32 {{[0-9]+}}, i32 0, [2 x { i8*, i32, i32 }] [{ i8*, i32, i32 } { i8* getelementptr inbounds ([3 x i8]* @__llvm_profile_name_foo, i32 0, i32 0), i32 3, i32 9 }, { i8*, i32, i32 } { i8* getelementptr inbounds ([4 x i8]* @__llvm_profile_name_main, i32 0, i32 0), i32 4, i32 9 }] +// CHECK: @__llvm_coverage_mapping = internal constant { i32, i32, i32, i32, [2 x { i8*, i32, i32, i64 }], [{{[0-9]+}} x i8] } { i32 2, i32 {{[0-9]+}}, i32 {{[0-9]+}}, i32 0, [2 x { i8*, i32, i32, i64 }] [{ i8*, i32, i32, i64 } { i8* getelementptr inbounds ([3 x i8]* @__llvm_profile_name_foo, i32 0, i32 0), i32 3, i32 9, i64 {{[0-9]+}} }, { i8*, i32, i32, i64 } { i8* getelementptr inbounds ([4 x i8]* @__llvm_profile_name_main, i32 0, i32 0), i32 4, i32 9, i64 {{[0-9]+}} }] |

