#include "ToolRunner.h"
#include "llvm/Config/config.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/raw_ostream.h"
#include <fstream>
#include <sstream>
#include <utility>
usingnamespacellvm;
#define DEBUG_TYPE …
namespace llvm {
cl::opt<bool> SaveTemps("save-temps", cl::init(false),
cl::desc("Save temporary files"));
}
namespace {
cl::opt<std::string>
RemoteClient("remote-client",
cl::desc("Remote execution client (rsh/ssh)"));
cl::opt<std::string> RemoteHost("remote-host",
cl::desc("Remote execution (rsh/ssh) host"));
cl::opt<std::string> RemotePort("remote-port",
cl::desc("Remote execution (rsh/ssh) port"));
cl::opt<std::string> RemoteUser("remote-user",
cl::desc("Remote execution (rsh/ssh) user id"));
cl::opt<std::string>
RemoteExtra("remote-extra-options",
cl::desc("Remote execution (rsh/ssh) extra options"));
}
static int RunProgramWithTimeout(StringRef ProgramPath,
ArrayRef<StringRef> Args, StringRef StdInFile,
StringRef StdOutFile, StringRef StdErrFile,
unsigned NumSeconds = 0,
unsigned MemoryLimit = 0,
std::string *ErrMsg = nullptr) { … }
static int RunProgramRemotelyWithTimeout(
StringRef RemoteClientPath, ArrayRef<StringRef> Args, StringRef StdInFile,
StringRef StdOutFile, StringRef StdErrFile, unsigned NumSeconds = 0,
unsigned MemoryLimit = 0) { … }
static Error ProcessFailure(StringRef ProgPath, ArrayRef<StringRef> Args,
unsigned Timeout = 0, unsigned MemoryLimit = 0) { … }
namespace {
class LLI : public AbstractInterpreter { … };
}
Expected<int> LLI::ExecuteProgram(const std::string &Bitcode,
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
const std::vector<std::string> &CCArgs,
const std::vector<std::string> &SharedLibs,
unsigned Timeout, unsigned MemoryLimit) { … }
void AbstractInterpreter::anchor() { … }
ErrorOr<std::string> llvm::FindProgramByName(const std::string &ExeName,
const char *Argv0,
void *MainAddr) { … }
AbstractInterpreter *
AbstractInterpreter::createLLI(const char *Argv0, std::string &Message,
const std::vector<std::string> *ToolArgs) { … }
namespace {
class CustomCompiler : public AbstractInterpreter { … };
}
Error CustomCompiler::compileProgram(const std::string &Bitcode,
unsigned Timeout, unsigned MemoryLimit) { … }
namespace {
class CustomExecutor : public AbstractInterpreter { … };
}
Expected<int> CustomExecutor::ExecuteProgram(
const std::string &Bitcode, const std::vector<std::string> &Args,
const std::string &InputFile, const std::string &OutputFile,
const std::vector<std::string> &CCArgs,
const std::vector<std::string> &SharedLibs, unsigned Timeout,
unsigned MemoryLimit) { … }
static void lexCommand(const char *Argv0, std::string &Message,
const std::string &CommandLine, std::string &CmdPath,
std::vector<std::string> &Args) { … }
AbstractInterpreter *AbstractInterpreter::createCustomCompiler(
const char *Argv0, std::string &Message,
const std::string &CompileCommandLine) { … }
AbstractInterpreter *
AbstractInterpreter::createCustomExecutor(const char *Argv0,
std::string &Message,
const std::string &ExecCommandLine) { … }
Expected<CC::FileType> LLC::OutputCode(const std::string &Bitcode,
std::string &OutputAsmFile,
unsigned Timeout, unsigned MemoryLimit) { … }
Error LLC::compileProgram(const std::string &Bitcode, unsigned Timeout,
unsigned MemoryLimit) { … }
Expected<int> LLC::ExecuteProgram(const std::string &Bitcode,
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
const std::vector<std::string> &ArgsForCC,
const std::vector<std::string> &SharedLibs,
unsigned Timeout, unsigned MemoryLimit) { … }
LLC *AbstractInterpreter::createLLC(const char *Argv0, std::string &Message,
const std::string &CCBinary,
const std::vector<std::string> *Args,
const std::vector<std::string> *CCArgs,
bool UseIntegratedAssembler) { … }
namespace {
class JIT : public AbstractInterpreter { … };
}
Expected<int> JIT::ExecuteProgram(const std::string &Bitcode,
const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
const std::vector<std::string> &CCArgs,
const std::vector<std::string> &SharedLibs,
unsigned Timeout, unsigned MemoryLimit) { … }
AbstractInterpreter *
AbstractInterpreter::createJIT(const char *Argv0, std::string &Message,
const std::vector<std::string> *Args) { … }
static bool IsARMArchitecture(std::vector<StringRef> Args) { … }
Expected<int> CC::ExecuteProgram(const std::string &ProgramFile,
const std::vector<std::string> &Args,
FileType fileType,
const std::string &InputFile,
const std::string &OutputFile,
const std::vector<std::string> &ArgsForCC,
unsigned Timeout, unsigned MemoryLimit) { … }
Error CC::MakeSharedObject(const std::string &InputFile, FileType fileType,
std::string &OutputFile,
const std::vector<std::string> &ArgsForCC) { … }
CC *CC::create(const char *Argv0, std::string &Message,
const std::string &CCBinary,
const std::vector<std::string> *Args) { … }