blob: 8480dbdc37e9c095861c7097c117bd1c224ab877 [file] [log] [blame]
Alex Lorenz34ac9b52014-08-19 17:32:30 +00001// RUN: %clang_cc1 -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name loopmacro.c %s | FileCheck %s
2
3# define HASH_BITS 15
4#define MIN_MATCH 3
5#define H_SHIFT ((HASH_BITS+MIN_MATCH-1)/MIN_MATCH)
6#define WMASK 0xFFFF
7#define HASH_MASK 0xFFFF
8#define UPDATE_HASH(h,c) (h = (((h)<<H_SHIFT) ^ (c)) & HASH_MASK)
9#define INSERT_STRING(s, match_head) \
10 (UPDATE_HASH(ins_h, window[(s) + MIN_MATCH-1]), \
11 prev[(s) & WMASK] = match_head = head[ins_h], \
12 head[ins_h] = (s))
13
14int main() { // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+12]]:2 = #0 (HasCodeBefore = 0)
15 int strstart = 0;
16 int hash_head = 2;
17 int prev_length = 5;
18 int ins_h = 1;
19 int prev[32] = { 0 };
20 int head[32] = { 0 };
21 int window[1024] = { 0 };
22 do { // CHECK-NEXT: File 0, [[@LINE]]:6 -> [[@LINE+3]]:30 = (#0 + #1) (HasCodeBefore = 0)
23 strstart++;
24 INSERT_STRING(strstart, hash_head); // CHECK-NEXT: Expansion,File 0, [[@LINE]]:7 -> [[@LINE]]:20 = (#0 + #1) (HasCodeBefore = 0, Expanded file = 1)
25 } while (--prev_length != 0);
26}
27// CHECK-NEXT: File 0, 24:21 -> 24:29 = (#0 + #1) (HasCodeBefore = 0)
28// CHECK-NEXT: File 0, 24:21 -> 24:29 = (#0 + #1) (HasCodeBefore = 0)
29// CHECK-NEXT: File 0, 24:21 -> 24:29 = (#0 + #1) (HasCodeBefore = 0)
30// CHECK-NEXT: File 0, 24:31 -> 24:40 = (#0 + #1) (HasCodeBefore = 0)
31// CHECK-NEXT: File 1, 10:4 -> 12:23 = (#0 + #1) (HasCodeBefore = 0)
Justin Bognerf59329b2014-10-01 03:33:52 +000032// CHECK-NEXT: Expansion,File 1, 10:5 -> 10:16 = (#0 + #1) (HasCodeBefore = 0, Expanded file = 2)
Alex Lorenz34ac9b52014-08-19 17:32:30 +000033// CHECK-NEXT: File 1, 10:17 -> 10:22 = (#0 + #1) (HasCodeBefore = 0)
34// CHECK-NEXT: File 1, 10:17 -> 10:22 = (#0 + #1) (HasCodeBefore = 0)
35// CHECK-NEXT: File 1, 10:24 -> 10:32 = (#0 + #1) (HasCodeBefore = 0)
36// CHECK-NEXT: File 1, 10:33 -> 10:36 = (#0 + #1) (HasCodeBefore = 0)
37// CHECK-NEXT: File 1, 10:46 -> 10:49 = (#0 + #1) (HasCodeBefore = 0)
Justin Bognerf59329b2014-10-01 03:33:52 +000038// CHECK-NEXT: File 2, 8:26 -> 8:66 = (#0 + #1) (HasCodeBefore = 0)
39// CHECK-NEXT: Expansion,File 2, 8:38 -> 8:45 = (#0 + #1) (HasCodeBefore = 0, Expanded file = 3)
40// CHECK-NEXT: File 3, 5:18 -> 5:53 = (#0 + #1) (HasCodeBefore = 0)