Daniel Dunbar | 7ab1c3e | 2009-10-27 19:48:08 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -triple i386-unknown-unknown -emit-llvm -Os -o - %s | FileCheck %s |
Daniel Dunbar | 0aa9424 | 2009-10-27 19:48:00 +0000 | [diff] [blame] | 2 | // CHECK: define signext i8 @f0(i32 %x) nounwind |
| 3 | // CHECK: define zeroext i8 @f1(i32 %x) nounwind |
| 4 | // CHECK: define void @f2(i8 signext %x) nounwind |
| 5 | // CHECK: define void @f3(i8 zeroext %x) nounwind |
| 6 | // CHECK: define signext i16 @f4(i32 %x) nounwind |
| 7 | // CHECK: define zeroext i16 @f5(i32 %x) nounwind |
| 8 | // CHECK: define void @f6(i16 signext %x) nounwind |
| 9 | // CHECK: define void @f7(i16 zeroext %x) nounwind |
Daniel Dunbar | 3a9a3e1 | 2008-09-05 00:57:45 +0000 | [diff] [blame] | 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 | |
Daniel Dunbar | 7ab1c3e | 2009-10-27 19:48:08 +0000 | [diff] [blame] | 27 | // CHECK: define void @f8() |
| 28 | // CHECK: nounwind |
| 29 | // CHECK: alwaysinline |
| 30 | // CHECK: { |
Daniel Dunbar | af668b0 | 2008-10-28 00:17:57 +0000 | [diff] [blame] | 31 | void __attribute__((always_inline)) f8(void) { } |
Daniel Dunbar | c0ef9f5 | 2009-02-20 18:06:48 +0000 | [diff] [blame] | 32 | |
Daniel Dunbar | 7ab1c3e | 2009-10-27 19:48:08 +0000 | [diff] [blame] | 33 | // CHECK: call void @f9_t() |
| 34 | // CHECK: noreturn |
| 35 | // CHECK: { |
Daniel Dunbar | c0ef9f5 | 2009-02-20 18:06:48 +0000 | [diff] [blame] | 36 | void __attribute__((noreturn)) f9_t(void); |
| 37 | void f9(void) { f9_t(); } |
| 38 | |
| 39 | // FIXME: We should be setting nounwind on calls. |
Daniel Dunbar | 7ab1c3e | 2009-10-27 19:48:08 +0000 | [diff] [blame] | 40 | // CHECK: call i32 @f10_t() |
| 41 | // CHECK: readnone |
| 42 | // CHECK: { |
Daniel Dunbar | c0ef9f5 | 2009-02-20 18:06:48 +0000 | [diff] [blame] | 43 | int __attribute__((const)) f10_t(void); |
| 44 | int f10(void) { return f10_t(); } |
Daniel Dunbar | 0334a4e | 2009-02-25 20:59:29 +0000 | [diff] [blame] | 45 | int f11(void) { |
| 46 | exit: |
| 47 | return f10_t(); |
| 48 | } |
| 49 | int f12(int arg) { |
| 50 | return arg ? 0 : f10_t(); |
| 51 | } |
Daniel Dunbar | c0ef9f5 | 2009-02-20 18:06:48 +0000 | [diff] [blame] | 52 | |
Daniel Dunbar | 0aa9424 | 2009-10-27 19:48:00 +0000 | [diff] [blame] | 53 | // CHECK: define void @f13() nounwind readnone |
Daniel Dunbar | 64c2e07 | 2009-04-10 22:14:52 +0000 | [diff] [blame] | 54 | void f13(void) __attribute__((pure)) __attribute__((const)); |
| 55 | void f13(void){} |
| 56 | |
Chris Lattner | bdb0132 | 2009-05-05 06:16:31 +0000 | [diff] [blame] | 57 | |
| 58 | // Ensure that these get inlined: rdar://6853279 |
Daniel Dunbar | 7ab1c3e | 2009-10-27 19:48:08 +0000 | [diff] [blame] | 59 | // CHECK: define void @f14 |
Daniel Dunbar | 0aa9424 | 2009-10-27 19:48:00 +0000 | [diff] [blame] | 60 | // CHECK-NOT: @ai_ |
Daniel Dunbar | 7ab1c3e | 2009-10-27 19:48:08 +0000 | [diff] [blame] | 61 | // CHECK: call void @f14_end |
Chris Lattner | bdb0132 | 2009-05-05 06:16:31 +0000 | [diff] [blame] | 62 | static __inline__ __attribute__((always_inline)) |
| 63 | int ai_1() { return 4; } |
| 64 | |
| 65 | static __inline__ __attribute__((always_inline)) |
| 66 | struct { |
| 67 | int a, b, c, d, e; |
Mike Stump | c36541e | 2009-07-21 20:52:43 +0000 | [diff] [blame] | 68 | } ai_2() { while (1) {} } |
Chris Lattner | bdb0132 | 2009-05-05 06:16:31 +0000 | [diff] [blame] | 69 | |
Daniel Dunbar | 7ab1c3e | 2009-10-27 19:48:08 +0000 | [diff] [blame] | 70 | void f14(int a) { |
| 71 | extern void f14_end(void); |
| 72 | if (a) |
| 73 | ai_2(); |
| 74 | ai_1(); |
| 75 | f14_end(); |
| 76 | } |
| 77 | |
| 78 | // <rdar://problem/7102668> [irgen] clang isn't setting the optsize bit on functions |
| 79 | // CHECK: define void @f15 |
| 80 | // CHECK: optsize |
| 81 | // CHECK: { |
| 82 | void f15(void) { |
Chris Lattner | bdb0132 | 2009-05-05 06:16:31 +0000 | [diff] [blame] | 83 | } |