aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-04-16 02:05:18 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-04-16 02:05:18 +0000
commit0c4de8a4eb5fd6437b571611794ef84427fc4755 (patch)
tree8aae5c2d53647feb8201445dbf0908ea03aed51d
parentb1928704201034c785a26296a49f69355eb56a05 (diff)
downloadexternal_llvm-0c4de8a4eb5fd6437b571611794ef84427fc4755.zip
external_llvm-0c4de8a4eb5fd6437b571611794ef84427fc4755.tar.gz
external_llvm-0c4de8a4eb5fd6437b571611794ef84427fc4755.tar.bz2
Move the re-stemming function up top and use it where it's currently inlined.
Break the arc-profile code out to a function like the notes emission code is, and reorder the functions in the file. The only functionality change is that we no longer modify the Module when the Module has no debug info to use. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129631 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Instrumentation/GCOVProfiling.cpp40
1 files changed, 25 insertions, 15 deletions
diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp
index ec05872..4e63a43 100644
--- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -54,6 +54,10 @@ namespace {
// Create the GCNO files for the Module based on DebugInfo.
void EmitGCNO(DebugInfoFinder &DIF);
+ // Modify the program to track transitions along edges and call into the
+ // profiling runtime to emit .gcda files when run.
+ bool EmitProfileArcs(DebugInfoFinder &DIF);
+
// Get pointers to the functions in the runtime library.
Constant *getStartFileFunc();
Constant *getEmitFunctionFunc();
@@ -285,6 +289,22 @@ namespace {
};
}
+// Replace the stem of a file, or add one if missing.
+static std::string ReplaceStem(std::string orig_filename, std::string new_stem){
+ return (sys::path::stem(orig_filename) + "." + new_stem).str();
+}
+
+bool GCOVProfiler::runOnModule(Module &M) {
+ Mod = &M;
+ Ctx = &M.getContext();
+
+ DebugInfoFinder DIF;
+ DIF.processModule(*Mod);
+
+ EmitGCNO(DIF);
+ return EmitProfileArcs(DIF);
+}
+
void GCOVProfiler::EmitGCNO(DebugInfoFinder &DIF) {
DenseMap<const MDNode *, raw_fd_ostream *> gcno_files;
for (DebugInfoFinder::iterator I = DIF.compile_unit_begin(),
@@ -296,9 +316,8 @@ void GCOVProfiler::EmitGCNO(DebugInfoFinder &DIF) {
DICompileUnit CU(*I);
raw_fd_ostream *&Out = gcno_files[CU];
std::string ErrorInfo;
- Out = new raw_fd_ostream(
- (sys::path::stem(CU.getFilename()) + ".gcno").str().c_str(),
- ErrorInfo, raw_fd_ostream::F_Binary);
+ Out = new raw_fd_ostream(ReplaceStem(CU.getFilename(), "gcno").c_str(),
+ ErrorInfo, raw_fd_ostream::F_Binary);
Out->write("oncg*404MVLL", 12);
}
@@ -342,14 +361,9 @@ void GCOVProfiler::EmitGCNO(DebugInfoFinder &DIF) {
}
}
-bool GCOVProfiler::runOnModule(Module &M) {
- Mod = &M;
- Ctx = &M.getContext();
-
- DebugInfoFinder DIF;
- DIF.processModule(*Mod);
-
- EmitGCNO(DIF);
+bool GCOVProfiler::EmitProfileArcs(DebugInfoFinder &DIF) {
+ if (DIF.subprogram_begin() == DIF.subprogram_end())
+ return false;
SmallVector<std::pair<GlobalVariable *, uint32_t>, 8> counters_by_ident;
for (DebugInfoFinder::iterator SPI = DIF.subprogram_begin(),
@@ -459,10 +473,6 @@ Constant *GCOVProfiler::getEndFileFunc() {
return Mod->getOrInsertFunction("llvm_gcda_end_file", FTy);
}
-static std::string ReplaceStem(std::string orig_filename, std::string new_stem){
- return (sys::path::stem(orig_filename) + "." + new_stem).str();
-}
-
void GCOVProfiler::InsertCounterWriteout(
DebugInfoFinder &DIF,
SmallVector<std::pair<GlobalVariable *, uint32_t>, 8> &counters_by_ident) {