1 // RUN: clang-cc -triple i386-unknown-unknown -emit-llvm -o %t %s && 2 // RUN: grep 'define signext i8 @f0(i32 %x) nounwind' %t && 3 // RUN: grep 'define zeroext i8 @f1(i32 %x) nounwind' %t && 4 // RUN: grep 'define void @f2(i8 signext %x) nounwind' %t && 5 // RUN: grep 'define void @f3(i8 zeroext %x) nounwind' %t && 6 // RUN: grep 'define signext i16 @f4(i32 %x) nounwind' %t && 7 // RUN: grep 'define zeroext i16 @f5(i32 %x) nounwind' %t && 8 // RUN: grep 'define void @f6(i16 signext %x) nounwind' %t && 9 // RUN: grep 'define void @f7(i16 zeroext %x) nounwind' %t && 10 11 signed char f0(int x) { return x; } 12 13 unsigned char f1(int x) { return x; } 14 15 void f2(signed char x) { } 16 17 void f3(unsigned char x) { } 18 19 signed short f4(int x) { return x; } 20 21 unsigned short f5(int x) { return x; } 22 23 void f6(signed short x) { } 24 25 void f7(unsigned short x) { } 26 27 // RUN: grep 'define void @f8() nounwind alwaysinline' %t && 28 void __attribute__((always_inline)) f8(void) { } 29 30 // RUN: grep 'call void @f9_t() noreturn' %t && 31 void __attribute__((noreturn)) f9_t(void); 32 void f9(void) { f9_t(); } 33 34 // FIXME: We should be setting nounwind on calls. 35 // RUN: grep 'call i32 @f10_t() readnone' %t && 36 int __attribute__((const)) f10_t(void); 37 int f10(void) { return f10_t(); } 38 int f11(void) { 39 exit: 40 return f10_t(); 41 } 42 int f12(int arg) { 43 return arg ? 0 : f10_t(); 44 } 45 46 // RUN: grep 'define void @f13() nounwind readnone' %t && 47 void f13(void) __attribute__((pure)) __attribute__((const)); 48 void f13(void){} 49 50 51 // Ensure that these get inlined: rdar://6853279 52 // RUN: not grep '@ai_' %t && 53 static __inline__ __attribute__((always_inline)) 54 int ai_1() { return 4; } 55 56 static __inline__ __attribute__((always_inline)) 57 struct { 58 int a, b, c, d, e; 59 } ai_2() { while (1) {} } 60 61 62 int foo() { 63 ai_2(); 64 return ai_1(); 65 } 66 67 68 69 // RUN: true 70