summaryrefslogtreecommitdiff
path: root/lib/VMCore/DebugInfo.cpp
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2012-10-09 08:13:15 +0000
committerAlexey Samsonov <samsonov@google.com>2012-10-09 08:13:15 +0000
commite97a3a4b4fccbe6283b616af93ab0117d3a7fee9 (patch)
treeafe233298f0be8fd15476c640cc05e3c131a0c85 /lib/VMCore/DebugInfo.cpp
parent6765834754cbb3cb0f15b4b15e98c5e73fa50066 (diff)
downloadllvm-e97a3a4b4fccbe6283b616af93ab0117d3a7fee9.tar.gz
llvm-e97a3a4b4fccbe6283b616af93ab0117d3a7fee9.tar.bz2
llvm-e97a3a4b4fccbe6283b616af93ab0117d3a7fee9.tar.xz
Fix PR14016.
DeadArgumentElimination pass can replace one LLVM function with another, invalidating a pointer stored in debug info metadata entry for this function. To fix this, we collect debug info descriptors for functions before running a DeadArgumentElimination pass and "patch" pointers in metadata nodes if we replace a function. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165490 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/DebugInfo.cpp')
-rw-r--r--lib/VMCore/DebugInfo.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/VMCore/DebugInfo.cpp b/lib/VMCore/DebugInfo.cpp
index c8f8f7d67b..3029ce2734 100644
--- a/lib/VMCore/DebugInfo.cpp
+++ b/lib/VMCore/DebugInfo.cpp
@@ -111,6 +111,16 @@ Function *DIDescriptor::getFunctionField(unsigned Elt) const {
return 0;
}
+void DIDescriptor::replaceFunctionField(unsigned Elt, Function *F) {
+ if (DbgNode == 0)
+ return;
+
+ if (Elt < DbgNode->getNumOperands()) {
+ MDNode *Node = const_cast<MDNode*>(DbgNode);
+ Node->replaceOperandWith(Elt, F);
+ }
+}
+
unsigned DIVariable::getNumAddrElements() const {
if (getVersion() <= LLVMDebugVersion8)
return DbgNode->getNumOperands()-6;