[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGen / pragma-do-while.cpp
blobecf8322cadcf96a6276b39a998c1b174ade2d82b
1 // RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
3 // We expect to get a loop structure like this:
4 // do.body: ; preds = %do.cond, ...
5 // ...
6 // br label %do.cond
7 // do.cond: ; preds = %do.body
8 // ...
9 // br i1 %cmp, label %do.body, label %do.end
10 // do.end: ; preds = %do.cond
11 // ...
13 // Verify that the loop metadata only is put on the backedge.
15 // CHECK-NOT: llvm.loop
16 // CHECK-LABEL: do.cond:
17 // CHECK: br {{.*}}, label %do.body, label %do.end, !llvm.loop ![[LMD1:[0-9]+]]
18 // CHECK-LABEL: do.end:
19 // CHECK-NOT: llvm.loop
20 // CHECK: ![[LMD1]] = distinct !{![[LMD1]], [[LMD2:![0-9]+]], ![[LMD3:[0-9]+]]}
21 // CHECK: [[LMD2]] = !{!"llvm.loop.mustprogress"}
22 // CHECK: ![[LMD3]] = !{!"llvm.loop.unroll.count", i32 4}
24 int test(int a[], int n) {
25 int i = 0;
26 int sum = 0;
28 #pragma unroll 4
31 a[i] = a[i] + 1;
32 sum = sum + a[i];
33 i++;
34 } while (i < n);
36 return sum;