mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-21 18:29:46 +00:00
Use the full path when outputting the `.gcda' file.
If we compile a single source program, the `.gcda' file will be generated where the program was executed. This isn't desirable, because that place may be at an unpredictable place (the program could call `chdir' for instance). Instead, we will output the `.gcda' file in the same place we output the `.gcno' file. I.e., the directory where the executable was generated. This matches GCC's behavior. <rdar://problem/13061072> & PR11809 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178084 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f8fd883fd3
commit
39c41c3c93
@ -32,6 +32,7 @@
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/DebugLoc.h"
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
#include "llvm/Support/InstIterator.h"
|
||||
#include "llvm/Support/PathV2.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
@ -123,7 +124,8 @@ namespace {
|
||||
Function *insertFlush(ArrayRef<std::pair<GlobalVariable*, MDNode*> >);
|
||||
void insertIndirectCounterIncrement();
|
||||
|
||||
std::string mangleName(DICompileUnit CU, const char *NewStem);
|
||||
std::string mangleName(DICompileUnit CU, const char *NewStem,
|
||||
bool FullPath);
|
||||
|
||||
GCOVOptions Options;
|
||||
|
||||
@ -363,7 +365,8 @@ namespace {
|
||||
};
|
||||
}
|
||||
|
||||
std::string GCOVProfiler::mangleName(DICompileUnit CU, const char *NewStem) {
|
||||
std::string GCOVProfiler::mangleName(DICompileUnit CU, const char *NewStem,
|
||||
bool FullPath) {
|
||||
if (NamedMDNode *GCov = M->getNamedMetadata("llvm.gcov")) {
|
||||
for (int i = 0, e = GCov->getNumOperands(); i != e; ++i) {
|
||||
MDNode *N = GCov->getOperand(i);
|
||||
@ -381,7 +384,13 @@ std::string GCOVProfiler::mangleName(DICompileUnit CU, const char *NewStem) {
|
||||
|
||||
SmallString<128> Filename = CU.getFilename();
|
||||
sys::path::replace_extension(Filename, NewStem);
|
||||
return sys::path::filename(Filename.str());
|
||||
StringRef FName = sys::path::filename(Filename);
|
||||
if (!FullPath)
|
||||
return FName;
|
||||
SmallString<128> CurPath;
|
||||
if (sys::fs::current_path(CurPath)) return FName;
|
||||
sys::path::append(CurPath, FName.str());
|
||||
return CurPath.str();
|
||||
}
|
||||
|
||||
bool GCOVProfiler::runOnModule(Module &M) {
|
||||
@ -404,7 +413,7 @@ void GCOVProfiler::emitProfileNotes() {
|
||||
|
||||
DICompileUnit CU(CU_Nodes->getOperand(i));
|
||||
std::string ErrorInfo;
|
||||
raw_fd_ostream out(mangleName(CU, "gcno").c_str(), ErrorInfo,
|
||||
raw_fd_ostream out(mangleName(CU, "gcno", false).c_str(), ErrorInfo,
|
||||
raw_fd_ostream::F_Binary);
|
||||
out.write("oncg", 4);
|
||||
out.write(ReversedVersion, 4);
|
||||
@ -726,7 +735,7 @@ Function *GCOVProfiler::insertCounterWriteout(
|
||||
if (CU_Nodes) {
|
||||
for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
|
||||
DICompileUnit CU(CU_Nodes->getOperand(i));
|
||||
std::string FilenameGcda = mangleName(CU, "gcda");
|
||||
std::string FilenameGcda = mangleName(CU, "gcda", true);
|
||||
Builder.CreateCall2(StartFile,
|
||||
Builder.CreateGlobalStringPtr(FilenameGcda),
|
||||
Builder.CreateGlobalStringPtr(ReversedVersion));
|
||||
|
Loading…
Reference in New Issue
Block a user