diff options
Diffstat (limited to 'llvm/lib/IR/Metadata.cpp')
-rw-r--r-- | llvm/lib/IR/Metadata.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp index a148ab65fc8..4f49312dfc4 100644 --- a/llvm/lib/IR/Metadata.cpp +++ b/llvm/lib/IR/Metadata.cpp @@ -329,12 +329,20 @@ bool ReplaceableMetadataImpl::isReplaceable(const Metadata &MD) { return dyn_cast<ValueAsMetadata>(&MD); } -static Function *getLocalFunction(Value *V) { +static DISubprogram *getLocalFunctionMetadata(Value *V) { assert(V && "Expected value"); - if (auto *A = dyn_cast<Argument>(V)) - return A->getParent(); - if (BasicBlock *BB = cast<Instruction>(V)->getParent()) - return BB->getParent(); + if (auto *A = dyn_cast<Argument>(V)) { + if (auto *Fn = A->getParent()) + return Fn->getSubprogram(); + return nullptr; + } + + if (BasicBlock *BB = cast<Instruction>(V)->getParent()) { + if (auto *Fn = BB->getParent()) + return Fn->getSubprogram(); + return nullptr; + } + return nullptr; } @@ -410,9 +418,9 @@ void ValueAsMetadata::handleRAUW(Value *From, Value *To) { delete MD; return; } - if (getLocalFunction(From) && getLocalFunction(To) && - getLocalFunction(From) != getLocalFunction(To)) { - // Function changed. + if (getLocalFunctionMetadata(From) && getLocalFunctionMetadata(To) && + getLocalFunctionMetadata(From) != getLocalFunctionMetadata(To)) { + // DISubprogram changed. MD->replaceAllUsesWith(nullptr); delete MD; return; |