32 OnlyNamed = onlyNamed;
36 incorporateType(
G.getType());
37 if (
G.hasInitializer())
38 incorporateValue(
G.getInitializer());
42 for (
const auto &A : M.
aliases()) {
43 incorporateType(A.getType());
44 if (
const Value *Aliasee = A.getAliasee())
45 incorporateValue(Aliasee);
51 incorporateType(FI.getType());
53 for (
const Use &U : FI.operands())
54 incorporateValue(U.get());
57 for (
const auto &A : FI.args())
63 incorporateType(
I.getType());
67 for (
const auto &
O :
I.operands())
68 if (&*
O && !isa<Instruction>(&*
O))
69 incorporateValue(&*
O);
72 I.getAllMetadataOtherThanDebugLoc(MDForInst);
73 for (
const auto &MD : MDForInst)
74 incorporateMDNode(MD.second);
79 for (
const auto &NMD : M.named_metadata())
80 for (
const auto *MDOp : NMD.operands())
81 incorporateMDNode(MDOp);
85 VisitedConstants.
clear();
92 void TypeFinder::incorporateType(
Type *Ty) {
94 if (!VisitedTypes.insert(Ty).second)
103 if (
StructType *STy = dyn_cast<StructType>(Ty))
104 if (!OnlyNamed || STy->hasName())
105 StructTypes.push_back(STy);
111 if (VisitedTypes.insert(*I).second)
113 }
while (!TypeWorklist.
empty());
120 void TypeFinder::incorporateValue(
const Value *V) {
121 if (
const auto *M = dyn_cast<MetadataAsValue>(V)) {
122 if (
const auto *
N = dyn_cast<MDNode>(M->getMetadata()))
123 return incorporateMDNode(
N);
124 if (
const auto *MDV = dyn_cast<ValueAsMetadata>(M->getMetadata()))
125 return incorporateValue(MDV->getValue());
129 if (!isa<Constant>(V) || isa<GlobalValue>(V))
return;
132 if (!VisitedConstants.
insert(V).second)
139 if (isa<Instruction>(V))
143 const User *U = cast<User>(V);
145 incorporateValue(&*
I);
150 void TypeFinder::incorporateMDNode(
const MDNode *V) {
152 if (!VisitedMetadata.insert(V).second)
159 if (
auto *
N = dyn_cast<MDNode>(
Op)) {
160 incorporateMDNode(
N);
163 if (
auto *
C = dyn_cast<ConstantAsMetadata>(
Op)) {
164 incorporateValue(
C->getValue());
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
void push_back(const T &Elt)
This defines the Use class.
Class to represent struct types.
A Use represents the edge between a Value definition and its users.
Type * getType() const
All values are typed, get the type of this value.
op_range operands() const
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
std::pair< iterator, bool > insert(const ValueT &V)
std::reverse_iterator< subtype_iterator > subtype_reverse_iterator
subtype_reverse_iterator subtype_rbegin() const
void run(const Module &M, bool onlyNamed)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
LLVM_NODISCARD T pop_back_val()
LLVM_NODISCARD bool empty() const
subtype_reverse_iterator subtype_rend() const
LLVM Value Representation.
iterator_range< global_iterator > globals()
iterator_range< alias_iterator > aliases()