summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/LTO/LTOCodeGenerator.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index 7f3d30a1e90..d0527b27b5c 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -374,21 +374,16 @@ void LTOCodeGenerator::preserveDiscardableGVs(
}
llvm::Type *i8PTy = llvm::Type::getInt8PtrTy(TheModule.getContext());
auto mayPreserveGlobal = [&](GlobalValue &GV) {
- if (!GV.isDiscardableIfUnused() || GV.isDeclaration())
+ if (!GV.isDiscardableIfUnused() || GV.isDeclaration() ||
+ !mustPreserveGV(GV))
return;
- if (!mustPreserveGV(GV))
- return;
- if (GV.hasAvailableExternallyLinkage()) {
- emitWarning(
+ if (GV.hasAvailableExternallyLinkage())
+ return emitWarning(
(Twine("Linker asked to preserve available_externally global: '") +
GV.getName() + "'").str());
- return;
- }
- if (GV.hasInternalLinkage()) {
- emitWarning((Twine("Linker asked to preserve internal global: '") +
+ if (GV.hasInternalLinkage())
+ return emitWarning((Twine("Linker asked to preserve internal global: '") +
GV.getName() + "'").str());
- return;
- }
UsedValuesSet.insert(ConstantExpr::getBitCast(&GV, i8PTy));
};
for (auto &GV : TheModule)
OpenPOWER on IntegriCloud