[llvm-commits] [llvm] r163799 - /llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp
Bill Wendling
isanbard at gmail.com
Thu Sep 13 07:32:31 PDT 2012
Author: void
Date: Thu Sep 13 09:32:30 2012
New Revision: 163799
URL: http://llvm.org/viewvc/llvm-project?rev=163799&view=rev
Log:
Use Nick's suggestion of storing a large NULL into the GV instead of memset, which requires TargetData.
Modified:
llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp
Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=163799&r1=163798&r2=163799&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Thu Sep 13 09:32:30 2012
@@ -34,7 +34,6 @@
#include "llvm/Support/InstIterator.h"
#include "llvm/Support/PathV2.h"
#include "llvm/Support/raw_ostream.h"
-#include "llvm/Target/TargetData.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
#include <string>
#include <utility>
@@ -102,7 +101,6 @@
Module *M;
LLVMContext *Ctx;
- const TargetData *TD;
};
}
@@ -354,7 +352,6 @@
bool GCOVProfiler::runOnModule(Module &M) {
this->M = &M;
- TD = getAnalysisIfAvailable<TargetData>();
Ctx = &M.getContext();
if (EmitNotes) emitGCNO();
@@ -653,8 +650,8 @@
NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu");
if (CU_Nodes) {
for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
- DICompileUnit compile_unit(CU_Nodes->getOperand(i));
- std::string FilenameGcda = mangleName(compile_unit, "gcda");
+ DICompileUnit CU(CU_Nodes->getOperand(i));
+ std::string FilenameGcda = mangleName(CU, "gcda");
Builder.CreateCall(StartFile,
Builder.CreateGlobalStringPtr(FilenameGcda));
for (ArrayRef<std::pair<GlobalVariable *, MDNode *> >::iterator
@@ -762,8 +759,6 @@
FlushF->setLinkage(GlobalValue::InternalLinkage);
FlushF->setUnnamedAddr(true);
- Type *Int8Ty = Type::getInt8Ty(*Ctx);
- Type *Int64Ty = Type::getInt64Ty(*Ctx);
BasicBlock *Entry = BasicBlock::Create(*Ctx, "entry", FlushF);
// Write out the current counters.
@@ -773,17 +768,14 @@
IRBuilder<> Builder(Entry);
Builder.CreateCall(WriteoutF);
- if (TD)
- // Zero out the counters.
- for (ArrayRef<std::pair<GlobalVariable *, MDNode *> >::iterator
- I = CountersBySP.begin(), E = CountersBySP.end();
- I != E; ++I) {
- GlobalVariable *GV = I->first;
- uint64_t NumBytes = TD->getTypeAllocSize(GV->getType()->getElementType());
- Builder.CreateMemSet(Builder.CreateConstGEP2_64(GV, 0, 0),
- ConstantInt::get(Int8Ty, 0),
- ConstantInt::get(Int64Ty, NumBytes), false);
- }
+ // Zero out the counters.
+ for (ArrayRef<std::pair<GlobalVariable *, MDNode *> >::iterator
+ I = CountersBySP.begin(), E = CountersBySP.end();
+ I != E; ++I) {
+ GlobalVariable *GV = I->first;
+ Constant *Null = Constant::getNullValue(GV->getType()->getElementType());
+ Builder.CreateStore(Null, GV);//Builder.CreateConstGEP2_64(GV, 0, 0));
+ }
Type *RetTy = FlushF->getReturnType();
if (RetTy == Type::getVoidTy(*Ctx))
More information about the llvm-commits
mailing list