Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / debug_private.c
blobe1d095b5de2bafdd6691595e51cd676034a39e19
1 // This testcase checks emission of debug info for variables inside
2 // private/firstprivate/lastprivate.
4 // REQUIRES: x86-registered-target
6 // RUN: %clang_cc1 -debug-info-kind=constructor -x c -verify -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm %s -o - | FileCheck %s
7 // RUN: %clang_cc1 -debug-info-kind=line-directives-only -x c -verify -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm %s -o - | FileCheck %s --check-prefix=NEG
8 // RUN: %clang_cc1 -debug-info-kind=line-tables-only -x c -verify -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm %s -o - | FileCheck %s --check-prefix=NEG
9 // RUN: %clang_cc1 -debug-info-kind=limited -x c -verify -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm %s -o - | FileCheck %s
10 // expected-no-diagnostics
12 // CHECK: define internal i32 @.omp_task_entry.
14 // CHECK: call void @llvm.dbg.declare(metadata ptr %.priv.ptr.addr.i, metadata [[PRIV1:![0-9]+]], metadata !DIExpression(DW_OP_deref))
15 // CHECK: call void @llvm.dbg.declare(metadata ptr %.priv.ptr.addr1.i, metadata [[PRIV2:![0-9]+]], metadata !DIExpression(DW_OP_deref))
16 // CHECK: call void @llvm.dbg.declare(metadata ptr %.firstpriv.ptr.addr.i, metadata [[FPRIV:![0-9]+]], metadata !DIExpression(DW_OP_deref))
17 // NEG-NOT: call void @llvm.dbg.declare
19 // CHECK: [[PRIV1]] = !DILocalVariable(name: "priv1"
20 // CHECK: [[PRIV2]] = !DILocalVariable(name: "priv2"
21 // CHECK: [[FPRIV]] = !DILocalVariable(name: "fpriv"
23 extern int printf(const char *, ...);
25 int foo(int n) {
26 int res, priv1, priv2, fpriv;
27 fpriv = n + 4;
29 if (n < 2)
30 return n;
31 else {
32 #pragma omp task shared(res) private(priv1, priv2) firstprivate(fpriv)
34 priv1 = n;
35 priv2 = n + 2;
36 printf("Task n=%d,priv1=%d,priv2=%d,fpriv=%d\n", n, priv1, priv2, fpriv);
38 res = priv1 + priv2 + fpriv + foo(n - 1);
40 #pragma omp taskwait
41 return res;
45 int main() {
46 int n = 10;
47 printf("foo(%d) = %d\n", n, foo(n));
48 return 0;