Function *F = SP.getFunction();
DEBUG(dbgs() << "Function: " << getFunctionName(SP) << "\n");
- uint32_t i = 0;
- for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
+
+ Function::iterator BB = F->begin(), E = F->end();
+ Blocks[BB++] = new GCOVBlock(0, os);
+ ReturnBlock = new GCOVBlock(1, os);
+
+ uint32_t i = 2;
+ for (; BB != E; ++BB) {
Blocks[BB] = new GCOVBlock(i++, os);
}
- ReturnBlock = new GCOVBlock(i++, os);
- string_ostream FnNameLine;
- FnNameLine << getFunctionName(SP) << SP.getLineNumber();
- FuncChecksum = hash_value(FnNameLine.str());
+ std::string FunctionNameAndLine;
+ raw_string_ostream FNLOS(FunctionNameAndLine);
+ FNLOS << getFunctionName(SP) << SP.getLineNumber();
+ FNLOS.flush();
+ FuncChecksum = hash_value(FunctionNameAndLine);
}
~GCOVFunction() {
}
std::string getEdgeDestinations() {
- string_ostream EdgeDestinations;
+ std::string EdgeDestinations;
+ raw_string_ostream EDOS(EdgeDestinations);
Function *F = Blocks.begin()->first->getParent();
for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) {
GCOVBlock &Block = *Blocks[I];
for (int i = 0, e = Block.OutEdges.size(); i != e; ++i)
- EdgeDestinations << Block.OutEdges[i]->Number;
+ EDOS << Block.OutEdges[i]->Number;
}
- return EdgeDestinations.str();
+ return EdgeDestinations;
}
uint32_t getFuncChecksum() {
// LTO, we'll generate the same .gcno files.
DICompileUnit CU(CU_Nodes->getOperand(i));
- std::string ErrorInfo;
- raw_fd_ostream out(mangleName(CU, "gcno").c_str(), ErrorInfo,
- sys::fs::F_None);
+ std::error_code EC;
+ raw_fd_ostream out(mangleName(CU, "gcno"), EC, sys::fs::F_None);
std::string EdgeDestinations;
DIArray SPs = CU.getSubprograms();
+ unsigned FunctionIdent = 0;
for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i) {
DISubprogram SP(SPs.getElement(i));
assert((!SP || SP.isSubprogram()) &&
++It;
EntryBlock.splitBasicBlock(It);
- Funcs.push_back(
- make_unique<GCOVFunction>(SP, &out, i, Options.UseCfgChecksum));
+ Funcs.push_back(make_unique<GCOVFunction>(SP, &out, FunctionIdent++,
+ Options.UseCfgChecksum));
GCOVFunction &Func = *Funcs.back();
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
Edge += Successors;
}
- ArrayRef<Constant*> V(&EdgeTable[0], TableSize);
GlobalVariable *EdgeTableGV =
new GlobalVariable(
*M, EdgeTableTy, true, GlobalValue::InternalLinkage,
- ConstantArray::get(EdgeTableTy, V),
+ ConstantArray::get(EdgeTableTy,
+ makeArrayRef(&EdgeTable[0],TableSize)),
"__llvm_gcda_edge_table");
EdgeTableGV->setUnnamedAddr(true);
return EdgeTableGV;