xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/indirect-goto.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-unknown-unknown -O3 -emit-llvm -o - %s | grep "ret i32 2520"
2f4a2713aSLionel Sambuc 
foo(unsigned i)3f4a2713aSLionel Sambuc static int foo(unsigned i) {
4f4a2713aSLionel Sambuc   void *addrs[] = { &&L1, &&L2, &&L3, &&L4, &&L5 };
5f4a2713aSLionel Sambuc   int res = 1;
6f4a2713aSLionel Sambuc 
7f4a2713aSLionel Sambuc   goto *addrs[i];
8f4a2713aSLionel Sambuc  L5: res *= 11;
9f4a2713aSLionel Sambuc  L4: res *= 7;
10f4a2713aSLionel Sambuc  L3: res *= 5;
11f4a2713aSLionel Sambuc  L2: res *= 3;
12f4a2713aSLionel Sambuc  L1: res *= 2;
13f4a2713aSLionel Sambuc   return res;
14f4a2713aSLionel Sambuc }
15f4a2713aSLionel Sambuc 
foo2(unsigned i)16f4a2713aSLionel Sambuc static int foo2(unsigned i) {
17f4a2713aSLionel Sambuc   static const void *addrs[] = { &&L1, &&L2, &&L3, &&L4, &&L5 };
18f4a2713aSLionel Sambuc   int res = 1;
19f4a2713aSLionel Sambuc 
20f4a2713aSLionel Sambuc   goto *addrs[i];
21f4a2713aSLionel Sambuc L5: res *= 11;
22f4a2713aSLionel Sambuc L4: res *= 7;
23f4a2713aSLionel Sambuc L3: res *= 5;
24f4a2713aSLionel Sambuc L2: res *= 3;
25f4a2713aSLionel Sambuc L1: res *= 2;
26f4a2713aSLionel Sambuc   return res;
27f4a2713aSLionel Sambuc }
28f4a2713aSLionel Sambuc 
main()29f4a2713aSLionel Sambuc int main() {
30f4a2713aSLionel Sambuc   return foo(3)+foo2(4);
31f4a2713aSLionel Sambuc }
32