Home | History | Annotate | Download | only in CodeGen
      1 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -DBITCODE -emit-llvm-bc -o %t.bc %s
      2 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -DBITCODE2 -emit-llvm-bc -o %t-2.bc %s
      3 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -mlink-bitcode-file %t.bc \
      4 // RUN:     -O3 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-NO-BC %s
      5 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -O3 -emit-llvm -o - \
      6 // RUN:     -mlink-bitcode-file %t.bc -mlink-bitcode-file %t-2.bc %s \
      7 // RUN:     | FileCheck -check-prefix=CHECK-NO-BC -check-prefix=CHECK-NO-BC2 %s
      8 // RUN: not %clang_cc1 -triple i386-pc-linux-gnu -DBITCODE -O3 -emit-llvm -o - \
      9 // RUN:     -mlink-bitcode-file %t.bc %s 2>&1 | FileCheck -check-prefix=CHECK-BC %s
     10 // Make sure we deal with failure to load the file.
     11 // RUN: not %clang_cc1 -triple i386-pc-linux-gnu -mlink-bitcode-file no-such-file.bc \
     12 // RUN:    -emit-llvm -o - %s 2>&1 | FileCheck -check-prefix=CHECK-NO-FILE %s
     13 
     14 int f(void);
     15 
     16 #ifdef BITCODE
     17 
     18 extern int f2(void);
     19 // CHECK-BC: fatal error: cannot link module {{.*}}'f': symbol multiply defined
     20 int f(void) {
     21   f2();
     22   return 42;
     23 }
     24 
     25 #elif BITCODE2
     26 int f2(void) { return 43; }
     27 #else
     28 
     29 // CHECK-NO-BC-LABEL: define i32 @g
     30 // CHECK-NO-BC: ret i32 42
     31 int g(void) {
     32   return f();
     33 }
     34 
     35 // CHECK-NO-BC-LABEL: define i32 @f
     36 // CHECK-NO-BC2-LABEL: define i32 @f2
     37 
     38 #endif
     39 
     40 // CHECK-NO-FILE: fatal error: cannot open file 'no-such-file.bc'
     41