summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO
diff options
context:
space:
mode:
authorRong Xu <xur@google.com>2018-04-02 17:27:38 +0000
committerRong Xu <xur@google.com>2018-04-02 17:27:38 +0000
commit5a8d4c3357c9c7910ef2a39ea10d66c0a24f327d (patch)
tree9d8ef315c4bcc74a748ffa9e30b0d5f0d3b25037 /llvm/lib/Transforms/IPO
parentde01668b14b45d97f038172aa7b076cc2985c737 (diff)
downloadbcm5719-llvm-5a8d4c3357c9c7910ef2a39ea10d66c0a24f327d.tar.gz
bcm5719-llvm-5a8d4c3357c9c7910ef2a39ea10d66c0a24f327d.zip
[DeadArgumentElim] Clone function level metadatas
Some Function level metadatas, such as function entry count, are not cloned in DeadArgumentElim. This happens a lot in lto/thinlto because of DeadArgumentElim after internalization. This patch clones the metadatas in the original function to the new function. Differential Revision: https://reviews.llvm.org/D44127 llvm-svn: 328991
Diffstat (limited to 'llvm/lib/Transforms/IPO')
-rw-r--r--llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
index 3a86c88c98f..0c54b7fc930 100644
--- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -240,8 +240,11 @@ bool DeadArgumentEliminationPass::DeleteDeadVarargs(Function &Fn) {
I2->takeName(&*I);
}
- // Patch the pointer to LLVM function in debug info descriptor.
- NF->setSubprogram(Fn.getSubprogram());
+ // Clone metadatas from the old function, including debug info descriptor.
+ SmallVector<std::pair<unsigned, MDNode *>, 1> MDs;
+ Fn.getAllMetadata(MDs);
+ for (auto MD : MDs)
+ NF->addMetadata(MD.first, *MD.second);
// Fix up any BlockAddresses that refer to the function.
Fn.replaceAllUsesWith(ConstantExpr::getBitCast(NF, Fn.getType()));
@@ -863,9 +866,6 @@ bool DeadArgumentEliminationPass::RemoveDeadStuffFromFunction(Function *F) {
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;
@@ -1058,6 +1058,12 @@ bool DeadArgumentEliminationPass::RemoveDeadStuffFromFunction(Function *F) {
BB.getInstList().erase(RI);
}
+ // Clone metadatas from the old function, including debug info descriptor.
+ SmallVector<std::pair<unsigned, MDNode *>, 1> MDs;
+ F->getAllMetadata(MDs);
+ for (auto MD : MDs)
+ NF->addMetadata(MD.first, *MD.second);
+
// Now that the old function is dead, delete it.
F->eraseFromParent();
OpenPOWER on IntegriCloud