xref: /llvm-project/clang/test/CodeGen/opt-record.c (revision adc402bf3d0565ac2bc7efbdd05f0d846e818041)
1 // RUN: %clang_cc1 -O3 -triple x86_64-unknown-linux-gnu -target-cpu x86-64 %s -o %t -opt-record-file %t.yaml -emit-obj
2 // RUN: cat %t.yaml | FileCheck %s
3 // RUN: llvm-profdata merge %S/Inputs/opt-record.proftext -o %t.profdata
4 // RUN: %clang_cc1 -O3 -triple x86_64-unknown-linux-gnu -target-cpu x86-64 -fprofile-instrument-use-path=%t.profdata %s -o %t -opt-record-file %t.yaml -emit-obj
5 // RUN: cat %t.yaml | FileCheck -check-prefix=CHECK -check-prefix=CHECK-PGO %s
6 // RUN: %clang_cc1 -O3 -triple x86_64-unknown-linux-gnu -target-cpu x86-64 %s -o %t -opt-record-file %t.yaml -opt-record-passes inline -emit-obj
7 // RUN: cat %t.yaml | FileCheck -check-prefix=CHECK-PASSES %s
8 // RUN: not %clang_cc1 -O3 -triple x86_64-unknown-linux-gnu -target-cpu x86-64 %s -o %t -opt-record-file %t.yaml -opt-record-passes "(foo" -emit-obj 2>&1 | FileCheck -check-prefix=CHECK-PATTERN-ERROR %s
9 // RUN: %clang_cc1 -O3 -triple x86_64-unknown-linux-gnu -target-cpu x86-64 %s -o %t -opt-record-file %t.yaml -opt-record-format yaml -emit-obj
10 // RUN: cat %t.yaml | FileCheck %s
11 // RUN: not %clang_cc1 -O3 -triple x86_64-unknown-linux-gnu -target-cpu x86-64 %s -o %t -opt-record-file %t.yaml -opt-record-format "unknown-format" -emit-obj 2>&1 | FileCheck -check-prefix=CHECK-FORMAT-ERROR %s
12 // REQUIRES: x86-registered-target
13 
14 void bar(void);
foo(void)15 void foo(void) { bar(); }
16 
Test(int * res,int * c,int * d,int * p,int n)17 void Test(int *res, int *c, int *d, int *p, int n) {
18   int i;
19 
20 #pragma clang loop vectorize(assume_safety)
21   for (i = 0; i < 1600; i++) {
22     res[i] = (p[i] == 0) ? res[i] : res[i] + d[i];
23   }
24 }
25 
26 // CHECK: --- !Missed
27 // CHECK: Pass:            inline
28 // CHECK: Name:            NoDefinition
29 // CHECK: DebugLoc:
30 // CHECK: Function:        foo
31 // CHECK-PGO: Hotness:
32 // CHECK-PASSES: Pass: inline
33 
34 // CHECK: --- !Passed
35 // CHECK: Pass:            loop-vectorize
36 // CHECK: Name:            Vectorized
37 // CHECK: DebugLoc:
38 // CHECK: Function:        Test
39 // CHECK-PGO: Hotness:
40 // CHECK-PASSES-NOT: loop-vectorize
41 
42 // CHECK-PATTERN-ERROR: error: in pattern '(foo': parentheses not balanced
43 
44 // CHECK-FORMAT-ERROR: error: unknown remark serializer format: 'unknown-format'
45