[llvm-commits] [llvm] r162855 - /llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp
Bill Wendling
isanbard at gmail.com
Wed Aug 29 13:30:45 PDT 2012
Author: void
Date: Wed Aug 29 15:30:44 2012
New Revision: 162855
URL: http://llvm.org/viewvc/llvm-project?rev=162855&view=rev
Log:
Use the full path to output the .gcda file.
This lets the user run the program from a different directory and still have the
.gcda files show up in the correct place.
<rdar://problem/12179524>
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=162855&r1=162854&r2=162855&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Wed Aug 29 15:30:44 2012
@@ -91,7 +91,7 @@
void insertCounterWriteout(ArrayRef<std::pair<GlobalVariable*, MDNode*> >);
void insertIndirectCounterIncrement();
- std::string mangleName(DICompileUnit CU, std::string NewStem);
+ std::string mangleName(DICompileUnit CU, const char *NewStem);
bool EmitNotes;
bool EmitData;
@@ -328,7 +328,10 @@
};
}
-std::string GCOVProfiler::mangleName(DICompileUnit CU, std::string NewStem) {
+std::string GCOVProfiler::mangleName(DICompileUnit CU, const char *NewStem) {
+ SmallString<128> Filename = CU.getFilename();
+ bool AsString = false;
+
if (NamedMDNode *GCov = M->getNamedMetadata("llvm.gcov")) {
for (int i = 0, e = GCov->getNumOperands(); i != e; ++i) {
MDNode *N = GCov->getOperand(i);
@@ -337,16 +340,25 @@
MDNode *CompileUnit = dyn_cast<MDNode>(N->getOperand(1));
if (!GCovFile || !CompileUnit) continue;
if (CompileUnit == CU) {
- SmallString<128> Filename = GCovFile->getString();
- sys::path::replace_extension(Filename, NewStem);
- return Filename.str();
+ Filename = GCovFile->getString();
+ AsString = true;
+ break;
}
}
}
- SmallString<128> Filename = CU.getFilename();
+ if (sys::path::is_relative(Filename.c_str())) {
+ SmallString<128> FullPath = CU.getDirectory();
+ sys::path::append(FullPath, Filename.begin(), Filename.end());
+ Filename = FullPath;
+ }
+
sys::path::replace_extension(Filename, NewStem);
- return sys::path::filename(Filename.str());
+
+ if (!AsString)
+ return sys::path::filename(Filename.str());
+
+ return Filename.str();
}
bool GCOVProfiler::runOnModule(Module &M) {
More information about the llvm-commits
mailing list