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