brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.2 KiB · 8a19395 Raw
200 lines · cpp
1// RUN: %clang_cc1 -std=c++14 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s2 3// Basic test.4namespace test0 {5  struct A {6    A();7    int x;8  };9 10  typedef A elt;11 12  // CHECK:    define{{.*}} ptr @_ZN5test04testEs(i16 noundef signext13  // CHECK:      [[N:%.*]] = sext i16 {{%.*}} to i3214  // CHECK-NEXT: [[T0:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 [[N]], i32 4)15  // CHECK-NEXT: [[T1:%.*]] = extractvalue { i32, i1 } [[T0]], 116  // CHECK-NEXT: [[T2:%.*]] = extractvalue { i32, i1 } [[T0]], 017  // CHECK-NEXT: [[T3:%.*]] = select i1 [[T1]], i32 -1, i32 [[T2]]18  // CHECK-NEXT: call noalias noundef nonnull ptr @_Znaj(i32 noundef [[T3]])19  // CHECK:      getelementptr inbounds {{.*}}, i32 [[N]]20  elt *test(short s) {21    return new elt[s];22  }23}24 25// test0 with a nested array.26namespace test1 {27  struct A {28    A();29    int x;30  };31 32  typedef A elt[100];33 34  // CHECK:    define{{.*}} ptr @_ZN5test14testEs(i16 noundef signext35  // CHECK:      [[N:%.*]] = sext i16 {{%.*}} to i3236  // CHECK-NEXT: [[T0:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 [[N]], i32 400)37  // CHECK-NEXT: [[T1:%.*]] = extractvalue { i32, i1 } [[T0]], 138  // CHECK-NEXT: [[T2:%.*]] = extractvalue { i32, i1 } [[T0]], 039  // CHECK-NEXT: [[T3:%.*]] = mul i32 [[N]], 10040  // CHECK-NEXT: [[T4:%.*]] = select i1 [[T1]], i32 -1, i32 [[T2]]41  // CHECK-NEXT: call noalias noundef nonnull ptr @_Znaj(i32 noundef [[T4]])42  // CHECK:      getelementptr inbounds {{.*}}, i32 [[T3]]43  elt *test(short s) {44    return new elt[s];45  }46}47 48// test1 with an array cookie.49namespace test2 {50  struct A {51    A();52    ~A();53    int x;54  };55 56  typedef A elt[100];57 58  // CHECK:    define{{.*}} ptr @_ZN5test24testEs(i16 noundef signext59  // CHECK:      [[N:%.*]] = sext i16 {{%.*}} to i3260  // CHECK-NEXT: [[T0:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 [[N]], i32 400)61  // CHECK-NEXT: [[T1:%.*]] = extractvalue { i32, i1 } [[T0]], 162  // CHECK-NEXT: [[T2:%.*]] = extractvalue { i32, i1 } [[T0]], 063  // CHECK-NEXT: [[T3:%.*]] = mul i32 [[N]], 10064  // CHECK-NEXT: [[T4:%.*]] = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 [[T2]], i32 4)65  // CHECK-NEXT: [[T5:%.*]] = extractvalue { i32, i1 } [[T4]], 166  // CHECK-NEXT: [[T6:%.*]] = or i1 [[T1]], [[T5]]67  // CHECK-NEXT: [[T7:%.*]] = extractvalue { i32, i1 } [[T4]], 068  // CHECK-NEXT: [[T8:%.*]] = select i1 [[T6]], i32 -1, i32 [[T7]]69  // CHECK-NEXT: call noalias noundef nonnull ptr @_Znaj(i32 noundef [[T8]])70  // CHECK:      getelementptr inbounds {{.*}}, i32 [[T3]]71  elt *test(short s) {72    return new elt[s];73  }74}75 76// test0 with a 1-byte element.77namespace test4 {78  struct A {79    A();80  };81 82  typedef A elt;83 84  // CHECK:    define{{.*}} ptr @_ZN5test44testEs(i16 noundef signext85  // CHECK:      [[N:%.*]] = sext i16 {{%.*}} to i3286  // CHECK-NEXT: call noalias noundef nonnull ptr @_Znaj(i32 noundef [[N]])87  // CHECK:      getelementptr inbounds {{.*}}, i32 [[N]]88  elt *test(short s) {89    return new elt[s];90  }91}92 93// test4 with no sext required.94namespace test5 {95  struct A {96    A();97  };98 99  typedef A elt;100 101  // CHECK:    define{{.*}} ptr @_ZN5test54testEi(i32102  // CHECK:      [[N:%.*]] = load i32, ptr103  // CHECK-NEXT: call noalias noundef nonnull ptr @_Znaj(i32 noundef [[N]])104  // CHECK:      getelementptr inbounds {{.*}}, i32 [[N]]105  elt *test(int s) {106    return new elt[s];107  }108}109 110// test0 with an unsigned size.111namespace test6 {112  struct A {113    A();114    int x;115  };116 117  typedef A elt;118 119  // CHECK:    define{{.*}} ptr @_ZN5test64testEt(i16 noundef zeroext120  // CHECK:      [[N:%.*]] = zext i16 {{%.*}} to i32121  // CHECK-NEXT: [[T0:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 [[N]], i32 4)122  // CHECK-NEXT: [[T1:%.*]] = extractvalue { i32, i1 } [[T0]], 1123  // CHECK-NEXT: [[T2:%.*]] = extractvalue { i32, i1 } [[T0]], 0124  // CHECK-NEXT: [[T3:%.*]] = select i1 [[T1]], i32 -1, i32 [[T2]]125  // CHECK-NEXT: call noalias noundef nonnull ptr @_Znaj(i32 noundef [[T3]])126  // CHECK:      getelementptr inbounds {{.*}}, i32 [[N]]127  elt *test(unsigned short s) {128    return new elt[s];129  }130}131 132// test1 with an unsigned size.133namespace test7 {134  struct A {135    A();136    int x;137  };138 139  typedef A elt[100];140 141  // CHECK:    define{{.*}} ptr @_ZN5test74testEt(i16 noundef zeroext142  // CHECK:      [[N:%.*]] = zext i16 {{%.*}} to i32143  // CHECK-NEXT: [[T0:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 [[N]], i32 400)144  // CHECK-NEXT: [[T1:%.*]] = extractvalue { i32, i1 } [[T0]], 1145  // CHECK-NEXT: [[T2:%.*]] = extractvalue { i32, i1 } [[T0]], 0146  // CHECK-NEXT: [[T3:%.*]] = mul i32 [[N]], 100147  // CHECK-NEXT: [[T4:%.*]] = select i1 [[T1]], i32 -1, i32 [[T2]]148  // CHECK-NEXT: call noalias noundef nonnull ptr @_Znaj(i32 noundef [[T4]])149  // CHECK:      getelementptr inbounds {{.*}}, i32 [[T3]]150  elt *test(unsigned short s) {151    return new elt[s];152  }153}154 155// test0 with a signed type larger than size_t.156namespace test8 {157  struct A {158    A();159    int x;160  };161 162  typedef A elt;163 164  // CHECK:    define{{.*}} ptr @_ZN5test84testEx(i64165  // CHECK:      [[N:%.*]] = load i64, ptr166  // CHECK-NEXT: [[T1:%.*]] = trunc i64 [[N]] to i32167  // CHECK-NEXT: [[T2:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 [[T1]], i32 4)168  // CHECK-NEXT: [[T3:%.*]] = extractvalue { i32, i1 } [[T2]], 1169  // CHECK-NEXT: [[T5:%.*]] = extractvalue { i32, i1 } [[T2]], 0170  // CHECK-NEXT: [[T6:%.*]] = select i1 [[T3]], i32 -1, i32 [[T5]]171  // CHECK-NEXT: call noalias noundef nonnull ptr @_Znaj(i32 noundef [[T6]])172  // CHECK:      getelementptr inbounds {{.*}}, i32 [[T1]]173  elt *test(long long s) {174    return new elt[s];175  }176}177 178// test8 with an unsigned type.179namespace test9 {180  struct A {181    A();182    int x;183  };184 185  typedef A elt;186 187  // CHECK:    define{{.*}} ptr @_ZN5test94testEy(i64188  // CHECK:      [[N:%.*]] = load i64, ptr189  // CHECK-NEXT: [[T1:%.*]] = trunc i64 [[N]] to i32190  // CHECK-NEXT: [[T2:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 [[T1]], i32 4)191  // CHECK-NEXT: [[T3:%.*]] = extractvalue { i32, i1 } [[T2]], 1192  // CHECK-NEXT: [[T5:%.*]] = extractvalue { i32, i1 } [[T2]], 0193  // CHECK-NEXT: [[T6:%.*]] = select i1 [[T3]], i32 -1, i32 [[T5]]194  // CHECK-NEXT: call noalias noundef nonnull ptr @_Znaj(i32 noundef [[T6]])195  // CHECK:      getelementptr inbounds {{.*}}, i32 [[T1]]196  elt *test(unsigned long long s) {197    return new elt[s];198  }199}200