1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
//===- TBAAForest.cpp - Per-functon TBAA Trees ----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "flang/Optimizer/Analysis/TBAAForest.h"
#include <mlir/Dialect/LLVMIR/LLVMAttrs.h>
mlir::LLVM::TBAATagAttr
fir::TBAATree::SubtreeState::getTag(llvm::StringRef uniqueName) const {
std::string id = (parentId + "/" + uniqueName).str();
mlir::LLVM::TBAATypeDescriptorAttr type =
mlir::LLVM::TBAATypeDescriptorAttr::get(
context, id, mlir::LLVM::TBAAMemberAttr::get(parent, 0));
return mlir::LLVM::TBAATagAttr::get(type, type, 0);
// return tag;
}
mlir::LLVM::TBAATagAttr fir::TBAATree::SubtreeState::getTag() const {
return mlir::LLVM::TBAATagAttr::get(parent, parent, 0);
}
fir::TBAATree fir::TBAATree::buildTree(mlir::StringAttr func) {
llvm::StringRef funcName = func.getValue();
std::string rootId = ("Flang function root " + funcName).str();
mlir::MLIRContext *ctx = func.getContext();
mlir::LLVM::TBAARootAttr funcRoot =
mlir::LLVM::TBAARootAttr::get(ctx, mlir::StringAttr::get(ctx, rootId));
static constexpr llvm::StringRef anyAccessTypeDescId = "any access";
mlir::LLVM::TBAATypeDescriptorAttr anyAccess =
mlir::LLVM::TBAATypeDescriptorAttr::get(
ctx, anyAccessTypeDescId,
mlir::LLVM::TBAAMemberAttr::get(funcRoot, 0));
static constexpr llvm::StringRef anyDataAccessTypeDescId = "any data access";
mlir::LLVM::TBAATypeDescriptorAttr dataRoot =
mlir::LLVM::TBAATypeDescriptorAttr::get(
ctx, anyDataAccessTypeDescId,
mlir::LLVM::TBAAMemberAttr::get(anyAccess, 0));
static constexpr llvm::StringRef boxMemberTypeDescId = "descriptor member";
mlir::LLVM::TBAATypeDescriptorAttr boxMemberTypeDesc =
mlir::LLVM::TBAATypeDescriptorAttr::get(
ctx, boxMemberTypeDescId,
mlir::LLVM::TBAAMemberAttr::get(anyAccess, 0));
return TBAATree{anyAccess, dataRoot, boxMemberTypeDesc};
}
fir::TBAATree::TBAATree(mlir::LLVM::TBAATypeDescriptorAttr anyAccess,
mlir::LLVM::TBAATypeDescriptorAttr dataRoot,
mlir::LLVM::TBAATypeDescriptorAttr boxMemberTypeDesc)
: targetDataTree(dataRoot.getContext(), "target data", dataRoot),
globalDataTree(dataRoot.getContext(), "global data",
targetDataTree.getRoot()),
allocatedDataTree(dataRoot.getContext(), "allocated data",
targetDataTree.getRoot()),
dummyArgDataTree(dataRoot.getContext(), "dummy arg data", dataRoot),
directDataTree(dataRoot.getContext(), "direct data",
targetDataTree.getRoot()),
anyAccessDesc(anyAccess), boxMemberTypeDesc(boxMemberTypeDesc),
anyDataTypeDesc(dataRoot) {}
|