From 21b742ffce7bec3d71e09c7c6d901a756d55feb3 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 29 Aug 2012 18:45:41 +0000 Subject: Use ArrayRef instead of SmallVector when passing vector into function. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162851 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/GCOVProfiling.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/Transforms/Instrumentation/GCOVProfiling.cpp') diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 264a6a6..293bad3 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -88,8 +88,7 @@ namespace { // Add the function to write out all our counters to the global destructor // list. - void insertCounterWriteout(SmallVector, 8> &); + void insertCounterWriteout(ArrayRef >); void insertIndirectCounterIncrement(); std::string mangleName(DICompileUnit CU, std::string NewStem); @@ -630,7 +629,7 @@ GlobalVariable *GCOVProfiler::getEdgeStateValue() { } void GCOVProfiler::insertCounterWriteout( - SmallVector, 8> &CountersBySP) { + ArrayRef > CountersBySP) { FunctionType *WriteoutFTy = FunctionType::get(Type::getVoidTy(*Ctx), false); Function *WriteoutF = Function::Create(WriteoutFTy, @@ -652,7 +651,7 @@ void GCOVProfiler::insertCounterWriteout( std::string FilenameGcda = mangleName(compile_unit, "gcda"); Builder.CreateCall(StartFile, Builder.CreateGlobalStringPtr(FilenameGcda)); - for (SmallVector, 8>::iterator + for (ArrayRef >::iterator I = CountersBySP.begin(), E = CountersBySP.end(); I != E; ++I) { DISubprogram SP(I->second); -- cgit v1.1 From 0e76db9ad43383ca9aeff7001a98d6d6d8d5e736 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 29 Aug 2012 20:30:44 +0000 Subject: 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162855 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/GCOVProfiling.cpp | 26 +++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'lib/Transforms/Instrumentation/GCOVProfiling.cpp') diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 293bad3..f01c6d5 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -91,7 +91,7 @@ namespace { void insertCounterWriteout(ArrayRef >); 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 @@ namespace { }; } -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 @@ std::string GCOVProfiler::mangleName(DICompileUnit CU, std::string NewStem) { MDNode *CompileUnit = dyn_cast(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) { -- cgit v1.1 From 6e5190c193f6267893daf6943af88e95039e739c Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Thu, 30 Aug 2012 00:34:21 +0000 Subject: Revert r162855 in favor of changing clang to emit the absolute coverage file path. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162883 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/GCOVProfiling.cpp | 26 +++++++----------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'lib/Transforms/Instrumentation/GCOVProfiling.cpp') diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index f01c6d5..293bad3 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -91,7 +91,7 @@ namespace { void insertCounterWriteout(ArrayRef >); void insertIndirectCounterIncrement(); - std::string mangleName(DICompileUnit CU, const char *NewStem); + std::string mangleName(DICompileUnit CU, std::string NewStem); bool EmitNotes; bool EmitData; @@ -328,10 +328,7 @@ namespace { }; } -std::string GCOVProfiler::mangleName(DICompileUnit CU, const char *NewStem) { - SmallString<128> Filename = CU.getFilename(); - bool AsString = false; - +std::string GCOVProfiler::mangleName(DICompileUnit CU, std::string NewStem) { if (NamedMDNode *GCov = M->getNamedMetadata("llvm.gcov")) { for (int i = 0, e = GCov->getNumOperands(); i != e; ++i) { MDNode *N = GCov->getOperand(i); @@ -340,25 +337,16 @@ std::string GCOVProfiler::mangleName(DICompileUnit CU, const char *NewStem) { MDNode *CompileUnit = dyn_cast(N->getOperand(1)); if (!GCovFile || !CompileUnit) continue; if (CompileUnit == CU) { - Filename = GCovFile->getString(); - AsString = true; - break; + SmallString<128> Filename = GCovFile->getString(); + sys::path::replace_extension(Filename, NewStem); + return Filename.str(); } } } - if (sys::path::is_relative(Filename.c_str())) { - SmallString<128> FullPath = CU.getDirectory(); - sys::path::append(FullPath, Filename.begin(), Filename.end()); - Filename = FullPath; - } - + SmallString<128> Filename = CU.getFilename(); sys::path::replace_extension(Filename, NewStem); - - if (!AsString) - return sys::path::filename(Filename.str()); - - return Filename.str(); + return sys::path::filename(Filename.str()); } bool GCOVProfiler::runOnModule(Module &M) { -- cgit v1.1 From 73996f44070df026e4d969b1b68461a70ebb3993 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Thu, 30 Aug 2012 01:32:31 +0000 Subject: Pass by pointer and not std::string. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162888 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/GCOVProfiling.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/Transforms/Instrumentation/GCOVProfiling.cpp') diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 293bad3..9fcde31 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -91,7 +91,7 @@ namespace { void insertCounterWriteout(ArrayRef >); 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,7 @@ namespace { }; } -std::string GCOVProfiler::mangleName(DICompileUnit CU, std::string NewStem) { +std::string GCOVProfiler::mangleName(DICompileUnit CU, const char *NewStem) { if (NamedMDNode *GCov = M->getNamedMetadata("llvm.gcov")) { for (int i = 0, e = GCov->getNumOperands(); i != e; ++i) { MDNode *N = GCov->getOperand(i); -- cgit v1.1