// Test TBAA tags for common and equivalence. // RUN: fir-opt --fir-add-alias-tags --split-input-file %s | FileCheck --check-prefixes=ALL,DEFAULT %s // RUN: fir-opt --fir-add-alias-tags --local-alloc-tbaa --split-input-file %s | FileCheck --check-prefixes=ALL,LOCAL %s // ALL: #[[ROOT:.+]] = #llvm.tbaa_root // ALL: #[[ANY:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[ANYDATA:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[TARGETDATA:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[GLOBALDATA:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[BLK:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[TAG:.+]] = #llvm.tbaa_tag module { // 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 = [#[[TAG]]]} : !fir.ref // ALL: fir.store{{.*}}{tbaa = [#[[TAG]]]} : !fir.ref // ALL: fir.store{{.*}}{tbaa = [#[[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 {uniq_name = "_QFtest_commonEa"} : (!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 {uniq_name = "_QFtest_commonEb"} : (!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) {uniq_name = "_QFtest_commonEc"} : (!fir.ref>, !fir.shape<1>) -> !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 } } // ----- // LOCAL: #[[ROOT:.+]] = #llvm.tbaa_root // LOCAL: #[[ANY:.+]] = #llvm.tbaa_type_desc}> // LOCAL: #[[ANYDATA:.+]] = #llvm.tbaa_type_desc}> // LOCAL: #[[TARGETDATA:.+]] = #llvm.tbaa_type_desc}> // LOCAL: #[[ALLOCATEDDATA:.+]] = #llvm.tbaa_type_desc}> // LOCAL: #[[EQUIV:.+]] = #llvm.tbaa_type_desc}> // LOCAL: #[[$ATTR_13:.+]] = #llvm.tbaa_tag // ALL-LABEL: func.func @_QPtest_local_equiv() { // LOCAL: fir.store{{.*}}{tbaa = [#[[TAG]]]} : !fir.ptr // LOCAL: fir.store{{.*}}{tbaa = [#[[TAG]]]} : !fir.ref // LOCAL: fir.store{{.*}}{tbaa = [#[[TAG]]]} : !fir.ptr // DEFAULT-NOT: fir.store{{.}}tbaa 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: #[[TARGETDATA:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[GLOBALDATA:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[EQUIV:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[TAG:.+]] = #llvm.tbaa_tag module { // 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: #[[TARGETDATA:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[GLOBALDATA:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[EQUIV:.+]] = #llvm.tbaa_type_desc}> // ALL: #[[TAG:.+]] = #llvm.tbaa_tag module { // 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 } }