Home | History | Annotate | Download | only in CodeGen
      1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -O3 -emit-llvm -o - %s | grep "ret i32 2520"
      2 
      3 static int foo(unsigned i) {
      4   void *addrs[] = { &&L1, &&L2, &&L3, &&L4, &&L5 };
      5   int res = 1;
      6 
      7   goto *addrs[i];
      8  L5: res *= 11;
      9  L4: res *= 7;
     10  L3: res *= 5;
     11  L2: res *= 3;
     12  L1: res *= 2;
     13   return res;
     14 }
     15 
     16 static int foo2(unsigned i) {
     17   static const void *addrs[] = { &&L1, &&L2, &&L3, &&L4, &&L5 };
     18   int res = 1;
     19 
     20   goto *addrs[i];
     21 L5: res *= 11;
     22 L4: res *= 7;
     23 L3: res *= 5;
     24 L2: res *= 3;
     25 L1: res *= 2;
     26   return res;
     27 }
     28 
     29 int main() {
     30   return foo(3)+foo2(4);
     31 }
     32