// Test TBAA tags for common and equivalence. // RUN: fir-opt --fir-add-alias-tags --split-input-file %s | FileCheck --check-prefixes=ALL %s // ALL: #[[ROOT:.+]] = #llvm.tbaa_root // ALL: #[[ANY:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[ANYDATA:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[GLOBALDATA:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[BLK:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[BLK_A:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[BLK_C:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[BLK_B:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[BLK_A_TAG:.+]] = #llvm.tbaa_tag // ALL: #[[BLK_C_TAG:.+]] = #llvm.tbaa_tag // ALL: #[[BLK_B_TAG:.+]] = #llvm.tbaa_tag module attributes {dlti.dl_spec = #dlti.dl_spec : vector<4xi64>, i1 = dense<8> : vector<2xi64>, i8 = dense<8> : vector<2xi64>, i16 = dense<16> : vector<2xi64>, i32 = dense<32> : vector<2xi64>, i64 = dense<[32, 64]> : vector<2xi64>, f16 = dense<16> : vector<2xi64>, f64 = dense<64> : vector<2xi64>, f128 = dense<128> : vector<2xi64>, "dlti.endianness" = "little">, llvm.data_layout = ""} { // ALL-LABEL: fir.global common @blk_(dense<0> : vector<48xi8>) {alignment = 4 : i64} : !fir.array<48xi8> fir.global common @blk_(dense<0> : vector<48xi8>) {alignment = 4 : i64} : !fir.array<48xi8> // ALL-LABEL: func.func @_QPtest_common() { // ALL: fir.store{{.*}}{tbaa = [#[[BLK_A_TAG]]]} : !fir.ref // ALL: fir.store{{.*}}{tbaa = [#[[BLK_C_TAG]]]} : !fir.ref // ALL: fir.store{{.*}}{tbaa = [#[[BLK_B_TAG]]]} : !fir.ref func.func @_QPtest_common() { %c1 = arith.constant 1 : index %c1_i32 = arith.constant 1 : i32 %cst = arith.constant 1.000000e+00 : f32 %c10 = arith.constant 10 : index %c8 = arith.constant 8 : index %c4 = arith.constant 4 : index %c0 = arith.constant 0 : index %0 = fir.dummy_scope : !fir.dscope %1 = fir.address_of(@blk_) : !fir.ref> %2 = fir.convert %1 : (!fir.ref>) -> !fir.ref> %3 = fir.coordinate_of %2, %c0 : (!fir.ref>, index) -> !fir.ref %4 = fir.convert %3 : (!fir.ref) -> !fir.ref %5 = fir.declare %4 storage(%1[0]) {uniq_name = "_QFtest_commonEa"} : (!fir.ref, !fir.ref>) -> !fir.ref %6 = fir.coordinate_of %2, %c4 : (!fir.ref>, index) -> !fir.ref %7 = fir.convert %6 : (!fir.ref) -> !fir.ref %8 = fir.declare %7 storage(%1[4]) {uniq_name = "_QFtest_commonEb"} : (!fir.ref, !fir.ref>) -> !fir.ref %9 = fir.coordinate_of %2, %c8 : (!fir.ref>, index) -> !fir.ref %10 = fir.convert %9 : (!fir.ref) -> !fir.ref> %11 = fir.shape %c10 : (index) -> !fir.shape<1> %12 = fir.declare %10(%11) storage(%1[8]) {uniq_name = "_QFtest_commonEc"} : (!fir.ref>, !fir.shape<1>, !fir.ref>) -> !fir.ref> fir.store %cst to %5 : !fir.ref %13 = fir.array_coor %12(%11) %c1 : (!fir.ref>, !fir.shape<1>, index) -> !fir.ref fir.store %c1_i32 to %13 : !fir.ref fir.store %cst to %8 : !fir.ref return } } // ----- // ALL: #[[ROOT:.+]] = #llvm.tbaa_root // ALL: #[[ANY:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[ANYDATA:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[ALLOCATEDDATA:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[EQUIV:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[TAG:.+]] = #llvm.tbaa_tag // ALL-LABEL: func.func @_QPtest_local_equiv() { // ALL: fir.store{{.*}}{tbaa = [#[[TAG]]]} : !fir.ptr // ALL: fir.store{{.*}}{tbaa = [#[[TAG]]]} : !fir.ref // ALL: fir.store{{.*}}{tbaa = [#[[TAG]]]} : !fir.ptr module attributes {dlti.dl_spec = #dlti.dl_spec : vector<4xi64>, i1 = dense<8> : vector<2xi64>, i8 = dense<8> : vector<2xi64>, i16 = dense<16> : vector<2xi64>, i32 = dense<32> : vector<2xi64>, i64 = dense<[32, 64]> : vector<2xi64>, f16 = dense<16> : vector<2xi64>, f64 = dense<64> : vector<2xi64>, f128 = dense<128> : vector<2xi64>, "dlti.endianness" = "little">, llvm.data_layout = ""} { func.func @_QPtest_local_equiv() { %c1 = arith.constant 1 : index %c1_i32 = arith.constant 1 : i32 %cst = arith.constant 1.000000e+00 : f32 %c10 = arith.constant 10 : index %c0 = arith.constant 0 : index %c8 = arith.constant 8 : index %0 = fir.dummy_scope : !fir.dscope %1 = fir.alloca !fir.array<40xi8> {uniq_name = "_QFtest_local_equivEa"} %2 = fir.coordinate_of %1, %c8 : (!fir.ref>, index) -> !fir.ref %3 = fir.convert %2 : (!fir.ref) -> !fir.ptr %4 = fir.declare %3 {uniq_name = "_QFtest_local_equivEa"} : (!fir.ptr) -> !fir.ptr %5 = fir.declare %3 {uniq_name = "_QFtest_local_equivEb"} : (!fir.ptr) -> !fir.ptr %6 = fir.coordinate_of %1, %c0 : (!fir.ref>, index) -> !fir.ref %7 = fir.convert %6 : (!fir.ref) -> !fir.ptr> %8 = fir.shape %c10 : (index) -> !fir.shape<1> %9 = fir.declare %7(%8) {uniq_name = "_QFtest_local_equivEc"} : (!fir.ptr>, !fir.shape<1>) -> !fir.ptr> fir.store %cst to %4 : !fir.ptr %10 = fir.array_coor %9(%8) %c1 : (!fir.ptr>, !fir.shape<1>, index) -> !fir.ref fir.store %c1_i32 to %10 : !fir.ref fir.store %cst to %5 : !fir.ptr return } } // ----- // ALL: #[[ROOT:.+]] = #llvm.tbaa_root // ALL: #[[ANY:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[ANYDATA:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[GLOBALDATA:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[EQUIV:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[TAG:.+]] = #llvm.tbaa_tag module attributes {dlti.dl_spec = #dlti.dl_spec : vector<4xi64>, i1 = dense<8> : vector<2xi64>, i8 = dense<8> : vector<2xi64>, i16 = dense<16> : vector<2xi64>, i32 = dense<32> : vector<2xi64>, i64 = dense<[32, 64]> : vector<2xi64>, f16 = dense<16> : vector<2xi64>, f64 = dense<64> : vector<2xi64>, f128 = dense<128> : vector<2xi64>, "dlti.endianness" = "little">, llvm.data_layout = ""} { // ALL-LABEL: fir.global internal @_QFtest_save_equivEa : !fir.array<40xi8> { fir.global internal @_QFtest_save_equivEa : !fir.array<40xi8> { %0 = fir.zero_bits !fir.array<40xi8> fir.has_value %0 : !fir.array<40xi8> } // ALL-LABEL: func.func @_QPtest_save_equiv() { // ALL: fir.store{{.*}}{tbaa = [#[[TAG]]]} : !fir.ptr // ALL: fir.store{{.*}}{tbaa = [#[[TAG]]]} : !fir.ref // ALL: fir.store{{.*}}{tbaa = [#[[TAG]]]} : !fir.ptr func.func @_QPtest_save_equiv() { %c1 = arith.constant 1 : index %c1_i32 = arith.constant 1 : i32 %cst = arith.constant 1.000000e+00 : f32 %c10 = arith.constant 10 : index %c0 = arith.constant 0 : index %c8 = arith.constant 8 : index %0 = fir.dummy_scope : !fir.dscope %1 = fir.address_of(@_QFtest_save_equivEa) : !fir.ref> %2 = fir.coordinate_of %1, %c8 : (!fir.ref>, index) -> !fir.ref %3 = fir.convert %2 : (!fir.ref) -> !fir.ptr %4 = fir.declare %3 {uniq_name = "_QFtest_save_equivEa"} : (!fir.ptr) -> !fir.ptr %5 = fir.declare %3 {uniq_name = "_QFtest_save_equivEb"} : (!fir.ptr) -> !fir.ptr %6 = fir.coordinate_of %1, %c0 : (!fir.ref>, index) -> !fir.ref %7 = fir.convert %6 : (!fir.ref) -> !fir.ptr> %8 = fir.shape %c10 : (index) -> !fir.shape<1> %9 = fir.declare %7(%8) {uniq_name = "_QFtest_save_equivEc"} : (!fir.ptr>, !fir.shape<1>) -> !fir.ptr> fir.store %cst to %4 : !fir.ptr %10 = fir.array_coor %9(%8) %c1 : (!fir.ptr>, !fir.shape<1>, index) -> !fir.ref fir.store %c1_i32 to %10 : !fir.ref fir.store %cst to %5 : !fir.ptr return } } // ----- // ALL: #[[ROOT:.+]] = #llvm.tbaa_root // ALL: #[[ANY:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[ANYDATA:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[GLOBALDATA:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[EQUIV:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[TAG:.+]] = #llvm.tbaa_tag module attributes {dlti.dl_spec = #dlti.dl_spec : vector<4xi64>, i1 = dense<8> : vector<2xi64>, i8 = dense<8> : vector<2xi64>, i16 = dense<16> : vector<2xi64>, i32 = dense<32> : vector<2xi64>, i64 = dense<[32, 64]> : vector<2xi64>, f16 = dense<16> : vector<2xi64>, f64 = dense<64> : vector<2xi64>, f128 = dense<128> : vector<2xi64>, "dlti.endianness" = "little">, llvm.data_layout = ""} { // ALL-LABEL: fir.global @_QMdataEa : !fir.array<40xi8> { fir.global @_QMdataEa : !fir.array<40xi8> { %0 = fir.zero_bits !fir.array<40xi8> fir.has_value %0 : !fir.array<40xi8> } // ALL-LABEL: func.func @_QPtest_global_equiv() { // ALL: fir.store{{.*}}{tbaa = [#[[TAG]]]} : !fir.ptr // ALL: fir.store{{.*}}{tbaa = [#[[TAG]]]} : !fir.ref // ALL: fir.store{{.*}}{tbaa = [#[[TAG]]]} : !fir.ptr func.func @_QPtest_global_equiv() { %c1 = arith.constant 1 : index %c1_i32 = arith.constant 1 : i32 %cst = arith.constant 1.000000e+00 : f32 %c10 = arith.constant 10 : index %c0 = arith.constant 0 : index %c8 = arith.constant 8 : index %0 = fir.dummy_scope : !fir.dscope %1 = fir.address_of(@_QMdataEa) : !fir.ref> %2 = fir.coordinate_of %1, %c8 : (!fir.ref>, index) -> !fir.ref %3 = fir.convert %2 : (!fir.ref) -> !fir.ptr %4 = fir.declare %3 {uniq_name = "_QMdataEa"} : (!fir.ptr) -> !fir.ptr %5 = fir.declare %3 {uniq_name = "_QMdataEb"} : (!fir.ptr) -> !fir.ptr %6 = fir.coordinate_of %1, %c0 : (!fir.ref>, index) -> !fir.ref %7 = fir.convert %6 : (!fir.ref) -> !fir.ptr> %8 = fir.shape %c10 : (index) -> !fir.shape<1> %9 = fir.declare %7(%8) {uniq_name = "_QMdataEc"} : (!fir.ptr>, !fir.shape<1>) -> !fir.ptr> fir.store %cst to %4 : !fir.ptr %10 = fir.array_coor %9(%8) %c1 : (!fir.ptr>, !fir.shape<1>, index) -> !fir.ref fir.store %c1_i32 to %10 : !fir.ref fir.store %cst to %5 : !fir.ptr return } }