brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · ee4db82 Raw
38 lines · c
1// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir2// RUN: FileCheck --input-file=%t.cir %s3 4void func1(void) {5  // Should lower default-initialized static vars.6  static int i;7  // CHECK-DAG: cir.global "private" internal dso_local @func1.i = #cir.int<0> : !s32i8 9  // Should lower constant-initialized static vars.10  static int j = 1;11  // CHECK-DAG: cir.global "private" internal dso_local @func1.j = #cir.int<1> : !s32i12 13  // Should properly shadow static vars in nested scopes.14  {15    static int j = 2;16    // CHECK-DAG: cir.global "private" internal dso_local @func1.j.1 = #cir.int<2> : !s32i17  }18  {19    static int j = 3;20    // CHECK-DAG: cir.global "private" internal dso_local @func1.j.2 = #cir.int<3> : !s32i21  }22 23  // Should lower basic static vars arithmetics.24  j++;25  // CHECK-DAG: %[[#V2:]] = cir.get_global @func1.j : !cir.ptr<!s32i>26  // CHECK-DAG: %[[#V3:]] = cir.load{{.*}} %[[#V2]] : !cir.ptr<!s32i>, !s32i27  // CHECK-DAG: %[[#V4:]] = cir.unary(inc, %[[#V3]]) nsw : !s32i, !s32i28  // CHECK-DAG: cir.store{{.*}} %[[#V4]], %[[#V2]] : !s32i, !cir.ptr<!s32i>29}30 31// Should shadow static vars on different functions.32void func2(void) {33  static char i;34  // CHECK-DAG: cir.global "private" internal dso_local @func2.i = #cir.int<0> : !s8i35  static float j;36  // CHECK-DAG: cir.global "private" internal dso_local @func2.j = #cir.fp<0.000000e+00> : !cir.float37}38