1// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -Os -o - %s | FileCheck %s 2// CHECK: define signext i8 @f0(i32 %x) [[NUW:#[0-9]+]] 3// CHECK: define zeroext i8 @f1(i32 %x) [[NUW]] 4// CHECK: define void @f2(i8 signext %x) [[NUW]] 5// CHECK: define void @f3(i8 zeroext %x) [[NUW]] 6// CHECK: define signext i16 @f4(i32 %x) [[NUW]] 7// CHECK: define zeroext i16 @f5(i32 %x) [[NUW]] 8// CHECK: define void @f6(i16 signext %x) [[NUW]] 9// CHECK: define void @f7(i16 zeroext %x) [[NUW]] 10 11signed char f0(int x) { return x; } 12 13unsigned char f1(int x) { return x; } 14 15void f2(signed char x) { } 16 17void f3(unsigned char x) { } 18 19signed short f4(int x) { return x; } 20 21unsigned short f5(int x) { return x; } 22 23void f6(signed short x) { } 24 25void f7(unsigned short x) { } 26 27// CHECK: define void @f8() 28// CHECK: [[AI:#[0-9]+]] 29// CHECK: { 30void __attribute__((always_inline)) f8(void) { } 31 32// CHECK: call void @f9_t() 33// CHECK: [[NR:#[0-9]+]] 34// CHECK: } 35void __attribute__((noreturn)) f9_t(void); 36void f9(void) { f9_t(); } 37 38// CHECK: call void @f9a() 39// CHECK: [[NR]] 40// CHECK: } 41_Noreturn void f9a(void); 42void f9b(void) { f9a(); } 43 44// FIXME: We should be setting nounwind on calls. 45// CHECK: call i32 @f10_t() 46// CHECK: [[NUW_RN:#[0-9]+]] 47// CHECK: { 48int __attribute__((const)) f10_t(void); 49int f10(void) { return f10_t(); } 50int f11(void) { 51 exit: 52 return f10_t(); 53} 54int f12(int arg) { 55 return arg ? 0 : f10_t(); 56} 57 58// CHECK: define void @f13() [[NUW]] 59void f13(void) __attribute__((pure)) __attribute__((const)); 60void f13(void){} 61 62 63// Ensure that these get inlined: rdar://6853279 64// CHECK: define void @f14 65// CHECK-NOT: @ai_ 66// CHECK: call void @f14_end 67static __inline__ __attribute__((always_inline)) 68int ai_1() { return 4; } 69 70static __inline__ __attribute__((always_inline)) 71struct { 72 int a, b, c, d, e; 73} ai_2() { while (1) {} } 74 75void f14(int a) { 76 extern void f14_end(void); 77 if (a) 78 ai_2(); 79 ai_1(); 80 f14_end(); 81} 82 83// <rdar://problem/7102668> [irgen] clang isn't setting the optsize bit on functions 84// CHECK: define void @f15 85// CHECK: [[NUW]] 86// CHECK: { 87void f15(void) { 88} 89 90// PR5254 91// CHECK: define void @f16 92// CHECK: [[ALIGN:#[0-9]+]] 93// CHECK: { 94void __attribute__((force_align_arg_pointer)) f16(void) { 95} 96 97// PR11038 98// CHECK: define void @f18() 99// CHECK: [[RT:#[0-9]+]] 100// CHECK: { 101// CHECK: call void @f17() 102// CHECK: [[RT_CALL:#[0-9]+]] 103// CHECK: ret void 104__attribute__ ((returns_twice)) void f17(void); 105__attribute__ ((returns_twice)) void f18(void) { 106 f17(); 107} 108 109// CHECK: define void @f19() 110// CHECK: { 111// CHECK: call i32 @setjmp(i32* null) 112// CHECK: [[RT_CALL]] 113// CHECK: ret void 114typedef int jmp_buf[((9 * 2) + 3 + 16)]; 115int setjmp(jmp_buf); 116void f19(void) { 117 setjmp(0); 118} 119 120// CHECK: attributes [[NUW]] = { nounwind optsize readnone{{.*}} } 121// CHECK: attributes [[AI]] = { alwaysinline nounwind optsize readnone{{.*}} } 122// CHECK: attributes [[ALIGN]] = { nounwind optsize readnone alignstack=16{{.*}} } 123// CHECK: attributes [[RT]] = { nounwind optsize returns_twice{{.*}} } 124// CHECK: attributes [[NR]] = { noreturn nounwind optsize } 125// CHECK: attributes [[NUW_RN]] = { nounwind optsize readnone } 126// CHECK: attributes [[RT_CALL]] = { nounwind optsize returns_twice } 127