Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGen / code_align.c
blobe9c3baebcc0906b483a5faaa0a2f3968a8bfc2cc
1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -x c %s %s -o - | FileCheck -check-prefix=CHECK-C %s
2 // RUN: %clang_cc1 -emit-llvm -x c++ -std=c++11 %s -o - | FileCheck %s --check-prefixes CHECK-C,CHECK-CPP
4 // CHECK-C: br label %for.cond, !llvm.loop ![[MD_FP:[0-9]+]]
5 // CHECK-C: br label %while.cond, !llvm.loop ![[MD_FP_1:[0-9]+]]
6 // CHECK-C: br i1 %cmp3, label %do.body, label %do.end, !llvm.loop ![[MD_FP_2:[0-9]+]]
7 // CHECK-C: br label %for.cond5, !llvm.loop ![[MD_FP_3:[0-9]+]]
9 // CHECK-CPP: br label %for.cond, !llvm.loop ![[MD_FP_4:[0-9]+]]
10 // CHECK-CPP: br label %for.cond2, !llvm.loop ![[MD_FP_5:[0-9]+]]
12 void bar(int);
13 void code_align() {
14 int a[10];
15 // CHECK-C: ![[MD_FP]] = distinct !{![[MD_FP]], ![[MP:[0-9]+]], ![[MD_code_align:[0-9]+]]}
16 // CHECK-C-NEXT: ![[MP]] = !{!"llvm.loop.mustprogress"}
17 // CHECK-C-NEXT: ![[MD_code_align]] = !{!"llvm.loop.align", i32 4}
18 [[clang::code_align(4)]]
19 for(int I=0; I<128; ++I) { bar(I); }
21 // CHECK-C: ![[MD_FP_1]] = distinct !{![[MD_FP_1]], ![[MP]], ![[MD_code_align_1:[0-9]+]]}
22 // CHECK-C-NEXT: ![[MD_code_align_1]] = !{!"llvm.loop.align", i32 16}
23 int i = 0;
24 [[clang::code_align(16)]] while (i < 60) {
25 a[i] += 3;
28 // CHECK-C: ![[MD_FP_2]] = distinct !{![[MD_FP_2]], ![[MP]], ![[MD_code_align_2:[0-9]+]]}
29 // CHECK-C-NEXT: ![[MD_code_align_2]] = !{!"llvm.loop.align", i32 8}
30 int b = 10;
31 [[clang::code_align(8)]] do {
32 b = b + 1;
33 } while (b < 20);
35 // CHECK-C: ![[MD_FP_3]] = distinct !{![[MD_FP_3]], ![[MP]], ![[MD_code_align_3:[0-9]+]]}
36 // CHECK-C-NEXT: ![[MD_code_align_3]] = !{!"llvm.loop.align", i32 64}
37 [[clang::code_align(64)]]
38 for(int I=0; I<128; ++I) { bar(I); }
41 #if __cplusplus >= 201103L
42 template <int A, int B>
43 void code_align_cpp() {
44 int a[10];
45 // CHECK-CPP: ![[MD_FP_4]] = distinct !{![[MD_FP_4]], ![[MP]], ![[MD_code_align_4:[0-9]+]]}
46 // CHECK-CPP-NEXT: ![[MD_code_align_4]] = !{!"llvm.loop.align", i32 32}
47 [[clang::code_align(A)]] for (int i = 0; i != 10; ++i)
48 a[i] = 0;
50 // CHECK-CPP: ![[MD_FP_5]] = distinct !{![[MD_FP_5]], ![[MD_code_align]]}
51 int c[] = {0, 1, 2, 3, 4, 5};
52 [[clang::code_align(B)]] for (int n : c) { n *= 2; }
55 int main() {
56 code_align_cpp<32, 4>();
57 return 0;
59 #endif