33 OnlyNamed = onlyNamed;
38 incorporateType(
I->getType());
39 if (
I->hasInitializer())
40 incorporateValue(
I->getInitializer());
46 incorporateType(
I->getType());
47 if (
const Value *Aliasee =
I->getAliasee())
48 incorporateValue(Aliasee);
54 incorporateType(FI.getType());
56 for (
const Use &U : FI.operands())
57 incorporateValue(U.get());
62 incorporateValue(&*AI);
67 incorporateType(
I.getType());
73 if (*OI && !isa<Instruction>(OI))
74 incorporateValue(*OI);
77 I.getAllMetadataOtherThanDebugLoc(MDForInst);
78 for (
unsigned i = 0, e = MDForInst.
size(); i != e; ++i)
79 incorporateMDNode(MDForInst[i].
second);
86 E = M.named_metadata_end();
I !=
E; ++
I) {
94 VisitedConstants.
clear();
101 void TypeFinder::incorporateType(
Type *Ty) {
103 if (!VisitedTypes.insert(Ty).second)
112 if (
StructType *STy = dyn_cast<StructType>(Ty))
113 if (!OnlyNamed || STy->hasName())
114 StructTypes.push_back(STy);
120 if (VisitedTypes.insert(*I).second)
122 }
while (!TypeWorklist.
empty());
129 void TypeFinder::incorporateValue(
const Value *V) {
130 if (
const auto *M = dyn_cast<MetadataAsValue>(V)) {
131 if (
const auto *
N = dyn_cast<MDNode>(M->getMetadata()))
132 return incorporateMDNode(
N);
133 if (
const auto *MDV = dyn_cast<ValueAsMetadata>(M->getMetadata()))
134 return incorporateValue(MDV->getValue());
138 if (!isa<Constant>(V) || isa<GlobalValue>(V))
return;
141 if (!VisitedConstants.
insert(V).second)
148 if (isa<Instruction>(V))
152 const User *U = cast<User>(V);
155 incorporateValue(*
I);
160 void TypeFinder::incorporateMDNode(
const MDNode *V) {
162 if (!VisitedMetadata.insert(V).second)
170 if (
auto *
N = dyn_cast<MDNode>(Op)) {
171 incorporateMDNode(
N);
174 if (
auto *
C = dyn_cast<ConstantAsMetadata>(Op)) {
175 incorporateValue(
C->getValue());
void push_back(const T &Elt)
This class represents an incoming formal argument to a Function.
A Module instance is used to store all the information related to an LLVM module. ...
unsigned getNumOperands() const
Return number of MDNode operands.
subtype_reverse_iterator subtype_rend() const
This defines the Use class.
Class to represent struct types.
A Use represents the edge between a Value definition and its users.
LLVM_NODISCARD bool empty() const
global_iterator global_begin()
alias_iterator alias_end()
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
std::pair< iterator, bool > insert(const ValueT &V)
std::reverse_iterator< subtype_iterator > subtype_reverse_iterator
MDNode * getOperand(unsigned i) const
global_iterator global_end()
const MDOperand & getOperand(unsigned I) const
Iterator for intrusive lists based on ilist_node.
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.
Type * getType() const
All values are typed, get the type of this value.
LLVM_NODISCARD T pop_back_val()
alias_iterator alias_begin()
const Use * const_op_iterator
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
LLVM Value Representation.
unsigned getNumOperands() const
subtype_reverse_iterator subtype_rbegin() const