aboutsummaryrefslogtreecommitdiffstats
path: root/lib/IR/TypeFinder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/IR/TypeFinder.cpp')
-rw-r--r--lib/IR/TypeFinder.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/lib/IR/TypeFinder.cpp b/lib/IR/TypeFinder.cpp
index 6796075..e2fb8f8 100644
--- a/lib/IR/TypeFinder.cpp
+++ b/lib/IR/TypeFinder.cpp
@@ -47,6 +47,9 @@ void TypeFinder::run(const Module &M, bool onlyNamed) {
if (FI->hasPrefixData())
incorporateValue(FI->getPrefixData());
+ if (FI->hasPrologueData())
+ incorporateValue(FI->getPrologueData());
+
// First incorporate the arguments.
for (Function::const_arg_iterator AI = FI->arg_begin(),
AE = FI->arg_end(); AI != AE; ++AI)
@@ -122,8 +125,13 @@ void TypeFinder::incorporateType(Type *Ty) {
/// other ways. GlobalValues, basic blocks, instructions, and inst operands are
/// all explicitly enumerated.
void TypeFinder::incorporateValue(const Value *V) {
- if (const MDNode *M = dyn_cast<MDNode>(V))
- return incorporateMDNode(M);
+ if (const auto *M = dyn_cast<MetadataAsValue>(V)) {
+ if (const auto *N = dyn_cast<MDNode>(M->getMetadata()))
+ return incorporateMDNode(N);
+ if (const auto *MDV = dyn_cast<ValueAsMetadata>(M->getMetadata()))
+ return incorporateValue(MDV->getValue());
+ return;
+ }
if (!isa<Constant>(V) || isa<GlobalValue>(V)) return;
@@ -149,11 +157,21 @@ void TypeFinder::incorporateValue(const Value *V) {
/// find types hiding within.
void TypeFinder::incorporateMDNode(const MDNode *V) {
// Already visited?
- if (!VisitedConstants.insert(V).second)
+ if (!VisitedMetadata.insert(V).second)
return;
// Look in operands for types.
- for (unsigned i = 0, e = V->getNumOperands(); i != e; ++i)
- if (Value *Op = V->getOperand(i))
- incorporateValue(Op);
+ for (unsigned i = 0, e = V->getNumOperands(); i != e; ++i) {
+ Metadata *Op = V->getOperand(i);
+ if (!Op)
+ continue;
+ if (auto *N = dyn_cast<MDNode>(Op)) {
+ incorporateMDNode(N);
+ continue;
+ }
+ if (auto *C = dyn_cast<ConstantAsMetadata>(Op)) {
+ incorporateValue(C->getValue());
+ continue;
+ }
+ }
}