24 OnlyNamed = onlyNamed;
29 incorporateType(
I->getType());
30 if (
I->hasInitializer())
31 incorporateValue(
I->getInitializer());
37 incorporateType(
I->getType());
38 if (
const Value *Aliasee =
I->getAliasee())
39 incorporateValue(Aliasee);
45 incorporateType(FI->getType());
47 if (FI->hasPrefixData())
48 incorporateValue(FI->getPrefixData());
50 if (FI->hasPrologueData())
51 incorporateValue(FI->getPrologueData());
53 if (FI->hasPersonalityFn())
54 incorporateValue(FI->getPersonalityFn());
58 AE = FI->arg_end(); AI != AE; ++AI)
64 E = BB->end(); II != E; ++II) {
74 if (*OI && !isa<Instruction>(OI))
75 incorporateValue(*OI);
79 for (
unsigned i = 0, e = MDForInst.
size(); i != e; ++i)
80 incorporateMDNode(MDForInst[i].second);
95 VisitedConstants.
clear();
102 void TypeFinder::incorporateType(
Type *Ty) {
104 if (!VisitedTypes.insert(Ty).second)
113 if (
StructType *STy = dyn_cast<StructType>(Ty))
114 if (!OnlyNamed || STy->hasName())
115 StructTypes.push_back(STy);
121 if (VisitedTypes.insert(*I).second)
123 }
while (!TypeWorklist.
empty());
130 void TypeFinder::incorporateValue(
const Value *V) {
131 if (
const auto *M = dyn_cast<MetadataAsValue>(V)) {
132 if (
const auto *
N = dyn_cast<MDNode>(M->getMetadata()))
133 return incorporateMDNode(
N);
134 if (
const auto *MDV = dyn_cast<ValueAsMetadata>(M->getMetadata()))
135 return incorporateValue(MDV->getValue());
139 if (!isa<Constant>(V) || isa<GlobalValue>(V))
return;
142 if (!VisitedConstants.
insert(V).second)
149 if (isa<Instruction>(V))
153 const User *U = cast<User>(V);
156 incorporateValue(*
I);
161 void TypeFinder::incorporateMDNode(
const MDNode *V) {
163 if (!VisitedMetadata.insert(V).second)
171 if (
auto *
N = dyn_cast<MDNode>(Op)) {
172 incorporateMDNode(
N);
175 if (
auto *
C = dyn_cast<ConstantAsMetadata>(Op)) {
176 incorporateValue(
C->getValue());
void push_back(const T &Elt)
A Module instance is used to store all the information related to an LLVM module. ...
unsigned getNumOperands() const
Return number of MDNode operands.
named_metadata_iterator named_metadata_end()
subtype_reverse_iterator subtype_rend() const
T LLVM_ATTRIBUTE_UNUSED_RESULT pop_back_val()
StructType - Class to represent struct types.
A Use represents the edge between a Value definition and its users.
global_iterator global_begin()
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
alias_iterator alias_end()
The instances of the Type class are immutable: once they are created, they are never changed...
void getAllMetadataOtherThanDebugLoc(SmallVectorImpl< std::pair< unsigned, MDNode * >> &MDs) const
getAllMetadataOtherThanDebugLoc - This does the same thing as getAllMetadata, except that it filters ...
MDNode * getOperand(unsigned i) const
global_iterator global_end()
const MDOperand & getOperand(unsigned I) const
std::pair< iterator, bool > insert(const ValueT &V)
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.
alias_iterator alias_begin()
LLVM Value Representation.
unsigned getNumOperands() const
std::reverse_iterator< subtype_iterator > subtype_reverse_iterator
subtype_reverse_iterator subtype_rbegin() const
named_metadata_iterator named_metadata_begin()
const Use * const_op_iterator