summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2010-03-16 16:51:38 +0000
committerrdivacky <rdivacky@FreeBSD.org>2010-03-16 16:51:38 +0000
commit0f448b841684305c051796982f300c9bff959307 (patch)
tree458dd25677a43aef6390ecadb4423817f00e08b0 /tools
parent9e2446b38c94db61b2416c28fee415c03663c11c (diff)
downloadFreeBSD-src-0f448b841684305c051796982f300c9bff959307.zip
FreeBSD-src-0f448b841684305c051796982f300c9bff959307.tar.gz
Update LLVM to r98631.
Diffstat (limited to 'tools')
-rw-r--r--tools/bugpoint/ExecutionDriver.cpp12
-rw-r--r--tools/bugpoint/ToolRunner.cpp82
-rw-r--r--tools/bugpoint/ToolRunner.h12
-rw-r--r--tools/edis/EDDisassembler.cpp10
-rw-r--r--tools/llvm-mc/llvm-mc.cpp44
-rw-r--r--tools/lto/LTOCodeGenerator.cpp86
-rw-r--r--tools/lto/LTOModule.cpp6
7 files changed, 152 insertions, 100 deletions
diff --git a/tools/bugpoint/ExecutionDriver.cpp b/tools/bugpoint/ExecutionDriver.cpp
index feda331..7228c01 100644
--- a/tools/bugpoint/ExecutionDriver.cpp
+++ b/tools/bugpoint/ExecutionDriver.cpp
@@ -28,7 +28,7 @@ namespace {
// for miscompilation.
//
enum OutputType {
- AutoPick, RunLLI, RunJIT, RunLLC, RunCBE, CBE_bug, LLC_Safe, Custom
+ AutoPick, RunLLI, RunJIT, RunLLC, RunLLCIA, RunCBE, CBE_bug, LLC_Safe,Custom
};
cl::opt<double>
@@ -45,6 +45,8 @@ namespace {
"Execute with the interpreter"),
clEnumValN(RunJIT, "run-jit", "Execute with JIT"),
clEnumValN(RunLLC, "run-llc", "Compile with LLC"),
+ clEnumValN(RunLLCIA, "run-llc-ia",
+ "Compile with LLC with integrated assembler"),
clEnumValN(RunCBE, "run-cbe", "Compile with CBE"),
clEnumValN(CBE_bug,"cbe-bug", "Find CBE bugs"),
clEnumValN(LLC_Safe, "llc-safe", "Use LLC for all"),
@@ -168,9 +170,11 @@ bool BugDriver::initializeExecutionEnvironment() {
&ToolArgv);
break;
case RunLLC:
+ case RunLLCIA:
case LLC_Safe:
Interpreter = AbstractInterpreter::createLLC(getToolName(), Message,
- &ToolArgv, &GCCToolArgv);
+ &ToolArgv, &GCCToolArgv,
+ InterpreterSel == RunLLCIA);
break;
case RunJIT:
Interpreter = AbstractInterpreter::createJIT(getToolName(), Message,
@@ -244,10 +248,12 @@ bool BugDriver::initializeExecutionEnvironment() {
}
break;
case RunLLC:
+ case RunLLCIA:
SafeToolArgs.push_back("--relocation-model=pic");
SafeInterpreter = AbstractInterpreter::createLLC(Path.c_str(), Message,
&SafeToolArgs,
- &GCCToolArgv);
+ &GCCToolArgv,
+ SafeInterpreterSel == RunLLCIA);
break;
case RunCBE:
SafeInterpreter = AbstractInterpreter::createCBE(Path.c_str(), Message,
diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp
index 645776e..62df0f1 100644
--- a/tools/bugpoint/ToolRunner.cpp
+++ b/tools/bugpoint/ToolRunner.cpp
@@ -141,7 +141,7 @@ static void ProcessFailure(sys::Path ProgPath, const char** Args) {
for (const char **Arg = Args; *Arg; ++Arg)
OS << " " << *Arg;
OS << "\n";
-
+
// Rerun the compiler, capturing any error messages to print them.
sys::Path ErrorFilename("bugpoint.program_error_messages");
std::string ErrMsg;
@@ -352,7 +352,8 @@ AbstractInterpreter *AbstractInterpreter::createCustom(
//
GCC::FileType LLC::OutputCode(const std::string &Bitcode,
sys::Path &OutputAsmFile) {
- sys::Path uniqueFile(Bitcode+".llc.s");
+ const char *Suffix = (UseIntegratedAssembler ? ".llc.o" : ".llc.s");
+ sys::Path uniqueFile(Bitcode + Suffix);
std::string ErrMsg;
if (uniqueFile.makeUnique(true, &ErrMsg)) {
errs() << "Error making unique filename: " << ErrMsg << "\n";
@@ -360,18 +361,23 @@ GCC::FileType LLC::OutputCode(const std::string &Bitcode,
}
OutputAsmFile = uniqueFile;
std::vector<const char *> LLCArgs;
- LLCArgs.push_back (LLCPath.c_str());
+ LLCArgs.push_back(LLCPath.c_str());
// Add any extra LLC args.
for (unsigned i = 0, e = ToolArgs.size(); i != e; ++i)
LLCArgs.push_back(ToolArgs[i].c_str());
- LLCArgs.push_back ("-o");
- LLCArgs.push_back (OutputAsmFile.c_str()); // Output to the Asm file
- LLCArgs.push_back (Bitcode.c_str()); // This is the input bitcode
+ LLCArgs.push_back("-o");
+ LLCArgs.push_back(OutputAsmFile.c_str()); // Output to the Asm file
+ LLCArgs.push_back(Bitcode.c_str()); // This is the input bitcode
+
+ if (UseIntegratedAssembler)
+ LLCArgs.push_back("-filetype=obj");
+
LLCArgs.push_back (0);
- outs() << "<llc>"; outs().flush();
+ outs() << (UseIntegratedAssembler ? "<llc-ia>" : "<llc>");
+ outs().flush();
DEBUG(errs() << "\nAbout to run:\t";
for (unsigned i=0, e = LLCArgs.size()-1; i != e; ++i)
errs() << " " << LLCArgs[i];
@@ -381,7 +387,7 @@ GCC::FileType LLC::OutputCode(const std::string &Bitcode,
sys::Path(), sys::Path(), sys::Path()))
ProcessFailure(sys::Path(LLCPath), &LLCArgs[0]);
- return GCC::AsmFile;
+ return UseIntegratedAssembler ? GCC::ObjectFile : GCC::AsmFile;
}
void LLC::compileProgram(const std::string &Bitcode) {
@@ -400,7 +406,7 @@ int LLC::ExecuteProgram(const std::string &Bitcode,
unsigned MemoryLimit) {
sys::Path OutputAsmFile;
- OutputCode(Bitcode, OutputAsmFile);
+ GCC::FileType FileKind = OutputCode(Bitcode, OutputAsmFile);
FileRemover OutFileRemover(OutputAsmFile, !SaveTemps);
std::vector<std::string> GCCArgs(ArgsForGCC);
@@ -408,7 +414,7 @@ int LLC::ExecuteProgram(const std::string &Bitcode,
GCCArgs.insert(GCCArgs.end(), gccArgs.begin(), gccArgs.end());
// Assuming LLC worked, compile the result with GCC and run it.
- return gcc->ExecuteProgram(OutputAsmFile.str(), Args, GCC::AsmFile,
+ return gcc->ExecuteProgram(OutputAsmFile.str(), Args, FileKind,
InputFile, OutputFile, GCCArgs,
Timeout, MemoryLimit);
}
@@ -418,7 +424,8 @@ int LLC::ExecuteProgram(const std::string &Bitcode,
LLC *AbstractInterpreter::createLLC(const char *Argv0,
std::string &Message,
const std::vector<std::string> *Args,
- const std::vector<std::string> *GCCArgs) {
+ const std::vector<std::string> *GCCArgs,
+ bool UseIntegratedAssembler) {
std::string LLCPath =
FindExecutable("llc", Argv0, (void *)(intptr_t)&createLLC).str();
if (LLCPath.empty()) {
@@ -432,7 +439,7 @@ LLC *AbstractInterpreter::createLLC(const char *Argv0,
errs() << Message << "\n";
exit(1);
}
- return new LLC(LLCPath, gcc, Args, GCCArgs);
+ return new LLC(LLCPath, gcc, Args, GCCArgs, UseIntegratedAssembler);
}
//===---------------------------------------------------------------------===//
@@ -605,17 +612,14 @@ CBE *AbstractInterpreter::createCBE(const char *Argv0,
// GCC abstraction
//
-static bool
-IsARMArchitecture(std::vector<std::string> Args)
-{
+static bool IsARMArchitecture(std::vector<std::string> Args) {
for (std::vector<std::string>::const_iterator
I = Args.begin(), E = Args.end(); I != E; ++I) {
StringRef S(*I);
if (!S.equals_lower("-arch")) {
++I;
- if (I != E && !S.substr(0, strlen("arm")).equals_lower("arm")) {
+ if (I != E && !S.substr(0, strlen("arm")).equals_lower("arm"))
return true;
- }
}
}
@@ -634,26 +638,33 @@ int GCC::ExecuteProgram(const std::string &ProgramFile,
GCCArgs.push_back(GCCPath.c_str());
+ if (TargetTriple.getArch() == Triple::x86)
+ GCCArgs.push_back("-m32");
+
for (std::vector<std::string>::const_iterator
I = gccArgs.begin(), E = gccArgs.end(); I != E; ++I)
GCCArgs.push_back(I->c_str());
// Specify -x explicitly in case the extension is wonky
- GCCArgs.push_back("-x");
- if (fileType == CFile) {
- GCCArgs.push_back("c");
- GCCArgs.push_back("-fno-strict-aliasing");
- } else {
- GCCArgs.push_back("assembler");
-
- // For ARM architectures we don't want this flag. bugpoint isn't
- // explicitly told what architecture it is working on, so we get
- // it from gcc flags
- if ((TargetTriple.getOS() == Triple::Darwin) &&
- !IsARMArchitecture(ArgsForGCC))
- GCCArgs.push_back("-force_cpusubtype_ALL");
+ if (fileType != ObjectFile) {
+ GCCArgs.push_back("-x");
+ if (fileType == CFile) {
+ GCCArgs.push_back("c");
+ GCCArgs.push_back("-fno-strict-aliasing");
+ } else {
+ GCCArgs.push_back("assembler");
+
+ // For ARM architectures we don't want this flag. bugpoint isn't
+ // explicitly told what architecture it is working on, so we get
+ // it from gcc flags
+ if ((TargetTriple.getOS() == Triple::Darwin) &&
+ !IsARMArchitecture(ArgsForGCC))
+ GCCArgs.push_back("-force_cpusubtype_ALL");
+ }
}
- GCCArgs.push_back(ProgramFile.c_str()); // Specify the input filename...
+
+ GCCArgs.push_back(ProgramFile.c_str()); // Specify the input filename.
+
GCCArgs.push_back("-x");
GCCArgs.push_back("none");
GCCArgs.push_back("-o");
@@ -765,13 +776,18 @@ int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType,
GCCArgs.push_back(GCCPath.c_str());
+ if (TargetTriple.getArch() == Triple::x86)
+ GCCArgs.push_back("-m32");
+
for (std::vector<std::string>::const_iterator
I = gccArgs.begin(), E = gccArgs.end(); I != E; ++I)
GCCArgs.push_back(I->c_str());
// Compile the C/asm file into a shared object
- GCCArgs.push_back("-x");
- GCCArgs.push_back(fileType == AsmFile ? "assembler" : "c");
+ if (fileType != ObjectFile) {
+ GCCArgs.push_back("-x");
+ GCCArgs.push_back(fileType == AsmFile ? "assembler" : "c");
+ }
GCCArgs.push_back("-fno-strict-aliasing");
GCCArgs.push_back(InputFile.c_str()); // Specify the input filename.
GCCArgs.push_back("-x");
diff --git a/tools/bugpoint/ToolRunner.h b/tools/bugpoint/ToolRunner.h
index 39b0bbf..0f75e99 100644
--- a/tools/bugpoint/ToolRunner.h
+++ b/tools/bugpoint/ToolRunner.h
@@ -58,7 +58,7 @@ class GCC {
if (GCCArgs) gccArgs = *GCCArgs;
}
public:
- enum FileType { AsmFile, CFile };
+ enum FileType { AsmFile, ObjectFile, CFile };
static GCC *create(std::string &Message,
const std::vector<std::string> *Args);
@@ -101,7 +101,8 @@ public:
const std::vector<std::string> *GCCArgs = 0);
static LLC *createLLC(const char *Argv0, std::string &Message,
const std::vector<std::string> *Args = 0,
- const std::vector<std::string> *GCCArgs = 0);
+ const std::vector<std::string> *GCCArgs = 0,
+ bool UseIntegratedAssembler = false);
static AbstractInterpreter* createLLI(const char *Argv0, std::string &Message,
const std::vector<std::string> *Args=0);
@@ -195,11 +196,14 @@ class LLC : public AbstractInterpreter {
std::vector<std::string> ToolArgs; // Extra args to pass to LLC.
std::vector<std::string> gccArgs; // Extra args to pass to GCC.
GCC *gcc;
+ bool UseIntegratedAssembler;
public:
LLC(const std::string &llcPath, GCC *Gcc,
const std::vector<std::string> *Args,
- const std::vector<std::string> *GCCArgs)
- : LLCPath(llcPath), gcc(Gcc) {
+ const std::vector<std::string> *GCCArgs,
+ bool useIntegratedAssembler)
+ : LLCPath(llcPath), gcc(Gcc),
+ UseIntegratedAssembler(useIntegratedAssembler) {
ToolArgs.clear();
if (Args) ToolArgs = *Args;
if (GCCArgs) gccArgs = *GCCArgs;
diff --git a/tools/edis/EDDisassembler.cpp b/tools/edis/EDDisassembler.cpp
index 99864fb..f2b2f91 100644
--- a/tools/edis/EDDisassembler.cpp
+++ b/tools/edis/EDDisassembler.cpp
@@ -341,19 +341,17 @@ int EDDisassembler::parseInst(SmallVectorImpl<MCParsedAsmOperand*> &operands,
SourceMgr sourceMgr;
sourceMgr.AddNewSourceBuffer(buf, SMLoc()); // ownership of buf handed over
- MCContext context;
- OwningPtr<MCStreamer> streamer
- (createNullStreamer(context));
+ MCContext context(*AsmInfo);
+ OwningPtr<MCStreamer> streamer(createNullStreamer(context));
AsmParser genericParser(sourceMgr, context, *streamer, *AsmInfo);
- OwningPtr<TargetAsmParser> specificParser
- (Tgt->createAsmParser(genericParser));
+ OwningPtr<TargetAsmParser> TargetParser(Tgt->createAsmParser(genericParser));
AsmToken OpcodeToken = genericParser.Lex();
if(OpcodeToken.is(AsmToken::Identifier)) {
instName = OpcodeToken.getString();
instLoc = OpcodeToken.getLoc();
- if (specificParser->ParseInstruction(instName, instLoc, operands))
+ if (TargetParser->ParseInstruction(instName, instLoc, operands))
ret = -1;
}
else {
diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp
index 76ce080..66e1260 100644
--- a/tools/llvm-mc/llvm-mc.cpp
+++ b/tools/llvm-mc/llvm-mc.cpp
@@ -26,7 +26,9 @@
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/System/Host.h"
#include "llvm/System/Signals.h"
+#include "llvm/Target/TargetAsmBackend.h"
#include "llvm/Target/TargetAsmParser.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetRegistry.h"
@@ -75,9 +77,16 @@ IncludeDirs("I", cl::desc("Directory of include files"),
cl::value_desc("directory"), cl::Prefix);
static cl::opt<std::string>
+ArchName("arch", cl::desc("Target arch to assemble for, "
+ "see -version for available targets"));
+
+static cl::opt<std::string>
TripleName("triple", cl::desc("Target triple to assemble for, "
- "see -version for available targets"),
- cl::init(LLVM_HOSTTRIPLE));
+ "see -version for available targets"));
+
+static cl::opt<bool>
+NoInitialTextSection("n", cl::desc(
+ "Don't assume assembly file starts in the text section"));
enum ActionType {
AC_AsLex,
@@ -97,6 +106,15 @@ Action(cl::desc("Action to perform:"),
clEnumValEnd));
static const Target *GetTarget(const char *ProgName) {
+ // Figure out the target triple.
+ if (TripleName.empty())
+ TripleName = sys::getHostTriple();
+ if (!ArchName.empty()) {
+ llvm::Triple TT(TripleName);
+ TT.setArchName(ArchName);
+ TripleName = TT.str();
+ }
+
// Get the target specific parser.
std::string Error;
const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, Error);
@@ -241,7 +259,11 @@ static int AssembleInput(const char *ProgName) {
// it later.
SrcMgr.setIncludeDirs(IncludeDirs);
- MCContext Ctx;
+
+ const MCAsmInfo *MAI = TheTarget->createAsmInfo(TripleName);
+ assert(MAI && "Unable to create target asm info!");
+
+ MCContext Ctx(*MAI);
formatted_raw_ostream *Out = GetOutputStream();
if (!Out)
return 1;
@@ -259,22 +281,20 @@ static int AssembleInput(const char *ProgName) {
OwningPtr<MCInstPrinter> IP;
OwningPtr<MCCodeEmitter> CE;
OwningPtr<MCStreamer> Str;
-
- const MCAsmInfo *MAI = TheTarget->createAsmInfo(TripleName);
- assert(MAI && "Unable to create target asm info!");
+ OwningPtr<TargetAsmBackend> TAB;
if (FileType == OFT_AssemblyFile) {
IP.reset(TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI, *Out));
if (ShowEncoding)
CE.reset(TheTarget->createCodeEmitter(*TM, Ctx));
- Str.reset(createAsmStreamer(Ctx, *Out, *MAI,
- TM->getTargetData()->isLittleEndian(),
+ Str.reset(createAsmStreamer(Ctx, *Out,TM->getTargetData()->isLittleEndian(),
/*asmverbose*/true, IP.get(), CE.get(),
ShowInst));
} else {
assert(FileType == OFT_ObjectFile && "Invalid file type!");
CE.reset(TheTarget->createCodeEmitter(*TM, Ctx));
- Str.reset(createMachOStreamer(Ctx, *Out, CE.get()));
+ TAB.reset(TheTarget->createAsmBackend(TripleName));
+ Str.reset(createMachOStreamer(Ctx, *TAB, *Out, CE.get()));
}
AsmParser Parser(SrcMgr, Ctx, *Str.get(), *MAI);
@@ -287,10 +307,14 @@ static int AssembleInput(const char *ProgName) {
Parser.setTargetParser(*TAP.get());
- int Res = Parser.Run();
+ int Res = Parser.Run(NoInitialTextSection);
if (Out != &fouts())
delete Out;
+ // Delete output on errors.
+ if (Res && OutputFilename != "-")
+ sys::Path(OutputFilename).eraseFromDisk();
+
return Res;
}
diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp
index 0a58aa7..15753d3 100644
--- a/tools/lto/LTOCodeGenerator.cpp
+++ b/tools/lto/LTOCodeGenerator.cpp
@@ -27,24 +27,25 @@
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/Bitcode/ReaderWriter.h"
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/FormattedStream.h"
-#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/StandardPasses.h"
-#include "llvm/Support/SystemUtils.h"
-#include "llvm/System/Host.h"
-#include "llvm/System/Program.h"
-#include "llvm/System/Signals.h"
+#include "llvm/MC/MCAsmInfo.h"
+#include "llvm/MC/MCContext.h"
#include "llvm/Target/Mangler.h"
#include "llvm/Target/SubtargetFeature.h"
#include "llvm/Target/TargetOptions.h"
-#include "llvm/MC/MCAsmInfo.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetRegistry.h"
#include "llvm/Target/TargetSelect.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Scalar.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FormattedStream.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/StandardPasses.h"
+#include "llvm/Support/SystemUtils.h"
+#include "llvm/System/Host.h"
+#include "llvm/System/Program.h"
+#include "llvm/System/Signals.h"
#include "llvm/Config/config.h"
#include <cstdlib>
#include <unistd.h>
@@ -252,7 +253,8 @@ bool LTOCodeGenerator::assemble(const std::string& asmPath,
args.push_back(arch);
}
// add -static to assembler command line when code model requires
- if ( (_assemblerPath != NULL) && (_codeModel == LTO_CODEGEN_PIC_MODEL_STATIC) )
+ if ( (_assemblerPath != NULL) &&
+ (_codeModel == LTO_CODEGEN_PIC_MODEL_STATIC) )
args.push_back("-static");
}
if ( needsCompilerOptions ) {
@@ -303,44 +305,44 @@ bool LTOCodeGenerator::determineTarget(std::string& errMsg)
// construct LTModule, hand over ownership of module and target
const std::string FeatureStr =
- SubtargetFeatures::getDefaultSubtargetFeatures(llvm::Triple(Triple));
+ SubtargetFeatures::getDefaultSubtargetFeatures(llvm::Triple(Triple));
_target = march->createTargetMachine(Triple, FeatureStr);
}
return false;
}
-void LTOCodeGenerator::applyScopeRestrictions()
-{
- if ( !_scopeRestrictionsDone ) {
- Module* mergedModule = _linker.getModule();
-
- // Start off with a verification pass.
- PassManager passes;
- passes.add(createVerifierPass());
-
- // mark which symbols can not be internalized
- if ( !_mustPreserveSymbols.empty() ) {
- Mangler mangler(*_target->getMCAsmInfo());
- std::vector<const char*> mustPreserveList;
- for (Module::iterator f = mergedModule->begin(),
- e = mergedModule->end(); f != e; ++f) {
- if ( !f->isDeclaration()
- && _mustPreserveSymbols.count(mangler.getNameWithPrefix(f)) )
- mustPreserveList.push_back(::strdup(f->getNameStr().c_str()));
- }
- for (Module::global_iterator v = mergedModule->global_begin(),
- e = mergedModule->global_end(); v != e; ++v) {
- if ( !v->isDeclaration()
- && _mustPreserveSymbols.count(mangler.getNameWithPrefix(v)) )
- mustPreserveList.push_back(::strdup(v->getNameStr().c_str()));
- }
- passes.add(createInternalizePass(mustPreserveList));
- }
- // apply scope restrictions
- passes.run(*mergedModule);
-
- _scopeRestrictionsDone = true;
+void LTOCodeGenerator::applyScopeRestrictions() {
+ if (_scopeRestrictionsDone) return;
+ Module *mergedModule = _linker.getModule();
+
+ // Start off with a verification pass.
+ PassManager passes;
+ passes.add(createVerifierPass());
+
+ // mark which symbols can not be internalized
+ if (!_mustPreserveSymbols.empty()) {
+ MCContext Context(*_target->getMCAsmInfo());
+ Mangler mangler(Context, *_target->getTargetData());
+ std::vector<const char*> mustPreserveList;
+ for (Module::iterator f = mergedModule->begin(),
+ e = mergedModule->end(); f != e; ++f) {
+ if (!f->isDeclaration() &&
+ _mustPreserveSymbols.count(mangler.getNameWithPrefix(f)))
+ mustPreserveList.push_back(::strdup(f->getNameStr().c_str()));
+ }
+ for (Module::global_iterator v = mergedModule->global_begin(),
+ e = mergedModule->global_end(); v != e; ++v) {
+ if (v->isDeclaration() &&
+ _mustPreserveSymbols.count(mangler.getNameWithPrefix(v)))
+ mustPreserveList.push_back(::strdup(v->getNameStr().c_str()));
}
+ passes.add(createInternalizePass(mustPreserveList));
+ }
+
+ // apply scope restrictions
+ passes.run(*mergedModule);
+
+ _scopeRestrictionsDone = true;
}
/// Optimize merged modules using various IPO passes
diff --git a/tools/lto/LTOModule.cpp b/tools/lto/LTOModule.cpp
index 15fb3f5..08576ab 100644
--- a/tools/lto/LTOModule.cpp
+++ b/tools/lto/LTOModule.cpp
@@ -1,4 +1,4 @@
-//===-LTOModule.cpp - LLVM Link Time Optimizer ----------------------------===//
+//===-- LTOModule.cpp - LLVM Link Time Optimizer --------------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -29,6 +29,7 @@
#include "llvm/Target/Mangler.h"
#include "llvm/Target/SubtargetFeature.h"
#include "llvm/MC/MCAsmInfo.h"
+#include "llvm/MC/MCContext.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetRegistry.h"
#include "llvm/Target/TargetSelect.h"
@@ -437,7 +438,8 @@ void LTOModule::lazyParseSymbols()
_symbolsParsed = true;
// Use mangler to add GlobalPrefix to names to match linker names.
- Mangler mangler(*_target->getMCAsmInfo());
+ MCContext Context(*_target->getMCAsmInfo());
+ Mangler mangler(Context, *_target->getTargetData());
// add functions
for (Module::iterator f = _module->begin(); f != _module->end(); ++f) {
OpenPOWER on IntegriCloud