mirror of
https://github.com/intel/llvm.git
synced 2026-01-19 09:31:59 +08:00
InstrProf: Make sure coverage propagates out of foreach loops correctly
llvm-svn: 236264
This commit is contained in:
@@ -714,8 +714,10 @@ struct CounterCoverageMappingBuilder
|
||||
Counter BackedgeCount = propagateCounts(BodyCount, S->getBody());
|
||||
BreakContinue BC = BreakContinueStack.pop_back_val();
|
||||
|
||||
Counter OutCount = addCounters(ParentCount, BC.BreakCount, BC.ContinueCount,
|
||||
subtractCounters(BodyCount, BackedgeCount));
|
||||
Counter LoopCount =
|
||||
addCounters(ParentCount, BackedgeCount, BC.ContinueCount);
|
||||
Counter OutCount =
|
||||
addCounters(BC.BreakCount, subtractCounters(LoopCount, BodyCount));
|
||||
if (OutCount != ParentCount)
|
||||
pushRegion(OutCount);
|
||||
}
|
||||
@@ -732,8 +734,10 @@ struct CounterCoverageMappingBuilder
|
||||
Counter BackedgeCount = propagateCounts(BodyCount, S->getBody());
|
||||
BreakContinue BC = BreakContinueStack.pop_back_val();
|
||||
|
||||
Counter OutCount = addCounters(ParentCount, BC.BreakCount, BC.ContinueCount,
|
||||
subtractCounters(BodyCount, BackedgeCount));
|
||||
Counter LoopCount =
|
||||
addCounters(ParentCount, BackedgeCount, BC.ContinueCount);
|
||||
Counter OutCount =
|
||||
addCounters(BC.BreakCount, subtractCounters(LoopCount, BodyCount));
|
||||
if (OutCount != ParentCount)
|
||||
pushRegion(OutCount);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
// RUN: %clang_cc1 -std=c++11 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name loops.cpp %s | FileCheck %s
|
||||
|
||||
// CHECK: rangedFor
|
||||
void rangedFor() { // CHECK-NEXT: File 0, [[@LINE]]:18 -> [[@LINE+6]]:2 = #0
|
||||
void rangedFor() { // CHECK-NEXT: File 0, [[@LINE]]:18 -> {{[0-9]+}}:2 = #0
|
||||
int arr[] = { 1, 2, 3, 4, 5 };
|
||||
int sum = 0;
|
||||
for(auto i : arr) { // CHECK-NEXT: File 0, [[@LINE]]:21 -> [[@LINE+2]]:4 = #1
|
||||
sum += i;
|
||||
for(auto i : arr) { // CHECK: File 0, [[@LINE]]:21 -> [[@LINE+6]]:4 = #1
|
||||
if (i == 3)
|
||||
continue; // CHECK: File 0, [[@LINE]]:7 -> [[@LINE]]:15 = #2
|
||||
sum += i; // CHECK: File 0, [[@LINE]]:5 -> {{[0-9]+}}:4 = (#1 - #2)
|
||||
if (sum >= 7)
|
||||
break; // CHECK: File 0, [[@LINE]]:7 -> [[@LINE]]:12 = #3
|
||||
}
|
||||
|
||||
// CHECK: File 0, [[@LINE+1]]:7 -> [[@LINE+1]]:10 = #0
|
||||
if (sum) {}
|
||||
}
|
||||
|
||||
// CHECK-NEXT: main
|
||||
// CHECK: main:
|
||||
int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> [[@LINE+24]]:2 = #0
|
||||
// CHECK-NEXT: File 0, [[@LINE+1]]:18 -> [[@LINE+1]]:24 = (#0 + #1)
|
||||
for(int i = 0; i < 10; ++i) // CHECK-NEXT: File 0, [[@LINE]]:26 -> [[@LINE]]:29 = #1
|
||||
|
||||
Reference in New Issue
Block a user