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 for (
const Use &U : FI.operands())
48 incorporateValue(U.get());
53 incorporateValue(&*AI);
58 incorporateType(
I.getType());
64 if (*OI && !isa<Instruction>(OI))
65 incorporateValue(*OI);
68 I.getAllMetadataOtherThanDebugLoc(MDForInst);
69 for (
unsigned i = 0, e = MDForInst.
size();
i != e; ++
i)
70 incorporateMDNode(MDForInst[
i].second);
77 E = M.named_metadata_end();
I !=
E; ++
I) {
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);
146 incorporateValue(*
I);
151 void TypeFinder::incorporateMDNode(
const MDNode *V) {
153 if (!VisitedMetadata.insert(V).second)
161 if (
auto *
N = dyn_cast<MDNode>(Op)) {
162 incorporateMDNode(
N);
165 if (
auto *
C = dyn_cast<ConstantAsMetadata>(Op)) {
166 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.
subtype_reverse_iterator subtype_rend() const
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()
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
alias_iterator alias_end()
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
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()
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
LLVM Value Representation.
unsigned getNumOperands() const
std::reverse_iterator< subtype_iterator > subtype_reverse_iterator
subtype_reverse_iterator subtype_rbegin() const
const Use * const_op_iterator