mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Conditionalize the format of the GCOV files by target type. Darwin uses the 4.2
format. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131503 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9c4dae6b0b
commit
f5c95b889f
@ -70,7 +70,7 @@ namespace {
|
|||||||
(void) llvm::createEdgeProfilerPass();
|
(void) llvm::createEdgeProfilerPass();
|
||||||
(void) llvm::createOptimalEdgeProfilerPass();
|
(void) llvm::createOptimalEdgeProfilerPass();
|
||||||
(void) llvm::createPathProfilerPass();
|
(void) llvm::createPathProfilerPass();
|
||||||
(void) llvm::createGCOVProfilerPass(true, true);
|
(void) llvm::createGCOVProfilerPass(true, true, false);
|
||||||
(void) llvm::createFunctionInliningPass();
|
(void) llvm::createFunctionInliningPass();
|
||||||
(void) llvm::createAlwaysInlinerPass();
|
(void) llvm::createAlwaysInlinerPass();
|
||||||
(void) llvm::createGlobalDCEPass();
|
(void) llvm::createGlobalDCEPass();
|
||||||
|
@ -28,7 +28,8 @@ ModulePass *createOptimalEdgeProfilerPass();
|
|||||||
ModulePass *createPathProfilerPass();
|
ModulePass *createPathProfilerPass();
|
||||||
|
|
||||||
// Insert GCOV profiling instrumentation
|
// Insert GCOV profiling instrumentation
|
||||||
ModulePass *createGCOVProfilerPass(bool EmitNotes = true, bool EmitData = true);
|
ModulePass *createGCOVProfilerPass(bool EmitNotes = true, bool EmitData = true,
|
||||||
|
bool Use402Format = false);
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
|
||||||
|
@ -43,11 +43,12 @@ namespace {
|
|||||||
public:
|
public:
|
||||||
static char ID;
|
static char ID;
|
||||||
GCOVProfiler()
|
GCOVProfiler()
|
||||||
: ModulePass(ID), EmitNotes(true), EmitData(true) {
|
: ModulePass(ID), EmitNotes(true), EmitData(true), Use402Format(false) {
|
||||||
initializeGCOVProfilerPass(*PassRegistry::getPassRegistry());
|
initializeGCOVProfilerPass(*PassRegistry::getPassRegistry());
|
||||||
}
|
}
|
||||||
GCOVProfiler(bool EmitNotes, bool EmitData)
|
GCOVProfiler(bool EmitNotes, bool EmitData, bool use402Format = false)
|
||||||
: ModulePass(ID), EmitNotes(EmitNotes), EmitData(EmitData) {
|
: ModulePass(ID), EmitNotes(EmitNotes), EmitData(EmitData),
|
||||||
|
Use402Format(use402Format) {
|
||||||
assert((EmitNotes || EmitData) && "GCOVProfiler asked to do nothing?");
|
assert((EmitNotes || EmitData) && "GCOVProfiler asked to do nothing?");
|
||||||
initializeGCOVProfilerPass(*PassRegistry::getPassRegistry());
|
initializeGCOVProfilerPass(*PassRegistry::getPassRegistry());
|
||||||
}
|
}
|
||||||
@ -93,6 +94,7 @@ namespace {
|
|||||||
|
|
||||||
bool EmitNotes;
|
bool EmitNotes;
|
||||||
bool EmitData;
|
bool EmitData;
|
||||||
|
bool Use402Format;
|
||||||
|
|
||||||
Module *M;
|
Module *M;
|
||||||
LLVMContext *Ctx;
|
LLVMContext *Ctx;
|
||||||
@ -103,8 +105,9 @@ char GCOVProfiler::ID = 0;
|
|||||||
INITIALIZE_PASS(GCOVProfiler, "insert-gcov-profiling",
|
INITIALIZE_PASS(GCOVProfiler, "insert-gcov-profiling",
|
||||||
"Insert instrumentation for GCOV profiling", false, false)
|
"Insert instrumentation for GCOV profiling", false, false)
|
||||||
|
|
||||||
ModulePass *llvm::createGCOVProfilerPass(bool EmitNotes, bool EmitData) {
|
ModulePass *llvm::createGCOVProfilerPass(bool EmitNotes, bool EmitData,
|
||||||
return new GCOVProfiler(EmitNotes, EmitData);
|
bool Use402Format) {
|
||||||
|
return new GCOVProfiler(EmitNotes, EmitData, Use402Format);
|
||||||
}
|
}
|
||||||
|
|
||||||
static DISubprogram findSubprogram(DIScope Scope) {
|
static DISubprogram findSubprogram(DIScope Scope) {
|
||||||
@ -250,7 +253,7 @@ namespace {
|
|||||||
// object users can construct, the blocks and lines will be rooted here.
|
// object users can construct, the blocks and lines will be rooted here.
|
||||||
class GCOVFunction : public GCOVRecord {
|
class GCOVFunction : public GCOVRecord {
|
||||||
public:
|
public:
|
||||||
GCOVFunction(DISubprogram SP, raw_ostream *os) {
|
GCOVFunction(DISubprogram SP, raw_ostream *os, bool Use402Format) {
|
||||||
this->os = os;
|
this->os = os;
|
||||||
|
|
||||||
Function *F = SP.getFunction();
|
Function *F = SP.getFunction();
|
||||||
@ -261,13 +264,16 @@ namespace {
|
|||||||
ReturnBlock = new GCOVBlock(i++, os);
|
ReturnBlock = new GCOVBlock(i++, os);
|
||||||
|
|
||||||
writeBytes(FunctionTag, 4);
|
writeBytes(FunctionTag, 4);
|
||||||
uint32_t BlockLen = 1 + 1 + 1 + 1 + lengthOfGCOVString(SP.getName()) +
|
uint32_t BlockLen = 1 + 1 + 1 + lengthOfGCOVString(SP.getName()) +
|
||||||
1 + lengthOfGCOVString(SP.getFilename()) + 1;
|
1 + lengthOfGCOVString(SP.getFilename()) + 1;
|
||||||
|
if (!Use402Format)
|
||||||
|
++BlockLen; // For second checksum.
|
||||||
write(BlockLen);
|
write(BlockLen);
|
||||||
uint32_t Ident = reinterpret_cast<intptr_t>((MDNode*)SP);
|
uint32_t Ident = reinterpret_cast<intptr_t>((MDNode*)SP);
|
||||||
write(Ident);
|
write(Ident);
|
||||||
write(0); // checksum #1
|
write(0); // checksum #1
|
||||||
write(0); // checksum #2
|
if (!Use402Format)
|
||||||
|
write(0); // checksum #2
|
||||||
writeGCOVString(SP.getName());
|
writeGCOVString(SP.getName());
|
||||||
writeGCOVString(SP.getFilename());
|
writeGCOVString(SP.getFilename());
|
||||||
write(SP.getLineNumber());
|
write(SP.getLineNumber());
|
||||||
@ -368,7 +374,10 @@ void GCOVProfiler::emitGCNO(DebugInfoFinder &DIF) {
|
|||||||
std::string ErrorInfo;
|
std::string ErrorInfo;
|
||||||
out = new raw_fd_ostream(mangleName(CU, "gcno").c_str(), ErrorInfo,
|
out = new raw_fd_ostream(mangleName(CU, "gcno").c_str(), ErrorInfo,
|
||||||
raw_fd_ostream::F_Binary);
|
raw_fd_ostream::F_Binary);
|
||||||
out->write("oncg*404MVLL", 12);
|
if (!Use402Format)
|
||||||
|
out->write("oncg*404MVLL", 12);
|
||||||
|
else
|
||||||
|
out->write("oncg*402MVLL", 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (DebugInfoFinder::iterator SPI = DIF.subprogram_begin(),
|
for (DebugInfoFinder::iterator SPI = DIF.subprogram_begin(),
|
||||||
@ -378,7 +387,7 @@ void GCOVProfiler::emitGCNO(DebugInfoFinder &DIF) {
|
|||||||
|
|
||||||
Function *F = SP.getFunction();
|
Function *F = SP.getFunction();
|
||||||
if (!F) continue;
|
if (!F) continue;
|
||||||
GCOVFunction Func(SP, os);
|
GCOVFunction Func(SP, os, Use402Format);
|
||||||
|
|
||||||
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
|
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
|
||||||
GCOVBlock &Block = Func.getBlock(BB);
|
GCOVBlock &Block = Func.getBlock(BB);
|
||||||
|
Loading…
Reference in New Issue
Block a user