33 OnlyNamed = onlyNamed;
37 incorporateType(
G.getType());
38 if (
G.hasInitializer())
39 incorporateValue(
G.getInitializer());
43 for (
const auto &A : M.
aliases()) {
44 incorporateType(A.getType());
45 if (
const Value *Aliasee = A.getAliasee())
46 incorporateValue(Aliasee);
52 incorporateType(FI.getType());
54 for (
const Use &U : FI.operands())
55 incorporateValue(U.get());
58 for (
const auto &A : FI.args())
64 incorporateType(
I.getType());
68 for (
const auto &
O :
I.operands())
69 if (&*
O && !isa<Instruction>(&*
O))
70 incorporateValue(&*
O);
73 I.getAllMetadataOtherThanDebugLoc(MDForInst);
74 for (
const auto &MD : MDForInst)
75 incorporateMDNode(MD.second);
80 for (
const auto &NMD : M.named_metadata())
81 for (
const auto &MDOp : NMD.operands())
82 incorporateMDNode(MDOp);
86 VisitedConstants.
clear();
93 void TypeFinder::incorporateType(
Type *Ty) {
95 if (!VisitedTypes.insert(Ty).second)
104 if (
StructType *STy = dyn_cast<StructType>(Ty))
105 if (!OnlyNamed || STy->hasName())
106 StructTypes.push_back(STy);
112 if (VisitedTypes.insert(*I).second)
114 }
while (!TypeWorklist.
empty());
121 void TypeFinder::incorporateValue(
const Value *V) {
122 if (
const auto *M = dyn_cast<MetadataAsValue>(V)) {
123 if (
const auto *
N = dyn_cast<MDNode>(M->getMetadata()))
124 return incorporateMDNode(
N);
125 if (
const auto *MDV = dyn_cast<ValueAsMetadata>(M->getMetadata()))
126 return incorporateValue(MDV->getValue());
130 if (!isa<Constant>(V) || isa<GlobalValue>(V))
return;
133 if (!VisitedConstants.
insert(V).second)
140 if (isa<Instruction>(V))
144 const User *U = cast<User>(V);
146 incorporateValue(&*
I);
151 void TypeFinder::incorporateMDNode(
const MDNode *V) {
153 if (!VisitedMetadata.insert(V).second)
160 if (
auto *
N = dyn_cast<MDNode>(
Op)) {
161 incorporateMDNode(
N);
164 if (
auto *
C = dyn_cast<ConstantAsMetadata>(
Op)) {
165 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()