aboutsummaryrefslogtreecommitdiff
path: root/flang
diff options
context:
space:
mode:
authorMarkus Böck <markus.bock+llvm@nextsilicon.com>2023-07-18 14:30:00 +0200
committerMarkus Böck <markus.bock+llvm@nextsilicon.com>2023-07-19 16:42:50 +0200
commit1dda134f85d4fab7ace7b9ec9b57a0319c14de8f (patch)
tree40ece736bd4512ca61cbb4b4452752614a1f68d3 /flang
parentcca053c1f07bb8349019bcb7f72c80ed8176bc11 (diff)
downloadllvm-1dda134f85d4fab7ace7b9ec9b57a0319c14de8f.zip
llvm-1dda134f85d4fab7ace7b9ec9b57a0319c14de8f.tar.gz
llvm-1dda134f85d4fab7ace7b9ec9b57a0319c14de8f.tar.bz2
[mlir][flang] Convert TBAA metadata to an attribute representation
The current representation of TBAA is the very last in-tree user of the `llvm.metadata` operation. Using ops to model metadata has a few disadvantages: * Building a graph has to be done through some weakly typed indirection mechanism such as `SymbolRefAttr` * Creating the metadata has to be done through a builder within a metadata op. * It is not multithreading safe as operation insertion into the same block is not thread-safe This patch therefore converts TBAA metadata into an attribute representation, in a similar manner as it has been done for alias groups and access groups in previous patches. This additionally has the large benefit of giving us more "correctness by construction" as it makes things like cycles in a TBAA graph, or references to an incorrectly typed metadata node impossible. Differential Revision: https://reviews.llvm.org/D155444
Diffstat (limited to 'flang')
-rw-r--r--flang/include/flang/Optimizer/CodeGen/TBAABuilder.h111
-rw-r--r--flang/lib/Optimizer/CodeGen/TBAABuilder.cpp93
-rw-r--r--flang/lib/Optimizer/CodeGen/TypeConverter.cpp2
-rw-r--r--flang/test/Fir/tbaa.fir152
4 files changed, 134 insertions, 224 deletions
diff --git a/flang/include/flang/Optimizer/CodeGen/TBAABuilder.h b/flang/include/flang/Optimizer/CodeGen/TBAABuilder.h
index 48c40a4..b94782b 100644
--- a/flang/include/flang/Optimizer/CodeGen/TBAABuilder.h
+++ b/flang/include/flang/Optimizer/CodeGen/TBAABuilder.h
@@ -164,7 +164,7 @@ namespace fir {
// < `<any data access>`, `<any data access>`, 0 >
class TBAABuilder {
public:
- TBAABuilder(mlir::ModuleOp module, bool applyTBAA);
+ TBAABuilder(mlir::MLIRContext *context, bool applyTBAA);
TBAABuilder(TBAABuilder const &) = delete;
TBAABuilder &operator=(TBAABuilder const &) = delete;
@@ -175,95 +175,74 @@ public:
mlir::LLVM::GEPOp gep);
private:
- // Return unique string name based on `basename`.
- std::string getNewTBAANodeName(llvm::StringRef basename);
-
- // Find or create TBAATagOp operation (TBAA access tag) with the specified
- // components and return the symbol it defines.
- mlir::SymbolRefAttr getAccessTag(mlir::SymbolRefAttr baseTypeDesc,
- mlir::SymbolRefAttr accessTypeDesc,
- int64_t offset);
- // Returns symbol of TBAATagOp representing access tag:
+ // Find or create TBAATagAttr attribute (TBAA access tag) with the specified
+ // components and return it.
+ mlir::LLVM::TBAATagAttr
+ getAccessTag(mlir::LLVM::TBAATypeDescriptorAttr baseTypeDesc,
+ mlir::LLVM::TBAATypeDescriptorAttr accessTypeDesc,
+ int64_t offset);
+
+ // Returns TBAATagAttr representing access tag:
// < <descriptor member>, <descriptor member>, 0 >
- mlir::SymbolRefAttr getAnyBoxAccessTag();
- // Returns symbol of TBAATagOp representing access tag:
+ mlir::LLVM::TBAATagAttr getAnyBoxAccessTag();
+ // Returns TBAATagAttr representing access tag:
// < <any data access>, <any data access>, 0 >
- mlir::SymbolRefAttr getAnyDataAccessTag();
-
- // Returns symbol of TBAATagOp representing access tag
- // described by the base and access FIR types and the LLVM::GepOp
- // representing the access in terms of the FIR types converted
- // to LLVM types. The base type must be derivative of fir::BaseBoxType.
- mlir::SymbolRefAttr getBoxAccessTag(mlir::Type baseFIRType,
- mlir::Type accessFIRType,
- mlir::LLVM::GEPOp gep);
-
- // Returns symbol of TBAATagOp representing access tag
- // described by the base and access FIR types and the LLVM::GepOp
- // representing the access in terms of the FIR types converted
- // to LLVM types. The FIR types must describe the "data" access,
- // i.e. not an access of any box/descriptor member.
- mlir::SymbolRefAttr getDataAccessTag(mlir::Type baseFIRType,
- mlir::Type accessFIRType,
- mlir::LLVM::GEPOp gep);
+ mlir::LLVM::TBAATagAttr getAnyDataAccessTag();
+
+ // Returns TBAATagAttr representing access tag described by the base and
+ // access FIR types and the LLVM::GepOp representing the access in terms of
+ // the FIR types converted to LLVM types. The base type must be derivative of
+ // fir::BaseBoxType.
+ mlir::LLVM::TBAATagAttr getBoxAccessTag(mlir::Type baseFIRType,
+ mlir::Type accessFIRType,
+ mlir::LLVM::GEPOp gep);
+
+ // Returns TBAATagAttr representing access tag described by the base and
+ // access FIR types and the LLVM::GepOp representing the access in terms of
+ // the FIR types converted to LLVM types. The FIR types must describe the
+ // "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);
// Set to true, if TBAA builder is active, otherwise, all public
// methods are no-ops.
bool enableTBAA;
- // LLVM::MetadataOp holding the TBAA operations.
- mlir::LLVM::MetadataOp tbaaMetaOp;
- // Symbol name of tbaaMetaOp.
- static constexpr llvm::StringRef tbaaMetaOpName = "__flang_tbaa";
-
- // Base names for TBAA operations:
- // TBAARootMetadataOp:
- static constexpr llvm::StringRef kRootSymBasename = "root";
- // TBAATypeDescriptorOp:
- static constexpr llvm::StringRef kTypeDescSymBasename = "type_desc";
- // TBAATagOp:
- static constexpr llvm::StringRef kTagSymBasename = "tag";
-
- // Symbol defined by the LLVM::TBAARootMetadataOp identifying
- // Flang's TBAA root.
- mlir::SymbolRefAttr flangTBAARoot;
+ // 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";
- // Symbol defined by LLVM::TBAATypeDescriptorOp identifying
- // "any access".
- mlir::SymbolRefAttr anyAccessTypeDesc;
+ // LLVM::TBAATypeDescriptorAttr identifying "any access".
+ mlir::LLVM::TBAATypeDescriptorAttr anyAccessTypeDesc;
// Identity string for "any access" type descriptor.
static constexpr llvm::StringRef anyAccessTypeDescId = "any access";
- // Symbol defined by LLVM::TBAATypeDescriptorOp identifying
- // "any data access" (i.e. non-box memory access).
- mlir::SymbolRefAttr anyDataAccessTypeDesc;
+ // 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";
- // Symbol defined by LLVM::TBAATypeDescriptorOp identifying
- // "descriptor member" access, i.e. any access within the bounds
- // of a box/descriptor.
- mlir::SymbolRefAttr boxMemberTypeDesc;
+ // 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";
- // Counter for unique naming of TBAA operations' symbols.
- unsigned tbaaNodeCounter = 0;
-
// Number of attached TBAA tags (used for debugging).
unsigned tagAttachmentCounter = 0;
- // Mapping from a FIR type to the symbol defined by the corresponding
- // TBAATypeDescriptorOp. It must be populated during the type conversion.
- // Currently unused.
- llvm::DenseMap<mlir::Type, mlir::SymbolRefAttr> typeDescMap;
+ // Mapping from a FIR type to the corresponding TBAATypeDescriptorAttr. It
+ // must be populated during the type conversion. Currently unused.
+ llvm::DenseMap<mlir::Type, mlir::LLVM::TBAATypeDescriptorAttr> typeDescMap;
// Each TBAA tag is a tuple of <baseTypeSym, accessTypeSym, offset>.
- // This map holds TBAATagOp symbol for each unique tuple.
- llvm::DenseMap<std::tuple<mlir::SymbolRefAttr, mlir::SymbolRefAttr, int64_t>,
- mlir::SymbolRefAttr>
+ // This map holds a TBAATagAttr for each unique tuple.
+ llvm::DenseMap<
+ std::tuple<mlir::LLVM::TBAANodeAttr, mlir::LLVM::TBAANodeAttr, int64_t>,
+ mlir::LLVM::TBAATagAttr>
tagsMap;
};
diff --git a/flang/lib/Optimizer/CodeGen/TBAABuilder.cpp b/flang/lib/Optimizer/CodeGen/TBAABuilder.cpp
index ffc72c7..04259c0 100644
--- a/flang/lib/Optimizer/CodeGen/TBAABuilder.cpp
+++ b/flang/lib/Optimizer/CodeGen/TBAABuilder.cpp
@@ -37,107 +37,58 @@ static llvm::cl::opt<unsigned>
llvm::cl::init(kTagAttachmentUnlimited));
namespace fir {
-std::string TBAABuilder::getNewTBAANodeName(llvm::StringRef basename) {
- return (llvm::Twine(basename) + llvm::Twine('_') +
- llvm::Twine(tbaaNodeCounter++))
- .str();
-}
-TBAABuilder::TBAABuilder(mlir::ModuleOp module, bool applyTBAA)
+TBAABuilder::TBAABuilder(MLIRContext *context, bool applyTBAA)
: enableTBAA(applyTBAA && !disableTBAA) {
if (!enableTBAA)
return;
- // In the usual Flang compilation flow, FIRToLLVMPass is run once,
- // and the MetadataOp holding TBAA operations is created at the beginning
- // of the pass. With tools like tco it is possible to invoke
- // FIRToLLVMPass on already converted MLIR, so the MetadataOp
- // already exists and creating a new one with the same name would
- // be incorrect. If the TBAA MetadataOp is already present,
- // we just disable all TBAABuilder actions (e.g. attachTBAATag()
- // is a no-op).
- if (llvm::any_of(
- module.getBodyRegion().getOps<LLVM::MetadataOp>(),
- [&](auto metaOp) { return metaOp.getSymName() == tbaaMetaOpName; })) {
- enableTBAA = false;
- return;
- }
-
- LLVM_DEBUG(llvm::dbgs() << "Creating TBAA MetadataOp for module '"
- << module.getName().value_or("<unknown>") << "'\n");
-
- // Create TBAA MetadataOp with the root and basic type descriptors.
- Location loc = module.getLoc();
- MLIRContext *context = module.getContext();
- OpBuilder builder(module.getBody(), module.getBody()->end());
- tbaaMetaOp = builder.create<MetadataOp>(loc, tbaaMetaOpName);
- builder.setInsertionPointToStart(&tbaaMetaOp.getBody().front());
-
// Root node.
- auto rootOp = builder.create<TBAARootMetadataOp>(
- loc, getNewTBAANodeName(kRootSymBasename), flangTBAARootId);
- flangTBAARoot = FlatSymbolRefAttr::get(rootOp);
+ flangTBAARoot =
+ TBAARootAttr::get(context, StringAttr::get(context, flangTBAARootId));
// Any access node.
- auto anyAccessOp = builder.create<TBAATypeDescriptorOp>(
- loc, getNewTBAANodeName(kTypeDescSymBasename),
- StringAttr::get(context, anyAccessTypeDescId),
- ArrayAttr::get(context, flangTBAARoot), ArrayRef<int64_t>{0});
- anyAccessTypeDesc = FlatSymbolRefAttr::get(anyAccessOp);
+ anyAccessTypeDesc = TBAATypeDescriptorAttr::get(
+ context, anyAccessTypeDescId, TBAAMemberAttr::get(flangTBAARoot, 0));
// Any data access node.
- auto anyDataAccessOp = builder.create<TBAATypeDescriptorOp>(
- loc, getNewTBAANodeName(kTypeDescSymBasename),
- StringAttr::get(context, anyDataAccessTypeDescId),
- ArrayAttr::get(context, anyAccessTypeDesc), ArrayRef<int64_t>{0});
- anyDataAccessTypeDesc = FlatSymbolRefAttr::get(anyDataAccessOp);
+ anyDataAccessTypeDesc =
+ TBAATypeDescriptorAttr::get(context, anyDataAccessTypeDescId,
+ TBAAMemberAttr::get(anyAccessTypeDesc, 0));
// Box member access node.
- auto boxMemberOp = builder.create<TBAATypeDescriptorOp>(
- loc, getNewTBAANodeName(kTypeDescSymBasename),
- StringAttr::get(context, boxMemberTypeDescId),
- ArrayAttr::get(context, anyAccessTypeDesc), ArrayRef<int64_t>{0});
- boxMemberTypeDesc = FlatSymbolRefAttr::get(boxMemberOp);
+ boxMemberTypeDesc = TBAATypeDescriptorAttr::get(
+ context, boxMemberTypeDescId, TBAAMemberAttr::get(anyAccessTypeDesc, 0));
}
-SymbolRefAttr TBAABuilder::getAccessTag(SymbolRefAttr baseTypeDesc,
- SymbolRefAttr accessTypeDesc,
- int64_t offset) {
- SymbolRefAttr &tag = tagsMap[{baseTypeDesc, accessTypeDesc, offset}];
+TBAATagAttr TBAABuilder::getAccessTag(TBAATypeDescriptorAttr baseTypeDesc,
+ TBAATypeDescriptorAttr accessTypeDesc,
+ int64_t offset) {
+ TBAATagAttr &tag = tagsMap[{baseTypeDesc, accessTypeDesc, offset}];
if (tag)
return tag;
// Initialize new tag.
- Location loc = tbaaMetaOp.getLoc();
- OpBuilder builder(&tbaaMetaOp.getBody().back(),
- tbaaMetaOp.getBody().back().end());
- auto tagOp = builder.create<TBAATagOp>(
- loc, getNewTBAANodeName(kTagSymBasename), baseTypeDesc.getLeafReference(),
- accessTypeDesc.getLeafReference(), offset);
- // TBAATagOp symbols must be referenced by their fully qualified
- // names, so create a path to TBAATagOp symbol.
- StringAttr metaOpName = SymbolTable::getSymbolName(tbaaMetaOp);
- tag = SymbolRefAttr::get(builder.getContext(), metaOpName,
- FlatSymbolRefAttr::get(tagOp));
+ tag = TBAATagAttr::get(baseTypeDesc, accessTypeDesc, offset);
return tag;
}
-SymbolRefAttr TBAABuilder::getAnyBoxAccessTag() {
+TBAATagAttr TBAABuilder::getAnyBoxAccessTag() {
return getAccessTag(boxMemberTypeDesc, boxMemberTypeDesc, /*offset=*/0);
}
-SymbolRefAttr TBAABuilder::getBoxAccessTag(Type baseFIRType, Type accessFIRType,
- GEPOp gep) {
+TBAATagAttr TBAABuilder::getBoxAccessTag(Type baseFIRType, Type accessFIRType,
+ GEPOp gep) {
return getAnyBoxAccessTag();
}
-SymbolRefAttr TBAABuilder::getAnyDataAccessTag() {
+TBAATagAttr TBAABuilder::getAnyDataAccessTag() {
return getAccessTag(anyDataAccessTypeDesc, anyDataAccessTypeDesc,
/*offset=*/0);
}
-SymbolRefAttr TBAABuilder::getDataAccessTag(Type baseFIRType,
- Type accessFIRType, GEPOp gep) {
+TBAATagAttr TBAABuilder::getDataAccessTag(Type baseFIRType, Type accessFIRType,
+ GEPOp gep) {
return getAnyDataAccessTag();
}
@@ -154,7 +105,7 @@ void TBAABuilder::attachTBAATag(AliasAnalysisOpInterface op, Type baseFIRType,
LLVM_DEBUG(llvm::dbgs() << "Attaching TBAA tag #" << tagAttachmentCounter
<< "\n");
- SymbolRefAttr tbaaTagSym;
+ TBAATagAttr tbaaTagSym;
if (baseFIRType.isa<fir::BaseBoxType>())
tbaaTagSym = getBoxAccessTag(baseFIRType, accessFIRType, gep);
else
diff --git a/flang/lib/Optimizer/CodeGen/TypeConverter.cpp b/flang/lib/Optimizer/CodeGen/TypeConverter.cpp
index 0cac01c..8de2dbb 100644
--- a/flang/lib/Optimizer/CodeGen/TypeConverter.cpp
+++ b/flang/lib/Optimizer/CodeGen/TypeConverter.cpp
@@ -37,7 +37,7 @@ LLVMTypeConverter::LLVMTypeConverter(mlir::ModuleOp module, bool applyTBAA)
specifics(CodeGenSpecifics::get(module.getContext(),
getTargetTriple(module),
getKindMapping(module))),
- tbaaBuilder(module, applyTBAA) {
+ tbaaBuilder(module->getContext(), applyTBAA) {
LLVM_DEBUG(llvm::dbgs() << "FIR type converter\n");
// Each conversion should return a value of type mlir::Type.
diff --git a/flang/test/Fir/tbaa.fir b/flang/test/Fir/tbaa.fir
index 3528f61..66bd41b 100644
--- a/flang/test/Fir/tbaa.fir
+++ b/flang/test/Fir/tbaa.fir
@@ -20,6 +20,13 @@ module {
}
}
+// CHECK-DAG: #[[ROOT:.*]] = #llvm.tbaa_root<id = "Flang Type TBAA 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>}>
+// CHECK-DAG: #[[$BOXT:.*]] = #llvm.tbaa_tag<base_type = #[[BOXMEM]], access_type = #[[BOXMEM]], offset = 0>
+// CHECK-DAG: #[[$DATAT:.*]] = #llvm.tbaa_tag<base_type = #[[ANYDACC]], access_type = #[[ANYDACC]], offset = 0>
+
// CHECK-LABEL: llvm.func @tbaa(
// CHECK-SAME: %[[VAL_0:.*]]: !llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>> {fir.bindc_name = "a"}) {
// CHECK: %[[VAL_1:.*]] = llvm.mlir.constant(1 : i32) : i32
@@ -28,10 +35,10 @@ module {
// CHECK: %[[VAL_4:.*]] = llvm.mlir.constant(0 : i64) : i64
// CHECK: %[[VAL_5:.*]] = llvm.mlir.constant(10 : i32) : i32
// CHECK: %[[VAL_6:.*]] = llvm.getelementptr %[[VAL_0]][0, 0] : (!llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>>) -> !llvm.ptr<ptr<struct<()>>>
-// CHECK: %[[VAL_7:.*]] = llvm.load %[[VAL_6]] {tbaa = [@__flang_tbaa::@[[BOXT:tag_[0-9]*]]]} : !llvm.ptr<ptr<struct<()>>>
+// CHECK: %[[VAL_7:.*]] = llvm.load %[[VAL_6]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<ptr<struct<()>>>
// CHECK: %[[VAL_8:.*]] = llvm.mlir.constant(0 : i64) : i64
// CHECK: %[[VAL_9:.*]] = llvm.getelementptr %[[VAL_0]][0, 7, 0, 2] : (!llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>>) -> !llvm.ptr<i64>
-// CHECK: %[[VAL_10:.*]] = llvm.load %[[VAL_9]] {tbaa = [@__flang_tbaa::@[[BOXT]]]} : !llvm.ptr<i64>
+// CHECK: %[[VAL_10:.*]] = llvm.load %[[VAL_9]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<i64>
// CHECK: %[[VAL_11:.*]] = llvm.mul %[[VAL_4]], %[[VAL_10]] : i64
// CHECK: %[[VAL_12:.*]] = llvm.add %[[VAL_11]], %[[VAL_8]] : i64
// CHECK: %[[VAL_13:.*]] = llvm.bitcast %[[VAL_7]] : !llvm.ptr<struct<()>> to !llvm.ptr<i8>
@@ -40,11 +47,11 @@ module {
// CHECK: %[[VAL_16:.*]] = llvm.mlir.constant(0 : i64) : i64
// CHECK: %[[VAL_17:.*]] = llvm.mlir.constant(-1 : i32) : i32
// CHECK: %[[VAL_18:.*]] = llvm.getelementptr %[[VAL_0]][0, 8] : (!llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>>) -> !llvm.ptr<ptr<i8>>
-// CHECK: %[[VAL_19:.*]] = llvm.load %[[VAL_18]] {tbaa = [@__flang_tbaa::@[[BOXT]]]} : !llvm.ptr<ptr<i8>>
+// CHECK: %[[VAL_19:.*]] = llvm.load %[[VAL_18]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<ptr<i8>>
// CHECK: %[[VAL_20:.*]] = llvm.getelementptr %[[VAL_0]][0, 1] : (!llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>>) -> !llvm.ptr<i64>
-// CHECK: %[[VAL_21:.*]] = llvm.load %[[VAL_20]] {tbaa = [@__flang_tbaa::@[[BOXT]]]} : !llvm.ptr<i64>
+// CHECK: %[[VAL_21:.*]] = llvm.load %[[VAL_20]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<i64>
// CHECK: %[[VAL_22:.*]] = llvm.getelementptr %[[VAL_0]][0, 4] : (!llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>>) -> !llvm.ptr<i32>
-// CHECK: %[[VAL_23:.*]] = llvm.load %[[VAL_22]] {tbaa = [@__flang_tbaa::@[[BOXT]]]} : !llvm.ptr<i32>
+// CHECK: %[[VAL_23:.*]] = llvm.load %[[VAL_22]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<i32>
// CHECK: %[[VAL_24:.*]] = llvm.mlir.undef : !llvm.struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, ptr<i8>, array<1 x i64>)>
// CHECK: %[[VAL_25:.*]] = llvm.insertvalue %[[VAL_21]], %[[VAL_24]][1] : !llvm.struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, ptr<i8>, array<1 x i64>)>
// CHECK: %[[VAL_26:.*]] = llvm.mlir.constant(20180515 : i32) : i32
@@ -64,29 +71,20 @@ module {
// CHECK: %[[VAL_40:.*]] = llvm.insertvalue %[[VAL_39]], %[[VAL_38]][7] : !llvm.struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, ptr<i8>, array<1 x i64>)>
// CHECK: %[[VAL_41:.*]] = llvm.bitcast %[[VAL_15]] : !llvm.ptr<struct<()>> to !llvm.ptr<struct<()>>
// CHECK: %[[VAL_42:.*]] = llvm.insertvalue %[[VAL_41]], %[[VAL_40]][0] : !llvm.struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, ptr<i8>, array<1 x i64>)>
-// CHECK: llvm.store %[[VAL_42]], %[[VAL_2]] {tbaa = [@__flang_tbaa::@[[BOXT]]]} : !llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, ptr<i8>, array<1 x i64>)>>
+// CHECK: llvm.store %[[VAL_42]], %[[VAL_2]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, ptr<i8>, array<1 x i64>)>>
// CHECK: %[[VAL_43:.*]] = llvm.getelementptr %[[VAL_2]][0, 4] : (!llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, ptr<i8>, array<1 x i64>)>>) -> !llvm.ptr<i8>
-// CHECK: %[[VAL_44:.*]] = llvm.load %[[VAL_43]] {tbaa = [@__flang_tbaa::@[[BOXT]]]} : !llvm.ptr<i8>
+// CHECK: %[[VAL_44:.*]] = llvm.load %[[VAL_43]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<i8>
// CHECK: %[[VAL_45:.*]] = llvm.icmp "eq" %[[VAL_44]], %[[VAL_3]] : i8
// CHECK: llvm.cond_br %[[VAL_45]], ^bb1, ^bb2
// CHECK: ^bb1:
// CHECK: %[[VAL_46:.*]] = llvm.getelementptr %[[VAL_2]][0, 0] : (!llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, ptr<i8>, array<1 x i64>)>>) -> !llvm.ptr<ptr<i32>>
-// CHECK: %[[VAL_47:.*]] = llvm.load %[[VAL_46]] {tbaa = [@__flang_tbaa::@[[BOXT]]]} : !llvm.ptr<ptr<i32>>
-// CHECK: llvm.store %[[VAL_5]], %[[VAL_47]] {tbaa = [@__flang_tbaa::@[[DATAT:tag_[0-9]*]]]} : !llvm.ptr<i32>
+// CHECK: %[[VAL_47:.*]] = llvm.load %[[VAL_46]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<ptr<i32>>
+// CHECK: llvm.store %[[VAL_5]], %[[VAL_47]] {tbaa = [#[[$DATAT]]]} : !llvm.ptr<i32>
// CHECK: llvm.br ^bb2
// CHECK: ^bb2:
// CHECK: llvm.return
// CHECK: }
-// CHECK-LABEL: llvm.metadata @__flang_tbaa {
-// CHECK: llvm.tbaa_root @[[ROOT:root_[0-9]*]] {id = "Flang Type TBAA Root"}
-// CHECK: llvm.tbaa_type_desc @[[ANYACC:type_desc_[0-9]*]] {id = "any access", members = {<@[[ROOT]], 0>}}
-// CHECK: llvm.tbaa_type_desc @[[ANYDACC:type_desc_[0-9]*]] {id = "any data access", members = {<@[[ANYACC]], 0>}}
-// CHECK: llvm.tbaa_type_desc @[[BOXMEM:type_desc_[0-9]*]] {id = "descriptor member", members = {<@[[ANYACC]], 0>}}
-// CHECK: llvm.tbaa_tag @[[BOXT]] {access_type = @[[BOXMEM]], base_type = @[[BOXMEM]], offset = 0 : i64}
-// CHECK: llvm.tbaa_tag @[[DATAT]] {access_type = @[[ANYDACC]], base_type = @[[ANYDACC]], offset = 0 : i64}
-// CHECK: }
-
// -----
module {
@@ -121,6 +119,11 @@ module {
}
}
+// CHECK-DAG: #[[ROOT:.*]] = #llvm.tbaa_root<id = "Flang Type TBAA 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>
+
// CHECK-LABEL: llvm.func @tbaa() {
// CHECK: %[[VAL_0:.*]] = llvm.mlir.constant(1 : i32) : i32
// CHECK: %[[VAL_1:.*]] = llvm.alloca %[[VAL_0]] x !llvm.struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)> {alignment = 8 : i64} : (i32) -> !llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>>
@@ -133,24 +136,24 @@ module {
// CHECK: %[[VAL_8:.*]] = llvm.mlir.addressof @_QQcl.2E2F64756D6D792E66393000 : !llvm.ptr<array<12 x i8>>
// CHECK: %[[VAL_9:.*]] = llvm.bitcast %[[VAL_8]] : !llvm.ptr<array<12 x i8>> to !llvm.ptr<i8>
// CHECK: %[[VAL_10:.*]] = llvm.call @_FortranAioBeginExternalListOutput(%[[VAL_6]], %[[VAL_9]], %[[VAL_5]]) {fastmathFlags = #llvm.fastmath<contract>} : (i32, !llvm.ptr<i8>, i32) -> !llvm.ptr<i8>
-// CHECK: %[[VAL_11:.*]] = llvm.load %[[VAL_7]] {tbaa = [@__flang_tbaa::@[[BOXT:tag_[0-9]*]]]} : !llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>>
-// CHECK: llvm.store %[[VAL_11]], %[[VAL_3]] {tbaa = [@__flang_tbaa::@[[BOXT]]]} : !llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>>
+// CHECK: %[[VAL_11:.*]] = llvm.load %[[VAL_7]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>>
+// CHECK: llvm.store %[[VAL_11]], %[[VAL_3]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>>
// CHECK: %[[VAL_12:.*]] = llvm.getelementptr %[[VAL_3]][0, 7, %[[VAL_4]], 0] : (!llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>>, i64) -> !llvm.ptr<i64>
-// CHECK: %[[VAL_13:.*]] = llvm.load %[[VAL_12]] {tbaa = [@__flang_tbaa::@[[BOXT]]]} : !llvm.ptr<i64>
+// CHECK: %[[VAL_13:.*]] = llvm.load %[[VAL_12]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<i64>
// CHECK: %[[VAL_14:.*]] = llvm.getelementptr %[[VAL_3]][0, 7, %[[VAL_4]], 1] : (!llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>>, i64) -> !llvm.ptr<i64>
-// CHECK: %[[VAL_15:.*]] = llvm.load %[[VAL_14]] {tbaa = [@__flang_tbaa::@[[BOXT]]]} : !llvm.ptr<i64>
+// CHECK: %[[VAL_15:.*]] = llvm.load %[[VAL_14]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<i64>
// CHECK: %[[VAL_16:.*]] = llvm.getelementptr %[[VAL_3]][0, 7, %[[VAL_4]], 2] : (!llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>>, i64) -> !llvm.ptr<i64>
-// CHECK: %[[VAL_17:.*]] = llvm.load %[[VAL_16]] {tbaa = [@__flang_tbaa::@[[BOXT]]]} : !llvm.ptr<i64>
+// CHECK: %[[VAL_17:.*]] = llvm.load %[[VAL_16]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<i64>
// CHECK: %[[VAL_18:.*]] = llvm.getelementptr %[[VAL_3]][0, 8] : (!llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>>) -> !llvm.ptr<ptr<i8>>
-// CHECK: %[[VAL_19:.*]] = llvm.load %[[VAL_18]] {tbaa = [@__flang_tbaa::@[[BOXT]]]} : !llvm.ptr<ptr<i8>>
+// CHECK: %[[VAL_19:.*]] = llvm.load %[[VAL_18]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<ptr<i8>>
// CHECK: %[[VAL_20:.*]] = llvm.mlir.constant(0 : i64) : i64
// CHECK: %[[VAL_21:.*]] = llvm.mlir.constant(-1 : i32) : i32
// CHECK: %[[VAL_22:.*]] = llvm.getelementptr %[[VAL_3]][0, 1] : (!llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>>) -> !llvm.ptr<i64>
-// CHECK: %[[VAL_23:.*]] = llvm.load %[[VAL_22]] {tbaa = [@__flang_tbaa::@[[BOXT]]]} : !llvm.ptr<i64>
+// CHECK: %[[VAL_23:.*]] = llvm.load %[[VAL_22]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<i64>
// CHECK: %[[VAL_24:.*]] = llvm.getelementptr %[[VAL_3]][0, 4] : (!llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>>) -> !llvm.ptr<i32>
-// CHECK: %[[VAL_25:.*]] = llvm.load %[[VAL_24]] {tbaa = [@__flang_tbaa::@[[BOXT]]]} : !llvm.ptr<i32>
+// CHECK: %[[VAL_25:.*]] = llvm.load %[[VAL_24]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<i32>
// CHECK: %[[VAL_26:.*]] = llvm.getelementptr %[[VAL_3]][0, 8] : (!llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>>) -> !llvm.ptr<ptr<i8>>
-// CHECK: %[[VAL_27:.*]] = llvm.load %[[VAL_26]] {tbaa = [@__flang_tbaa::@[[BOXT]]]} : !llvm.ptr<ptr<i8>>
+// CHECK: %[[VAL_27:.*]] = llvm.load %[[VAL_26]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<ptr<i8>>
// CHECK: %[[VAL_28:.*]] = llvm.mlir.undef : !llvm.struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>
// CHECK: %[[VAL_29:.*]] = llvm.insertvalue %[[VAL_23]], %[[VAL_28]][1] : !llvm.struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>
// CHECK: %[[VAL_30:.*]] = llvm.mlir.constant(20180515 : i32) : i32
@@ -169,13 +172,13 @@ module {
// CHECK: %[[VAL_43:.*]] = llvm.bitcast %[[VAL_27]] : !llvm.ptr<i8> to !llvm.ptr<i8>
// CHECK: %[[VAL_44:.*]] = llvm.insertvalue %[[VAL_43]], %[[VAL_42]][8] : !llvm.struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>
// CHECK: %[[VAL_45:.*]] = llvm.getelementptr %[[VAL_3]][0, 7, 0, 0] : (!llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>>) -> !llvm.ptr<i64>
-// CHECK: %[[VAL_46:.*]] = llvm.load %[[VAL_45]] {tbaa = [@__flang_tbaa::@[[BOXT]]]} : !llvm.ptr<i64>
+// CHECK: %[[VAL_46:.*]] = llvm.load %[[VAL_45]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<i64>
// CHECK: %[[VAL_47:.*]] = llvm.getelementptr %[[VAL_3]][0, 7, 0, 1] : (!llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>>) -> !llvm.ptr<i64>
-// CHECK: %[[VAL_48:.*]] = llvm.load %[[VAL_47]] {tbaa = [@__flang_tbaa::@[[BOXT]]]} : !llvm.ptr<i64>
+// CHECK: %[[VAL_48:.*]] = llvm.load %[[VAL_47]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<i64>
// CHECK: %[[VAL_49:.*]] = llvm.getelementptr %[[VAL_3]][0, 7, 0, 2] : (!llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>>) -> !llvm.ptr<i64>
-// CHECK: %[[VAL_50:.*]] = llvm.load %[[VAL_49]] {tbaa = [@__flang_tbaa::@[[BOXT]]]} : !llvm.ptr<i64>
+// CHECK: %[[VAL_50:.*]] = llvm.load %[[VAL_49]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<i64>
// CHECK: %[[VAL_51:.*]] = llvm.getelementptr %[[VAL_3]][0, 0] : (!llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>>) -> !llvm.ptr<ptr<struct<()>>>
-// CHECK: %[[VAL_52:.*]] = llvm.load %[[VAL_51]] {tbaa = [@__flang_tbaa::@[[BOXT]]]} : !llvm.ptr<ptr<struct<()>>>
+// CHECK: %[[VAL_52:.*]] = llvm.load %[[VAL_51]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<ptr<struct<()>>>
// CHECK: %[[VAL_53:.*]] = llvm.mlir.constant(0 : i64) : i64
// CHECK: %[[VAL_54:.*]] = llvm.mlir.constant(1 : i64) : i64
// CHECK: %[[VAL_55:.*]] = llvm.icmp "eq" %[[VAL_48]], %[[VAL_53]] : i64
@@ -185,7 +188,7 @@ module {
// CHECK: %[[VAL_59:.*]] = llvm.insertvalue %[[VAL_50]], %[[VAL_58]][7, 0, 2] : !llvm.struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>
// CHECK: %[[VAL_60:.*]] = llvm.bitcast %[[VAL_52]] : !llvm.ptr<struct<()>> to !llvm.ptr<struct<()>>
// CHECK: %[[VAL_61:.*]] = llvm.insertvalue %[[VAL_60]], %[[VAL_59]][0] : !llvm.struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>
-// CHECK: llvm.store %[[VAL_61]], %[[VAL_1]] {tbaa = [@__flang_tbaa::@[[BOXT]]]} : !llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>>
+// CHECK: llvm.store %[[VAL_61]], %[[VAL_1]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>>
// CHECK: %[[VAL_62:.*]] = llvm.bitcast %[[VAL_1]] : !llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>> to !llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, ptr<i8>, array<1 x i64>)>>
// CHECK: %[[VAL_63:.*]] = llvm.call @_FortranAioOutputDescriptor(%[[VAL_10]], %[[VAL_62]]) {fastmathFlags = #llvm.fastmath<contract>} : (!llvm.ptr<i8>, !llvm.ptr<struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, ptr<i8>, array<1 x i64>)>>) -> i1
// CHECK: %[[VAL_64:.*]] = llvm.call @_FortranAioEndIoStatement(%[[VAL_10]]) {fastmathFlags = #llvm.fastmath<contract>} : (!llvm.ptr<i8>) -> i32
@@ -235,14 +238,6 @@ module {
// CHECK: llvm.return %[[VAL_30]] : !llvm.struct<(ptr<struct<()>>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>, ptr<i8>, array<1 x i64>)>
// CHECK: }
-// CHECK-LABEL: llvm.metadata @__flang_tbaa {
-// CHECK: llvm.tbaa_root @[[ROOT:root_[0-9]*]] {id = "Flang Type TBAA Root"}
-// CHECK: llvm.tbaa_type_desc @[[ANYACC:type_desc_[0-9]*]] {id = "any access", members = {<@[[ROOT]], 0>}}
-// CHECK: llvm.tbaa_type_desc @[[ANYDACC:type_desc_[0-9]*]] {id = "any data access", members = {<@[[ANYACC]], 0>}}
-// CHECK: llvm.tbaa_type_desc @[[BOXMEM:type_desc_[0-9]*]] {id = "descriptor member", members = {<@[[ANYACC]], 0>}}
-// CHECK: llvm.tbaa_tag @[[BOXT]] {access_type = @[[BOXMEM]], base_type = @[[BOXMEM]], offset = 0 : i64}
-// CHECK: }
-
// -----
func.func @tbaa(%arg0: !fir.box<!fir.array<*:f64>>) -> i32 {
@@ -250,21 +245,18 @@ 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: #[[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>
+
// CHECK-LABEL: llvm.func @tbaa(
// CHECK-SAME: %[[VAL_0:.*]]: !llvm.ptr<struct<(ptr<f64>, i64, i32, i8, i8, i8, i8)>>) -> i32 {
// CHECK: %[[VAL_1:.*]] = llvm.getelementptr %[[VAL_0]][0, 3] : (!llvm.ptr<struct<(ptr<f64>, i64, i32, i8, i8, i8, i8)>>) -> !llvm.ptr<i32>
-// CHECK: %[[VAL_2:.*]] = llvm.load %[[VAL_1]] {tbaa = [@__flang_tbaa::@[[BOXT:tag_[0-9]*]]]} : !llvm.ptr<i32>
+// CHECK: %[[VAL_2:.*]] = llvm.load %[[VAL_1]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<i32>
// CHECK: llvm.return %[[VAL_2]] : i32
// CHECK: }
-// CHECK-LABEL: llvm.metadata @__flang_tbaa {
-// CHECK: llvm.tbaa_root @[[ROOT:root_[0-9]*]] {id = "Flang Type TBAA Root"}
-// CHECK: llvm.tbaa_type_desc @[[ANYACC:type_desc_[0-9]*]] {id = "any access", members = {<@[[ROOT]], 0>}}
-// CHECK: llvm.tbaa_type_desc @[[ANYDACC:type_desc_[0-9]*]] {id = "any data access", members = {<@[[ANYACC]], 0>}}
-// CHECK: llvm.tbaa_type_desc @[[BOXMEM:type_desc_[0-9]*]] {id = "descriptor member", members = {<@[[ANYACC]], 0>}}
-// CHECK: llvm.tbaa_tag @[[BOXT]] {access_type = @[[BOXMEM]], base_type = @[[BOXMEM]], offset = 0 : i64}
-// CHECK: }
-
// -----
func.func @tbaa(%arg0: !fir.box<!fir.array<*:f64>>) -> i1 {
@@ -272,23 +264,20 @@ 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: #[[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>
+
// CHECK-LABEL: llvm.func @tbaa(
// CHECK-SAME: %[[VAL_0:.*]]: !llvm.ptr<struct<(ptr<f64>, i64, i32, i8, i8, i8, i8)>>) -> i1 {
// CHECK: %[[VAL_1:.*]] = llvm.getelementptr %[[VAL_0]][0, 3] : (!llvm.ptr<struct<(ptr<f64>, i64, i32, i8, i8, i8, i8)>>) -> !llvm.ptr<i32>
-// CHECK: %[[VAL_2:.*]] = llvm.load %[[VAL_1]] {tbaa = [@__flang_tbaa::@[[BOXT:tag_[0-9]*]]]} : !llvm.ptr<i32>
+// CHECK: %[[VAL_2:.*]] = llvm.load %[[VAL_1]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<i32>
// CHECK: %[[VAL_3:.*]] = llvm.mlir.constant(0 : i32) : i32
// CHECK: %[[VAL_4:.*]] = llvm.icmp "ne" %[[VAL_2]], %[[VAL_3]] : i32
// CHECK: llvm.return %[[VAL_4]] : i1
// CHECK: }
-// CHECK-LABEL: llvm.metadata @__flang_tbaa {
-// CHECK: llvm.tbaa_root @[[ROOT:root_[0-9]*]] {id = "Flang Type TBAA Root"}
-// CHECK: llvm.tbaa_type_desc @[[ANYACC:type_desc_[0-9]*]] {id = "any access", members = {<@[[ROOT]], 0>}}
-// CHECK: llvm.tbaa_type_desc @[[ANYDACC:type_desc_[0-9]*]] {id = "any data access", members = {<@[[ANYACC]], 0>}}
-// CHECK: llvm.tbaa_type_desc @[[BOXMEM:type_desc_[0-9]*]] {id = "descriptor member", members = {<@[[ANYACC]], 0>}}
-// CHECK: llvm.tbaa_tag @[[BOXT]] {access_type = @[[BOXMEM]], base_type = @[[BOXMEM]], offset = 0 : i64}
-// CHECK: }
-
// -----
func.func @tbaa(%arg0: !fir.box<f32>) -> i32 {
@@ -296,21 +285,18 @@ func.func @tbaa(%arg0: !fir.box<f32>) -> i32 {
return %0 : i32
}
+// CHECK-DAG: #[[ROOT:.*]] = #llvm.tbaa_root<id = "Flang Type TBAA 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>
+
// CHECK-LABEL: llvm.func @tbaa(
// CHECK-SAME: %[[VAL_0:.*]]: !llvm.ptr<struct<(ptr<f32>, i64, i32, i8, i8, i8, i8)>>) -> i32 {
// CHECK: %[[VAL_1:.*]] = llvm.getelementptr %[[VAL_0]][0, 1] : (!llvm.ptr<struct<(ptr<f32>, i64, i32, i8, i8, i8, i8)>>) -> !llvm.ptr<i32>
-// CHECK: %[[VAL_2:.*]] = llvm.load %[[VAL_1]] {tbaa = [@__flang_tbaa::@[[BOXT:tag_[0-9]*]]]} : !llvm.ptr<i32>
+// CHECK: %[[VAL_2:.*]] = llvm.load %[[VAL_1]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<i32>
// CHECK: llvm.return %[[VAL_2]] : i32
// CHECK: }
-// CHECK-LABEL: llvm.metadata @__flang_tbaa {
-// CHECK: llvm.tbaa_root @[[ROOT:root_[0-9]*]] {id = "Flang Type TBAA Root"}
-// CHECK: llvm.tbaa_type_desc @[[ANYACC:type_desc_[0-9]*]] {id = "any access", members = {<@[[ROOT]], 0>}}
-// CHECK: llvm.tbaa_type_desc @[[ANYDACC:type_desc_[0-9]*]] {id = "any data access", members = {<@[[ANYACC]], 0>}}
-// CHECK: llvm.tbaa_type_desc @[[BOXMEM:type_desc_[0-9]*]] {id = "descriptor member", members = {<@[[ANYACC]], 0>}}
-// CHECK: llvm.tbaa_tag @[[BOXT]] {access_type = @[[BOXMEM]], base_type = @[[BOXMEM]], offset = 0 : i64}
-// CHECK: }
-
// -----
func.func @tbaa(%arg0: !fir.box<!fir.array<*:f64>>) -> i1 {
@@ -318,10 +304,15 @@ 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: #[[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>
+
// CHECK-LABEL: llvm.func @tbaa(
// CHECK-SAME: %[[VAL_0:.*]]: !llvm.ptr<struct<(ptr<f64>, i64, i32, i8, i8, i8, i8)>>) -> i1 {
// CHECK: %[[VAL_1:.*]] = llvm.getelementptr %[[VAL_0]][0, 5] : (!llvm.ptr<struct<(ptr<f64>, i64, i32, i8, i8, i8, i8)>>) -> !llvm.ptr<i32>
-// CHECK: %[[VAL_2:.*]] = llvm.load %[[VAL_1]] {tbaa = [@__flang_tbaa::@[[BOXT:tag_[0-9]*]]]} : !llvm.ptr<i32>
+// CHECK: %[[VAL_2:.*]] = llvm.load %[[VAL_1]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<i32>
// CHECK: %[[VAL_3:.*]] = llvm.mlir.constant(2 : i32) : i32
// CHECK: %[[VAL_4:.*]] = llvm.and %[[VAL_2]], %[[VAL_3]] : i32
// CHECK: %[[VAL_5:.*]] = llvm.mlir.constant(0 : i32) : i32
@@ -329,14 +320,6 @@ func.func @tbaa(%arg0: !fir.box<!fir.array<*:f64>>) -> i1 {
// CHECK: llvm.return %[[VAL_6]] : i1
// CHECK: }
-// CHECK-LABEL: llvm.metadata @__flang_tbaa {
-// CHECK: llvm.tbaa_root @[[ROOT:root_[0-9]*]] {id = "Flang Type TBAA Root"}
-// CHECK: llvm.tbaa_type_desc @[[ANYACC:type_desc_[0-9]*]] {id = "any access", members = {<@[[ROOT]], 0>}}
-// CHECK: llvm.tbaa_type_desc @[[ANYDACC:type_desc_[0-9]*]] {id = "any data access", members = {<@[[ANYACC]], 0>}}
-// CHECK: llvm.tbaa_type_desc @[[BOXMEM:type_desc_[0-9]*]] {id = "descriptor member", members = {<@[[ANYACC]], 0>}}
-// CHECK: llvm.tbaa_tag @[[BOXT]] {access_type = @[[BOXMEM]], base_type = @[[BOXMEM]], offset = 0 : i64}
-// CHECK: }
-
// -----
func.func @tbaa(%arg0: !fir.box<!fir.array<?xi32>>) {
@@ -345,6 +328,11 @@ func.func @tbaa(%arg0: !fir.box<!fir.array<?xi32>>) {
return
}
+// CHECK-DAG: #[[ROOT:.*]] = #llvm.tbaa_root<id = "Flang Type TBAA 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>
+
// CHECK-LABEL: llvm.func @tbaa(
// CHECK-SAME: %[[VAL_0:.*]]: !llvm.ptr<struct<(ptr<i32>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)>>) {
// CHECK: %[[VAL_1:.*]] = llvm.mlir.constant(0 : i64) : i64
@@ -353,21 +341,13 @@ func.func @tbaa(%arg0: !fir.box<!fir.array<?xi32>>) {
// CHECK: %[[VAL_4:.*]] = llvm.sub %[[VAL_1]], %[[VAL_2]] : i64
// CHECK: %[[VAL_5:.*]] = llvm.mul %[[VAL_4]], %[[VAL_2]] : i64
// CHECK: %[[VAL_6:.*]] = llvm.getelementptr %[[VAL_0]][0, 7, 0, 2] : (!llvm.ptr<struct<(ptr<i32>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)>>) -> !llvm.ptr<i64>
-// CHECK: %[[VAL_7:.*]] = llvm.load %[[VAL_6]] {tbaa = [@__flang_tbaa::@[[BOXT:tag_[0-9]*]]]} : !llvm.ptr<i64>
+// CHECK: %[[VAL_7:.*]] = llvm.load %[[VAL_6]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<i64>
// CHECK: %[[VAL_8:.*]] = llvm.mul %[[VAL_5]], %[[VAL_7]] : i64
// CHECK: %[[VAL_9:.*]] = llvm.add %[[VAL_8]], %[[VAL_3]] : i64
// CHECK: %[[VAL_10:.*]] = llvm.getelementptr %[[VAL_0]][0, 0] : (!llvm.ptr<struct<(ptr<i32>, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)>>) -> !llvm.ptr<ptr<i32>>
-// CHECK: %[[VAL_11:.*]] = llvm.load %[[VAL_10]] {tbaa = [@__flang_tbaa::@[[BOXT]]]} : !llvm.ptr<ptr<i32>>
+// CHECK: %[[VAL_11:.*]] = llvm.load %[[VAL_10]] {tbaa = [#[[$BOXT]]]} : !llvm.ptr<ptr<i32>>
// CHECK: %[[VAL_12:.*]] = llvm.bitcast %[[VAL_11]] : !llvm.ptr<i32> to !llvm.ptr<i8>
// CHECK: %[[VAL_13:.*]] = llvm.getelementptr %[[VAL_12]]{{\[}}%[[VAL_9]]] : (!llvm.ptr<i8>, i64) -> !llvm.ptr<i8>
// CHECK: %[[VAL_14:.*]] = llvm.bitcast %[[VAL_13]] : !llvm.ptr<i8> to !llvm.ptr<i32>
// CHECK: llvm.return
// CHECK: }
-
-// CHECK-LABEL: llvm.metadata @__flang_tbaa {
-// CHECK: llvm.tbaa_root @[[ROOT:root_[0-9]*]] {id = "Flang Type TBAA Root"}
-// CHECK: llvm.tbaa_type_desc @[[ANYACC:type_desc_[0-9]*]] {id = "any access", members = {<@[[ROOT]], 0>}}
-// CHECK: llvm.tbaa_type_desc @[[ANYDACC:type_desc_[0-9]*]] {id = "any data access", members = {<@[[ANYACC]], 0>}}
-// CHECK: llvm.tbaa_type_desc @[[BOXMEM:type_desc_[0-9]*]] {id = "descriptor member", members = {<@[[ANYACC]], 0>}}
-// CHECK: llvm.tbaa_tag @[[BOXT]] {access_type = @[[BOXMEM]], base_type = @[[BOXMEM]], offset = 0 : i64}
-// CHECK: }