brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.4 KiB · bb8670a Raw
120 lines · c
1// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -disable-llvm-passes -Os -o - %s | FileCheck %s2// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -disable-llvm-passes -Os -std=c99 -o - %s | FileCheck %s3// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -disable-llvm-passes -Os -std=c99 -o - %s | FileCheck %s4// CHECK: define{{.*}} signext i8 @f0(i32 noundef %x) [[NUW:#[0-9]+]]5// CHECK: define{{.*}} zeroext i8 @f1(i32 noundef %x) [[NUW]]6// CHECK: define{{.*}} void @f2(i8 noundef signext %x) [[NUW]]7// CHECK: define{{.*}} void @f3(i8 noundef zeroext %x) [[NUW]]8// CHECK: define{{.*}} signext i16 @f4(i32 noundef %x) [[NUW]]9// CHECK: define{{.*}} zeroext i16 @f5(i32 noundef %x) [[NUW]]10// CHECK: define{{.*}} void @f6(i16 noundef signext %x) [[NUW]]11// CHECK: define{{.*}} void @f7(i16 noundef zeroext %x) [[NUW]]12 13signed char f0(int x) { return x; }14 15unsigned char f1(int x) { return x; }16 17void f2(signed char x) { }18 19void f3(unsigned char x) { }20 21signed short f4(int x) { return x; }22 23unsigned short f5(int x) { return x; }24 25void f6(signed short x) { }26 27void f7(unsigned short x) { }28 29// CHECK-LABEL: define{{.*}} void @f8()30// CHECK: [[AI:#[0-9]+]]31// CHECK: {32void __attribute__((always_inline)) f8(void) { }33 34// CHECK: call void @f9_t()35// CHECK: [[NR:#[0-9]+]]36// CHECK: }37void __attribute__((noreturn)) f9_t(void);38void f9(void) { f9_t(); }39 40// CHECK: call void @f9a()41// CHECK: [[NR]]42// CHECK: }43_Noreturn void f9a(void);44void f9b(void) { f9a(); }45 46// FIXME: We should be setting nounwind on calls.47// CHECK: call i32 @f10_t()48// CHECK: [[NUW_RN:#[0-9]+]]49// CHECK: {50int __attribute__((const)) f10_t(void);51int f10(void) { return f10_t(); }52int f11(void) {53 exit:54  return f10_t();55}56int f12(int arg) {57  return arg ? 0 : f10_t();58}59 60// CHECK: define{{.*}} i32 @f13() [[NUW_OS_RN:#[0-9]+]]61int f13(void) __attribute__((const));62int f13(void){ return 0; }63 64 65// [irgen] clang isn't setting the optsize bit on functions66// CHECK-LABEL: define{{.*}} void @f1567// CHECK: [[NUW]]68// CHECK: {69void f15(void) {70}71 72// PR525473// CHECK-LABEL: define{{.*}} void @f1674// CHECK: [[SR:#[0-9]+]]75// CHECK: {76void __attribute__((force_align_arg_pointer)) f16(void) {77}78 79// PR1103880// CHECK-LABEL: define{{.*}} void @f18()81// CHECK: [[RT:#[0-9]+]]82// CHECK: {83// CHECK: call void @f17()84// CHECK: [[RT_CALL:#[0-9]+]]85// CHECK: ret void86__attribute__ ((returns_twice)) void f17(void);87__attribute__ ((returns_twice)) void f18(void) {88        f17();89}90 91// CHECK-LABEL: define{{.*}} void @f19()92// CHECK: {93// CHECK: call i32 @setjmp(ptr noundef null)94// CHECK: [[RT_CALL]]95// CHECK: ret void96typedef int jmp_buf[((9 * 2) + 3 + 16)];97int setjmp(jmp_buf);98void f19(void) {99  setjmp(0);100}101 102// CHECK-LABEL: define{{.*}} void @f20()103// CHECK: {104// CHECK: call i32 @_setjmp(ptr noundef null)105// CHECK: [[RT_CALL]]106// CHECK: ret void107int _setjmp(jmp_buf);108void f20(void) {109  _setjmp(0);110}111 112// CHECK: attributes [[NUW]] = { nounwind optsize{{.*}} }113// CHECK: attributes [[AI]] = { alwaysinline nounwind optsize{{.*}} }114// CHECK: attributes [[NUW_OS_RN]] = { nounwind optsize willreturn memory(none){{.*}} }115// CHECK: attributes [[SR]] = { nounwind optsize{{.*}} "stackrealign"{{.*}} }116// CHECK: attributes [[RT]] = { nounwind optsize returns_twice{{.*}} }117// CHECK: attributes [[NR]] = { noreturn optsize }118// CHECK: attributes [[NUW_RN]] = { nounwind optsize willreturn memory(none) }119// CHECK: attributes [[RT_CALL]] = { optsize returns_twice }120