summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-05-05 20:05:33 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-05-05 20:05:33 +0000
commit8eb3397a73d1968beec5bd984966de49ae94cdaf (patch)
treed7eb9e116a80545ce3c4a5b7ce191a968bcfeda0 /llvm/lib
parent62de33c2dbf0ff10e9eaf24c921509c2e8d836f4 (diff)
downloadbcm5719-llvm-8eb3397a73d1968beec5bd984966de49ae94cdaf.tar.gz
bcm5719-llvm-8eb3397a73d1968beec5bd984966de49ae94cdaf.zip
Degrade assertions to a warning in LTOCodeGenerator for preserved linkonce
The assertions were assuming that the linker will not ask to preserve a global that is internal or available_externally, as it does not really make sense. In practice this break the bootstrap of clang, I degrade to a warning for now. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 268671
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/LTO/LTOCodeGenerator.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index 1980965b169..a7dad55a819 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -351,7 +351,7 @@ std::unique_ptr<TargetMachine> LTOCodeGenerator::createTargetMachine() {
// If a linkonce global is present in the MustPreserveSymbols, we need to make
// sure we honor this. To force the compiler to not drop it, we add it to the
// "llvm.compiler.used" global.
-static void preserveDiscardableGVs(
+void LTOCodeGenerator::preserveDiscardableGVs(
Module &TheModule,
llvm::function_ref<bool(const GlobalValue &)> mustPreserveGV) {
SetVector<Constant *> UsedValuesSet;
@@ -368,7 +368,17 @@ static void preserveDiscardableGVs(
return;
if (!mustPreserveGV(GV))
return;
- assert(!GV.hasAvailableExternallyLinkage() && !GV.hasInternalLinkage());
+ if (GV.hasAvailableExternallyLinkage()) {
+ emitWarning(
+ (Twine("Linker asked to preserve available_externally global: '") +
+ GV.getName() + "'").str());
+ return;
+ }
+ if (GV.hasInternalLinkage()) {
+ emitWarning((Twine("Linker asked to preserve internal global: '") +
+ GV.getName() + "'").str());
+ return;
+ }
UsedValuesSet.insert(ConstantExpr::getBitCast(&GV, i8PTy));
};
for (auto &GV : TheModule)
@@ -643,3 +653,10 @@ void LTOCodeGenerator::emitError(const std::string &ErrMsg) {
else
Context.diagnose(LTODiagnosticInfo(ErrMsg));
}
+
+void LTOCodeGenerator::emitWarning(const std::string &ErrMsg) {
+ if (DiagHandler)
+ (*DiagHandler)(LTO_DS_WARNING, ErrMsg.c_str(), DiagContext);
+ else
+ Context.diagnose(LTODiagnosticInfo(ErrMsg, DS_Warning));
+}
OpenPOWER on IntegriCloud