Commit c5bc5cb3 by John Porto

Subzero. Flags refactoring.

BUG= R=stichnot@chromium.org Review URL: https://codereview.chromium.org/1803403002 .
parent 4c16ac0f
...@@ -166,14 +166,13 @@ void BrowserCompileServer::getParsedFlags(uint32_t NumThreads, int argc, ...@@ -166,14 +166,13 @@ void BrowserCompileServer::getParsedFlags(uint32_t NumThreads, int argc,
char **argv) { char **argv) {
ClFlags::parseFlags(argc, argv); ClFlags::parseFlags(argc, argv);
ClFlags::getParsedClFlags(*Flags); ClFlags::getParsedClFlags(*Flags);
ClFlags::getParsedClFlagsExtra(*ExtraFlags);
// Set some defaults which aren't specified via the argv string. // Set some defaults which aren't specified via the argv string.
Flags->setNumTranslationThreads(NumThreads); Flags->setNumTranslationThreads(NumThreads);
Flags->setUseSandboxing(true); Flags->setUseSandboxing(true);
Flags->setOutFileType(FT_Elf); Flags->setOutFileType(FT_Elf);
Flags->setTargetArch(getTargetArch()); Flags->setTargetArch(getTargetArch());
ExtraFlags->setBuildOnRead(true); Flags->setBuildOnRead(true);
ExtraFlags->setInputFileFormat(llvm::PNaClFormat); Flags->setInputFileFormat(llvm::PNaClFormat);
} }
bool BrowserCompileServer::pushInputBytes(const void *Data, size_t NumBytes) { bool BrowserCompileServer::pushInputBytes(const void *Data, size_t NumBytes) {
...@@ -220,7 +219,7 @@ void BrowserCompileServer::startCompileThread(int ObjFD) { ...@@ -220,7 +219,7 @@ void BrowserCompileServer::startCompileThread(int ObjFD) {
CompileThread = std::thread([this]() { CompileThread = std::thread([this]() {
llvm::install_fatal_error_handler(fatalErrorHandler, this); llvm::install_fatal_error_handler(fatalErrorHandler, this);
Ctx->initParserThread(); Ctx->initParserThread();
this->getCompiler().run(*ExtraFlags, *Ctx.get(), this->getCompiler().run(*Flags, *Ctx.get(),
// Retain original reference, but the compiler // Retain original reference, but the compiler
// (LLVM's MemoryObject) wants to handle deletion. // (LLVM's MemoryObject) wants to handle deletion.
std::unique_ptr<llvm::DataStreamer>(InputStream)); std::unique_ptr<llvm::DataStreamer>(InputStream));
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#define SUBZERO_SRC_ICEBROWSERCOMPILESERVER_H #define SUBZERO_SRC_ICEBROWSERCOMPILESERVER_H
#include "IceClFlags.h" #include "IceClFlags.h"
#include "IceClFlagsExtra.h"
#include "IceCompileServer.h" #include "IceCompileServer.h"
#include "IceDefs.h" #include "IceDefs.h"
#include "IceELFStreamer.h" #include "IceELFStreamer.h"
...@@ -42,9 +41,7 @@ class BrowserCompileServer : public CompileServer { ...@@ -42,9 +41,7 @@ class BrowserCompileServer : public CompileServer {
class StringStream; class StringStream;
public: public:
BrowserCompileServer() BrowserCompileServer() : Flags(&GlobalContext::Flags), HadError(false) {}
: Flags(&GlobalContext::Flags), ExtraFlags(&GlobalContext::ExtraFlags),
HadError(false) {}
~BrowserCompileServer() final; ~BrowserCompileServer() final;
...@@ -105,7 +102,6 @@ private: ...@@ -105,7 +102,6 @@ private:
std::unique_ptr<StringStream> ErrorStream; std::unique_ptr<StringStream> ErrorStream;
std::unique_ptr<ELFStreamer> ELFStream; std::unique_ptr<ELFStreamer> ELFStream;
ClFlags *Flags; ClFlags *Flags;
ClFlagsExtra *ExtraFlags;
std::thread CompileThread; std::thread CompileThread;
std::atomic<bool> HadError; std::atomic<bool> HadError;
}; };
......
...@@ -441,7 +441,7 @@ void getRandomPostOrder(CfgNode *Node, BitVector &ToVisit, ...@@ -441,7 +441,7 @@ void getRandomPostOrder(CfgNode *Node, BitVector &ToVisit,
} // end of anonymous namespace } // end of anonymous namespace
void Cfg::shuffleNodes() { void Cfg::shuffleNodes() {
if (!Ctx->getFlags().shouldReorderBasicBlocks()) if (!Ctx->getFlags().getReorderBasicBlocks())
return; return;
NodeList ReversedReachable; NodeList ReversedReachable;
...@@ -764,7 +764,7 @@ void Cfg::doAddressOpt() { ...@@ -764,7 +764,7 @@ void Cfg::doAddressOpt() {
} }
void Cfg::doNopInsertion() { void Cfg::doNopInsertion() {
if (!Ctx->getFlags().shouldDoNopInsertion()) if (!Ctx->getFlags().getShouldDoNopInsertion())
return; return;
TimerMarker T(TimerStack::TT_doNopInsertion, this); TimerMarker T(TimerStack::TT_doNopInsertion, this);
RandomNumberGenerator RNG(Ctx->getFlags().getRandomSeed(), RPE_NopInsertion, RandomNumberGenerator RNG(Ctx->getFlags().getRandomSeed(), RPE_NopInsertion,
......
//===- subzero/src/IceClFlagsExtra.h - Extra Cl Flags -----------*- C++ -*-===//
//
// The Subzero Code Generator
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
///
/// \file
/// \brief Defines class Ice::ClFlagsExtra
///
//===----------------------------------------------------------------------===//
#ifndef SUBZERO_SRC_ICECLFLAGSEXTRA_H
#define SUBZERO_SRC_ICECLFLAGSEXTRA_H
#include "IceDefs.h"
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wredundant-move"
#endif // __clang__
#include "llvm/IRReader/IRReader.h"
#ifdef __clang__
#pragma clang diagnostic pop
#endif // __clang__
namespace Ice {
/// Declares command line flags primarily used for non-minimal builds.
class ClFlagsExtra {
ClFlagsExtra(const ClFlagsExtra &) = delete;
ClFlagsExtra &operator=(const ClFlagsExtra &) = delete;
public:
ClFlagsExtra() = default;
/// Get the value of ClFlagsExtra::AlwaysExitSuccess
bool getAlwaysExitSuccess() const { return AlwaysExitSuccess; }
/// Set ClFlagsExtra::AlwaysExitSuccess to a new value
void setAlwaysExitSuccess(bool NewValue) { AlwaysExitSuccess = NewValue; }
/// Get the value of ClFlagsExtra::BuildOnRead
bool getBuildOnRead() const { return BuildOnRead; }
/// Set ClFlagsExtra::BuildOnRead to a new value
void setBuildOnRead(bool NewValue) { BuildOnRead = NewValue; }
/// Get the value of ClFlagsExtra::GenerateBuildAtts
bool getGenerateBuildAtts() const { return GenerateBuildAtts; }
/// Set ClFlagsExtra::GenerateBuildAtts to a new value
void setGenerateBuildAtts(bool NewValue) { GenerateBuildAtts = NewValue; }
/// Get the value of ClFlagsExtra::LLVMVerboseErrors
bool getLLVMVerboseErrors() const { return LLVMVerboseErrors; }
/// Set ClFlagsExtra::LLVMVerboseErrors to a new value
void setLLVMVerboseErrors(bool NewValue) { LLVMVerboseErrors = NewValue; }
/// Get the value of ClFlagsExtra::BitcodeAsText
bool getBitcodeAsText() const { return BitcodeAsText; }
/// Set ClFlagsExtra::BitcodeAsText to a new value
void setBitcodeAsText(bool NewValue) { BitcodeAsText = NewValue; }
/// Get the value of ClFlagsExtra::InputFileFormat
llvm::NaClFileFormat getInputFileFormat() const { return InputFileFormat; }
/// Set ClFlagsExtra::InputFileFormat to a new value
void setInputFileFormat(llvm::NaClFileFormat NewValue) {
InputFileFormat = NewValue;
}
/// Get the value of ClFlagsExtra::AppName
const IceString &getAppName() const { return AppName; }
/// Set ClFlagsExtra::AppName to a new value
void setAppName(const IceString &NewValue) { AppName = NewValue; }
/// Get the value of ClFlagsExtra::IRFilename
const IceString &getIRFilename() const { return IRFilename; }
/// Set ClFlagsExtra::IRFilename to a new value
void setIRFilename(const IceString &NewValue) { IRFilename = NewValue; }
/// Get the value of ClFlagsExtra::LogFilename
const IceString &getLogFilename() const { return LogFilename; }
/// Set ClFlagsExtra::LogFilename to a new value
void setLogFilename(const IceString &NewValue) { LogFilename = NewValue; }
/// Get the value of ClFlagsExtra::OutputFilename
const IceString &getOutputFilename() const { return OutputFilename; }
/// Set ClFlagsExtra::OutputFilename to a new value
void setOutputFilename(const IceString &NewValue) {
OutputFilename = NewValue;
}
private:
/// see anonymous_namespace{IceClFlags.cpp}::AlwaysExitSuccess
bool AlwaysExitSuccess = false;
/// see anonymous_namespace{IceClFlags.cpp}::BitcodeAsText
bool BitcodeAsText = false;
/// see anonymous_namespace{IceClFlags.cpp}::BuildOnRead
bool BuildOnRead = false;
/// see anonymous_namespace{IceClFlags.cpp}::GenerateBuildAtts
bool GenerateBuildAtts = false;
/// see anonymous_namespace{IceClFlags.cpp}::LLVMVerboseErrors
bool LLVMVerboseErrors = false;
/// see anonymous_namespace{IceClFlags.cpp}::InputFileFormat
llvm::NaClFileFormat InputFileFormat = llvm::LLVMFormat;
/// see anonymous_namespace{IceClFlags.cpp}::AppName
IceString AppName = "";
/// see anonymous_namespace{IceClFlags.cpp}::IRFilename
IceString IRFilename = "";
/// see anonymous_namespace{IceClFlags.cpp}::LogFilename
IceString LogFilename = "";
/// see anonymous_namespace{IceClFlags.cpp}::OutputFilename
IceString OutputFilename = "";
};
} // end of namespace Ice
#endif // SUBZERO_SRC_ICECLFLAGSEXTRA_H
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "IceCompileServer.h" #include "IceCompileServer.h"
#include "IceClFlags.h" #include "IceClFlags.h"
#include "IceClFlagsExtra.h"
#include "IceELFStreamer.h" #include "IceELFStreamer.h"
#include "IceGlobalContext.h" #include "IceGlobalContext.h"
#include "LinuxMallocProfiling.h" #include "LinuxMallocProfiling.h"
...@@ -96,7 +95,7 @@ std::unique_ptr<Ostream> makeStream(const IceString &Filename, ...@@ -96,7 +95,7 @@ std::unique_ptr<Ostream> makeStream(const IceString &Filename,
} }
ErrorCodes getReturnValue(ErrorCodes Val) { ErrorCodes getReturnValue(ErrorCodes Val) {
if (GlobalContext::ExtraFlags.getAlwaysExitSuccess()) if (GlobalContext::Flags.getAlwaysExitSuccess())
return EC_None; return EC_None;
return Val; return Val;
} }
...@@ -160,16 +159,14 @@ void CLCompileServer::run() { ...@@ -160,16 +159,14 @@ void CLCompileServer::run() {
} }
ClFlags::parseFlags(argc, argv); ClFlags::parseFlags(argc, argv);
ClFlags &Flags = GlobalContext::Flags; ClFlags &Flags = GlobalContext::Flags;
ClFlagsExtra &ExtraFlags = GlobalContext::ExtraFlags;
ClFlags::getParsedClFlags(Flags); ClFlags::getParsedClFlags(Flags);
ClFlags::getParsedClFlagsExtra(ExtraFlags);
// Override report_fatal_error if we want to exit with 0 status. // Override report_fatal_error if we want to exit with 0 status.
if (ExtraFlags.getAlwaysExitSuccess()) if (Flags.getAlwaysExitSuccess())
llvm::install_fatal_error_handler(reportFatalErrorThenExitSuccess, this); llvm::install_fatal_error_handler(reportFatalErrorThenExitSuccess, this);
std::error_code EC; std::error_code EC;
std::unique_ptr<Ostream> Ls = makeStream(ExtraFlags.getLogFilename(), EC); std::unique_ptr<Ostream> Ls = makeStream(Flags.getLogFilename(), EC);
if (EC) { if (EC) {
llvm::report_fatal_error("Unable to open log file"); llvm::report_fatal_error("Unable to open log file");
} }
...@@ -180,14 +177,14 @@ void CLCompileServer::run() { ...@@ -180,14 +177,14 @@ void CLCompileServer::run() {
std::unique_ptr<ELFStreamer> ELFStr; std::unique_ptr<ELFStreamer> ELFStr;
switch (Flags.getOutFileType()) { switch (Flags.getOutFileType()) {
case FT_Elf: { case FT_Elf: {
if (ExtraFlags.getOutputFilename() == "-") { if (Flags.getOutputFilename() == "-" && !Flags.getGenerateBuildAtts()) {
*Ls << "Error: writing binary ELF to stdout is unsupported\n"; *Ls << "Error: writing binary ELF to stdout is unsupported\n";
return transferErrorCode(getReturnValue(Ice::EC_Args)); return transferErrorCode(getReturnValue(Ice::EC_Args));
} }
std::unique_ptr<llvm::raw_fd_ostream> FdOs(new llvm::raw_fd_ostream( std::unique_ptr<llvm::raw_fd_ostream> FdOs(new llvm::raw_fd_ostream(
ExtraFlags.getOutputFilename(), EC, llvm::sys::fs::F_None)); Flags.getOutputFilename(), EC, llvm::sys::fs::F_None));
if (EC) { if (EC) {
*Ls << "Failed to open output file: " << ExtraFlags.getOutputFilename() *Ls << "Failed to open output file: " << Flags.getOutputFilename()
<< ":\n" << EC.message() << "\n"; << ":\n" << EC.message() << "\n";
return transferErrorCode(getReturnValue(Ice::EC_Args)); return transferErrorCode(getReturnValue(Ice::EC_Args));
} }
...@@ -199,9 +196,9 @@ void CLCompileServer::run() { ...@@ -199,9 +196,9 @@ void CLCompileServer::run() {
} break; } break;
case FT_Asm: case FT_Asm:
case FT_Iasm: { case FT_Iasm: {
Os = makeStream(ExtraFlags.getOutputFilename(), EC); Os = makeStream(Flags.getOutputFilename(), EC);
if (EC) { if (EC) {
*Ls << "Failed to open output file: " << ExtraFlags.getOutputFilename() *Ls << "Failed to open output file: " << Flags.getOutputFilename()
<< ":\n" << EC.message() << "\n"; << ":\n" << EC.message() << "\n";
return transferErrorCode(getReturnValue(Ice::EC_Args)); return transferErrorCode(getReturnValue(Ice::EC_Args));
} }
...@@ -209,36 +206,36 @@ void CLCompileServer::run() { ...@@ -209,36 +206,36 @@ void CLCompileServer::run() {
} break; } break;
} }
if (BuildDefs::minimal() && ExtraFlags.getBitcodeAsText()) if (BuildDefs::minimal() && Flags.getBitcodeAsText())
llvm::report_fatal_error("Can't specify 'bitcode-as-text' flag in " llvm::report_fatal_error("Can't specify 'bitcode-as-text' flag in "
"minimal build"); "minimal build");
IceString StrError; IceString StrError;
std::unique_ptr<llvm::DataStreamer> InputStream( std::unique_ptr<llvm::DataStreamer> InputStream(
(!BuildDefs::minimal() && ExtraFlags.getBitcodeAsText()) (!BuildDefs::minimal() && Flags.getBitcodeAsText())
? TextDataStreamer::create(ExtraFlags.getIRFilename(), &StrError) ? TextDataStreamer::create(Flags.getIRFilename(), &StrError)
: llvm::getDataFileStreamer(ExtraFlags.getIRFilename(), &StrError)); : llvm::getDataFileStreamer(Flags.getIRFilename(), &StrError));
if (!StrError.empty() || !InputStream) { if (!StrError.empty() || !InputStream) {
llvm::SMDiagnostic Err(ExtraFlags.getIRFilename(), llvm::SMDiagnostic Err(Flags.getIRFilename(), llvm::SourceMgr::DK_Error,
llvm::SourceMgr::DK_Error, StrError); StrError);
Err.print(ExtraFlags.getAppName().c_str(), *Ls); Err.print(Flags.getAppName().c_str(), *Ls);
return transferErrorCode(getReturnValue(Ice::EC_Bitcode)); return transferErrorCode(getReturnValue(Ice::EC_Bitcode));
} }
if (ExtraFlags.getGenerateBuildAtts()) { if (Flags.getGenerateBuildAtts()) {
dumpBuildAttributes(*Os.get()); dumpBuildAttributes(*Os.get());
return transferErrorCode(getReturnValue(Ice::EC_None)); return transferErrorCode(getReturnValue(Ice::EC_None));
} }
Ctx.reset(new GlobalContext(Ls.get(), Os.get(), Ls.get(), ELFStr.get())); Ctx.reset(new GlobalContext(Ls.get(), Os.get(), Ls.get(), ELFStr.get()));
if (Ctx->getFlags().getNumTranslationThreads() != 0) { if (Ctx->getFlags().getNumTranslationThreads() != 0) {
std::thread CompileThread([this, &ExtraFlags, &InputStream]() { std::thread CompileThread([this, &Flags, &InputStream]() {
Ctx->initParserThread(); Ctx->initParserThread();
getCompiler().run(ExtraFlags, *Ctx.get(), std::move(InputStream)); getCompiler().run(Flags, *Ctx.get(), std::move(InputStream));
}); });
CompileThread.join(); CompileThread.join();
} else { } else {
getCompiler().run(ExtraFlags, *Ctx.get(), std::move(InputStream)); getCompiler().run(Flags, *Ctx.get(), std::move(InputStream));
} }
transferErrorCode( transferErrorCode(
getReturnValue(static_cast<ErrorCodes>(Ctx->getErrorStatus()->value()))); getReturnValue(static_cast<ErrorCodes>(Ctx->getErrorStatus()->value())));
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "IceBuildDefs.h" #include "IceBuildDefs.h"
#include "IceCfg.h" #include "IceCfg.h"
#include "IceClFlags.h" #include "IceClFlags.h"
#include "IceClFlagsExtra.h" #include "IceClFlags.h"
#include "IceConverter.h" #include "IceConverter.h"
#include "IceELFObjectWriter.h" #include "IceELFObjectWriter.h"
#include "PNaClTranslator.h" #include "PNaClTranslator.h"
...@@ -57,7 +57,7 @@ bool llvmIRInput(const IceString &Filename) { ...@@ -57,7 +57,7 @@ bool llvmIRInput(const IceString &Filename) {
} // end of anonymous namespace } // end of anonymous namespace
void Compiler::run(const Ice::ClFlagsExtra &ExtraFlags, GlobalContext &Ctx, void Compiler::run(const Ice::ClFlags &Flags, GlobalContext &Ctx,
std::unique_ptr<llvm::DataStreamer> &&InputStream) { std::unique_ptr<llvm::DataStreamer> &&InputStream) {
// The Minimal build (specifically, when dump()/emit() are not implemented) // The Minimal build (specifically, when dump()/emit() are not implemented)
// allows only --filetype=obj. Check here to avoid cryptic error messages // allows only --filetype=obj. Check here to avoid cryptic error messages
...@@ -77,9 +77,8 @@ void Compiler::run(const Ice::ClFlagsExtra &ExtraFlags, GlobalContext &Ctx, ...@@ -77,9 +77,8 @@ void Compiler::run(const Ice::ClFlagsExtra &ExtraFlags, GlobalContext &Ctx,
Ctx.startWorkerThreads(); Ctx.startWorkerThreads();
std::unique_ptr<Translator> Translator; std::unique_ptr<Translator> Translator;
const IceString &IRFilename = ExtraFlags.getIRFilename(); const IceString &IRFilename = Flags.getIRFilename();
const bool BuildOnRead = const bool BuildOnRead = Flags.getBuildOnRead() && !llvmIRInput(IRFilename);
ExtraFlags.getBuildOnRead() && !llvmIRInput(IRFilename);
if (BuildOnRead) { if (BuildOnRead) {
std::unique_ptr<PNaClTranslator> PTranslator(new PNaClTranslator(&Ctx)); std::unique_ptr<PNaClTranslator> PTranslator(new PNaClTranslator(&Ctx));
std::unique_ptr<llvm::StreamingMemoryObject> MemObj( std::unique_ptr<llvm::StreamingMemoryObject> MemObj(
...@@ -100,14 +99,14 @@ void Compiler::run(const Ice::ClFlagsExtra &ExtraFlags, GlobalContext &Ctx, ...@@ -100,14 +99,14 @@ void Compiler::run(const Ice::ClFlagsExtra &ExtraFlags, GlobalContext &Ctx,
llvm::SMDiagnostic Err; llvm::SMDiagnostic Err;
TimerMarker T1(Ice::TimerStack::TT_parse, &Ctx); TimerMarker T1(Ice::TimerStack::TT_parse, &Ctx);
llvm::DiagnosticHandlerFunction DiagnosticHandler = llvm::DiagnosticHandlerFunction DiagnosticHandler =
ExtraFlags.getLLVMVerboseErrors() Flags.getLLVMVerboseErrors()
? redirectNaClDiagnosticToStream(llvm::errs()) ? redirectNaClDiagnosticToStream(llvm::errs())
: nullptr; : nullptr;
std::unique_ptr<llvm::Module> Mod = std::unique_ptr<llvm::Module> Mod =
NaClParseIRFile(IRFilename, ExtraFlags.getInputFileFormat(), Err, NaClParseIRFile(IRFilename, Flags.getInputFileFormat(), Err,
llvm::getGlobalContext(), DiagnosticHandler); llvm::getGlobalContext(), DiagnosticHandler);
if (!Mod) { if (!Mod) {
Err.print(ExtraFlags.getAppName().c_str(), llvm::errs()); Err.print(Flags.getAppName().c_str(), llvm::errs());
Ctx.getErrorStatus()->assign(EC_Bitcode); Ctx.getErrorStatus()->assign(EC_Bitcode);
return; return;
} }
......
...@@ -23,7 +23,7 @@ class DataStreamer; ...@@ -23,7 +23,7 @@ class DataStreamer;
namespace Ice { namespace Ice {
class ClFlagsExtra; class ClFlags;
/// A compiler driver. It may be called to handle a single compile request. /// A compiler driver. It may be called to handle a single compile request.
class Compiler { class Compiler {
...@@ -35,7 +35,7 @@ public: ...@@ -35,7 +35,7 @@ public:
/// Run the compiler with the given GlobalContext for compilation state. Upon /// Run the compiler with the given GlobalContext for compilation state. Upon
/// error, the Context's error status will be set. /// error, the Context's error status will be set.
void run(const ClFlagsExtra &ExtraFlags, GlobalContext &Ctx, void run(const ClFlags &ExtraFlags, GlobalContext &Ctx,
std::unique_ptr<llvm::DataStreamer> &&InputStream); std::unique_ptr<llvm::DataStreamer> &&InputStream);
}; };
......
...@@ -532,7 +532,7 @@ template <typename ConstType> void ELFObjectWriter::writeConstantPool(Type Ty) { ...@@ -532,7 +532,7 @@ template <typename ConstType> void ELFObjectWriter::writeConstantPool(Type Ty) {
// If the -reorder-pooled-constant option is set to true, we should shuffle // If the -reorder-pooled-constant option is set to true, we should shuffle
// the constants before we emit them. // the constants before we emit them.
if (Ctx.getFlags().shouldReorderPooledConstants() && !Pool.empty()) { if (Ctx.getFlags().getReorderPooledConstants() && !Pool.empty()) {
// Use the constant's kind value as the salt for creating random number // Use the constant's kind value as the salt for creating random number
// generator. // generator.
Operand::OperandKind K = (*Pool.begin())->getKind(); Operand::OperandKind K = (*Pool.begin())->getKind();
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "IceCfg.h" #include "IceCfg.h"
#include "IceCfgNode.h" #include "IceCfgNode.h"
#include "IceClFlags.h" #include "IceClFlags.h"
#include "IceClFlagsExtra.h"
#include "IceDefs.h" #include "IceDefs.h"
#include "IceELFObjectWriter.h" #include "IceELFObjectWriter.h"
#include "IceGlobalInits.h" #include "IceGlobalInits.h"
...@@ -427,7 +426,7 @@ void GlobalContext::lowerGlobals(const IceString &SectionSuffix) { ...@@ -427,7 +426,7 @@ void GlobalContext::lowerGlobals(const IceString &SectionSuffix) {
saveBlockInfoPtrs(); saveBlockInfoPtrs();
// If we need to shuffle the layout of global variables, shuffle them now. // If we need to shuffle the layout of global variables, shuffle them now.
if (getFlags().shouldReorderGlobalVariables()) { if (getFlags().getReorderGlobalVariables()) {
// Create a random number generator for global variable reordering. // Create a random number generator for global variable reordering.
RandomNumberGenerator RNG(getFlags().getRandomSeed(), RandomNumberGenerator RNG(getFlags().getRandomSeed(),
RPE_GlobalVariableReordering); RPE_GlobalVariableReordering);
...@@ -494,7 +493,7 @@ void GlobalContext::emitItems() { ...@@ -494,7 +493,7 @@ void GlobalContext::emitItems() {
bool EmitQueueEmpty = false; bool EmitQueueEmpty = false;
const uint32_t ShuffleWindowSize = const uint32_t ShuffleWindowSize =
std::max(1u, getFlags().getReorderFunctionsWindowSize()); std::max(1u, getFlags().getReorderFunctionsWindowSize());
bool Shuffle = Threaded && getFlags().shouldReorderFunctions(); bool Shuffle = Threaded && getFlags().getReorderFunctions();
// Create a random number generator for function reordering. // Create a random number generator for function reordering.
RandomNumberGenerator RNG(getFlags().getRandomSeed(), RPE_FunctionReordering); RandomNumberGenerator RNG(getFlags().getRandomSeed(), RPE_FunctionReordering);
...@@ -801,7 +800,7 @@ JumpTableDataList GlobalContext::getJumpTables() { ...@@ -801,7 +800,7 @@ JumpTableDataList GlobalContext::getJumpTables() {
return A.getId() < B.getId(); return A.getId() < B.getId();
}); });
if (getFlags().shouldReorderPooledConstants()) { if (getFlags().getReorderPooledConstants()) {
// If reorder-pooled-constants option is set to true, we also shuffle the // If reorder-pooled-constants option is set to true, we also shuffle the
// jump tables before emitting them. // jump tables before emitting them.
...@@ -919,7 +918,6 @@ void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) { ...@@ -919,7 +918,6 @@ void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) {
} }
ClFlags GlobalContext::Flags; ClFlags GlobalContext::Flags;
ClFlagsExtra GlobalContext::ExtraFlags;
TimerIdT TimerMarker::getTimerIdFromFuncName(GlobalContext *Ctx, TimerIdT TimerMarker::getTimerIdFromFuncName(GlobalContext *Ctx,
const IceString &FuncName) { const IceString &FuncName) {
......
...@@ -492,7 +492,6 @@ public: ...@@ -492,7 +492,6 @@ public:
} }
static ClFlags Flags; static ClFlags Flags;
static ClFlagsExtra ExtraFlags;
/// DisposeGlobalVariablesAfterLowering controls whether the memory used by /// DisposeGlobalVariablesAfterLowering controls whether the memory used by
/// GlobaleVariables can be reclaimed right after they have been lowered. /// GlobaleVariables can be reclaimed right after they have been lowered.
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#ifdef __clang__ #ifdef __clang__
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter" #pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wredundant-move"
#endif // __clang__ #endif // __clang__
#include "llvm/Bitcode/NaCl/NaClBitcodeParser.h" // for NaClBitcodeRecord. #include "llvm/Bitcode/NaCl/NaClBitcodeParser.h" // for NaClBitcodeRecord.
......
...@@ -27,6 +27,9 @@ ...@@ -27,6 +27,9 @@
#include "IceOperand.h" #include "IceOperand.h"
#include "IceRegAlloc.h" #include "IceRegAlloc.h"
#include <string>
#include <vector>
#define TARGET_LOWERING_CLASS_FOR(t) Target_##t #define TARGET_LOWERING_CLASS_FOR(t) Target_##t
// We prevent target-specific implementation details from leaking outside their // We prevent target-specific implementation details from leaking outside their
...@@ -179,14 +182,14 @@ void TargetLowering::filterTypeToRegisterSet( ...@@ -179,14 +182,14 @@ void TargetLowering::filterTypeToRegisterSet(
RegNameToIndex[getRegName(RegNum)] = RegNum; RegNameToIndex[getRegName(RegNum)] = RegNum;
} }
ClFlags::StringVector BadRegNames; std::vector<std::string> BadRegNames;
// The processRegList function iterates across the RegNames vector. Each // The processRegList function iterates across the RegNames vector. Each
// entry in the vector is a string of the form "<reg>" or "<class>:<reg>". // entry in the vector is a string of the form "<reg>" or "<class>:<reg>".
// The register class and register number are computed, and the corresponding // The register class and register number are computed, and the corresponding
// bit is set in RegSet[][]. If "<class>:" is missing, then the bit is set // bit is set in RegSet[][]. If "<class>:" is missing, then the bit is set
// for all classes. // for all classes.
auto processRegList = [&](const ClFlags::StringVector &RegNames, auto processRegList = [&](const std::vector<std::string> &RegNames,
std::vector<SmallBitVector> &RegSet) { std::vector<SmallBitVector> &RegSet) {
for (const IceString &RegClassAndName : RegNames) { for (const IceString &RegClassAndName : RegNames) {
IceString RClass; IceString RClass;
...@@ -474,10 +477,10 @@ void TargetLowering::regAlloc(RegAllocKind Kind) { ...@@ -474,10 +477,10 @@ void TargetLowering::regAlloc(RegAllocKind Kind) {
if (hasFramePointer()) if (hasFramePointer())
RegExclude |= RegSet_FramePointer; RegExclude |= RegSet_FramePointer;
SmallBitVector RegMask = getRegisterSet(RegInclude, RegExclude); SmallBitVector RegMask = getRegisterSet(RegInclude, RegExclude);
bool Repeat = (Kind == RAK_Global && Ctx->getFlags().shouldRepeatRegAlloc()); bool Repeat = (Kind == RAK_Global && Ctx->getFlags().getRepeatRegAlloc());
do { do {
LinearScan.init(Kind); LinearScan.init(Kind);
LinearScan.scan(RegMask, Ctx->getFlags().shouldRandomizeRegAlloc()); LinearScan.scan(RegMask, Ctx->getFlags().getRandomizeRegisterAllocation());
if (!LinearScan.hasEvictions()) if (!LinearScan.hasEvictions())
Repeat = false; Repeat = false;
Kind = RAK_SecondChance; Kind = RAK_SecondChance;
......
...@@ -1032,7 +1032,7 @@ void TargetARM32::translateO2() { ...@@ -1032,7 +1032,7 @@ void TargetARM32::translateO2() {
Func->processAllocas(SortAndCombineAllocas); Func->processAllocas(SortAndCombineAllocas);
Func->dump("After Alloca processing"); Func->dump("After Alloca processing");
if (!Ctx->getFlags().getPhiEdgeSplit()) { if (!Ctx->getFlags().getEnablePhiEdgeSplit()) {
// Lower Phi instructions. // Lower Phi instructions.
Func->placePhiLoads(); Func->placePhiLoads();
if (Func->hasError()) if (Func->hasError())
...@@ -1100,7 +1100,7 @@ void TargetARM32::translateO2() { ...@@ -1100,7 +1100,7 @@ void TargetARM32::translateO2() {
copyRegAllocFromInfWeightVariable64On32(Func->getVariables()); copyRegAllocFromInfWeightVariable64On32(Func->getVariables());
Func->dump("After linear scan regalloc"); Func->dump("After linear scan regalloc");
if (Ctx->getFlags().getPhiEdgeSplit()) { if (Ctx->getFlags().getEnablePhiEdgeSplit()) {
Func->advancedPhiLowering(); Func->advancedPhiLowering();
Func->dump("After advanced Phi lowering"); Func->dump("After advanced Phi lowering");
} }
...@@ -1129,7 +1129,7 @@ void TargetARM32::translateO2() { ...@@ -1129,7 +1129,7 @@ void TargetARM32::translateO2() {
Func->dump("After branch optimization"); Func->dump("After branch optimization");
// Nop insertion // Nop insertion
if (Ctx->getFlags().shouldDoNopInsertion()) { if (Ctx->getFlags().getShouldDoNopInsertion()) {
Func->doNopInsertion(); Func->doNopInsertion();
} }
} }
...@@ -1191,7 +1191,7 @@ void TargetARM32::translateOm1() { ...@@ -1191,7 +1191,7 @@ void TargetARM32::translateOm1() {
Func->dump("After postLowerLegalization"); Func->dump("After postLowerLegalization");
// Nop insertion // Nop insertion
if (Ctx->getFlags().shouldDoNopInsertion()) { if (Ctx->getFlags().getShouldDoNopInsertion()) {
Func->doNopInsertion(); Func->doNopInsertion();
} }
} }
...@@ -6803,7 +6803,7 @@ template <typename T> void emitConstantPool(GlobalContext *Ctx) { ...@@ -6803,7 +6803,7 @@ template <typename T> void emitConstantPool(GlobalContext *Ctx) {
<< "\n" << "\n"
<< "\t.align\t" << Align << "\n"; << "\t.align\t" << Align << "\n";
if (Ctx->getFlags().shouldReorderPooledConstants()) { if (Ctx->getFlags().getReorderPooledConstants()) {
// TODO(jpp): add constant pooling. // TODO(jpp): add constant pooling.
UnimplementedError(Ctx->getFlags()); UnimplementedError(Ctx->getFlags());
} }
......
...@@ -137,7 +137,7 @@ void TargetMIPS32::translateO2() { ...@@ -137,7 +137,7 @@ void TargetMIPS32::translateO2() {
Func->processAllocas(SortAndCombineAllocas); Func->processAllocas(SortAndCombineAllocas);
Func->dump("After Alloca processing"); Func->dump("After Alloca processing");
if (!Ctx->getFlags().getPhiEdgeSplit()) { if (!Ctx->getFlags().getEnablePhiEdgeSplit()) {
// Lower Phi instructions. // Lower Phi instructions.
Func->placePhiLoads(); Func->placePhiLoads();
if (Func->hasError()) if (Func->hasError())
...@@ -200,7 +200,7 @@ void TargetMIPS32::translateO2() { ...@@ -200,7 +200,7 @@ void TargetMIPS32::translateO2() {
return; return;
Func->dump("After linear scan regalloc"); Func->dump("After linear scan regalloc");
if (Ctx->getFlags().getPhiEdgeSplit()) { if (Ctx->getFlags().getEnablePhiEdgeSplit()) {
Func->advancedPhiLowering(); Func->advancedPhiLowering();
Func->dump("After advanced Phi lowering"); Func->dump("After advanced Phi lowering");
} }
...@@ -222,7 +222,7 @@ void TargetMIPS32::translateO2() { ...@@ -222,7 +222,7 @@ void TargetMIPS32::translateO2() {
Func->dump("After branch optimization"); Func->dump("After branch optimization");
// Nop insertion // Nop insertion
if (Ctx->getFlags().shouldDoNopInsertion()) { if (Ctx->getFlags().getShouldDoNopInsertion()) {
Func->doNopInsertion(); Func->doNopInsertion();
} }
} }
...@@ -267,7 +267,7 @@ void TargetMIPS32::translateOm1() { ...@@ -267,7 +267,7 @@ void TargetMIPS32::translateOm1() {
Func->dump("After stack frame mapping"); Func->dump("After stack frame mapping");
// Nop insertion // Nop insertion
if (Ctx->getFlags().shouldDoNopInsertion()) { if (Ctx->getFlags().getShouldDoNopInsertion()) {
Func->doNopInsertion(); Func->doNopInsertion();
} }
} }
......
...@@ -391,7 +391,7 @@ template <typename TraitsType> void TargetX86Base<TraitsType>::translateO2() { ...@@ -391,7 +391,7 @@ template <typename TraitsType> void TargetX86Base<TraitsType>::translateO2() {
Func->processAllocas(SortAndCombineAllocas); Func->processAllocas(SortAndCombineAllocas);
Func->dump("After Alloca processing"); Func->dump("After Alloca processing");
if (!Ctx->getFlags().getPhiEdgeSplit()) { if (!Ctx->getFlags().getEnablePhiEdgeSplit()) {
// Lower Phi instructions. // Lower Phi instructions.
Func->placePhiLoads(); Func->placePhiLoads();
if (Func->hasError()) if (Func->hasError())
...@@ -477,7 +477,7 @@ template <typename TraitsType> void TargetX86Base<TraitsType>::translateO2() { ...@@ -477,7 +477,7 @@ template <typename TraitsType> void TargetX86Base<TraitsType>::translateO2() {
return; return;
Func->dump("After linear scan regalloc"); Func->dump("After linear scan regalloc");
if (Ctx->getFlags().getPhiEdgeSplit()) { if (Ctx->getFlags().getEnablePhiEdgeSplit()) {
Func->advancedPhiLowering(); Func->advancedPhiLowering();
Func->dump("After advanced Phi lowering"); Func->dump("After advanced Phi lowering");
} }
...@@ -7303,7 +7303,7 @@ void TargetDataX86<TraitsType>::emitConstantPool(GlobalContext *Ctx) { ...@@ -7303,7 +7303,7 @@ void TargetDataX86<TraitsType>::emitConstantPool(GlobalContext *Ctx) {
// If reorder-pooled-constants option is set to true, we need to shuffle the // If reorder-pooled-constants option is set to true, we need to shuffle the
// constant pool before emitting it. // constant pool before emitting it.
if (Ctx->getFlags().shouldReorderPooledConstants() && !Pool.empty()) { if (Ctx->getFlags().getReorderPooledConstants() && !Pool.empty()) {
// Use the constant's kind value as the salt for creating random number // Use the constant's kind value as the salt for creating random number
// generator. // generator.
Operand::OperandKind K = (*Pool.begin())->getKind(); Operand::OperandKind K = (*Pool.begin())->getKind();
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#ifdef __clang__ #ifdef __clang__
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter" #pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wredundant-move"
#endif // __clang__ #endif // __clang__
#include "llvm/IR/DerivedTypes.h" #include "llvm/IR/DerivedTypes.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment