From 1e3dec662ea18131c495db50caccc57f77b7a5fe Mon Sep 17 00:00:00 2001 From: rdivacky Date: Thu, 27 May 2010 15:15:58 +0000 Subject: Update LLVM to r104832. --- tools/bugpoint/ExecutionDriver.cpp | 29 +++++++---- tools/bugpoint/Miscompilation.cpp | 14 ++--- tools/bugpoint/ToolRunner.cpp | 57 ++++++++++++-------- tools/bugpoint/ToolRunner.h | 27 ++++++---- tools/edis/EDInst.cpp | 4 +- tools/gold/Makefile | 2 +- tools/gold/gold-plugin.cpp | 14 +++++ tools/llc/llc.cpp | 104 ++++++++++++------------------------- tools/llvm-ld/llvm-ld.cpp | 2 - tools/llvm-mc/Disassembler.cpp | 7 +++ tools/llvm-mc/llvm-mc.cpp | 13 +++-- tools/lto/LTOCodeGenerator.cpp | 5 +- tools/lto/LTOModule.cpp | 5 +- tools/opt/opt.cpp | 20 +++---- 14 files changed, 161 insertions(+), 142 deletions(-) (limited to 'tools') diff --git a/tools/bugpoint/ExecutionDriver.cpp b/tools/bugpoint/ExecutionDriver.cpp index 9eb3314..57f12d5 100644 --- a/tools/bugpoint/ExecutionDriver.cpp +++ b/tools/bugpoint/ExecutionDriver.cpp @@ -118,6 +118,10 @@ namespace { cl::desc("..."), cl::ZeroOrMore, cl::PositionalEatsArgs); + cl::opt + GCCBinary("gcc", cl::init("gcc"), + cl::desc("The gcc binary to use. (default 'gcc')")); + cl::list GCCToolArgv("gcc-tool-args", cl::Positional, cl::desc("..."), @@ -143,8 +147,8 @@ bool BugDriver::initializeExecutionEnvironment() { case AutoPick: InterpreterSel = RunCBE; Interpreter = - AbstractInterpreter::createCBE(getToolName(), Message, &ToolArgv, - &GCCToolArgv); + AbstractInterpreter::createCBE(getToolName(), Message, GCCBinary, + &ToolArgv, &GCCToolArgv); if (!Interpreter) { InterpreterSel = RunJIT; Interpreter = AbstractInterpreter::createJIT(getToolName(), Message, @@ -153,7 +157,8 @@ bool BugDriver::initializeExecutionEnvironment() { if (!Interpreter) { InterpreterSel = RunLLC; Interpreter = AbstractInterpreter::createLLC(getToolName(), Message, - &ToolArgv, &GCCToolArgv); + GCCBinary, &ToolArgv, + &GCCToolArgv); } if (!Interpreter) { InterpreterSel = RunLLI; @@ -173,7 +178,8 @@ bool BugDriver::initializeExecutionEnvironment() { case RunLLCIA: case LLC_Safe: Interpreter = AbstractInterpreter::createLLC(getToolName(), Message, - &ToolArgv, &GCCToolArgv, + GCCBinary, &ToolArgv, + &GCCToolArgv, InterpreterSel == RunLLCIA); break; case RunJIT: @@ -183,7 +189,8 @@ bool BugDriver::initializeExecutionEnvironment() { case RunCBE: case CBE_bug: Interpreter = AbstractInterpreter::createCBE(getToolName(), Message, - &ToolArgv, &GCCToolArgv); + GCCBinary, &ToolArgv, + &GCCToolArgv); break; case Custom: Interpreter = AbstractInterpreter::createCustom(Message, CustomExecCommand); @@ -209,6 +216,7 @@ bool BugDriver::initializeExecutionEnvironment() { SafeInterpreterSel = RunLLC; SafeToolArgs.push_back("--relocation-model=pic"); SafeInterpreter = AbstractInterpreter::createLLC(Path.c_str(), Message, + GCCBinary, &SafeToolArgs, &GCCToolArgv); } @@ -219,6 +227,7 @@ bool BugDriver::initializeExecutionEnvironment() { SafeInterpreterSel = RunLLC; SafeToolArgs.push_back("--relocation-model=pic"); SafeInterpreter = AbstractInterpreter::createLLC(Path.c_str(), Message, + GCCBinary, &SafeToolArgs, &GCCToolArgv); } @@ -230,6 +239,7 @@ bool BugDriver::initializeExecutionEnvironment() { InterpreterSel != RunCBE) { SafeInterpreterSel = RunCBE; SafeInterpreter = AbstractInterpreter::createCBE(Path.c_str(), Message, + GCCBinary, &SafeToolArgs, &GCCToolArgv); } @@ -239,6 +249,7 @@ bool BugDriver::initializeExecutionEnvironment() { SafeInterpreterSel = RunLLC; SafeToolArgs.push_back("--relocation-model=pic"); SafeInterpreter = AbstractInterpreter::createLLC(Path.c_str(), Message, + GCCBinary, &SafeToolArgs, &GCCToolArgv); } @@ -251,13 +262,13 @@ bool BugDriver::initializeExecutionEnvironment() { case RunLLCIA: SafeToolArgs.push_back("--relocation-model=pic"); SafeInterpreter = AbstractInterpreter::createLLC(Path.c_str(), Message, - &SafeToolArgs, + GCCBinary, &SafeToolArgs, &GCCToolArgv, SafeInterpreterSel == RunLLCIA); break; case RunCBE: SafeInterpreter = AbstractInterpreter::createCBE(Path.c_str(), Message, - &SafeToolArgs, + GCCBinary, &SafeToolArgs, &GCCToolArgv); break; case Custom: @@ -271,7 +282,7 @@ bool BugDriver::initializeExecutionEnvironment() { } if (!SafeInterpreter) { outs() << Message << "\nExiting.\n"; exit(1); } - gcc = GCC::create(Message, &GCCToolArgv); + gcc = GCC::create(Message, GCCBinary, &GCCToolArgv); if (!gcc) { outs() << Message << "\nExiting.\n"; exit(1); } // If there was an error creating the selected interpreter, quit with error. @@ -301,7 +312,7 @@ void BugDriver::compileProgram(Module *M, std::string *Error) { FileRemover BitcodeFileRemover(BitcodeFile, !SaveTemps); // Actually compile the program! - Interpreter->compileProgram(BitcodeFile.str(), Error); + Interpreter->compileProgram(BitcodeFile.str(), Error, Timeout, MemoryLimit); } diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp index 45bb745..71484a2 100644 --- a/tools/bugpoint/Miscompilation.cpp +++ b/tools/bugpoint/Miscompilation.cpp @@ -126,7 +126,8 @@ ReduceMiscompilingPasses::doTest(std::vector &Prefix, // Ok, so now we know that the prefix passes work, try running the suffix // passes on the result of the prefix passes. // - Module *PrefixOutput = ParseInputFile(BitcodeResult, BD.getContext()); + OwningPtr PrefixOutput(ParseInputFile(BitcodeResult, + BD.getContext())); if (PrefixOutput == 0) { errs() << BD.getToolName() << ": Error reading bitcode file '" << BitcodeResult << "'!\n"; @@ -142,7 +143,7 @@ ReduceMiscompilingPasses::doTest(std::vector &Prefix, << "' passes compile correctly after the '" << getPassesString(Prefix) << "' passes: "; - Module *OriginalInput = BD.swapProgramIn(PrefixOutput); + OwningPtr OriginalInput(BD.swapProgramIn(PrefixOutput.take())); if (BD.runPasses(Suffix, BitcodeResult, false/*delete*/, true/*quiet*/)) { errs() << " Error running this sequence of passes" << " on the input program!\n"; @@ -157,13 +158,13 @@ ReduceMiscompilingPasses::doTest(std::vector &Prefix, return InternalError; if (Diff) { outs() << " nope.\n"; - delete OriginalInput; // We pruned down the original input... return KeepSuffix; } // Otherwise, we must not be running the bad pass anymore. outs() << " yup.\n"; // No miscompilation! - delete BD.swapProgramIn(OriginalInput); // Restore orig program & free test + // Restore orig program & free test. + delete BD.swapProgramIn(OriginalInput.take()); return NoFailure; } @@ -222,15 +223,14 @@ static bool TestMergedProgram(BugDriver &BD, Module *M1, Module *M2, } delete M2; // We are done with this module. - Module *OldProgram = BD.swapProgramIn(M1); + OwningPtr OldProgram(BD.swapProgramIn(M1)); // Execute the program. If it does not match the expected output, we must // return true. bool Broken = BD.diffProgram("", "", false, &Error); if (!Error.empty()) { // Delete the linked module & restore the original - BD.swapProgramIn(OldProgram); - delete M1; + delete BD.swapProgramIn(OldProgram.take()); } return Broken; } diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp index 7ade778..3149a7a 100644 --- a/tools/bugpoint/ToolRunner.cpp +++ b/tools/bugpoint/ToolRunner.cpp @@ -133,7 +133,9 @@ static int RunProgramRemotelyWithTimeout(const sys::Path &RemoteClientPath, return ReturnCode; } -static std::string ProcessFailure(sys::Path ProgPath, const char** Args) { +static std::string ProcessFailure(sys::Path ProgPath, const char** Args, + unsigned Timeout = 0, + unsigned MemoryLimit = 0) { std::ostringstream OS; OS << "\nError running tool:\n "; for (const char **Arg = Args; *Arg; ++Arg) @@ -148,7 +150,8 @@ static std::string ProcessFailure(sys::Path ProgPath, const char** Args) { exit(1); } RunProgramWithTimeout(ProgPath, Args, sys::Path(""), ErrorFilename, - ErrorFilename); // FIXME: check return code ? + ErrorFilename, Timeout, MemoryLimit); + // FIXME: check return code ? // Print out the error messages generated by GCC if possible... std::ifstream ErrorFile(ErrorFilename.c_str()); @@ -353,7 +356,8 @@ AbstractInterpreter *AbstractInterpreter::createCustom( // LLC Implementation of AbstractIntepreter interface // GCC::FileType LLC::OutputCode(const std::string &Bitcode, - sys::Path &OutputAsmFile, std::string &Error) { + sys::Path &OutputAsmFile, std::string &Error, + unsigned Timeout, unsigned MemoryLimit) { const char *Suffix = (UseIntegratedAssembler ? ".llc.o" : ".llc.s"); sys::Path uniqueFile(Bitcode + Suffix); std::string ErrMsg; @@ -386,14 +390,17 @@ GCC::FileType LLC::OutputCode(const std::string &Bitcode, errs() << "\n"; ); if (RunProgramWithTimeout(sys::Path(LLCPath), &LLCArgs[0], - sys::Path(), sys::Path(), sys::Path())) - Error = ProcessFailure(sys::Path(LLCPath), &LLCArgs[0]); + sys::Path(), sys::Path(), sys::Path(), + Timeout, MemoryLimit)) + Error = ProcessFailure(sys::Path(LLCPath), &LLCArgs[0], + Timeout, MemoryLimit); return UseIntegratedAssembler ? GCC::ObjectFile : GCC::AsmFile; } -void LLC::compileProgram(const std::string &Bitcode, std::string *Error) { +void LLC::compileProgram(const std::string &Bitcode, std::string *Error, + unsigned Timeout, unsigned MemoryLimit) { sys::Path OutputAsmFile; - OutputCode(Bitcode, OutputAsmFile, *Error); + OutputCode(Bitcode, OutputAsmFile, *Error, Timeout, MemoryLimit); OutputAsmFile.eraseFromDisk(); } @@ -408,12 +415,12 @@ int LLC::ExecuteProgram(const std::string &Bitcode, unsigned MemoryLimit) { sys::Path OutputAsmFile; - GCC::FileType FileKind = OutputCode(Bitcode, OutputAsmFile, *Error); + GCC::FileType FileKind = OutputCode(Bitcode, OutputAsmFile, *Error, Timeout, + MemoryLimit); FileRemover OutFileRemover(OutputAsmFile, !SaveTemps); std::vector GCCArgs(ArgsForGCC); GCCArgs.insert(GCCArgs.end(), SharedLibs.begin(), SharedLibs.end()); - 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, FileKind, @@ -425,6 +432,7 @@ int LLC::ExecuteProgram(const std::string &Bitcode, /// LLC *AbstractInterpreter::createLLC(const char *Argv0, std::string &Message, + const std::string &GCCBinary, const std::vector *Args, const std::vector *GCCArgs, bool UseIntegratedAssembler) { @@ -436,12 +444,12 @@ LLC *AbstractInterpreter::createLLC(const char *Argv0, } Message = "Found llc: " + LLCPath + "\n"; - GCC *gcc = GCC::create(Message, GCCArgs); + GCC *gcc = GCC::create(Message, GCCBinary, GCCArgs); if (!gcc) { errs() << Message << "\n"; exit(1); } - return new LLC(LLCPath, gcc, Args, GCCArgs, UseIntegratedAssembler); + return new LLC(LLCPath, gcc, Args, UseIntegratedAssembler); } //===---------------------------------------------------------------------===// @@ -528,7 +536,8 @@ AbstractInterpreter *AbstractInterpreter::createJIT(const char *Argv0, } GCC::FileType CBE::OutputCode(const std::string &Bitcode, - sys::Path &OutputCFile, std::string &Error) { + sys::Path &OutputCFile, std::string &Error, + unsigned Timeout, unsigned MemoryLimit) { sys::Path uniqueFile(Bitcode+".cbe.c"); std::string ErrMsg; if (uniqueFile.makeUnique(true, &ErrMsg)) { @@ -556,14 +565,15 @@ GCC::FileType CBE::OutputCode(const std::string &Bitcode, errs() << "\n"; ); if (RunProgramWithTimeout(LLCPath, &LLCArgs[0], sys::Path(), sys::Path(), - sys::Path())) - Error = ProcessFailure(LLCPath, &LLCArgs[0]); + sys::Path(), Timeout, MemoryLimit)) + Error = ProcessFailure(LLCPath, &LLCArgs[0], Timeout, MemoryLimit); return GCC::CFile; } -void CBE::compileProgram(const std::string &Bitcode, std::string *Error) { +void CBE::compileProgram(const std::string &Bitcode, std::string *Error, + unsigned Timeout, unsigned MemoryLimit) { sys::Path OutputCFile; - OutputCode(Bitcode, OutputCFile, *Error); + OutputCode(Bitcode, OutputCFile, *Error, Timeout, MemoryLimit); OutputCFile.eraseFromDisk(); } @@ -577,7 +587,7 @@ int CBE::ExecuteProgram(const std::string &Bitcode, unsigned Timeout, unsigned MemoryLimit) { sys::Path OutputCFile; - OutputCode(Bitcode, OutputCFile, *Error); + OutputCode(Bitcode, OutputCFile, *Error, Timeout, MemoryLimit); FileRemover CFileRemove(OutputCFile, !SaveTemps); @@ -593,6 +603,7 @@ int CBE::ExecuteProgram(const std::string &Bitcode, /// CBE *AbstractInterpreter::createCBE(const char *Argv0, std::string &Message, + const std::string &GCCBinary, const std::vector *Args, const std::vector *GCCArgs) { sys::Path LLCPath = @@ -604,7 +615,7 @@ CBE *AbstractInterpreter::createCBE(const char *Argv0, } Message = "Found llc: " + LLCPath.str() + "\n"; - GCC *gcc = GCC::create(Message, GCCArgs); + GCC *gcc = GCC::create(Message, GCCBinary, GCCArgs); if (!gcc) { errs() << Message << "\n"; exit(1); @@ -619,10 +630,9 @@ CBE *AbstractInterpreter::createCBE(const char *Argv0, static bool IsARMArchitecture(std::vector Args) { for (std::vector::const_iterator I = Args.begin(), E = Args.end(); I != E; ++I) { - StringRef S(*I); - if (!S.equals_lower("-arch")) { + if (StringRef(*I).equals_lower("-arch")) { ++I; - if (I != E && !S.substr(0, strlen("arm")).equals_lower("arm")) + if (I != E && StringRef(*I).substr(0, strlen("arm")).equals_lower("arm")) return true; } } @@ -852,10 +862,11 @@ int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType, /// create - Try to find the `gcc' executable /// GCC *GCC::create(std::string &Message, + const std::string &GCCBinary, const std::vector *Args) { - sys::Path GCCPath = sys::Program::FindProgramByName("gcc"); + sys::Path GCCPath = sys::Program::FindProgramByName(GCCBinary); if (GCCPath.isEmpty()) { - Message = "Cannot find `gcc' in executable directory or PATH!\n"; + Message = "Cannot find `"+ GCCBinary +"' in executable directory or PATH!\n"; return 0; } diff --git a/tools/bugpoint/ToolRunner.h b/tools/bugpoint/ToolRunner.h index cba10f2..d966fc0 100644 --- a/tools/bugpoint/ToolRunner.h +++ b/tools/bugpoint/ToolRunner.h @@ -49,6 +49,7 @@ public: enum FileType { AsmFile, ObjectFile, CFile }; static GCC *create(std::string &Message, + const std::string &GCCBinary, const std::vector *Args); /// ExecuteProgram - Execute the program specified by "ProgramFile" (which is @@ -87,9 +88,11 @@ public: class AbstractInterpreter { public: static CBE *createCBE(const char *Argv0, std::string &Message, + const std::string &GCCBinary, const std::vector *Args = 0, const std::vector *GCCArgs = 0); static LLC *createLLC(const char *Argv0, std::string &Message, + const std::string &GCCBinary, const std::vector *Args = 0, const std::vector *GCCArgs = 0, bool UseIntegratedAssembler = false); @@ -109,14 +112,17 @@ public: /// compileProgram - Compile the specified program from bitcode to executable /// code. This does not produce any output, it is only used when debugging /// the code generator. It returns false if the code generator fails. - virtual void compileProgram(const std::string &Bitcode, std::string *Error) {} + virtual void compileProgram(const std::string &Bitcode, std::string *Error, + unsigned Timeout = 0, unsigned MemoryLimit = 0) {} /// OutputCode - Compile the specified program from bitcode to code /// understood by the GCC driver (either C or asm). If the code generator /// fails, it sets Error, otherwise, this function returns the type of code /// emitted. virtual GCC::FileType OutputCode(const std::string &Bitcode, - sys::Path &OutFile, std::string &Error) { + sys::Path &OutFile, std::string &Error, + unsigned Timeout = 0, + unsigned MemoryLimit = 0) { Error = "OutputCode not supported by this AbstractInterpreter!"; return GCC::AsmFile; } @@ -158,7 +164,8 @@ public: /// compileProgram - Compile the specified program from bitcode to executable /// code. This does not produce any output, it is only used when debugging /// the code generator. Returns false if the code generator fails. - virtual void compileProgram(const std::string &Bitcode, std::string *Error); + virtual void compileProgram(const std::string &Bitcode, std::string *Error, + unsigned Timeout = 0, unsigned MemoryLimit = 0); virtual int ExecuteProgram(const std::string &Bitcode, const std::vector &Args, @@ -177,7 +184,9 @@ public: /// fails, it sets Error, otherwise, this function returns the type of code /// emitted. virtual GCC::FileType OutputCode(const std::string &Bitcode, - sys::Path &OutFile, std::string &Error); + sys::Path &OutFile, std::string &Error, + unsigned Timeout = 0, + unsigned MemoryLimit = 0); }; @@ -187,26 +196,24 @@ public: class LLC : public AbstractInterpreter { std::string LLCPath; // The path to the LLC executable. std::vector ToolArgs; // Extra args to pass to LLC. - std::vector gccArgs; // Extra args to pass to GCC. GCC *gcc; bool UseIntegratedAssembler; public: LLC(const std::string &llcPath, GCC *Gcc, const std::vector *Args, - const std::vector *GCCArgs, bool useIntegratedAssembler) : LLCPath(llcPath), gcc(Gcc), UseIntegratedAssembler(useIntegratedAssembler) { ToolArgs.clear(); if (Args) ToolArgs = *Args; - if (GCCArgs) gccArgs = *GCCArgs; } ~LLC() { delete gcc; } /// compileProgram - Compile the specified program from bitcode to executable /// code. This does not produce any output, it is only used when debugging /// the code generator. Returns false if the code generator fails. - virtual void compileProgram(const std::string &Bitcode, std::string *Error); + virtual void compileProgram(const std::string &Bitcode, std::string *Error, + unsigned Timeout = 0, unsigned MemoryLimit = 0); virtual int ExecuteProgram(const std::string &Bitcode, const std::vector &Args, @@ -225,7 +232,9 @@ public: /// fails, it sets Error, otherwise, this function returns the type of code /// emitted. virtual GCC::FileType OutputCode(const std::string &Bitcode, - sys::Path &OutFile, std::string &Error); + sys::Path &OutFile, std::string &Error, + unsigned Timeout = 0, + unsigned MemoryLimit = 0); }; } // End llvm namespace diff --git a/tools/edis/EDInst.cpp b/tools/edis/EDInst.cpp index af3a54a..c009f0f 100644 --- a/tools/edis/EDInst.cpp +++ b/tools/edis/EDInst.cpp @@ -81,7 +81,9 @@ unsigned EDInst::instID() { bool EDInst::isBranch() { if (ThisInstInfo) - return ThisInstInfo->instructionType == kInstructionTypeBranch; + return + ThisInstInfo->instructionType == kInstructionTypeBranch || + ThisInstInfo->instructionType == kInstructionTypeCall; else return false; } diff --git a/tools/gold/Makefile b/tools/gold/Makefile index 77eacb7..1627346 100644 --- a/tools/gold/Makefile +++ b/tools/gold/Makefile @@ -8,7 +8,7 @@ ##===----------------------------------------------------------------------===## LEVEL = ../.. -LIBRARYNAME = libLLVMgold +LIBRARYNAME = LLVMgold EXPORTED_SYMBOL_FILE = $(PROJ_SRC_DIR)/gold.exports diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp index 16e645f..2e5c179 100644 --- a/tools/gold/gold-plugin.cpp +++ b/tools/gold/gold-plugin.cpp @@ -59,6 +59,7 @@ namespace { namespace options { static bool generate_api_file = false; + static std::string bc_path; static const char *as_path = NULL; // Additional options to pass into the code generator. // Note: This array will contain all plugin options which are not claimed @@ -81,6 +82,14 @@ namespace options { } else { as_path = strdup(opt + 3); } + } else if(llvm::StringRef(opt).startswith("also-emit-llvm=")) { + const char *path = opt + strlen("also-emit-llvm="); + if (bc_path != "") { + (*message)(LDPL_WARNING, "Path to the output IL file specified twice. " + "Discarding %s", opt); + } else { + bc_path = path; + } } else { // Save this option to pass to the code generator. extra.push_back(std::string(opt)); @@ -374,6 +383,11 @@ static ld_plugin_status all_symbols_read_hook(void) { } } + if (options::bc_path != "") { + bool err = lto_codegen_write_merged_modules(cg, options::bc_path.c_str()); + if (err) + (*message)(LDPL_FATAL, "Failed to write the output file."); + } size_t bufsize = 0; const char *buffer = static_cast(lto_codegen_compile(cg, &bufsize)); diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index 378cc63..f3eed56 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -119,7 +119,8 @@ GetFileNameRoot(const std::string &InputFilename) { return outputFilename; } -static formatted_raw_ostream *GetOutputStream(const char *TargetName, +static formatted_raw_ostream *GetOutputStream(const char *TargetName, + Triple::OSType OS, const char *ProgName) { if (OutputFilename != "") { if (OutputFilename == "-") @@ -166,7 +167,10 @@ static formatted_raw_ostream *GetOutputStream(const char *TargetName, OutputFilename += ".s"; break; case TargetMachine::CGFT_ObjectFile: - OutputFilename += ".o"; + if (OS == Triple::Win32) + OutputFilename += ".obj"; + else + OutputFilename += ".o"; Binary = true; break; case TargetMachine::CGFT_Null: @@ -284,7 +288,8 @@ int main(int argc, char **argv) { TargetMachine &Target = *target.get(); // Figure out where we are going to send the output... - formatted_raw_ostream *Out = GetOutputStream(TheTarget->getName(), argv[0]); + formatted_raw_ostream *Out = GetOutputStream(TheTarget->getName(), + TheTriple.getOS(), argv[0]); if (Out == 0) return 1; CodeGenOpt::Level OLvl = CodeGenOpt::Default; @@ -307,75 +312,34 @@ int main(int argc, char **argv) { bool DisableVerify = true; #endif - // If this target requires addPassesToEmitWholeFile, do it now. This is - // used by strange things like the C backend. - if (Target.WantsWholeFile()) { - PassManager PM; - - // Add the target data from the target machine, if it exists, or the module. - if (const TargetData *TD = Target.getTargetData()) - PM.add(new TargetData(*TD)); - else - PM.add(new TargetData(&mod)); - - if (!NoVerify) - PM.add(createVerifierPass()); - - // Ask the target to add backend passes as necessary. - if (Target.addPassesToEmitWholeFile(PM, *Out, FileType, OLvl, - DisableVerify)) { - errs() << argv[0] << ": target does not support generation of this" - << " file type!\n"; - if (Out != &fouts()) delete Out; - // And the Out file is empty and useless, so remove it now. - sys::Path(OutputFilename).eraseFromDisk(); - return 1; - } - PM.run(mod); - } else { - // Build up all of the passes that we want to do to the module. - FunctionPassManager Passes(M.get()); - - // Add the target data from the target machine, if it exists, or the module. - if (const TargetData *TD = Target.getTargetData()) - Passes.add(new TargetData(*TD)); - else - Passes.add(new TargetData(&mod)); - -#ifndef NDEBUG - if (!NoVerify) - Passes.add(createVerifierPass()); -#endif - - // Override default to generate verbose assembly. - Target.setAsmVerbosityDefault(true); - - if (Target.addPassesToEmitFile(Passes, *Out, FileType, OLvl, - DisableVerify)) { - errs() << argv[0] << ": target does not support generation of this" - << " file type!\n"; - if (Out != &fouts()) delete Out; - // And the Out file is empty and useless, so remove it now. - sys::Path(OutputFilename).eraseFromDisk(); - return 1; - } - - Passes.doInitialization(); - - // Run our queue of passes all at once now, efficiently. - // TODO: this could lazily stream functions out of the module. - for (Module::iterator I = mod.begin(), E = mod.end(); I != E; ++I) - if (!I->isDeclaration()) { - if (DisableRedZone) - I->addFnAttr(Attribute::NoRedZone); - if (NoImplicitFloats) - I->addFnAttr(Attribute::NoImplicitFloat); - Passes.run(*I); - } - - Passes.doFinalization(); + // Build up all of the passes that we want to do to the module. + PassManager PM; + + // Add the target data from the target machine, if it exists, or the module. + if (const TargetData *TD = Target.getTargetData()) + PM.add(new TargetData(*TD)); + else + PM.add(new TargetData(&mod)); + + if (!NoVerify) + PM.add(createVerifierPass()); + + // Override default to generate verbose assembly. + Target.setAsmVerbosityDefault(true); + + // Ask the target to add backend passes as necessary. + if (Target.addPassesToEmitFile(PM, *Out, FileType, OLvl, + DisableVerify)) { + errs() << argv[0] << ": target does not support generation of this" + << " file type!\n"; + if (Out != &fouts()) delete Out; + // And the Out file is empty and useless, so remove it now. + sys::Path(OutputFilename).eraseFromDisk(); + return 1; } + PM.run(mod); + // Delete the ostream if it's not a stdout stream if (Out != &fouts()) delete Out; diff --git a/tools/llvm-ld/llvm-ld.cpp b/tools/llvm-ld/llvm-ld.cpp index ce52b59..ad6956c 100644 --- a/tools/llvm-ld/llvm-ld.cpp +++ b/tools/llvm-ld/llvm-ld.cpp @@ -266,7 +266,6 @@ static int GenerateAssembly(const std::string &OutputFilename, // We will use GCC to assemble the program so set the assembly syntax to AT&T, // regardless of what the target in the bitcode file is. args.push_back("-x86-asm-syntax=att"); - args.push_back("-f"); args.push_back("-o"); args.push_back(OutputFilename.c_str()); args.push_back(InputFilename.c_str()); @@ -289,7 +288,6 @@ static int GenerateCFile(const std::string &OutputFile, std::vector args; args.push_back(llc.c_str()); args.push_back("-march=c"); - args.push_back("-f"); args.push_back("-o"); args.push_back(OutputFile.c_str()); args.push_back(InputFile.c_str()); diff --git a/tools/llvm-mc/Disassembler.cpp b/tools/llvm-mc/Disassembler.cpp index 9234a14..37b2cb8 100644 --- a/tools/llvm-mc/Disassembler.cpp +++ b/tools/llvm-mc/Disassembler.cpp @@ -314,6 +314,11 @@ int Disassembler::disassembleEnhanced(const std::string &TS, } outs() << " "; + + if (EDInstIsBranch(inst)) + outs() << "
"; + if (EDInstIsMove(inst)) + outs() << " "; int numOperands = EDNumOperands(inst); @@ -342,6 +347,8 @@ int Disassembler::disassembleEnhanced(const std::string &TS, operand, verboseEvaluator, &disassembler); + + outs() << "=" << evaluatedResult; outs() << " "; } diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp index 47f67c5..a114ab0 100644 --- a/tools/llvm-mc/llvm-mc.cpp +++ b/tools/llvm-mc/llvm-mc.cpp @@ -58,6 +58,9 @@ OutputAsmVariant("output-asm-variant", static cl::opt RelaxAll("mc-relax-all", cl::desc("Relax all fixups")); +static cl::opt +EnableLogging("enable-api-logging", cl::desc("Enable MC API logging")); + enum OutputFileType { OFT_Null, OFT_AssemblyFile, @@ -75,9 +78,6 @@ FileType("filetype", cl::init(OFT_AssemblyFile), "Emit a native object ('.o') file"), clEnumValEnd)); -static cl::opt -Force("f", cl::desc("Enable binary output on terminals")); - static cl::list IncludeDirs("I", cl::desc("Directory of include files"), cl::value_desc("directory"), cl::Prefix); @@ -304,7 +304,12 @@ static int AssembleInput(const char *ProgName) { assert(FileType == OFT_ObjectFile && "Invalid file type!"); CE.reset(TheTarget->createCodeEmitter(*TM, Ctx)); TAB.reset(TheTarget->createAsmBackend(TripleName)); - Str.reset(createMachOStreamer(Ctx, *TAB, *Out, CE.get(), RelaxAll)); + Str.reset(TheTarget->createObjectStreamer(TripleName, Ctx, *TAB, + *Out, CE.get(), RelaxAll)); + } + + if (EnableLogging) { + Str.reset(createLoggingStreamer(Str.take(), errs())); } AsmParser Parser(SrcMgr, Ctx, *Str.get(), *MAI); diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp index 1010592..59e8405 100644 --- a/tools/lto/LTOCodeGenerator.cpp +++ b/tools/lto/LTOCodeGenerator.cpp @@ -300,8 +300,9 @@ 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 Features; + Features.getDefaultSubtargetFeatures("" /* cpu */, llvm::Triple(Triple)); + std::string FeatureStr = Features.getString(); _target = march->createTargetMachine(Triple, FeatureStr); } return false; diff --git a/tools/lto/LTOModule.cpp b/tools/lto/LTOModule.cpp index b269e78..0870205 100644 --- a/tools/lto/LTOModule.cpp +++ b/tools/lto/LTOModule.cpp @@ -140,8 +140,9 @@ LTOModule* LTOModule::makeLTOModule(MemoryBuffer* buffer, return NULL; // construct LTModule, hand over ownership of module and target - const std::string FeatureStr = - SubtargetFeatures::getDefaultSubtargetFeatures(llvm::Triple(Triple)); + SubtargetFeatures Features; + Features.getDefaultSubtargetFeatures("" /* cpu */, llvm::Triple(Triple)); + std::string FeatureStr = Features.getString(); TargetMachine* target = march->createTargetMachine(Triple, FeatureStr); return new LTOModule(m.take(), target); } diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index ff19942..51b920f 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -268,7 +268,7 @@ struct BasicBlockPassPrinter : public BasicBlockPass { }; char BasicBlockPassPrinter::ID = 0; -inline void addPass(PassManager &PM, Pass *P) { +inline void addPass(PassManagerBase &PM, Pass *P) { // Add the pass to the pass manager... PM.add(P); @@ -281,7 +281,7 @@ inline void addPass(PassManager &PM, Pass *P) { /// duplicates llvm-gcc behaviour. /// /// OptLevel - Optimization Level -void AddOptimizationPasses(PassManager &MPM, FunctionPassManager &FPM, +void AddOptimizationPasses(PassManagerBase &MPM, PassManagerBase &FPM, unsigned OptLevel) { createStandardFunctionPasses(&FPM, OptLevel); @@ -305,7 +305,7 @@ void AddOptimizationPasses(PassManager &MPM, FunctionPassManager &FPM, InliningPass); } -void AddStandardCompilePasses(PassManager &PM) { +void AddStandardCompilePasses(PassManagerBase &PM) { PM.add(createVerifierPass()); // Verify that input is correct addPass(PM, createLowerSetJmpPass()); // Lower llvm.setjmp/.longjmp @@ -328,7 +328,7 @@ void AddStandardCompilePasses(PassManager &PM) { InliningPass); } -void AddStandardLinkPasses(PassManager &PM) { +void AddStandardLinkPasses(PassManagerBase &PM) { PM.add(createVerifierPass()); // Verify that input is correct // If the -strip-debug command line option was specified, do it. @@ -422,9 +422,9 @@ int main(int argc, char **argv) { if (TD) Passes.add(TD); - OwningPtr FPasses; + OwningPtr FPasses; if (OptLevelO1 || OptLevelO2 || OptLevelO3) { - FPasses.reset(new FunctionPassManager(M.get())); + FPasses.reset(new PassManager()); if (TD) FPasses->add(new TargetData(*TD)); } @@ -521,12 +521,8 @@ int main(int argc, char **argv) { if (OptLevelO3) AddOptimizationPasses(Passes, *FPasses, 3); - if (OptLevelO1 || OptLevelO2 || OptLevelO3) { - FPasses->doInitialization(); - for (Module::iterator I = M.get()->begin(), E = M.get()->end(); - I != E; ++I) - FPasses->run(*I); - } + if (OptLevelO1 || OptLevelO2 || OptLevelO3) + FPasses->run(*M.get()); // Check that the module is well formed on completion of optimization if (!NoVerify && !VerifyEach) -- cgit v1.1