brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.1 KiB · d1829b1 Raw
179 lines · c
1// RUN: %clang_cc1 -triple x86_64 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s2 3#define _(x) (__builtin_preserve_access_index(x))4 5const void *unit1(const void *arg) {6  return _(arg);7}8// CHECK: define dso_local ptr @unit19// CHECK-NOT: llvm.preserve.array.access.index10// CHECK-NOT: llvm.preserve.struct.access.index11// CHECK-NOT: llvm.preserve.union.access.index12 13const void *unit2(void) {14  return _((const void *)0xffffffffFFFF0000ULL);15}16// CHECK: define dso_local ptr @unit217// CHECK-NOT: llvm.preserve.array.access.index18// CHECK-NOT: llvm.preserve.struct.access.index19// CHECK-NOT: llvm.preserve.union.access.index20 21const void *unit3(const int *arg) {22  return _(arg + 1);23}24// CHECK: define dso_local ptr @unit325// CHECK-NOT: llvm.preserve.array.access.index26// CHECK-NOT: llvm.preserve.struct.access.index27// CHECK-NOT: llvm.preserve.union.access.index28 29const void *unit4(const int *arg) {30  return _(&arg[1]);31}32// CHECK: define dso_local ptr @unit433// CHECK-NOT: getelementptr34// CHECK: call ptr @llvm.preserve.array.access.index.p0.p0(ptr elementtype(i32) %{{[0-9a-z]+}}, i32 0, i32 1), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[POINTER:[0-9]+]]35 36const void *unit5(const int *arg[5]) {37  return _(&arg[1][2]);38}39// CHECK: define dso_local ptr @unit540// CHECK-NOT: getelementptr41// CHECK: call ptr @llvm.preserve.array.access.index.p0.p0(ptr elementtype(ptr) %{{[0-9a-z]+}}, i32 0, i32 1), !dbg !{{[0-9]+}}, !llvm.preserve.access.index !{{[0-9]+}}42// CHECK-NOT: getelementptr43// CHECK: call ptr @llvm.preserve.array.access.index.p0.p0(ptr elementtype(i32) %{{[0-9a-z]+}}, i32 0, i32 2), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[POINTER:[0-9]+]]44 45struct s1 {46  char a;47  int b;48};49 50struct s2 {51  char a1:1;52  char a2:1;53  int b;54};55 56struct s3 {57  char a1:1;58  char a2:1;59  char :6;60  int b;61};62 63const void *unit6(struct s1 *arg) {64  return _(&arg->a);65}66// CHECK: define dso_local ptr @unit667// CHECK-NOT: getelementptr68// CHECK: call ptr @llvm.preserve.struct.access.index.p0.p0(ptr elementtype(%struct.s1) %{{[0-9a-z]+}}, i32 0, i32 0), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[STRUCT_S1:[0-9]+]]69 70const void *unit7(struct s1 *arg) {71  return _(&arg->b);72}73// CHECK: define dso_local ptr @unit774// CHECK-NOT: getelementptr75// CHECK: call ptr @llvm.preserve.struct.access.index.p0.p0(ptr elementtype(%struct.s1) %{{[0-9a-z]+}}, i32 1, i32 1), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[STRUCT_S1]]76 77const void *unit8(struct s2 *arg) {78  return _(&arg->b);79}80// CHECK: define dso_local ptr @unit881// CHECK-NOT: getelementptr82// CHECK: call ptr @llvm.preserve.struct.access.index.p0.p0(ptr elementtype(%struct.s2) %{{[0-9a-z]+}}, i32 1, i32 2), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[STRUCT_S2:[0-9]+]]83 84const void *unit9(struct s3 *arg) {85  return _(&arg->b);86}87// CHECK: define dso_local ptr @unit988// CHECK-NOT: getelementptr89// CHECK: call ptr @llvm.preserve.struct.access.index.p0.p0(ptr elementtype(%struct.s3) %{{[0-9a-z]+}}, i32 1, i32 2), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[STRUCT_S3:[0-9]+]]90 91union u1 {92  char a;93  int b;94};95 96union u2 {97  char a;98  int :32;99  int b;100};101 102const void *unit10(union u1 *arg) {103  return _(&arg->a);104}105// CHECK: define dso_local ptr @unit10106// CHECK-NOT: getelementptr107// CHECK: call ptr @llvm.preserve.union.access.index.p0.p0(ptr %{{[0-9a-z]+}}, i32 0), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[UNION_U1:[0-9]+]]108 109const void *unit11(union u1 *arg) {110  return _(&arg->b);111}112// CHECK: define dso_local ptr @unit11113// CHECK-NOT: getelementptr114// CHECK: call ptr @llvm.preserve.union.access.index.p0.p0(ptr %{{[0-9a-z]+}}, i32 1), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[UNION_U1]]115 116const void *unit12(union u2 *arg) {117  return _(&arg->b);118}119// CHECK: define dso_local ptr @unit12120// CHECK-NOT: getelementptr121// CHECK: call ptr @llvm.preserve.union.access.index.p0.p0(ptr %{{[0-9a-z]+}}, i32 1), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[UNION_U2:[0-9]+]]122 123struct s4 {124  char d;125  union u {126    int b[4];127    char a;128  } c;129};130 131union u3 {132  struct s {133    int b[4];134  } c;135  char a;136};137 138const void *unit13(struct s4 *arg) {139  return _(&arg->c.b[2]);140}141// CHECK: define dso_local ptr @unit13142// CHECK: call ptr @llvm.preserve.struct.access.index.p0.p0(ptr elementtype(%struct.s4) %{{[0-9a-z]+}}, i32 1, i32 1), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[STRUCT_S4:[0-9]+]]143// CHECK: call ptr @llvm.preserve.union.access.index.p0.p0(ptr %{{[0-9a-z]+}}, i32 0), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[UNION_I_U:[0-9]+]]144// CHECK: call ptr @llvm.preserve.array.access.index.p0.p0(ptr elementtype([4 x i32]) %{{[0-9a-z]+}}, i32 1, i32 2), !dbg !{{[0-9]+}}, !llvm.preserve.access.index !{{[0-9]+}}145 146const void *unit14(union u3 *arg) {147  return _(&arg->c.b[2]);148}149// CHECK: define dso_local ptr @unit14150// CHECK: call ptr @llvm.preserve.union.access.index.p0.p0(ptr %{{[0-9a-z]+}}, i32 0), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[UNION_U3:[0-9]+]]151// CHECK: call ptr @llvm.preserve.struct.access.index.p0.p0(ptr elementtype(%struct.s) %{{[0-9a-z]+}}, i32 0, i32 0), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[STRUCT_I_S:[0-9]+]]152// CHECK: call ptr @llvm.preserve.array.access.index.p0.p0(ptr elementtype([4 x i32]) %{{[0-9a-z]+}}, i32 1, i32 2), !dbg !{{[0-9]+}}, !llvm.preserve.access.index !{{[0-9]+}}153 154const void *unit15(struct s4 *arg) {155  return _(&arg[2].c.a);156}157// CHECK: define dso_local ptr @unit15158// CHECK: call ptr @llvm.preserve.array.access.index.p0.p0(ptr elementtype(%struct.s4) %{{[0-9a-z]+}}, i32 0, i32 2), !dbg !{{[0-9]+}}, !llvm.preserve.access.index !{{[0-9]+}}159// CHECK: call ptr @llvm.preserve.struct.access.index.p0.p0(ptr elementtype(%struct.s4) %{{[0-9a-z]+}}, i32 1, i32 1), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[STRUCT_S4]]160// CHECK: call ptr @llvm.preserve.union.access.index.p0.p0(ptr %{{[0-9a-z]+}}, i32 1), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[UNION_I_U]]161 162const void *unit16(union u3 *arg) {163  return _(&arg[2].a);164}165// CHECK: define dso_local ptr @unit16166// CHECK: call ptr @llvm.preserve.array.access.index.p0.p0(ptr elementtype(%union.u3) %{{[0-9a-z]+}}, i32 0, i32 2), !dbg !{{[0-9]+}}, !llvm.preserve.access.index !{{[0-9]+}}167// CHECK: call ptr @llvm.preserve.union.access.index.p0.p0(ptr %{{[0-9a-z]+}}, i32 1), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[UNION_U3]]168 169// CHECK: ![[POINTER]] = !DIDerivedType(tag: DW_TAG_pointer_type170// CHECK: ![[STRUCT_S4]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s4"171// CHECK: ![[UNION_I_U]] = distinct !DICompositeType(tag: DW_TAG_union_type, name: "u"172// CHECK: ![[UNION_U3]] = distinct !DICompositeType(tag: DW_TAG_union_type, name: "u3"173// CHECK: ![[STRUCT_I_S]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s"174// CHECK: ![[STRUCT_S1]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s1"175// CHECK: ![[STRUCT_S2]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s2"176// CHECK: ![[STRUCT_S3]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s3"177// CHECK: ![[UNION_U1]] = distinct !DICompositeType(tag: DW_TAG_union_type, name: "u1"178// CHECK: ![[UNION_U2]] = distinct !DICompositeType(tag: DW_TAG_union_type, name: "u2"179