diff options
author | Derek Schuff <dschuff@chromium.org> | 2012-07-09 10:52:46 -0700 |
---|---|---|
committer | Derek Schuff <dschuff@chromium.org> | 2012-07-09 11:00:37 -0700 |
commit | 5dbcc7e0c9c12f4a4042fb4a226654aee927999c (patch) | |
tree | b316a3370e9286cb4e6f81b2f9d8bd8b54ce5123 /lib/Linker | |
parent | 86dc97be9ac3b4804528e087b04b4f4192cdee54 (diff) |
LOCALMODs from hg 0b098ca44de7 against r158408 (hg 90a87d6bfe45)
(only non-new files; new files in git 4f429c8b)
Change-Id: Ia39f818088485bd90e4d048db404f8d6ba5f836b
Diffstat (limited to 'lib/Linker')
-rw-r--r-- | lib/Linker/LinkArchives.cpp | 19 | ||||
-rw-r--r-- | lib/Linker/LinkModules.cpp | 20 |
2 files changed, 38 insertions, 1 deletions
diff --git a/lib/Linker/LinkArchives.cpp b/lib/Linker/LinkArchives.cpp index c16d1958cd..c5656a54c9 100644 --- a/lib/Linker/LinkArchives.cpp +++ b/lib/Linker/LinkArchives.cpp @@ -16,10 +16,24 @@ #include "llvm/Module.h" #include "llvm/ADT/SetOperations.h" #include "llvm/Bitcode/Archive.h" + +#include "llvm/Support/CommandLine.h" // @LOCALMOD + #include <memory> #include <set> using namespace llvm; +// @LOCALMOD-START +// NOTE: this has a similar effect as +// tools/llvm/llvm-preserve.ll +// which in turn is similar to the GNUS's attribute((used)) +// TODO(robertm): This is a little hackish for now +static cl::list<std::string> +UndefList("referenced-list", cl::value_desc("list"), + cl::desc("A list of symbols assumed to be referenced externally"), + cl::CommaSeparated); +// @LOCALMOD-END + /// GetAllUndefinedSymbols - calculates the set of undefined symbols that still /// exist in an LLVM module. This is a bit tricky because there may be two /// symbols with the same name but different LLVM types that will be resolved to @@ -36,7 +50,10 @@ static void GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) { std::set<std::string> DefinedSymbols; UndefinedSymbols.clear(); - + // @LOCALMOD-START + UndefinedSymbols.insert(UndefList.begin(), UndefList.end()); + // @LOCALMOD-END + // If the program doesn't define a main, try pulling one in from a .a file. // This is needed for programs where the main function is defined in an // archive, such f2c'd programs. diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index 7293f3d0e8..aec2547f00 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -932,6 +932,19 @@ void ModuleLinker::linkFunctionBody(Function *Dst, Function *Src) { ValueMap[I] = DI; } + // @LOCALMOD-BEGIN + // Local patch for http://llvm.org/bugs/show_bug.cgi?id=11112 + // and http://llvm.org/bugs/show_bug.cgi?id=10887 + // Create an identity mapping for instructions so that alloca instructions + // do not get dropped and related debug info isn't lost. E.g., prevent + // call @llvm.dbg.declare(metadata !{i32 * %local_var}, ...) + // from becoming + // call @llvm.dbg.declare(null, ...) + for (Function::iterator BB = Src->begin(), BE = Src->end(); BB != BE; ++BB) + for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) + ValueMap[I] = I; + // @LOCALMOD-END + if (Mode == Linker::DestroySource) { // Splice the body of the source function into the dest function. Dst->getBasicBlockList().splice(Dst->end(), Src->getBasicBlockList()); @@ -949,6 +962,13 @@ void ModuleLinker::linkFunctionBody(Function *Dst, Function *Src) { SmallVector<ReturnInst*, 8> Returns; // Ignore returns. CloneFunctionInto(Dst, Src, ValueMap, false, Returns, "", NULL, &TypeMap); } + + // @LOCALMOD-BEGIN + // There is no need for the identity mapping anymore. + for (Function::iterator BB = Src->begin(), BE = Src->end(); BB != BE; ++BB) + for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) + ValueMap.erase(I); + // @LOCALMOD-END // There is no need to map the arguments anymore. for (Function::arg_iterator I = Src->arg_begin(), E = Src->arg_end(); |