[DeadArgumentElim] Set pointer to DISubprogram before calling RAUW. NFC
It is better to update pointer of the DISuprogram before we call RAUW for
still live arguments of the function, because with the change reviewed in
D42541 in RAUW we compare DISubprograms rather than functions itself.
Patch by Djordje Todorovic.
Differential Revision: https://reviews.llvm.org/D42794
llvm-svn: 324335
diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
index 5446541..78e4d66 100644
--- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -825,6 +825,9 @@
F->getParent()->getFunctionList().insert(F->getIterator(), NF);
NF->takeName(F);
+ // Patch the pointer to LLVM function in debug info descriptor.
+ NF->setSubprogram(F->getSubprogram());
+
// Loop over all of the callers of the function, transforming the call sites
// to pass in a smaller number of arguments into the new function.
std::vector<Value*> Args;
@@ -1017,9 +1020,6 @@
BB.getInstList().erase(RI);
}
- // Patch the pointer to LLVM function in debug info descriptor.
- NF->setSubprogram(F->getSubprogram());
-
// Now that the old function is dead, delete it.
F->eraseFromParent();