diff options
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/IPO/GlobalOpt.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp index 52c1cc5d279..f1686a0a615 100644 --- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp +++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp @@ -1653,7 +1653,7 @@ static bool deleteIfDead(GlobalValue &GV, SmallSet<const Comdat *, 8> &NotDiscardableComdats) { GV.removeDeadConstantUsers(); - if (!GV.isDiscardableIfUnused()) + if (!GV.isDiscardableIfUnused() && !GV.isDeclaration()) return false; if (const Comdat *C = GV.getComdat()) @@ -1662,7 +1662,7 @@ static bool deleteIfDead(GlobalValue &GV, bool Dead; if (auto *F = dyn_cast<Function>(&GV)) - Dead = F->isDefTriviallyDead(); + Dead = (F->isDeclaration() && F->use_empty()) || F->isDefTriviallyDead(); else Dead = GV.use_empty(); if (!Dead) |

