From 253353c9cf1ff16d9c30a89c2fb96160ac5a9d65 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Thu, 13 Sep 2012 00:09:55 +0000 Subject: Introduce the __llvm_gcov_flush function. This function writes out the current values of the counters and then resets them. This can be used similarly to the __gcov_flush function to sync the counters when need be. For instance, in a situation where the application doesn't exit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163757 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/GCOVProfiling.cpp | 62 +++++++++++++++++++++--- 1 file changed, 56 insertions(+), 6 deletions(-) (limited to 'lib/Transforms/Instrumentation/GCOVProfiling.cpp') diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 9fcde31..197a329 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -34,6 +34,7 @@ #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 #include @@ -90,6 +91,7 @@ namespace { // list. void insertCounterWriteout(ArrayRef >); void insertIndirectCounterIncrement(); + void insertFlush(ArrayRef >); std::string mangleName(DICompileUnit CU, const char *NewStem); @@ -100,6 +102,7 @@ namespace { Module *M; LLVMContext *Ctx; + const TargetData *TD; }; } @@ -351,6 +354,7 @@ std::string GCOVProfiler::mangleName(DICompileUnit CU, const char *NewStem) { bool GCOVProfiler::runOnModule(Module &M) { this->M = &M; + TD = getAnalysisIfAvailable(); Ctx = &M.getContext(); if (EmitNotes) emitGCNO(); @@ -518,6 +522,7 @@ bool GCOVProfiler::emitProfileArcs() { } insertCounterWriteout(CountersBySP); + insertFlush(CountersBySP); } if (InsertIndCounterIncrCode) @@ -630,13 +635,14 @@ GlobalVariable *GCOVProfiler::getEdgeStateValue() { void GCOVProfiler::insertCounterWriteout( ArrayRef > CountersBySP) { - FunctionType *WriteoutFTy = - FunctionType::get(Type::getVoidTy(*Ctx), false); - Function *WriteoutF = Function::Create(WriteoutFTy, - GlobalValue::InternalLinkage, - "__llvm_gcov_writeout", M); + FunctionType *WriteoutFTy = FunctionType::get(Type::getVoidTy(*Ctx), false); + Function *WriteoutF = M->getFunction("__llvm_gcov_writeout"); + if (!WriteoutF) + WriteoutF = Function::Create(WriteoutFTy, GlobalValue::InternalLinkage, + "__llvm_gcov_writeout", M); WriteoutF->setUnnamedAddr(true); - BasicBlock *BB = BasicBlock::Create(*Ctx, "", WriteoutF); + + BasicBlock *BB = BasicBlock::Create(*Ctx, "entry", WriteoutF); IRBuilder<> Builder(BB); Constant *StartFile = getStartFileFunc(); @@ -744,3 +750,47 @@ void GCOVProfiler::insertIndirectCounterIncrement() { Builder.SetInsertPoint(Exit); Builder.CreateRetVoid(); } + +void GCOVProfiler:: +insertFlush(ArrayRef > CountersBySP) { + FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), false); + Function *FlushF = M->getFunction("__llvm_gcov_flush"); + if (!FlushF) + FlushF = Function::Create(FTy, GlobalValue::InternalLinkage, + "__llvm_gcov_flush", M); + else + 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. + Constant *WriteoutF = M->getFunction("__llvm_gcov_writeout"); + assert(WriteoutF && "Need to create the writeout function first!"); + + IRBuilder<> Builder(Entry); + Builder.CreateCall(WriteoutF); + + if (TD) + // Zero out the counters. + for (ArrayRef >::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); + } + + Type *RetTy = FlushF->getReturnType(); + if (RetTy == Type::getVoidTy(*Ctx)) + Builder.CreateRetVoid(); + else if (RetTy->isIntegerTy()) + // Used if __llvm_gcov_flush was implicitly declared. + Builder.CreateRet(ConstantInt::get(RetTy, 0)); + else + report_fatal_error("invalid return type for __llvm_gcov_flush"); +} -- cgit v1.1 From 032dbee2a9d401ee05beb648465f21168e279bda Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Thu, 13 Sep 2012 14:32:30 +0000 Subject: 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 --- lib/Transforms/Instrumentation/GCOVProfiling.cpp | 28 +++++++++--------------- 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'lib/Transforms/Instrumentation/GCOVProfiling.cpp') diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 197a329..5d4a1b3 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -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 #include @@ -102,7 +101,6 @@ namespace { Module *M; LLVMContext *Ctx; - const TargetData *TD; }; } @@ -354,7 +352,6 @@ std::string GCOVProfiler::mangleName(DICompileUnit CU, const char *NewStem) { bool GCOVProfiler::runOnModule(Module &M) { this->M = &M; - TD = getAnalysisIfAvailable(); Ctx = &M.getContext(); if (EmitNotes) emitGCNO(); @@ -653,8 +650,8 @@ void GCOVProfiler::insertCounterWriteout( 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 >::iterator @@ -762,8 +759,6 @@ insertFlush(ArrayRef > CountersBySP) { 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 @@ insertFlush(ArrayRef > CountersBySP) { IRBuilder<> Builder(Entry); Builder.CreateCall(WriteoutF); - if (TD) - // Zero out the counters. - for (ArrayRef >::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 >::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)) -- cgit v1.1 From ec3fc2eac0e9203dd1094b9ce458e8c1b42b832f Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 14 Sep 2012 22:35:49 +0000 Subject: Remove comment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163945 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/GCOVProfiling.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/Transforms/Instrumentation/GCOVProfiling.cpp') diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 5d4a1b3..06c1ec5 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -774,7 +774,7 @@ insertFlush(ArrayRef > CountersBySP) { I != E; ++I) { GlobalVariable *GV = I->first; Constant *Null = Constant::getNullValue(GV->getType()->getElementType()); - Builder.CreateStore(Null, GV);//Builder.CreateConstGEP2_64(GV, 0, 0)); + Builder.CreateStore(Null, GV); } Type *RetTy = FlushF->getReturnType(); -- cgit v1.1 From 78fff8ec487a7c16633c5795e38e297ce6ddafa4 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 17 Sep 2012 17:57:05 +0000 Subject: s/__llvm_gcov_flush/__gcov_flush/g git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164040 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/GCOVProfiling.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/Transforms/Instrumentation/GCOVProfiling.cpp') diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 06c1ec5..bcee0c5 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -751,10 +751,10 @@ void GCOVProfiler::insertIndirectCounterIncrement() { void GCOVProfiler:: insertFlush(ArrayRef > CountersBySP) { FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), false); - Function *FlushF = M->getFunction("__llvm_gcov_flush"); + Function *FlushF = M->getFunction("__gcov_flush"); if (!FlushF) FlushF = Function::Create(FTy, GlobalValue::InternalLinkage, - "__llvm_gcov_flush", M); + "__gcov_flush", M); else FlushF->setLinkage(GlobalValue::InternalLinkage); FlushF->setUnnamedAddr(true); @@ -781,8 +781,8 @@ insertFlush(ArrayRef > CountersBySP) { if (RetTy == Type::getVoidTy(*Ctx)) Builder.CreateRetVoid(); else if (RetTy->isIntegerTy()) - // Used if __llvm_gcov_flush was implicitly declared. + // Used if __gcov_flush was implicitly declared. Builder.CreateRet(ConstantInt::get(RetTy, 0)); else - report_fatal_error("invalid return type for __llvm_gcov_flush"); + report_fatal_error("invalid return type for __gcov_flush"); } -- cgit v1.1 From 8831c0605bbc0c82ce56c2fb85bd681d1c013925 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 9 Oct 2012 00:01:21 +0000 Subject: Convert to using the Attributes::Builder interface. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165465 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/GCOVProfiling.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/Transforms/Instrumentation/GCOVProfiling.cpp') diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index bcee0c5..4c71fe3 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -682,7 +682,9 @@ void GCOVProfiler::insertCounterWriteout( "__llvm_gcov_init", M); F->setUnnamedAddr(true); F->setLinkage(GlobalValue::InternalLinkage); - F->addFnAttr(Attribute::NoInline); + Attributes::Builder B; + B.addNoInlineAttr(); + F->addFnAttr(Attributes::get(B)); BB = BasicBlock::Create(*Ctx, "entry", F); Builder.SetInsertPoint(BB); @@ -701,7 +703,9 @@ void GCOVProfiler::insertIndirectCounterIncrement() { cast(GCOVProfiler::getIncrementIndirectCounterFunc()); Fn->setUnnamedAddr(true); Fn->setLinkage(GlobalValue::InternalLinkage); - Fn->addFnAttr(Attribute::NoInline); + Attributes::Builder B; + B.addNoInlineAttr(); + Fn->addFnAttr(Attributes::get(B)); Type *Int32Ty = Type::getInt32Ty(*Ctx); Type *Int64Ty = Type::getInt64Ty(*Ctx); -- cgit v1.1 From 2e879bcd52583335c753c005d203bf2ffe8b67b5 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 9 Oct 2012 09:11:20 +0000 Subject: Use the enum value of the attributes when adding them to the attributes builder. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165494 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/GCOVProfiling.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/Transforms/Instrumentation/GCOVProfiling.cpp') diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 4c71fe3..66d8570 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -683,7 +683,7 @@ void GCOVProfiler::insertCounterWriteout( F->setUnnamedAddr(true); F->setLinkage(GlobalValue::InternalLinkage); Attributes::Builder B; - B.addNoInlineAttr(); + B.addAttribute(Attributes::NoInline); F->addFnAttr(Attributes::get(B)); BB = BasicBlock::Create(*Ctx, "entry", F); @@ -704,7 +704,7 @@ void GCOVProfiler::insertIndirectCounterIncrement() { Fn->setUnnamedAddr(true); Fn->setLinkage(GlobalValue::InternalLinkage); Attributes::Builder B; - B.addNoInlineAttr(); + B.addAttribute(Attributes::NoInline); Fn->addFnAttr(Attributes::get(B)); Type *Int32Ty = Type::getInt32Ty(*Ctx); -- cgit v1.1 From f5e6d70f8c8f21e744a10fd463cdeddae31cbab5 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 10 Oct 2012 03:12:49 +0000 Subject: Have 'addFnAttr' take the attribute enum value. Then have it build the attribute object and add it appropriately. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165595 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/GCOVProfiling.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'lib/Transforms/Instrumentation/GCOVProfiling.cpp') diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 66d8570..e9192e5 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -682,9 +682,7 @@ void GCOVProfiler::insertCounterWriteout( "__llvm_gcov_init", M); F->setUnnamedAddr(true); F->setLinkage(GlobalValue::InternalLinkage); - Attributes::Builder B; - B.addAttribute(Attributes::NoInline); - F->addFnAttr(Attributes::get(B)); + F->addFnAttr(Attributes::NoInline); BB = BasicBlock::Create(*Ctx, "entry", F); Builder.SetInsertPoint(BB); @@ -703,9 +701,7 @@ void GCOVProfiler::insertIndirectCounterIncrement() { cast(GCOVProfiler::getIncrementIndirectCounterFunc()); Fn->setUnnamedAddr(true); Fn->setLinkage(GlobalValue::InternalLinkage); - Attributes::Builder B; - B.addAttribute(Attributes::NoInline); - Fn->addFnAttr(Attributes::get(B)); + Fn->addFnAttr(Attributes::NoInline); Type *Int32Ty = Type::getInt32Ty(*Ctx); Type *Int64Ty = Type::getInt64Ty(*Ctx); -- cgit v1.1 From 2f87640b86315beab8a5671cc23f524e59c58bd3 Mon Sep 17 00:00:00 2001 From: Micah Villmow Date: Wed, 24 Oct 2012 17:20:04 +0000 Subject: Delete a directory that wasn't supposed to be checked in yet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166591 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/GCOVProfiling.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/Transforms/Instrumentation/GCOVProfiling.cpp') diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index e9192e5..3998c8b 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -586,8 +586,8 @@ Constant *GCOVProfiler::getIncrementIndirectCounterFunc() { Type *Int32Ty = Type::getInt32Ty(*Ctx); Type *Int64Ty = Type::getInt64Ty(*Ctx); Type *Args[] = { - Int32Ty->getPointerTo(), // uint32_t *predecessor - Int64Ty->getPointerTo()->getPointerTo() // uint64_t **counters + Int32Ty->getPointerTo(Int32Ty), // uint32_t *predecessor + Int64Ty->getPointerTo(Int64Ty)->getPointerTo(Int64Ty) // uint64_t **counters }; FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), Args, false); return M->getOrInsertFunction("__llvm_gcov_indirect_counter_increment", FTy); @@ -733,7 +733,8 @@ void GCOVProfiler::insertIndirectCounterIncrement() { Value *GEP = Builder.CreateGEP(Arg, ZExtPred); Value *Counter = Builder.CreateLoad(GEP, "counter"); Cond = Builder.CreateICmpEQ(Counter, - Constant::getNullValue(Int64Ty->getPointerTo())); + Constant::getNullValue( + Int64Ty->getPointerTo(Counter->getType()))); Builder.CreateCondBr(Cond, Exit, CounterEnd); // ++*counter; -- cgit v1.1 From b8bce928f4ffdf50eff69334f3e25b27848536b6 Mon Sep 17 00:00:00 2001 From: Micah Villmow Date: Wed, 24 Oct 2012 17:25:11 +0000 Subject: Back out r166591, not sure why this made it through since I cancelled the command. Bleh, sorry about this! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166596 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/GCOVProfiling.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/Transforms/Instrumentation/GCOVProfiling.cpp') diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 3998c8b..e9192e5 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -586,8 +586,8 @@ Constant *GCOVProfiler::getIncrementIndirectCounterFunc() { Type *Int32Ty = Type::getInt32Ty(*Ctx); Type *Int64Ty = Type::getInt64Ty(*Ctx); Type *Args[] = { - Int32Ty->getPointerTo(Int32Ty), // uint32_t *predecessor - Int64Ty->getPointerTo(Int64Ty)->getPointerTo(Int64Ty) // uint64_t **counters + Int32Ty->getPointerTo(), // uint32_t *predecessor + Int64Ty->getPointerTo()->getPointerTo() // uint64_t **counters }; FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), Args, false); return M->getOrInsertFunction("__llvm_gcov_indirect_counter_increment", FTy); @@ -733,8 +733,7 @@ void GCOVProfiler::insertIndirectCounterIncrement() { Value *GEP = Builder.CreateGEP(Arg, ZExtPred); Value *Counter = Builder.CreateLoad(GEP, "counter"); Cond = Builder.CreateICmpEQ(Counter, - Constant::getNullValue( - Int64Ty->getPointerTo(Counter->getType()))); + Constant::getNullValue(Int64Ty->getPointerTo())); Builder.CreateCondBr(Cond, Exit, CounterEnd); // ++*counter; -- cgit v1.1 From 9e6ee16b1814268897965b81e82a74ef39173ee1 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sat, 17 Nov 2012 13:49:37 +0000 Subject: Plug a memory leak in the GCOV profiling emitter, which never released the edge table memory. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168259 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/GCOVProfiling.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/Transforms/Instrumentation/GCOVProfiling.cpp') diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index e9192e5..a8adaa6 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -540,13 +540,13 @@ GlobalVariable *GCOVProfiler::buildEdgeLookupTable( // read it. Threads and invoke make this untrue. // emit [(succs * preds) x i64*], logically [succ x [pred x i64*]]. + size_t TableSize = Succs.size() * Preds.size(); Type *Int64PtrTy = Type::getInt64PtrTy(*Ctx); - ArrayType *EdgeTableTy = ArrayType::get( - Int64PtrTy, Succs.size() * Preds.size()); + ArrayType *EdgeTableTy = ArrayType::get(Int64PtrTy, TableSize); - Constant **EdgeTable = new Constant*[Succs.size() * Preds.size()]; + OwningArrayPtr EdgeTable(new Constant*[TableSize]); Constant *NullValue = Constant::getNullValue(Int64PtrTy); - for (int i = 0, ie = Succs.size() * Preds.size(); i != ie; ++i) + for (size_t i = 0; i != TableSize; ++i) EdgeTable[i] = NullValue; unsigned Edge = 0; @@ -566,7 +566,7 @@ GlobalVariable *GCOVProfiler::buildEdgeLookupTable( Edge += Successors; } - ArrayRef V(&EdgeTable[0], Succs.size() * Preds.size()); + ArrayRef V(&EdgeTable[0], TableSize); GlobalVariable *EdgeTableGV = new GlobalVariable( *M, EdgeTableTy, true, GlobalValue::InternalLinkage, -- cgit v1.1 From d04a8d4b33ff316ca4cf961e06c9e312eff8e64f Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Mon, 3 Dec 2012 16:50:05 +0000 Subject: Use the new script to sort the includes of every file under lib. Sooooo many of these had incorrect or strange main module includes. I have manually inspected all of these, and fixed the main module include to be the nearest plausible thing I could find. If you own or care about any of these source files, I encourage you to take some time and check that these edits were sensible. I can't have broken anything (I strictly added headers, and reordered them, never removed), but they may not be the headers you'd really like to identify as containing the API being implemented. Many forward declarations and missing includes were added to a header files to allow them to parse cleanly when included first. The main module rule does in fact have its merits. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169131 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/GCOVProfiling.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/Transforms/Instrumentation/GCOVProfiling.cpp') diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index a8adaa6..2f09062 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -16,19 +16,19 @@ #define DEBUG_TYPE "insert-gcov-profiling" -#include "ProfilingUtils.h" #include "llvm/Transforms/Instrumentation.h" -#include "llvm/DebugInfo.h" -#include "llvm/IRBuilder.h" -#include "llvm/Instructions.h" -#include "llvm/Module.h" -#include "llvm/Pass.h" +#include "ProfilingUtils.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/UniqueVector.h" +#include "llvm/DebugInfo.h" +#include "llvm/IRBuilder.h" +#include "llvm/Instructions.h" +#include "llvm/Module.h" +#include "llvm/Pass.h" #include "llvm/Support/Debug.h" #include "llvm/Support/DebugLoc.h" #include "llvm/Support/InstIterator.h" -- cgit v1.1 From 08e13e4488cde76fc51f942e773874627a88eeae Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 10 Dec 2012 19:46:49 +0000 Subject: Don't use a red zone for code coverage if the user specified `-mno-red-zone'. The `-mno-red-zone' flag wasn't being propagated to the functions that code coverage generates. This allowed some of them to use the red zone when that wasn't allowed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169754 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/GCOVProfiling.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'lib/Transforms/Instrumentation/GCOVProfiling.cpp') diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 2f09062..5e064cd 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -45,11 +45,11 @@ namespace { static char ID; GCOVProfiler() : ModulePass(ID), EmitNotes(true), EmitData(true), Use402Format(false), - UseExtraChecksum(false) { + UseExtraChecksum(false), NoRedZone(false) { initializeGCOVProfilerPass(*PassRegistry::getPassRegistry()); } GCOVProfiler(bool EmitNotes, bool EmitData, bool use402Format = false, - bool useExtraChecksum = false) + bool useExtraChecksum = false, bool NoRedZone = false) : ModulePass(ID), EmitNotes(EmitNotes), EmitData(EmitData), Use402Format(use402Format), UseExtraChecksum(useExtraChecksum) { assert((EmitNotes || EmitData) && "GCOVProfiler asked to do nothing?"); @@ -98,6 +98,7 @@ namespace { bool EmitData; bool Use402Format; bool UseExtraChecksum; + bool NoRedZone; Module *M; LLVMContext *Ctx; @@ -110,8 +111,10 @@ INITIALIZE_PASS(GCOVProfiler, "insert-gcov-profiling", ModulePass *llvm::createGCOVProfilerPass(bool EmitNotes, bool EmitData, bool Use402Format, - bool UseExtraChecksum) { - return new GCOVProfiler(EmitNotes, EmitData, Use402Format, UseExtraChecksum); + bool UseExtraChecksum, + bool NoRedZone) { + return new GCOVProfiler(EmitNotes, EmitData, Use402Format, UseExtraChecksum, + NoRedZone); } namespace { @@ -638,6 +641,9 @@ void GCOVProfiler::insertCounterWriteout( WriteoutF = Function::Create(WriteoutFTy, GlobalValue::InternalLinkage, "__llvm_gcov_writeout", M); WriteoutF->setUnnamedAddr(true); + WriteoutF->addFnAttr(Attributes::NoInline); + if (NoRedZone) + WriteoutF->addFnAttr(Attributes::NoRedZone); BasicBlock *BB = BasicBlock::Create(*Ctx, "entry", WriteoutF); IRBuilder<> Builder(BB); @@ -683,6 +689,8 @@ void GCOVProfiler::insertCounterWriteout( F->setUnnamedAddr(true); F->setLinkage(GlobalValue::InternalLinkage); F->addFnAttr(Attributes::NoInline); + if (NoRedZone) + F->addFnAttr(Attributes::NoRedZone); BB = BasicBlock::Create(*Ctx, "entry", F); Builder.SetInsertPoint(BB); @@ -702,6 +710,8 @@ void GCOVProfiler::insertIndirectCounterIncrement() { Fn->setUnnamedAddr(true); Fn->setLinkage(GlobalValue::InternalLinkage); Fn->addFnAttr(Attributes::NoInline); + if (NoRedZone) + Fn->addFnAttr(Attributes::NoRedZone); Type *Int32Ty = Type::getInt32Ty(*Ctx); Type *Int64Ty = Type::getInt64Ty(*Ctx); @@ -758,6 +768,9 @@ insertFlush(ArrayRef > CountersBySP) { else FlushF->setLinkage(GlobalValue::InternalLinkage); FlushF->setUnnamedAddr(true); + FlushF->addFnAttr(Attributes::NoInline); + if (NoRedZone) + FlushF->addFnAttr(Attributes::NoRedZone); BasicBlock *Entry = BasicBlock::Create(*Ctx, "entry", FlushF); -- cgit v1.1 From f209dea96a34f8c3c06e19710e9ff008d4f18c6c Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 18 Dec 2012 03:35:05 +0000 Subject: Initialize NoRedZone and remove unused default values. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170404 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/GCOVProfiling.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/Transforms/Instrumentation/GCOVProfiling.cpp') diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 5e064cd..7c582f1 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -48,10 +48,11 @@ namespace { UseExtraChecksum(false), NoRedZone(false) { initializeGCOVProfilerPass(*PassRegistry::getPassRegistry()); } - GCOVProfiler(bool EmitNotes, bool EmitData, bool use402Format = false, - bool useExtraChecksum = false, bool NoRedZone = false) + GCOVProfiler(bool EmitNotes, bool EmitData, bool use402Format, + bool useExtraChecksum, bool NoRedZone_) : ModulePass(ID), EmitNotes(EmitNotes), EmitData(EmitData), - Use402Format(use402Format), UseExtraChecksum(useExtraChecksum) { + Use402Format(use402Format), UseExtraChecksum(useExtraChecksum), + NoRedZone(NoRedZone_) { assert((EmitNotes || EmitData) && "GCOVProfiler asked to do nothing?"); initializeGCOVProfilerPass(*PassRegistry::getPassRegistry()); } -- cgit v1.1 From 034b94b17006f51722886b0f2283fb6fb19aca1f Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 19 Dec 2012 07:18:57 +0000 Subject: Rename the 'Attributes' class to 'Attribute'. It's going to represent a single attribute in the future. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170502 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/GCOVProfiling.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib/Transforms/Instrumentation/GCOVProfiling.cpp') diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 7c582f1..25d605e 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -642,9 +642,9 @@ void GCOVProfiler::insertCounterWriteout( WriteoutF = Function::Create(WriteoutFTy, GlobalValue::InternalLinkage, "__llvm_gcov_writeout", M); WriteoutF->setUnnamedAddr(true); - WriteoutF->addFnAttr(Attributes::NoInline); + WriteoutF->addFnAttr(Attribute::NoInline); if (NoRedZone) - WriteoutF->addFnAttr(Attributes::NoRedZone); + WriteoutF->addFnAttr(Attribute::NoRedZone); BasicBlock *BB = BasicBlock::Create(*Ctx, "entry", WriteoutF); IRBuilder<> Builder(BB); @@ -689,9 +689,9 @@ void GCOVProfiler::insertCounterWriteout( "__llvm_gcov_init", M); F->setUnnamedAddr(true); F->setLinkage(GlobalValue::InternalLinkage); - F->addFnAttr(Attributes::NoInline); + F->addFnAttr(Attribute::NoInline); if (NoRedZone) - F->addFnAttr(Attributes::NoRedZone); + F->addFnAttr(Attribute::NoRedZone); BB = BasicBlock::Create(*Ctx, "entry", F); Builder.SetInsertPoint(BB); @@ -710,9 +710,9 @@ void GCOVProfiler::insertIndirectCounterIncrement() { cast(GCOVProfiler::getIncrementIndirectCounterFunc()); Fn->setUnnamedAddr(true); Fn->setLinkage(GlobalValue::InternalLinkage); - Fn->addFnAttr(Attributes::NoInline); + Fn->addFnAttr(Attribute::NoInline); if (NoRedZone) - Fn->addFnAttr(Attributes::NoRedZone); + Fn->addFnAttr(Attribute::NoRedZone); Type *Int32Ty = Type::getInt32Ty(*Ctx); Type *Int64Ty = Type::getInt64Ty(*Ctx); @@ -769,9 +769,9 @@ insertFlush(ArrayRef > CountersBySP) { else FlushF->setLinkage(GlobalValue::InternalLinkage); FlushF->setUnnamedAddr(true); - FlushF->addFnAttr(Attributes::NoInline); + FlushF->addFnAttr(Attribute::NoInline); if (NoRedZone) - FlushF->addFnAttr(Attributes::NoRedZone); + FlushF->addFnAttr(Attribute::NoRedZone); BasicBlock *Entry = BasicBlock::Create(*Ctx, "entry", FlushF); -- cgit v1.1 From 0b8c9a80f20772c3793201ab5b251d3520b9cea3 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Wed, 2 Jan 2013 11:36:10 +0000 Subject: Move all of the header files which are involved in modelling the LLVM IR into their new header subdirectory: include/llvm/IR. This matches the directory structure of lib, and begins to correct a long standing point of file layout clutter in LLVM. There are still more header files to move here, but I wanted to handle them in separate commits to make tracking what files make sense at each layer easier. The only really questionable files here are the target intrinsic tablegen files. But that's a battle I'd rather not fight today. I've updated both CMake and Makefile build systems (I think, and my tests think, but I may have missed something). I've also re-sorted the includes throughout the project. I'll be committing updates to Clang, DragonEgg, and Polly momentarily. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171366 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/GCOVProfiling.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/Transforms/Instrumentation/GCOVProfiling.cpp') diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index 25d605e..eb0dc1e 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -25,9 +25,9 @@ #include "llvm/ADT/StringMap.h" #include "llvm/ADT/UniqueVector.h" #include "llvm/DebugInfo.h" -#include "llvm/IRBuilder.h" -#include "llvm/Instructions.h" -#include "llvm/Module.h" +#include "llvm/IR/IRBuilder.h" +#include "llvm/IR/Instructions.h" +#include "llvm/IR/Module.h" #include "llvm/Pass.h" #include "llvm/Support/Debug.h" #include "llvm/Support/DebugLoc.h" -- cgit v1.1