[flang] use TBAAForest in TBAABuilder

This is important to ensure that tags end up in the same trees that were
created in the FIR TBAA pass. If they are in different trees then
everything in one tree will be assumed to MayAlias with everything in the
other tree. This leads to poor performance.

@vzakhari requested that the old (not-per-function) trees are
maintained so I left the old test intact.

PR: https://github.com/llvm/llvm-project/pull/68437
This commit is contained in:
Tom Eccles 2023-09-14 15:01:08 +00:00
parent db1d40f319
commit 6042c2eb9e
5 changed files with 182 additions and 76 deletions

View File

@ -13,8 +13,8 @@
#ifndef FORTRAN_OPTIMIZER_CODEGEN_TBAABUILDER_H
#define FORTRAN_OPTIMIZER_CODEGEN_TBAABUILDER_H
#include "flang/Optimizer/Analysis/TBAAForest.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/IR/BuiltinAttributes.h"
namespace fir {
@ -25,9 +25,9 @@ namespace fir {
//
// TBAA type information is represented with LLVM::MetadataOp operation
// with specific symbol name `TBAABuilder::tbaaMetaOpName`. The basic
// TBAA tree used for Flang consists of the following nodes:
// TBAA trees used for Flang consists of the following nodes:
// llvm.metadata @__flang_tbaa {
// llvm.tbaa_root @root_0 {id = "Flang Type TBAA Root"}
// llvm.tbaa_root @root_0 {id = "Flang Type TBAA Function Root funcName"}
// llvm.tbaa_type_desc @type_desc_1 {id = "any access",
// members = {<@root_0, 0>}}
// llvm.tbaa_type_desc @type_desc_2 {id = "any data access",
@ -162,9 +162,14 @@ namespace fir {
// Given the storage association, all non-box accesses are represented
// with the conservative data access tag:
// < `<any data access>`, `<any data access>`, 0 >
// additional tags are added in flang/Optimizer/Transforms/AddAliasTags.cpp
// (before CodeGen)
class TBAABuilder {
public:
TBAABuilder(mlir::MLIRContext *context, bool applyTBAA);
/// if forceUnifiedTree is true, functions will not have different TBAA trees
TBAABuilder(mlir::MLIRContext *context, bool applyTBAA,
bool forceUnifiedTree = false);
TBAABuilder(TBAABuilder const &) = delete;
TBAABuilder &operator=(TBAABuilder const &) = delete;
@ -184,13 +189,13 @@ private:
// Returns TBAATagAttr representing access tag:
// < <descriptor member>, <descriptor member>, 0 >
mlir::LLVM::TBAATagAttr getAnyBoxAccessTag();
mlir::LLVM::TBAATagAttr getAnyBoxAccessTag(mlir::LLVM::LLVMFuncOp func);
// Returns TBAATagAttr representing access tag:
// < <any data access>, <any data access>, 0 >
mlir::LLVM::TBAATagAttr getAnyDataAccessTag();
mlir::LLVM::TBAATagAttr getAnyDataAccessTag(mlir::LLVM::LLVMFuncOp func);
// Returns TBAATagAttr representing access tag:
// < <any access>, <any access>, 0 >
mlir::LLVM::TBAATagAttr getAnyAccessTag();
mlir::LLVM::TBAATagAttr getAnyAccessTag(mlir::LLVM::LLVMFuncOp func);
// Returns TBAATagAttr representing access tag described by the base and
// access FIR types and the LLVM::GepOp representing the access in terms of
@ -198,7 +203,8 @@ private:
// fir::BaseBoxType.
mlir::LLVM::TBAATagAttr getBoxAccessTag(mlir::Type baseFIRType,
mlir::Type accessFIRType,
mlir::LLVM::GEPOp gep);
mlir::LLVM::GEPOp gep,
mlir::LLVM::LLVMFuncOp func);
// Returns TBAATagAttr representing access tag described by the base and
// access FIR types and the LLVM::GepOp representing the access in terms of
@ -206,34 +212,13 @@ private:
// "data" access, i.e. not an access of any box/descriptor member.
mlir::LLVM::TBAATagAttr getDataAccessTag(mlir::Type baseFIRType,
mlir::Type accessFIRType,
mlir::LLVM::GEPOp gep);
mlir::LLVM::GEPOp gep,
mlir::LLVM::LLVMFuncOp func);
// Set to true, if TBAA builder is active, otherwise, all public
// methods are no-ops.
bool enableTBAA;
// LLVM::TBAARootAttr identifying Flang's TBAA root.
mlir::LLVM::TBAARootAttr flangTBAARoot;
// Identity string for Flang's TBAA root.
static constexpr llvm::StringRef flangTBAARootId = "Flang Type TBAA Root";
// LLVM::TBAATypeDescriptorAttr identifying "any access".
mlir::LLVM::TBAATypeDescriptorAttr anyAccessTypeDesc;
// Identity string for "any access" type descriptor.
static constexpr llvm::StringRef anyAccessTypeDescId = "any access";
// LLVM::TBAATypeDescriptorAttr identifying "any data access" (i.e. non-box
// memory access).
mlir::LLVM::TBAATypeDescriptorAttr anyDataAccessTypeDesc;
// Identity string for "any data access" type descriptor.
static constexpr llvm::StringRef anyDataAccessTypeDescId = "any data access";
// LLVM::TBAATypeDescriptorAttr identifying "descriptor member" access, i.e.
// any access within the bounds of a box/descriptor.
mlir::LLVM::TBAATypeDescriptorAttr boxMemberTypeDesc;
// Identity string for "descriptor member" type descriptor.
static constexpr llvm::StringRef boxMemberTypeDescId = "descriptor member";
// Number of attached TBAA tags (used for debugging).
unsigned tagAttachmentCounter = 0;
@ -247,6 +232,8 @@ private:
std::tuple<mlir::LLVM::TBAANodeAttr, mlir::LLVM::TBAANodeAttr, int64_t>,
mlir::LLVM::TBAATagAttr>
tagsMap;
TBAAForrest trees;
};
} // namespace fir

View File

@ -15,6 +15,9 @@
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include <mlir/Dialect/LLVMIR/LLVMAttrs.h>
#include <mlir/Dialect/LLVMIR/LLVMDialect.h>
#include <mlir/Dialect/LLVMIR/LLVMTypes.h>
#define DEBUG_TYPE "flang-tbaa-builder"
@ -27,6 +30,13 @@ static llvm::cl::opt<bool> disableTBAA(
"to override default Flang behavior"),
llvm::cl::init(false));
// disabling this will play badly with the FIR TBAA pass, leading to worse
// performance
static llvm::cl::opt<bool> perFunctionTBAATrees(
"per-function-tbaa-trees",
llvm::cl::desc("Give each function an independent TBAA tree (default)"),
llvm::cl::init(true), llvm::cl::Hidden);
// tagAttachmentLimit is a debugging option that allows limiting
// the number of TBAA access tag attributes attached to operations.
// It is set to kTagAttachmentUnlimited by default denoting "no limit".
@ -38,27 +48,12 @@ static llvm::cl::opt<unsigned>
namespace fir {
TBAABuilder::TBAABuilder(MLIRContext *context, bool applyTBAA)
: enableTBAA(applyTBAA && !disableTBAA) {
TBAABuilder::TBAABuilder(MLIRContext *context, bool applyTBAA,
bool forceUnifiedTree)
: enableTBAA(applyTBAA && !disableTBAA),
trees(/*separatePerFunction=*/perFunctionTBAATrees && !forceUnifiedTree) {
if (!enableTBAA)
return;
// Root node.
flangTBAARoot =
TBAARootAttr::get(context, StringAttr::get(context, flangTBAARootId));
// Any access node.
anyAccessTypeDesc = TBAATypeDescriptorAttr::get(
context, anyAccessTypeDescId, TBAAMemberAttr::get(flangTBAARoot, 0));
// Any data access node.
anyDataAccessTypeDesc =
TBAATypeDescriptorAttr::get(context, anyDataAccessTypeDescId,
TBAAMemberAttr::get(anyAccessTypeDesc, 0));
// Box member access node.
boxMemberTypeDesc = TBAATypeDescriptorAttr::get(
context, boxMemberTypeDescId, TBAAMemberAttr::get(anyAccessTypeDesc, 0));
}
TBAATagAttr TBAABuilder::getAccessTag(TBAATypeDescriptorAttr baseTypeDesc,
@ -73,26 +68,31 @@ TBAATagAttr TBAABuilder::getAccessTag(TBAATypeDescriptorAttr baseTypeDesc,
return tag;
}
TBAATagAttr TBAABuilder::getAnyBoxAccessTag() {
TBAATagAttr TBAABuilder::getAnyBoxAccessTag(mlir::LLVM::LLVMFuncOp func) {
TBAATypeDescriptorAttr boxMemberTypeDesc = trees[func].boxMemberTypeDesc;
return getAccessTag(boxMemberTypeDesc, boxMemberTypeDesc, /*offset=*/0);
}
TBAATagAttr TBAABuilder::getBoxAccessTag(Type baseFIRType, Type accessFIRType,
GEPOp gep) {
return getAnyBoxAccessTag();
GEPOp gep,
mlir::LLVM::LLVMFuncOp func) {
return getAnyBoxAccessTag(func);
}
TBAATagAttr TBAABuilder::getAnyDataAccessTag() {
TBAATagAttr TBAABuilder::getAnyDataAccessTag(mlir::LLVM::LLVMFuncOp func) {
TBAATypeDescriptorAttr anyDataAccessTypeDesc = trees[func].anyDataTypeDesc;
return getAccessTag(anyDataAccessTypeDesc, anyDataAccessTypeDesc,
/*offset=*/0);
}
TBAATagAttr TBAABuilder::getDataAccessTag(Type baseFIRType, Type accessFIRType,
GEPOp gep) {
return getAnyDataAccessTag();
GEPOp gep,
mlir::LLVM::LLVMFuncOp func) {
return getAnyDataAccessTag(func);
}
TBAATagAttr TBAABuilder::getAnyAccessTag() {
TBAATagAttr TBAABuilder::getAnyAccessTag(mlir::LLVM::LLVMFuncOp func) {
TBAATypeDescriptorAttr anyAccessTypeDesc = trees[func].anyAccessDesc;
return getAccessTag(anyAccessTypeDesc, anyAccessTypeDesc, /*offset=*/0);
}
@ -101,6 +101,9 @@ void TBAABuilder::attachTBAATag(AliasAnalysisOpInterface op, Type baseFIRType,
if (!enableTBAA)
return;
mlir::LLVM::LLVMFuncOp func = op->getParentOfType<mlir::LLVM::LLVMFuncOp>();
assert(func && "func.func should have already been converted to llvm.func");
++tagAttachmentCounter;
if (tagAttachmentLimit != kTagAttachmentUnlimited &&
tagAttachmentCounter > tagAttachmentLimit)
@ -115,11 +118,11 @@ void TBAABuilder::attachTBAATag(AliasAnalysisOpInterface op, Type baseFIRType,
// a mix of data members and descriptor members may alias
// with both data and descriptor accesses.
// Conservatively set any-access tag if there is any descriptor member.
tbaaTagSym = getAnyAccessTag();
tbaaTagSym = getAnyAccessTag(func);
} else if (baseFIRType.isa<fir::BaseBoxType>()) {
tbaaTagSym = getBoxAccessTag(baseFIRType, accessFIRType, gep);
tbaaTagSym = getBoxAccessTag(baseFIRType, accessFIRType, gep, func);
} else {
tbaaTagSym = getDataAccessTag(baseFIRType, accessFIRType, gep);
tbaaTagSym = getDataAccessTag(baseFIRType, accessFIRType, gep, func);
}
if (!tbaaTagSym)

View File

@ -11,7 +11,7 @@
#tbaa_type_desc = #llvm.tbaa_type_desc<id = "any access", members = {<#tbaa_root, 0>}>
#tbaa_type_desc1 = #llvm.tbaa_type_desc<id = "any data access", members = {<#tbaa_type_desc, 0>}>
#tbaa_type_desc2 = #llvm.tbaa_type_desc<id = "dummy arg data", members = {<#tbaa_type_desc1, 0>}>
#tbaa_type_desc3 = #llvm.tbaa_type_desc<id = "dummy arg data/a", members = {<#tbaa_type_desc2, 0>}>
#tbaa_type_desc3 = #llvm.tbaa_type_desc<id = "dummy arg data/_QFfuncEa", members = {<#tbaa_type_desc2, 0>}>
#tbaa_tag = #llvm.tbaa_tag<base_type = #tbaa_type_desc3, access_type = #tbaa_type_desc3, offset = 0>
module attributes {fir.defaultkind = "a1c4d8i4l4r4", fir.kindmap = "", llvm.target_triple = "aarch64-unknown-linux-gnu"} {
func.func @_QPsimple(%arg0: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "a"}) {
@ -39,9 +39,9 @@ module attributes {fir.defaultkind = "a1c4d8i4l4r4", fir.kindmap = "", llvm.targ
// CHECK: store i32 %[[A2]], ptr %[[A1]], align 4, !tbaa ![[A_ACCESS_TAG]]
// CHECK: ret void
// CHECK: }
// CHECK: ![[ANY_ACCESS_TYPE:.*]] = !{!"any access", ![[ROOT:.*]], i64 0}
// CHECK: ![[ROOT]] = !{!"Flang function root _QPsimple"}
// CHECK: ![[A_ACCESS_TAG]] = !{![[A_ACCESS_TYPE:.*]], ![[A_ACCESS_TYPE]], i64 0}
// CHECK: ![[A_ACCESS_TYPE]] = !{!"dummy arg data/a", ![[DUMMY_ARG_TYPE:.*]], i64 0}
// CHECK: ![[A_ACCESS_TYPE]] = !{!"dummy arg data/_QFfuncEa", ![[DUMMY_ARG_TYPE:.*]], i64 0}
// CHECK: ![[DUMMY_ARG_TYPE]] = !{!"dummy arg data", ![[DATA_ACCESS_TYPE:.*]], i64 0}
// CHECK: ![[DATA_ACCESS_TYPE]] = !{!"any data access", ![[ANY_ACCESS_TYPE:.*]], i64 0}
// CHECK: ![[ANY_ACCESS_TYPE]] = !{!"any access", ![[ROOT:.*]], i64 0}
// CHECK: ![[ROOT]] = !{!"Flang function root _QPsimple"}
// CHECK: ![[DATA_ACCESS_TYPE]] = !{!"any data access", ![[ANY_ACCESS_TYPE]], i64 0}

View File

@ -0,0 +1,114 @@
// test that tbaa attributes can be added to fir.load and fir.store
// and that these attributes are propagated to LLVMIR and that these
// interoperrate with tbaa tags added during codegen
// RUN: tco %s | FileCheck %s
// subroutine func(a)
// integer, intent(inout) :: a(:)
// a = a+1
// a(1) = a(2)
#tbaa_root = #llvm.tbaa_root<id = "Flang function root _QPfunc">
#tbaa_type_desc = #llvm.tbaa_type_desc<id = "any access", members = {<#tbaa_root, 0>}>
#tbaa_type_desc1 = #llvm.tbaa_type_desc<id = "any data access", members = {<#tbaa_type_desc, 0>}>
#tbaa_type_desc2 = #llvm.tbaa_type_desc<id = "dummy arg data", members = {<#tbaa_type_desc1, 0>}>
#tbaa_type_desc3 = #llvm.tbaa_type_desc<id = "dummy arg data/_QFfuncEa", members = {<#tbaa_type_desc2, 0>}>
#tbaa_tag = #llvm.tbaa_tag<base_type = #tbaa_type_desc3, access_type = #tbaa_type_desc3, offset = 0>
module attributes {fir.defaultkind = "a1c4d8i4l4r4", fir.kindmap = "", llvm.target_triple = "aarch64-unknown-linux-gnu"} {
func.func @_QPfunc(%arg0: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "a"}) {
%c3_i32 = arith.constant 3 : i32
%c1_i32 = arith.constant 1 : i32
%c0 = arith.constant 0 : index
%c2 = arith.constant 2 : index
%c1 = arith.constant 1 : index
%0 = fir.alloca !fir.box<!fir.array<?xi32>>
%1 = fir.declare %arg0 {fortran_attrs = #fir.var_attrs<intent_inout>, uniq_name = "_QFfuncEa"} : (!fir.box<!fir.array<?xi32>>) -> !fir.box<!fir.array<?xi32>>
%2 = fir.rebox %1 : (!fir.box<!fir.array<?xi32>>) -> !fir.box<!fir.array<?xi32>>
%3:3 = fir.box_dims %2, %c0 : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index)
%4 = fir.shape %3#1 : (index) -> !fir.shape<1>
%5 = fir.allocmem !fir.array<?xi32>, %3#1 {bindc_name = ".tmp.array", uniq_name = ""}
%6 = fir.declare %5(%4) {uniq_name = ".tmp.array"} : (!fir.heap<!fir.array<?xi32>>, !fir.shape<1>) -> !fir.heap<!fir.array<?xi32>>
%7 = fir.embox %6(%4) : (!fir.heap<!fir.array<?xi32>>, !fir.shape<1>) -> !fir.box<!fir.array<?xi32>>
fir.do_loop %arg1 = %c1 to %3#1 step %c1 unordered {
%16 = fir.array_coor %2 %arg1 : (!fir.box<!fir.array<?xi32>>, index) -> !fir.ref<i32>
// load with tbaa
%17 = fir.load %16 {tbaa = [#tbaa_tag]} : !fir.ref<i32>
%18 = arith.addi %17, %c1_i32 : i32
%19 = fir.array_coor %6(%4) %arg1 : (!fir.heap<!fir.array<?xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
// store without tbaa
fir.store %18 to %19 : !fir.ref<i32>
}
fir.store %2 to %0 : !fir.ref<!fir.box<!fir.array<?xi32>>>
%8 = fir.address_of(@_QQcl.2F746D702F73696D706C652E66393000) : !fir.ref<!fir.char<1,16>>
%9 = fir.convert %0 : (!fir.ref<!fir.box<!fir.array<?xi32>>>) -> !fir.ref<!fir.box<none>>
%10 = fir.convert %7 : (!fir.box<!fir.array<?xi32>>) -> !fir.box<none>
%11 = fir.convert %8 : (!fir.ref<!fir.char<1,16>>) -> !fir.ref<i8>
%12 = fir.call @_FortranAAssign(%9, %10, %11, %c3_i32) : (!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.ref<i8>, i32) -> none
fir.freemem %6 : !fir.heap<!fir.array<?xi32>>
%13 = fir.array_coor %2 %c2 : (!fir.box<!fir.array<?xi32>>, index) -> !fir.ref<i32>
// load modified not to have tbaa
%14 = fir.load %13 : !fir.ref<i32>
%15 = fir.array_coor %2 %c1 : (!fir.box<!fir.array<?xi32>>, index) -> !fir.ref<i32>
// store with tbaa
fir.store %14 to %15 {tbaa = [#tbaa_tag]} : !fir.ref<i32>
return
}
func.func private @_FortranAAssign(!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.ref<i8>, i32) -> none attributes {fir.runtime}
fir.global linkonce @_QQcl.2F746D702F73696D706C652E66393000 constant : !fir.char<1,16> {
%0 = fir.string_lit "/tmp/simple.f90\00"(16) : !fir.char<1,16>
fir.has_value %0 : !fir.char<1,16>
}
}
// CHECK-LABEL: define void @_QPfunc(
// CHECK-SAME: ptr %[[ARG0:.*]]) {
// [...]
// CHECK: %[[VAL5:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %[[ARG0]], i32 0, i32 7, i32 0, i32 0
// box access:
// CHECK: %[[VAL6:.*]] = load i64, ptr %[[VAL5]], align 4, !tbaa ![[BOX_ACCESS_TAG:.*]]
// CHECK: %[[VAL7:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %0, i32 0, i32 7, i32 0, i32 1
// box access:
// CHECK: %[[VAL8:.*]] = load i64, ptr %[[VAL7]], align 4, !tbaa ![[BOX_ACCESS_TAG]]
// CHECK: %[[VAL9:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %[[ARG0]], i32 0, i32 7, i32 0, i32 2
// box access:
// CHECK: %[[VAL10:.*]] = load i64, ptr %[[VAL9]], align 4, !tbaa ![[BOX_ACCESS_TAG]]
// CHECK: %[[VAL11:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %[[ARG0]], i32 0, i32 0
// box access:
// CHECK: %[[VAL12:.*]] = load ptr, ptr %[[VAL11]], align 8, !tbaa ![[BOX_ACCESS_TAG]]
// CHECK: %[[VAL15:.*]] = insertvalue { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] } %14, ptr %[[VAL12]], 0
// CHECK: store { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] } %[[VAL15]], ptr %{{.*}}, align 8, !tbaa ![[BOX_ACCESS_TAG]]
// CHECK: %[[VAL16:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %{{.*}}, i32 0, i32 7, i64 0, i32 0
// box access:
// CHECK: %[[VAL17:.*]] = load i64, ptr %[[VAL16]], align 4, !tbaa ![[BOX_ACCESS_TAG]]
// CHECK: %[[VAL18:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %{{.*}}, i32 0, i32 7, i64 0, i32 1
// box access:
// CHECK: %[[VAL19:.*]] = load i64, ptr %[[VAL18]], align 4, !tbaa ![[BOX_ACCESS_TAG]]
// CHECK: %[[VAL20:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %{{.*}}, i32 0, i32 7, i64 0, i32 2
// box access:
// CHECK: %[[VAL21:.*]] = load i64, ptr %[[VAL20]], align 4, !tbaa ![[BOX_ACCESS_TAG]]
// [...]
// box access:
// CHECK: store { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] } %{{.*}}, ptr %{{.*}}, align 8, !tbaa ![[BOX_ACCESS_TAG]]
// [...]
// [...]
// CHECK: %[[VAL40:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %{{.*}}, i32 0, i32 0
// box access:
// CHECK: %[[VAL41:.*]] = load ptr, ptr %[[VAL40]], align 8, !tbaa ![[BOX_ACCESS_TAG]]
// CHECK: %[[VAL42:.*]] = getelementptr i8, ptr %[[VAL41]], i64 %{{.*}}
// access to 'a':
// CHECK: %[[VAL43:.*]] = load i32, ptr %[[VAL42]], align 4, !tbaa ![[A_ACCESS_TAG:.*]]
// [...]
// CHECK: %[[VAL50:.*]] = getelementptr i32, ptr %{{.*}}, i64 %{{.*}}
// store to the temporary:
// CHECK: store i32 %{{.*}}, ptr %[[VAL50]], align 4, !tbaa ![[DATA_ACCESS_TAG:.*]]
// [...]
// CHECK: [[BOX_ACCESS_TAG]] = !{![[BOX_ACCESS_TYPE:.*]], ![[BOX_ACCESS_TYPE]], i64 0}
// CHECK: ![[BOX_ACCESS_TYPE]] = !{!"descriptor member", ![[ANY_ACCESS_TYPE:.*]], i64 0}
// CHECK: ![[ANY_ACCESS_TYPE]] = !{!"any access", ![[ROOT_TYPE:.*]], i64 0}
// CHECK: ![[ROOT_TYPE]] = !{!"Flang function root _QPfunc"}
// CHECK: ![[A_ACCESS_TAG]] = !{![[A_ACCESS_TYPE:.*]], ![[A_ACCESS_TYPE]], i64 0}
// CHECK: ![[A_ACCESS_TYPE]] = !{!"dummy arg data/_QFfuncEa", ![[ARG_ACCESS_TYPE:.*]], i64 0}
// CHECK: ![[ARG_ACCESS_TYPE]] = !{!"dummy arg data", ![[DATA_ACCESS_TYPE:.*]], i64 0}
// CHECK: ![[DATA_ACCESS_TYPE]] = !{!"any data access", ![[ANY_ACCESS_TYPE]], i64 0}
// CHECK: ![[DATA_ACCESS_TAG]] = !{![[DATA_ACCESS_TYPE]], ![[DATA_ACCESS_TYPE]], i64 0}

View File

@ -1,5 +1,7 @@
// RUN: fir-opt %s --split-input-file --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu apply-tbaa=true" | FileCheck %s
// RUN: fir-opt %s --split-input-file --fir-to-llvm-ir="target=aarch64-unknown-linux-gnu apply-tbaa=true" | FileCheck %s
// test without per-function tbaa trees so that this functionality does not bitrot
// per-function tbaa tbaa-codegen2.fir
// RUN: fir-opt %s --split-input-file --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu apply-tbaa=true" --per-function-tbaa-trees=false | FileCheck %s
// RUN: fir-opt %s --split-input-file --fir-to-llvm-ir="target=aarch64-unknown-linux-gnu apply-tbaa=true" --per-function-tbaa-trees=false | FileCheck %s
module {
func.func @tbaa(%arg0: !fir.class<!fir.array<?xnone>> {fir.bindc_name = "a"}) {
@ -20,7 +22,7 @@ module {
}
}
// CHECK-DAG: #[[ROOT:.*]] = #llvm.tbaa_root<id = "Flang Type TBAA Root">
// CHECK-DAG: #[[ROOT:.*]] = #llvm.tbaa_root<id = "Flang function root ">
// CHECK-DAG: #[[ANYACC:.*]] = #llvm.tbaa_type_desc<id = "any access", members = {<#[[ROOT]], 0>}>
// CHECK-DAG: #[[ANYDACC:.*]] = #llvm.tbaa_type_desc<id = "any data access", members = {<#[[ANYACC]], 0>}>
// CHECK-DAG: #[[BOXMEM:.*]] = #llvm.tbaa_type_desc<id = "descriptor member", members = {<#[[ANYACC]], 0>}>
@ -119,7 +121,7 @@ module {
}
}
// CHECK-DAG: #[[ROOT:.*]] = #llvm.tbaa_root<id = "Flang Type TBAA Root">
// CHECK-DAG: #[[ROOT:.*]] = #llvm.tbaa_root<id = "Flang function root ">
// CHECK-DAG: #[[ANYACC:.*]] = #llvm.tbaa_type_desc<id = "any access", members = {<#[[ROOT]], 0>}>
// CHECK-DAG: #[[BOXMEM:.*]] = #llvm.tbaa_type_desc<id = "descriptor member", members = {<#[[ANYACC]], 0>}>
// CHECK-DAG: #[[$BOXT:.*]] = #llvm.tbaa_tag<base_type = #[[BOXMEM]], access_type = #[[BOXMEM]], offset = 0>
@ -245,7 +247,7 @@ func.func @tbaa(%arg0: !fir.box<!fir.array<*:f64>>) -> i32 {
return %0 : i32
}
// CHECK-DAG: #[[ROOT:.*]] = #llvm.tbaa_root<id = "Flang Type TBAA Root">
// CHECK-DAG: #[[ROOT:.*]] = #llvm.tbaa_root<id = "Flang function root ">
// CHECK-DAG: #[[ANYACC:.*]] = #llvm.tbaa_type_desc<id = "any access", members = {<#[[ROOT]], 0>}>
// CHECK-DAG: #[[BOXMEM:.*]] = #llvm.tbaa_type_desc<id = "descriptor member", members = {<#[[ANYACC]], 0>}>
// CHECK-DAG: #[[$BOXT:.*]] = #llvm.tbaa_tag<base_type = #[[BOXMEM]], access_type = #[[BOXMEM]], offset = 0>
@ -264,7 +266,7 @@ func.func @tbaa(%arg0: !fir.box<!fir.array<*:f64>>) -> i1 {
return %0 : i1
}
// CHECK-DAG: #[[ROOT:.*]] = #llvm.tbaa_root<id = "Flang Type TBAA Root">
// CHECK-DAG: #[[ROOT:.*]] = #llvm.tbaa_root<id = "Flang function root ">
// CHECK-DAG: #[[ANYACC:.*]] = #llvm.tbaa_type_desc<id = "any access", members = {<#[[ROOT]], 0>}>
// CHECK-DAG: #[[BOXMEM:.*]] = #llvm.tbaa_type_desc<id = "descriptor member", members = {<#[[ANYACC]], 0>}>
// CHECK-DAG: #[[$BOXT:.*]] = #llvm.tbaa_tag<base_type = #[[BOXMEM]], access_type = #[[BOXMEM]], offset = 0>
@ -285,7 +287,7 @@ func.func @tbaa(%arg0: !fir.box<f32>) -> i32 {
return %0 : i32
}
// CHECK-DAG: #[[ROOT:.*]] = #llvm.tbaa_root<id = "Flang Type TBAA Root">
// CHECK-DAG: #[[ROOT:.*]] = #llvm.tbaa_root<id = "Flang function root ">
// CHECK-DAG: #[[ANYACC:.*]] = #llvm.tbaa_type_desc<id = "any access", members = {<#[[ROOT]], 0>}>
// CHECK-DAG: #[[BOXMEM:.*]] = #llvm.tbaa_type_desc<id = "descriptor member", members = {<#[[ANYACC]], 0>}>
// CHECK-DAG: #[[$BOXT:.*]] = #llvm.tbaa_tag<base_type = #[[BOXMEM]], access_type = #[[BOXMEM]], offset = 0>
@ -304,7 +306,7 @@ func.func @tbaa(%arg0: !fir.box<!fir.array<*:f64>>) -> i1 {
return %0 : i1
}
// CHECK-DAG: #[[ROOT:.*]] = #llvm.tbaa_root<id = "Flang Type TBAA Root">
// CHECK-DAG: #[[ROOT:.*]] = #llvm.tbaa_root<id = "Flang function root ">
// CHECK-DAG: #[[ANYACC:.*]] = #llvm.tbaa_type_desc<id = "any access", members = {<#[[ROOT]], 0>}>
// CHECK-DAG: #[[BOXMEM:.*]] = #llvm.tbaa_type_desc<id = "descriptor member", members = {<#[[ANYACC]], 0>}>
// CHECK-DAG: #[[$BOXT:.*]] = #llvm.tbaa_tag<base_type = #[[BOXMEM]], access_type = #[[BOXMEM]], offset = 0>
@ -328,7 +330,7 @@ func.func @tbaa(%arg0: !fir.box<!fir.array<?xi32>>) {
return
}
// CHECK-DAG: #[[ROOT:.*]] = #llvm.tbaa_root<id = "Flang Type TBAA Root">
// CHECK-DAG: #[[ROOT:.*]] = #llvm.tbaa_root<id = "Flang function root ">
// CHECK-DAG: #[[ANYACC:.*]] = #llvm.tbaa_type_desc<id = "any access", members = {<#[[ROOT]], 0>}>
// CHECK-DAG: #[[BOXMEM:.*]] = #llvm.tbaa_type_desc<id = "descriptor member", members = {<#[[ANYACC]], 0>}>
// CHECK-DAG: #[[$BOXT:.*]] = #llvm.tbaa_tag<base_type = #[[BOXMEM]], access_type = #[[BOXMEM]], offset = 0>
@ -356,7 +358,7 @@ func.func @tbaa(%arg0: !fir.box<!fir.array<?xi32>>) {
// Check that the scalar aggregate load/store with a descriptor member
// is mapped to any-access.
// CHECK-DAG: #[[ROOT:.*]] = #llvm.tbaa_root<id = "Flang Type TBAA Root">
// CHECK-DAG: #[[ROOT:.*]] = #llvm.tbaa_root<id = "Flang function root ">
// CHECK-DAG: #[[ANYACC:.*]] = #llvm.tbaa_type_desc<id = "any access", members = {<#[[ROOT]], 0>}>
// CHECK-DAG: #[[$ANYT:.*]] = #llvm.tbaa_tag<base_type = #[[ANYACC]], access_type = #[[ANYACC]], offset = 0>
@ -373,7 +375,7 @@ func.func @tbaa(%arg0: !fir.ref<!fir.type<_QMtypesTt{x:!fir.box<!fir.heap<f32>>}
// Check that the array aggregate load/store with a descriptor member
// is mapped to any-access.
// CHECK-DAG: #[[ROOT:.*]] = #llvm.tbaa_root<id = "Flang Type TBAA Root">
// CHECK-DAG: #[[ROOT:.*]] = #llvm.tbaa_root<id = "Flang function root ">
// CHECK-DAG: #[[ANYACC:.*]] = #llvm.tbaa_type_desc<id = "any access", members = {<#[[ROOT]], 0>}>
// CHECK-DAG: #[[$ANYT:.*]] = #llvm.tbaa_tag<base_type = #[[ANYACC]], access_type = #[[ANYACC]], offset = 0>