aboutsummaryrefslogtreecommitdiff
path: root/lib/Bitcode
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Bitcode')
-rw-r--r--lib/Bitcode/Reader/BitcodeReader.cpp25
-rw-r--r--lib/Bitcode/Writer/BitcodeWriter.cpp3
2 files changed, 28 insertions, 0 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index 3bd64a92d3..34114be946 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1547,6 +1547,14 @@ bool BitcodeReader::ParseModule(bool Resume) {
std::string S;
if (ConvertToString(Record, 0, S))
return Error("Invalid MODULE_CODE_TRIPLE record");
+
+ // @LOCALMOD-BEGIN
+ // This hack is needed in order to get Clang compiled binaries
+ // working with the Gold plugin, until PNaCl backend is introduced
+ // in lib/Target/PNaCl.
+ if (S == "le32-unknown-nacl")
+ S = "armv7-none-linux-gnueabi";
+ // @LOCALMOD-END
TheModule->setTargetTriple(S);
break;
}
@@ -2850,6 +2858,16 @@ bool BitcodeReader::isDematerializable(const GlobalValue *GV) const {
const Function *F = dyn_cast<Function>(GV);
if (!F || F->isDeclaration())
return false;
+ // @LOCALMOD-START
+ // Don't dematerialize functions with BBs which have their address taken;
+ // it will cause any referencing blockAddress constants to also be destroyed,
+ // but because they are GVs, they need to stay around until PassManager
+ // finalization.
+ for (Function::const_iterator BB = F->begin(); BB != F->end(); ++BB) {
+ if (BB->hasAddressTaken())
+ return false;
+ }
+ // @LOCALMOD-END
return DeferredFunctionInfo.count(const_cast<Function*>(F));
}
@@ -2981,6 +2999,8 @@ Module *llvm::getLazyBitcodeModule(MemoryBuffer *Buffer,
R->materializeForwardReferencedFunctions();
+ M->convertMetadataToLibraryList(); // @LOCALMOD
+
return M;
}
@@ -2999,6 +3019,11 @@ Module *llvm::getStreamedBitcodeModule(const std::string &name,
return 0;
}
R->setBufferOwned(false); // no buffer to delete
+
+ R->materializeForwardReferencedFunctions();
+
+ M->convertMetadataToLibraryList(); // @LOCALMOD
+
return M;
}
diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp
index 4ee762eae1..38fe5a8643 100644
--- a/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -1942,6 +1942,9 @@ void llvm::WriteBitcodeToFile(const Module *M, raw_ostream &Out) {
SmallVector<char, 0> Buffer;
Buffer.reserve(256*1024);
+ // Convert Deplib info to metadata
+ M->convertLibraryListToMetadata(); // @LOCALMOD
+
// If this is darwin or another generic macho target, reserve space for the
// header.
Triple TT(M->getTargetTriple());