summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2016-08-31 23:04:32 +0000
committerNick Lewycky <nicholas@mxc.ca>2016-08-31 23:04:32 +0000
commit97e49ac59e428a935971139dc69750e25c8d2ac8 (patch)
tree5ac34fb77d4c1aa3e2e38fbf4c52dd1c4b9683fd /clang/lib/CodeGen/CodeGenModule.cpp
parent7f4f9cd5469cf2547d9cc89d07dae524107335f9 (diff)
downloadbcm5719-llvm-97e49ac59e428a935971139dc69750e25c8d2ac8.tar.gz
bcm5719-llvm-97e49ac59e428a935971139dc69750e25c8d2ac8.zip
Add -fprofile-dir= to clang.
-fprofile-dir=path allows the user to specify where .gcda files should be emitted when the program is run. In particular, this is the first flag that causes the .gcno and .o files to have different paths, LLVM is extended to support this. -fprofile-dir= does not change the file name in the .gcno (and thus where lcov looks for the source) but it does change the name in the .gcda (and thus where the runtime library writes the .gcda file). It's different from a GCOV_PREFIX because a user can observe that the GCOV_PREFIX_STRIP will strip paths off of -fprofile-dir= but not off of a supplied GCOV_PREFIX. To implement this we split -coverage-file into -coverage-data-file and -coverage-notes-file to specify the two different names. The !llvm.gcov metadata node grows from a 2-element form {string coverage-file, node dbg.cu} to 3-elements, {string coverage-notes-file, string coverage-data-file, node dbg.cu}. In the 3-element form, the file name is already "mangled" with .gcno/.gcda suffixes, while the 2-element form left that to the middle end pass. llvm-svn: 280306
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 1d74e4cd838..e296a4cc514 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4208,18 +4208,24 @@ void CodeGenModule::EmitTargetMetadata() {
}
void CodeGenModule::EmitCoverageFile() {
- if (!getCodeGenOpts().CoverageFile.empty()) {
- if (llvm::NamedMDNode *CUNode = TheModule.getNamedMetadata("llvm.dbg.cu")) {
- llvm::NamedMDNode *GCov = TheModule.getOrInsertNamedMetadata("llvm.gcov");
- llvm::LLVMContext &Ctx = TheModule.getContext();
- llvm::MDString *CoverageFile =
- llvm::MDString::get(Ctx, getCodeGenOpts().CoverageFile);
- for (int i = 0, e = CUNode->getNumOperands(); i != e; ++i) {
- llvm::MDNode *CU = CUNode->getOperand(i);
- llvm::Metadata *Elts[] = {CoverageFile, CU};
- GCov->addOperand(llvm::MDNode::get(Ctx, Elts));
- }
- }
+ if (getCodeGenOpts().CoverageDataFile.empty() &&
+ getCodeGenOpts().CoverageNotesFile.empty())
+ return;
+
+ llvm::NamedMDNode *CUNode = TheModule.getNamedMetadata("llvm.dbg.cu");
+ if (!CUNode)
+ return;
+
+ llvm::NamedMDNode *GCov = TheModule.getOrInsertNamedMetadata("llvm.gcov");
+ llvm::LLVMContext &Ctx = TheModule.getContext();
+ auto *CoverageDataFile =
+ llvm::MDString::get(Ctx, getCodeGenOpts().CoverageDataFile);
+ auto *CoverageNotesFile =
+ llvm::MDString::get(Ctx, getCodeGenOpts().CoverageNotesFile);
+ for (int i = 0, e = CUNode->getNumOperands(); i != e; ++i) {
+ llvm::MDNode *CU = CUNode->getOperand(i);
+ llvm::Metadata *Elts[] = {CoverageNotesFile, CoverageDataFile, CU};
+ GCov->addOperand(llvm::MDNode::get(Ctx, Elts));
}
}
OpenPOWER on IntegriCloud