mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 19:31:58 +00:00
Move registering the execution of a basic block to the beginning rather than the end.
There are situations which can affect the correctness (or at least expectation) of the gcov output. For instance, if a call to __gcov_flush() occurs within a block before the execution count is registered and then the program aborts in some way, then that block will not be marked as executed. This is not normally what the user expects. If we move the code that's registering when a block is executed to the beginning, we can catch these types of situations. PR16893 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188849 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b1f4f120a5
commit
f675b3c644
@ -519,15 +519,15 @@ bool GCOVProfiler::emitProfileArcs() {
|
||||
TerminatorInst *TI = BB->getTerminator();
|
||||
int Successors = isa<ReturnInst>(TI) ? 1 : TI->getNumSuccessors();
|
||||
if (Successors) {
|
||||
IRBuilder<> Builder(TI);
|
||||
|
||||
if (Successors == 1) {
|
||||
IRBuilder<> Builder(BB->getFirstInsertionPt());
|
||||
Value *Counter = Builder.CreateConstInBoundsGEP2_64(Counters, 0,
|
||||
Edge);
|
||||
Value *Count = Builder.CreateLoad(Counter);
|
||||
Count = Builder.CreateAdd(Count, Builder.getInt64(1));
|
||||
Builder.CreateStore(Count, Counter);
|
||||
} else if (BranchInst *BI = dyn_cast<BranchInst>(TI)) {
|
||||
IRBuilder<> Builder(BI);
|
||||
Value *Sel = Builder.CreateSelect(BI->getCondition(),
|
||||
Builder.getInt64(Edge),
|
||||
Builder.getInt64(Edge + 1));
|
||||
@ -543,6 +543,7 @@ bool GCOVProfiler::emitProfileArcs() {
|
||||
for (int i = 0; i != Successors; ++i)
|
||||
ComplexEdgeSuccs.insert(TI->getSuccessor(i));
|
||||
}
|
||||
|
||||
Edge += Successors;
|
||||
}
|
||||
}
|
||||
@ -554,14 +555,13 @@ bool GCOVProfiler::emitProfileArcs() {
|
||||
GlobalVariable *EdgeState = getEdgeStateValue();
|
||||
|
||||
for (int i = 0, e = ComplexEdgePreds.size(); i != e; ++i) {
|
||||
IRBuilder<> Builder(ComplexEdgePreds[i+1]->getTerminator());
|
||||
IRBuilder<> Builder(ComplexEdgePreds[i + 1]->getFirstInsertionPt());
|
||||
Builder.CreateStore(Builder.getInt32(i), EdgeState);
|
||||
}
|
||||
|
||||
for (int i = 0, e = ComplexEdgeSuccs.size(); i != e; ++i) {
|
||||
// call runtime to perform increment
|
||||
BasicBlock::iterator InsertPt =
|
||||
ComplexEdgeSuccs[i+1]->getFirstInsertionPt();
|
||||
IRBuilder<> Builder(InsertPt);
|
||||
// Call runtime to perform increment.
|
||||
IRBuilder<> Builder(ComplexEdgeSuccs[i+1]->getFirstInsertionPt());
|
||||
Value *CounterPtrArray =
|
||||
Builder.CreateConstInBoundsGEP2_64(EdgeTable, 0,
|
||||
i * ComplexEdgePreds.size());
|
||||
|
Loading…
Reference in New Issue
Block a user