mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-18 11:24:01 +00:00
Use Nick's suggestion of storing a large NULL into the GV instead of memset, which requires TargetData.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163799 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -34,7 +34,6 @@
|
|||||||
#include "llvm/Support/InstIterator.h"
|
#include "llvm/Support/InstIterator.h"
|
||||||
#include "llvm/Support/PathV2.h"
|
#include "llvm/Support/PathV2.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
|
||||||
#include "llvm/Transforms/Utils/ModuleUtils.h"
|
#include "llvm/Transforms/Utils/ModuleUtils.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@ -102,7 +101,6 @@ namespace {
|
|||||||
|
|
||||||
Module *M;
|
Module *M;
|
||||||
LLVMContext *Ctx;
|
LLVMContext *Ctx;
|
||||||
const TargetData *TD;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,7 +352,6 @@ std::string GCOVProfiler::mangleName(DICompileUnit CU, const char *NewStem) {
|
|||||||
|
|
||||||
bool GCOVProfiler::runOnModule(Module &M) {
|
bool GCOVProfiler::runOnModule(Module &M) {
|
||||||
this->M = &M;
|
this->M = &M;
|
||||||
TD = getAnalysisIfAvailable<TargetData>();
|
|
||||||
Ctx = &M.getContext();
|
Ctx = &M.getContext();
|
||||||
|
|
||||||
if (EmitNotes) emitGCNO();
|
if (EmitNotes) emitGCNO();
|
||||||
@ -653,8 +650,8 @@ void GCOVProfiler::insertCounterWriteout(
|
|||||||
NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu");
|
NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu");
|
||||||
if (CU_Nodes) {
|
if (CU_Nodes) {
|
||||||
for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
|
for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
|
||||||
DICompileUnit compile_unit(CU_Nodes->getOperand(i));
|
DICompileUnit CU(CU_Nodes->getOperand(i));
|
||||||
std::string FilenameGcda = mangleName(compile_unit, "gcda");
|
std::string FilenameGcda = mangleName(CU, "gcda");
|
||||||
Builder.CreateCall(StartFile,
|
Builder.CreateCall(StartFile,
|
||||||
Builder.CreateGlobalStringPtr(FilenameGcda));
|
Builder.CreateGlobalStringPtr(FilenameGcda));
|
||||||
for (ArrayRef<std::pair<GlobalVariable *, MDNode *> >::iterator
|
for (ArrayRef<std::pair<GlobalVariable *, MDNode *> >::iterator
|
||||||
@ -762,8 +759,6 @@ insertFlush(ArrayRef<std::pair<GlobalVariable*, MDNode*> > CountersBySP) {
|
|||||||
FlushF->setLinkage(GlobalValue::InternalLinkage);
|
FlushF->setLinkage(GlobalValue::InternalLinkage);
|
||||||
FlushF->setUnnamedAddr(true);
|
FlushF->setUnnamedAddr(true);
|
||||||
|
|
||||||
Type *Int8Ty = Type::getInt8Ty(*Ctx);
|
|
||||||
Type *Int64Ty = Type::getInt64Ty(*Ctx);
|
|
||||||
BasicBlock *Entry = BasicBlock::Create(*Ctx, "entry", FlushF);
|
BasicBlock *Entry = BasicBlock::Create(*Ctx, "entry", FlushF);
|
||||||
|
|
||||||
// Write out the current counters.
|
// Write out the current counters.
|
||||||
@ -773,16 +768,13 @@ insertFlush(ArrayRef<std::pair<GlobalVariable*, MDNode*> > CountersBySP) {
|
|||||||
IRBuilder<> Builder(Entry);
|
IRBuilder<> Builder(Entry);
|
||||||
Builder.CreateCall(WriteoutF);
|
Builder.CreateCall(WriteoutF);
|
||||||
|
|
||||||
if (TD)
|
|
||||||
// Zero out the counters.
|
// Zero out the counters.
|
||||||
for (ArrayRef<std::pair<GlobalVariable *, MDNode *> >::iterator
|
for (ArrayRef<std::pair<GlobalVariable *, MDNode *> >::iterator
|
||||||
I = CountersBySP.begin(), E = CountersBySP.end();
|
I = CountersBySP.begin(), E = CountersBySP.end();
|
||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
GlobalVariable *GV = I->first;
|
GlobalVariable *GV = I->first;
|
||||||
uint64_t NumBytes = TD->getTypeAllocSize(GV->getType()->getElementType());
|
Constant *Null = Constant::getNullValue(GV->getType()->getElementType());
|
||||||
Builder.CreateMemSet(Builder.CreateConstGEP2_64(GV, 0, 0),
|
Builder.CreateStore(Null, GV);//Builder.CreateConstGEP2_64(GV, 0, 0));
|
||||||
ConstantInt::get(Int8Ty, 0),
|
|
||||||
ConstantInt::get(Int64Ty, NumBytes), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Type *RetTy = FlushF->getReturnType();
|
Type *RetTy = FlushF->getReturnType();
|
||||||
|
Reference in New Issue
Block a user