Commit 0d4fc92b by Jim Stichnoth

eliminate code related to --no-ir-gen

BUG= R=stichnot@chromium.org Review URL: https://codereview.chromium.org/1522433004 .
parent 2a18dd3f
...@@ -16,7 +16,6 @@ if(PNACL_BROWSER_TRANSLATOR) ...@@ -16,7 +16,6 @@ if(PNACL_BROWSER_TRANSLATOR)
-DALLOW_LLVM_CL=0 -DALLOW_LLVM_CL=0
-DALLOW_LLVM_IR=0 -DALLOW_LLVM_IR=0
-DALLOW_LLVM_IR_AS_INPUT=0 -DALLOW_LLVM_IR_AS_INPUT=0
-DALLOW_DISABLE_IR_GEN=0
-DALLOW_MINIMAL_BUILD=1 -DALLOW_MINIMAL_BUILD=1
-DPNACL_BROWSER_TRANSLATOR=1 -DPNACL_BROWSER_TRANSLATOR=1
) )
...@@ -26,7 +25,6 @@ else() ...@@ -26,7 +25,6 @@ else()
-DALLOW_LLVM_CL=1 -DALLOW_LLVM_CL=1
-DALLOW_LLVM_IR=1 -DALLOW_LLVM_IR=1
-DALLOW_LLVM_IR_AS_INPUT=1 -DALLOW_LLVM_IR_AS_INPUT=1
-DALLOW_DISABLE_IR_GEN=1
-DALLOW_MINIMAL_BUILD=0 -DALLOW_MINIMAL_BUILD=0
-DPNACL_BROWSER_TRANSLATOR=0 -DPNACL_BROWSER_TRANSLATOR=0
) )
......
...@@ -21,11 +21,11 @@ CXX.Flags += -std=gnu++11 ...@@ -21,11 +21,11 @@ CXX.Flags += -std=gnu++11
ifeq ($(PNACL_BROWSER_TRANSLATOR),1) ifeq ($(PNACL_BROWSER_TRANSLATOR),1)
CPP.Defines += -DALLOW_DUMP=0 -DALLOW_LLVM_CL=0 -DALLOW_LLVM_IR=0 \ CPP.Defines += -DALLOW_DUMP=0 -DALLOW_LLVM_CL=0 -DALLOW_LLVM_IR=0 \
-DALLOW_LLVM_IR_AS_INPUT=0 -DALLOW_DISABLE_IR_GEN=0 \ -DALLOW_LLVM_IR_AS_INPUT=0 -DALLOW_MINIMAL_BUILD=1 \
-DALLOW_MINIMAL_BUILD=1 -DPNACL_BROWSER_TRANSLATOR=1 -DPNACL_BROWSER_TRANSLATOR=1
else else
CPP.Defines += -DALLOW_DUMP=1 -DALLOW_LLVM_CL=1 -DALLOW_LLVM_IR=1 \ CPP.Defines += -DALLOW_DUMP=1 -DALLOW_LLVM_CL=1 -DALLOW_LLVM_IR=1 \
-DALLOW_LLVM_IR_AS_INPUT=1 -DALLOW_DISABLE_IR_GEN=1 \ -DALLOW_LLVM_IR_AS_INPUT=1 -DALLOW_MINIMAL_BUILD=0 \
-DALLOW_MINIMAL_BUILD=0 -DPNACL_BROWSER_TRANSLATOR=0 -DPNACL_BROWSER_TRANSLATOR=0
endif endif
...@@ -78,12 +78,10 @@ ifdef MINIMAL ...@@ -78,12 +78,10 @@ ifdef MINIMAL
NOASSERT = 1 NOASSERT = 1
OBJDIR := $(OBJDIR)+Min OBJDIR := $(OBJDIR)+Min
BASE_CXX_DEFINES += -DALLOW_DUMP=0 -DALLOW_LLVM_CL=0 -DALLOW_LLVM_IR=0 \ BASE_CXX_DEFINES += -DALLOW_DUMP=0 -DALLOW_LLVM_CL=0 -DALLOW_LLVM_IR=0 \
-DALLOW_LLVM_IR_AS_INPUT=0 -DALLOW_DISABLE_IR_GEN=0 \ -DALLOW_LLVM_IR_AS_INPUT=0 -DALLOW_MINIMAL_BUILD=1
-DALLOW_MINIMAL_BUILD=1
else else
BASE_CXX_DEFINES += -DALLOW_DUMP=1 -DALLOW_LLVM_CL=1 -DALLOW_LLVM_IR=1 \ BASE_CXX_DEFINES += -DALLOW_DUMP=1 -DALLOW_LLVM_CL=1 -DALLOW_LLVM_IR=1 \
-DALLOW_LLVM_IR_AS_INPUT=1 -DALLOW_DISABLE_IR_GEN=1 \ -DALLOW_LLVM_IR_AS_INPUT=1 -DALLOW_MINIMAL_BUILD=0
-DALLOW_MINIMAL_BUILD=0
endif endif
SB_CXX_DEFINES := $(BASE_CXX_DEFINES) -DPNACL_BROWSER_TRANSLATOR=1 SB_CXX_DEFINES := $(BASE_CXX_DEFINES) -DPNACL_BROWSER_TRANSLATOR=1
......
...@@ -15,14 +15,14 @@ ...@@ -15,14 +15,14 @@
#define SUBZERO_SRC_ICEBUILDDEFS_H #define SUBZERO_SRC_ICEBUILDDEFS_H
namespace Ice { namespace Ice {
/// \brief Defines constexpr functions that express various Subzero build /// \brief Defines constexpr functions that express various Subzero build
/// system defined values. /// system defined values.
/// ///
/// These resulting constexpr functions allow code to in effect be /// These resulting constexpr functions allow code to in effect be
/// conditionally compiled without having to do this using the older C++ /// conditionally compiled without having to do this using the older C++
/// preprocessor solution. /// preprocessor solution.
/** \verbatim /** \verbatim
For example whenever the value of FEATURE_SUPPORTED is needed, instead For example whenever the value of FEATURE_SUPPORTED is needed, instead
of (except in these constexpr functions): of (except in these constexpr functions):
...@@ -72,13 +72,9 @@ namespace Ice { ...@@ -72,13 +72,9 @@ namespace Ice {
**/ **/
namespace BuildDefs { namespace BuildDefs {
// The ALLOW_* etc. symbols must be #defined to zero or non-zero. // The ALLOW_* etc. symbols must be #defined to zero or non-zero.
/// Return true if ALLOW_DISABLE_IR_GEN is defined as a non-zero value
constexpr bool disableIrGen() { return ALLOW_DISABLE_IR_GEN; }
/// Return true if ALLOW_DUMP is defined as a non-zero value
constexpr bool dump() { return ALLOW_DUMP; } constexpr bool dump() { return ALLOW_DUMP; }
/// Return true if ALLOW_LLVM_CL is defined as a non-zero value /// Return true if ALLOW_LLVM_CL is defined as a non-zero value
constexpr bool llvmCl() { return ALLOW_LLVM_CL; } constexpr bool llvmCl() { return ALLOW_LLVM_CL; }
......
...@@ -82,9 +82,7 @@ cl::opt<bool> DisableHybridAssembly( ...@@ -82,9 +82,7 @@ cl::opt<bool> DisableHybridAssembly(
cl::opt<bool> DisableInternal("externalize", cl::opt<bool> DisableInternal("externalize",
cl::desc("Externalize all symbols")); cl::desc("Externalize all symbols"));
// Note: Modifiable only if ALLOW_DISABLE_IR_GEN.
cl::opt<bool> DisableIRGeneration("no-ir-gen",
cl::desc("Disable generating Subzero IR."));
cl::opt<bool> DisableTranslation("notranslate", cl::opt<bool> DisableTranslation("notranslate",
cl::desc("Disable Subzero translation")); cl::desc("Disable Subzero translation"));
...@@ -390,7 +388,6 @@ void ClFlags::resetClFlags(ClFlags &OutFlags) { ...@@ -390,7 +388,6 @@ void ClFlags::resetClFlags(ClFlags &OutFlags) {
OutFlags.DecorateAsm = false; OutFlags.DecorateAsm = false;
OutFlags.DisableHybridAssembly = false; OutFlags.DisableHybridAssembly = false;
OutFlags.DisableInternal = false; OutFlags.DisableInternal = false;
OutFlags.DisableIRGeneration = false;
OutFlags.DisableTranslation = false; OutFlags.DisableTranslation = false;
OutFlags.DumpStats = false; OutFlags.DumpStats = false;
OutFlags.EnableBlockProfile = false; OutFlags.EnableBlockProfile = false;
...@@ -434,9 +431,6 @@ void ClFlags::resetClFlags(ClFlags &OutFlags) { ...@@ -434,9 +431,6 @@ void ClFlags::resetClFlags(ClFlags &OutFlags) {
} }
void ClFlags::getParsedClFlags(ClFlags &OutFlags) { void ClFlags::getParsedClFlags(ClFlags &OutFlags) {
if (::DisableIRGeneration)
::DisableTranslation = true;
Ice::VerboseMask VMask = Ice::IceV_None; Ice::VerboseMask VMask = Ice::IceV_None;
// Don't generate verbose messages if routines to dump messages are not // Don't generate verbose messages if routines to dump messages are not
// available. // available.
...@@ -457,7 +451,6 @@ void ClFlags::getParsedClFlags(ClFlags &OutFlags) { ...@@ -457,7 +451,6 @@ void ClFlags::getParsedClFlags(ClFlags &OutFlags) {
OutFlags.setDisableHybridAssembly(::DisableHybridAssembly || OutFlags.setDisableHybridAssembly(::DisableHybridAssembly ||
(::OutFileType != Ice::FT_Iasm)); (::OutFileType != Ice::FT_Iasm));
OutFlags.setDisableInternal(::DisableInternal); OutFlags.setDisableInternal(::DisableInternal);
OutFlags.setDisableIRGeneration(::DisableIRGeneration);
OutFlags.setDisableTranslation(::DisableTranslation); OutFlags.setDisableTranslation(::DisableTranslation);
OutFlags.setDumpStats(::DumpStats); OutFlags.setDumpStats(::DumpStats);
OutFlags.setEnableBlockProfile(::EnableBlockProfile); OutFlags.setEnableBlockProfile(::EnableBlockProfile);
......
...@@ -70,11 +70,6 @@ public: ...@@ -70,11 +70,6 @@ public:
bool getDisableInternal() const { return DisableInternal; } bool getDisableInternal() const { return DisableInternal; }
void setDisableInternal(bool NewValue) { DisableInternal = NewValue; } void setDisableInternal(bool NewValue) { DisableInternal = NewValue; }
bool getDisableIRGeneration() const {
return BuildDefs::disableIrGen() && DisableIRGeneration;
}
void setDisableIRGeneration(bool NewValue) { DisableIRGeneration = NewValue; }
bool getDisableTranslation() const { return DisableTranslation; } bool getDisableTranslation() const { return DisableTranslation; }
void setDisableTranslation(bool NewValue) { DisableTranslation = NewValue; } void setDisableTranslation(bool NewValue) { DisableTranslation = NewValue; }
...@@ -260,7 +255,6 @@ private: ...@@ -260,7 +255,6 @@ private:
bool DecorateAsm; bool DecorateAsm;
bool DisableHybridAssembly; bool DisableHybridAssembly;
bool DisableInternal; bool DisableInternal;
bool DisableIRGeneration;
bool DisableTranslation; bool DisableTranslation;
bool DumpStats; bool DumpStats;
bool EnableBlockProfile; bool EnableBlockProfile;
......
...@@ -47,7 +47,6 @@ struct { ...@@ -47,7 +47,6 @@ struct {
int FlagValue; int FlagValue;
} ConditionalBuildAttributes[] = { } ConditionalBuildAttributes[] = {
{"dump", BuildDefs::dump()}, {"dump", BuildDefs::dump()},
{"disable_ir_gen", BuildDefs::disableIrGen()},
{"llvm_cl", BuildDefs::llvmCl()}, {"llvm_cl", BuildDefs::llvmCl()},
{"llvm_ir", BuildDefs::llvmIr()}, {"llvm_ir", BuildDefs::llvmIr()},
{"llvm_ir_as_input", BuildDefs::llvmIrAsInput()}, {"llvm_ir_as_input", BuildDefs::llvmIrAsInput()},
...@@ -95,12 +94,6 @@ void Compiler::run(const Ice::ClFlagsExtra &ExtraFlags, GlobalContext &Ctx, ...@@ -95,12 +94,6 @@ void Compiler::run(const Ice::ClFlagsExtra &ExtraFlags, GlobalContext &Ctx,
if (ExtraFlags.getGenerateBuildAtts()) if (ExtraFlags.getGenerateBuildAtts())
return Ctx.getErrorStatus()->assign(EC_None); return Ctx.getErrorStatus()->assign(EC_None);
if (!BuildDefs::disableIrGen() && Ctx.getFlags().getDisableIRGeneration()) {
Ctx.getStrError() << "Error: Build doesn't allow --no-ir-gen when not "
<< "ALLOW_DISABLE_IR_GEN!\n";
return Ctx.getErrorStatus()->assign(EC_Args);
}
// 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
// downstream. // downstream.
......
...@@ -89,8 +89,6 @@ public: ...@@ -89,8 +89,6 @@ public:
: LLVM2ICEConverter(Converter), Func(nullptr) {} : LLVM2ICEConverter(Converter), Func(nullptr) {}
void convertFunction(const Function *F) { void convertFunction(const Function *F) {
if (Ctx->isIRGenerationDisabled())
return;
Func = Ice::Cfg::create(Ctx, Converter.getNextSequenceNumber()); Func = Ice::Cfg::create(Ctx, Converter.getNextSequenceNumber());
Ice::Cfg::setCurrentCfg(Func.get()); Ice::Cfg::setCurrentCfg(Func.get());
......
...@@ -222,10 +222,6 @@ public: ...@@ -222,10 +222,6 @@ public:
const ClFlags &getFlags() const { return Flags; } const ClFlags &getFlags() const { return Flags; }
bool isIRGenerationDisabled() const {
return getFlags().getDisableIRGeneration();
}
/// Allocate data of type T using the global allocator. We allow entities /// Allocate data of type T using the global allocator. We allow entities
/// allocated from this global allocator to be either trivially or /// allocated from this global allocator to be either trivially or
/// non-trivially destructible. We optimize the case when T is trivially /// non-trivially destructible. We optimize the case when T is trivially
......
...@@ -166,8 +166,6 @@ public: ...@@ -166,8 +166,6 @@ public:
static ConstantPrimitive *create(GlobalContext *Ctx, Type Ty, static ConstantPrimitive *create(GlobalContext *Ctx, Type Ty,
PrimType Value) { PrimType Value) {
assert(!Ctx->isIRGenerationDisabled() &&
"Attempt to build primitive constant when IR generation disabled");
return new (Ctx->allocate<ConstantPrimitive>()) return new (Ctx->allocate<ConstantPrimitive>())
ConstantPrimitive(Ty, Value); ConstantPrimitive(Ty, Value);
} }
...@@ -279,8 +277,6 @@ class ConstantRelocatable : public Constant { ...@@ -279,8 +277,6 @@ class ConstantRelocatable : public Constant {
public: public:
static ConstantRelocatable *create(GlobalContext *Ctx, Type Ty, static ConstantRelocatable *create(GlobalContext *Ctx, Type Ty,
const RelocatableTuple &Tuple) { const RelocatableTuple &Tuple) {
assert(!Ctx->isIRGenerationDisabled() &&
"Attempt to build relocatable constant when IR generation disabled");
return new (Ctx->allocate<ConstantRelocatable>()) ConstantRelocatable( return new (Ctx->allocate<ConstantRelocatable>()) ConstantRelocatable(
Ty, Tuple.Offset, Tuple.Name, Tuple.SuppressMangling); Ty, Tuple.Offset, Tuple.Name, Tuple.SuppressMangling);
} }
...@@ -320,8 +316,6 @@ class ConstantUndef : public Constant { ...@@ -320,8 +316,6 @@ class ConstantUndef : public Constant {
public: public:
static ConstantUndef *create(GlobalContext *Ctx, Type Ty) { static ConstantUndef *create(GlobalContext *Ctx, Type Ty) {
assert(!Ctx->isIRGenerationDisabled() &&
"Attempt to build undefined constant when IR generation disabled");
return new (Ctx->allocate<ConstantUndef>()) ConstantUndef(Ty); return new (Ctx->allocate<ConstantUndef>()) ConstantUndef(Ty);
} }
......
...@@ -250,11 +250,6 @@ public: ...@@ -250,11 +250,6 @@ public:
size_t getNumTypeIDValues() const { return TypeIDValues.size(); } size_t getNumTypeIDValues() const { return TypeIDValues.size(); }
/// Returns true if generation of Subzero IR is disabled.
bool isIRGenerationDisabled() const {
return Translator.getFlags().getDisableIRGeneration();
}
/// Returns the undefined type associated with type ID. Note: Returns extended /// Returns the undefined type associated with type ID. Note: Returns extended
/// type ready to be defined. /// type ready to be defined.
ExtendedType *getTypeByIDForDefining(NaClBcIndexSize_t ID) { ExtendedType *getTypeByIDForDefining(NaClBcIndexSize_t ID) {
...@@ -534,11 +529,8 @@ private: ...@@ -534,11 +529,8 @@ private:
for (const Ice::FunctionDeclaration *Func : FunctionDeclarations) { for (const Ice::FunctionDeclaration *Func : FunctionDeclarations) {
if (!Func->verifyLinkageCorrect(Ctx)) if (!Func->verifyLinkageCorrect(Ctx))
reportLinkageError("Function", *Func); reportLinkageError("Function", *Func);
Ice::Constant *C = nullptr; Ice::Constant *C = getConstantSym(
if (!isIRGenerationDisabled()) { Func->getName(), Func->getSuppressMangling(), Func->isProto());
C = getConstantSym(Func->getName(), Func->getSuppressMangling(),
Func->isProto());
}
ValueIDConstants.push_back(C); ValueIDConstants.push_back(C);
} }
} }
...@@ -549,11 +541,9 @@ private: ...@@ -549,11 +541,9 @@ private:
for (const Ice::VariableDeclaration *Decl : *VariableDeclarations) { for (const Ice::VariableDeclaration *Decl : *VariableDeclarations) {
if (!Decl->verifyLinkageCorrect(Ctx)) if (!Decl->verifyLinkageCorrect(Ctx))
reportLinkageError("Global", *Decl); reportLinkageError("Global", *Decl);
Ice::Constant *C = nullptr; Ice::Constant *C =
if (!isIRGenerationDisabled()) { getConstantSym(Decl->getName(), Decl->getSuppressMangling(),
C = getConstantSym(Decl->getName(), Decl->getSuppressMangling(),
!Decl->hasInitializer()); !Decl->hasInitializer());
}
ValueIDConstants.push_back(C); ValueIDConstants.push_back(C);
} }
} }
...@@ -681,10 +671,6 @@ protected: ...@@ -681,10 +671,6 @@ protected:
const Ice::ClFlags &getFlags() const { return getTranslator().getFlags(); } const Ice::ClFlags &getFlags() const { return getTranslator().getFlags(); }
bool isIRGenerationDisabled() const {
return getTranslator().getFlags().getDisableIRGeneration();
}
// Default implementation. Reports that block is unknown and skips its // Default implementation. Reports that block is unknown and skips its
// contents. // contents.
bool ParseBlock(unsigned BlockID) override; bool ParseBlock(unsigned BlockID) override;
...@@ -1145,11 +1131,9 @@ void GlobalsParser::ProcessRecord() { ...@@ -1145,11 +1131,9 @@ void GlobalsParser::ProcessRecord() {
uint32_t Alignment = uint32_t Alignment =
Context->extractAlignment(this, "Global variable", Values[0]); Context->extractAlignment(this, "Global variable", Values[0]);
CurGlobalVar = getGlobalVarByID(NextGlobalID); CurGlobalVar = getGlobalVarByID(NextGlobalID);
if (!isIRGenerationDisabled()) {
InitializersNeeded = 1; InitializersNeeded = 1;
CurGlobalVar->setAlignment(Alignment); CurGlobalVar->setAlignment(Alignment);
CurGlobalVar->setIsConstant(Values[1] != 0); CurGlobalVar->setIsConstant(Values[1] != 0);
}
++NextGlobalID; ++NextGlobalID;
return; return;
} }
...@@ -1169,16 +1153,12 @@ void GlobalsParser::ProcessRecord() { ...@@ -1169,16 +1153,12 @@ void GlobalsParser::ProcessRecord() {
Error(StrBuf.str()); Error(StrBuf.str());
return; return;
} }
if (isIRGenerationDisabled())
return;
InitializersNeeded = Values[0]; InitializersNeeded = Values[0];
return; return;
case naclbitc::GLOBALVAR_ZEROFILL: { case naclbitc::GLOBALVAR_ZEROFILL: {
// ZEROFILL: [size] // ZEROFILL: [size]
if (!isValidRecordSize(1, "zerofill")) if (!isValidRecordSize(1, "zerofill"))
return; return;
if (isIRGenerationDisabled())
return;
CurGlobalVar->addInitializer( CurGlobalVar->addInitializer(
Ice::VariableDeclaration::ZeroInitializer::create(Values[0])); Ice::VariableDeclaration::ZeroInitializer::create(Values[0]));
return; return;
...@@ -1187,8 +1167,6 @@ void GlobalsParser::ProcessRecord() { ...@@ -1187,8 +1167,6 @@ void GlobalsParser::ProcessRecord() {
// DATA: [b0, b1, ...] // DATA: [b0, b1, ...]
if (!isValidRecordSizeAtLeast(1, "data")) if (!isValidRecordSizeAtLeast(1, "data"))
return; return;
if (isIRGenerationDisabled())
return;
CurGlobalVar->addInitializer( CurGlobalVar->addInitializer(
Ice::VariableDeclaration::DataInitializer::create(Values)); Ice::VariableDeclaration::DataInitializer::create(Values));
return; return;
...@@ -1197,8 +1175,6 @@ void GlobalsParser::ProcessRecord() { ...@@ -1197,8 +1175,6 @@ void GlobalsParser::ProcessRecord() {
// RELOC: [val, [addend]] // RELOC: [val, [addend]]
if (!isValidRecordSizeInRange(1, 2, "reloc")) if (!isValidRecordSizeInRange(1, 2, "reloc"))
return; return;
if (isIRGenerationDisabled())
return;
NaClBcIndexSize_t Index = Values[0]; NaClBcIndexSize_t Index = Values[0];
NaClBcIndexSize_t IndexLimit = SpecifiedNumberVars + NumFunctionIDs; NaClBcIndexSize_t IndexLimit = SpecifiedNumberVars + NumFunctionIDs;
if (Index >= IndexLimit) { if (Index >= IndexLimit) {
...@@ -1365,13 +1341,7 @@ public: ...@@ -1365,13 +1341,7 @@ public:
// TODO(kschimpf) Clean up API to add a function signature to a CFG. // TODO(kschimpf) Clean up API to add a function signature to a CFG.
const Ice::FuncSigType &Signature = FuncDecl->getSignature(); const Ice::FuncSigType &Signature = FuncDecl->getSignature();
if (isIRGenerationDisabled()) {
CurrentNode = nullptr;
for (Ice::Type ArgType : Signature.getArgList()) {
(void)ArgType;
setNextLocalInstIndex(nullptr);
}
} else {
Func->setFunctionName(FuncDecl->getName()); Func->setFunctionName(FuncDecl->getName());
Func->setReturnType(Signature.getReturnType()); Func->setReturnType(Signature.getReturnType());
Func->setInternal(FuncDecl->getLinkage() == GlobalValue::InternalLinkage); Func->setInternal(FuncDecl->getLinkage() == GlobalValue::InternalLinkage);
...@@ -1380,7 +1350,7 @@ public: ...@@ -1380,7 +1350,7 @@ public:
for (Ice::Type ArgType : Signature.getArgList()) { for (Ice::Type ArgType : Signature.getArgList()) {
Func->addArg(getNextInstVar(ArgType)); Func->addArg(getNextInstVar(ArgType));
} }
}
bool ParserResult = ParseThisBlock(); bool ParserResult = ParseThisBlock();
// Temporarily end per-function timing, which will be resumed by the // Temporarily end per-function timing, which will be resumed by the
...@@ -1424,8 +1394,6 @@ public: ...@@ -1424,8 +1394,6 @@ public:
if (Index < CachedNumGlobalValueIDs) { if (Index < CachedNumGlobalValueIDs) {
return Context->getGlobalConstantByID(Index); return Context->getGlobalConstantByID(Index);
} }
if (isIRGenerationDisabled())
return nullptr;
NaClBcIndexSize_t LocalIndex = Index - CachedNumGlobalValueIDs; NaClBcIndexSize_t LocalIndex = Index - CachedNumGlobalValueIDs;
if (LocalIndex >= LocalOperands.size()) if (LocalIndex >= LocalOperands.size())
reportGetOperandUndefined(Index); reportGetOperandUndefined(Index);
...@@ -1480,14 +1448,12 @@ private: ...@@ -1480,14 +1448,12 @@ private:
// Creates and appends a new basic block to the list of basic blocks. // Creates and appends a new basic block to the list of basic blocks.
Ice::CfgNode *installNextBasicBlock() { Ice::CfgNode *installNextBasicBlock() {
assert(!isIRGenerationDisabled());
Ice::CfgNode *Node = Func->makeNode(); Ice::CfgNode *Node = Func->makeNode();
return Node; return Node;
} }
// Returns the Index-th basic block in the list of basic blocks. // Returns the Index-th basic block in the list of basic blocks.
Ice::CfgNode *getBasicBlock(NaClBcIndexSize_t Index) { Ice::CfgNode *getBasicBlock(NaClBcIndexSize_t Index) {
assert(!isIRGenerationDisabled());
if (Index >= Func->getNumNodes()) { if (Index >= Func->getNumNodes()) {
std::string Buffer; std::string Buffer;
raw_string_ostream StrBuf(Buffer); raw_string_ostream StrBuf(Buffer);
...@@ -1503,7 +1469,6 @@ private: ...@@ -1503,7 +1469,6 @@ private:
// Index corresponds to a branch instruction. Hence, if the branch references // Index corresponds to a branch instruction. Hence, if the branch references
// the entry block, it also generates a corresponding error. // the entry block, it also generates a corresponding error.
Ice::CfgNode *getBranchBasicBlock(NaClBcIndexSize_t Index) { Ice::CfgNode *getBranchBasicBlock(NaClBcIndexSize_t Index) {
assert(!isIRGenerationDisabled());
if (Index == 0) { if (Index == 0) {
Error("Branch to entry block not allowed"); Error("Branch to entry block not allowed");
} }
...@@ -1512,7 +1477,6 @@ private: ...@@ -1512,7 +1477,6 @@ private:
// Generate an instruction variable with type Ty. // Generate an instruction variable with type Ty.
Ice::Variable *createInstVar(Ice::Type Ty) { Ice::Variable *createInstVar(Ice::Type Ty) {
assert(!isIRGenerationDisabled());
if (Ty == Ice::IceType_void) { if (Ty == Ice::IceType_void) {
Error("Can't define instruction value using type void"); Error("Can't define instruction value using type void");
// Recover since we can't throw an exception. // Recover since we can't throw an exception.
...@@ -1523,7 +1487,6 @@ private: ...@@ -1523,7 +1487,6 @@ private:
// Generates the next available local variable using the given type. // Generates the next available local variable using the given type.
Ice::Variable *getNextInstVar(Ice::Type Ty) { Ice::Variable *getNextInstVar(Ice::Type Ty) {
assert(!isIRGenerationDisabled());
assert(NextLocalInstIndex >= CachedNumGlobalValueIDs); assert(NextLocalInstIndex >= CachedNumGlobalValueIDs);
// Before creating one, see if a forwardtyperef has already defined it. // Before creating one, see if a forwardtyperef has already defined it.
NaClBcIndexSize_t LocalIndex = NextLocalInstIndex - CachedNumGlobalValueIDs; NaClBcIndexSize_t LocalIndex = NextLocalInstIndex - CachedNumGlobalValueIDs;
...@@ -1566,7 +1529,7 @@ private: ...@@ -1566,7 +1529,7 @@ private:
// Sets element Index (in the local operands list) to Op. // Sets element Index (in the local operands list) to Op.
void setOperand(NaClBcIndexSize_t Index, Ice::Operand *Op) { void setOperand(NaClBcIndexSize_t Index, Ice::Operand *Op) {
assert(Op || isIRGenerationDisabled()); assert(Op);
// Check if simple push works. // Check if simple push works.
NaClBcIndexSize_t LocalIndex = Index - CachedNumGlobalValueIDs; NaClBcIndexSize_t LocalIndex = Index - CachedNumGlobalValueIDs;
if (LocalIndex == LocalOperands.size()) { if (LocalIndex == LocalOperands.size()) {
...@@ -2134,8 +2097,6 @@ void FunctionParser::ExitBlock() { ...@@ -2134,8 +2097,6 @@ void FunctionParser::ExitBlock() {
// Check if the last instruction in the function was terminating. // Check if the last instruction in the function was terminating.
if (!InstIsTerminating) { if (!InstIsTerminating) {
Error("Last instruction in function not terminator"); Error("Last instruction in function not terminator");
if (isIRGenerationDisabled())
return;
// Recover by inserting an unreachable instruction. // Recover by inserting an unreachable instruction.
CurrentNode->appendInst(Ice::InstUnreachable::create(Func.get())); CurrentNode->appendInst(Ice::InstUnreachable::create(Func.get()));
} }
...@@ -2147,8 +2108,6 @@ void FunctionParser::ExitBlock() { ...@@ -2147,8 +2108,6 @@ void FunctionParser::ExitBlock() {
<< " basic blocks, but defined " << CurrentBbIndex << "."; << " basic blocks, but defined " << CurrentBbIndex << ".";
Error(StrBuf.str()); Error(StrBuf.str());
} }
if (isIRGenerationDisabled())
return;
// Before translating, check for blocks without instructions, and insert // Before translating, check for blocks without instructions, and insert
// unreachable. This shouldn't happen, but be safe. // unreachable. This shouldn't happen, but be safe.
size_t Index = 0; size_t Index = 0;
...@@ -2183,7 +2142,6 @@ void FunctionParser::ProcessRecord() { ...@@ -2183,7 +2142,6 @@ void FunctionParser::ProcessRecord() {
if (InstIsTerminating) { if (InstIsTerminating) {
InstIsTerminating = false; InstIsTerminating = false;
++CurrentBbIndex; ++CurrentBbIndex;
if (!isIRGenerationDisabled())
CurrentNode = getBasicBlock(CurrentBbIndex); CurrentNode = getBasicBlock(CurrentBbIndex);
} }
// The base index for relative indexing. // The base index for relative indexing.
...@@ -2217,8 +2175,6 @@ void FunctionParser::ProcessRecord() { ...@@ -2217,8 +2175,6 @@ void FunctionParser::ProcessRecord() {
} }
DeclaredNumberBbs = NumBbs; DeclaredNumberBbs = NumBbs;
if (isIRGenerationDisabled())
return;
// Install the basic blocks, skipping bb0 which was created in the // Install the basic blocks, skipping bb0 which was created in the
// constructor. // constructor.
for (size_t i = 1; i < NumBbs; ++i) for (size_t i = 1; i < NumBbs; ++i)
...@@ -2231,11 +2187,6 @@ void FunctionParser::ProcessRecord() { ...@@ -2231,11 +2187,6 @@ void FunctionParser::ProcessRecord() {
return; return;
Ice::Operand *Op1 = getRelativeOperand(Values[0], BaseIndex); Ice::Operand *Op1 = getRelativeOperand(Values[0], BaseIndex);
Ice::Operand *Op2 = getRelativeOperand(Values[1], BaseIndex); Ice::Operand *Op2 = getRelativeOperand(Values[1], BaseIndex);
if (isIRGenerationDisabled()) {
assert(Op1 == nullptr && Op2 == nullptr);
setNextLocalInstIndex(nullptr);
return;
}
Ice::Type Type1 = Op1->getType(); Ice::Type Type1 = Op1->getType();
Ice::Type Type2 = Op2->getType(); Ice::Type Type2 = Op2->getType();
if (Type1 != Type2) { if (Type1 != Type2) {
...@@ -2263,11 +2214,6 @@ void FunctionParser::ProcessRecord() { ...@@ -2263,11 +2214,6 @@ void FunctionParser::ProcessRecord() {
Ice::Operand *Src = getRelativeOperand(Values[0], BaseIndex); Ice::Operand *Src = getRelativeOperand(Values[0], BaseIndex);
Ice::Type CastType = Context->getSimpleTypeByID(Values[1]); Ice::Type CastType = Context->getSimpleTypeByID(Values[1]);
Ice::InstCast::OpKind CastKind; Ice::InstCast::OpKind CastKind;
if (isIRGenerationDisabled()) {
assert(Src == nullptr);
setNextLocalInstIndex(nullptr);
return;
}
if (!convertCastOpToIceOp(Values[2], Src->getType(), CastType, CastKind)) { if (!convertCastOpToIceOp(Values[2], Src->getType(), CastType, CastKind)) {
appendErrorInstruction(CastType); appendErrorInstruction(CastType);
return; return;
...@@ -2283,11 +2229,6 @@ void FunctionParser::ProcessRecord() { ...@@ -2283,11 +2229,6 @@ void FunctionParser::ProcessRecord() {
Ice::Operand *ThenVal = getRelativeOperand(Values[0], BaseIndex); Ice::Operand *ThenVal = getRelativeOperand(Values[0], BaseIndex);
Ice::Operand *ElseVal = getRelativeOperand(Values[1], BaseIndex); Ice::Operand *ElseVal = getRelativeOperand(Values[1], BaseIndex);
Ice::Operand *CondVal = getRelativeOperand(Values[2], BaseIndex); Ice::Operand *CondVal = getRelativeOperand(Values[2], BaseIndex);
if (isIRGenerationDisabled()) {
assert(ThenVal == nullptr && ElseVal == nullptr && CondVal == nullptr);
setNextLocalInstIndex(nullptr);
return;
}
Ice::Type ThenType = ThenVal->getType(); Ice::Type ThenType = ThenVal->getType();
Ice::Type ElseType = ElseVal->getType(); Ice::Type ElseType = ElseVal->getType();
if (ThenType != ElseType) { if (ThenType != ElseType) {
...@@ -2331,11 +2272,6 @@ void FunctionParser::ProcessRecord() { ...@@ -2331,11 +2272,6 @@ void FunctionParser::ProcessRecord() {
return; return;
Ice::Operand *Vec = getRelativeOperand(Values[0], BaseIndex); Ice::Operand *Vec = getRelativeOperand(Values[0], BaseIndex);
Ice::Operand *Index = getRelativeOperand(Values[1], BaseIndex); Ice::Operand *Index = getRelativeOperand(Values[1], BaseIndex);
if (isIRGenerationDisabled()) {
assert(Vec == nullptr && Index == nullptr);
setNextLocalInstIndex(nullptr);
return;
}
Ice::Type VecType = Vec->getType(); Ice::Type VecType = Vec->getType();
VectorIndexCheckValue IndexCheckValue = validateVectorIndex(Vec, Index); VectorIndexCheckValue IndexCheckValue = validateVectorIndex(Vec, Index);
if (IndexCheckValue != VectorIndexValid) { if (IndexCheckValue != VectorIndexValid) {
...@@ -2359,11 +2295,6 @@ void FunctionParser::ProcessRecord() { ...@@ -2359,11 +2295,6 @@ void FunctionParser::ProcessRecord() {
Ice::Operand *Vec = getRelativeOperand(Values[0], BaseIndex); Ice::Operand *Vec = getRelativeOperand(Values[0], BaseIndex);
Ice::Operand *Elt = getRelativeOperand(Values[1], BaseIndex); Ice::Operand *Elt = getRelativeOperand(Values[1], BaseIndex);
Ice::Operand *Index = getRelativeOperand(Values[2], BaseIndex); Ice::Operand *Index = getRelativeOperand(Values[2], BaseIndex);
if (isIRGenerationDisabled()) {
assert(Vec == nullptr && Elt == nullptr && Index == nullptr);
setNextLocalInstIndex(nullptr);
return;
}
Ice::Type VecType = Vec->getType(); Ice::Type VecType = Vec->getType();
VectorIndexCheckValue IndexCheckValue = validateVectorIndex(Vec, Index); VectorIndexCheckValue IndexCheckValue = validateVectorIndex(Vec, Index);
if (IndexCheckValue != VectorIndexValid) { if (IndexCheckValue != VectorIndexValid) {
...@@ -2397,11 +2328,6 @@ void FunctionParser::ProcessRecord() { ...@@ -2397,11 +2328,6 @@ void FunctionParser::ProcessRecord() {
return; return;
Ice::Operand *Op1 = getRelativeOperand(Values[0], BaseIndex); Ice::Operand *Op1 = getRelativeOperand(Values[0], BaseIndex);
Ice::Operand *Op2 = getRelativeOperand(Values[1], BaseIndex); Ice::Operand *Op2 = getRelativeOperand(Values[1], BaseIndex);
if (isIRGenerationDisabled()) {
assert(Op1 == nullptr && Op2 == nullptr);
setNextLocalInstIndex(nullptr);
return;
}
Ice::Type Op1Type = Op1->getType(); Ice::Type Op1Type = Op1->getType();
Ice::Type Op2Type = Op2->getType(); Ice::Type Op2Type = Op2->getType();
Ice::Type DestType = getCompareResultType(Op1Type); Ice::Type DestType = getCompareResultType(Op1Type);
...@@ -2463,15 +2389,9 @@ void FunctionParser::ProcessRecord() { ...@@ -2463,15 +2389,9 @@ void FunctionParser::ProcessRecord() {
if (!isValidRecordSizeInRange(0, 1, "return")) if (!isValidRecordSizeInRange(0, 1, "return"))
return; return;
if (Values.empty()) { if (Values.empty()) {
if (isIRGenerationDisabled())
return;
CurrentNode->appendInst(Ice::InstRet::create(Func.get())); CurrentNode->appendInst(Ice::InstRet::create(Func.get()));
} else { } else {
Ice::Operand *RetVal = getRelativeOperand(Values[0], BaseIndex); Ice::Operand *RetVal = getRelativeOperand(Values[0], BaseIndex);
if (isIRGenerationDisabled()) {
assert(RetVal == nullptr);
return;
}
CurrentNode->appendInst(Ice::InstRet::create(Func.get(), RetVal)); CurrentNode->appendInst(Ice::InstRet::create(Func.get(), RetVal));
} }
return; return;
...@@ -2480,8 +2400,6 @@ void FunctionParser::ProcessRecord() { ...@@ -2480,8 +2400,6 @@ void FunctionParser::ProcessRecord() {
InstIsTerminating = true; InstIsTerminating = true;
if (Values.size() == 1) { if (Values.size() == 1) {
// BR: [bb#] // BR: [bb#]
if (isIRGenerationDisabled())
return;
Ice::CfgNode *Block = getBranchBasicBlock(Values[0]); Ice::CfgNode *Block = getBranchBasicBlock(Values[0]);
if (Block == nullptr) if (Block == nullptr)
return; return;
...@@ -2491,10 +2409,6 @@ void FunctionParser::ProcessRecord() { ...@@ -2491,10 +2409,6 @@ void FunctionParser::ProcessRecord() {
if (!isValidRecordSize(3, "branch")) if (!isValidRecordSize(3, "branch"))
return; return;
Ice::Operand *Cond = getRelativeOperand(Values[2], BaseIndex); Ice::Operand *Cond = getRelativeOperand(Values[2], BaseIndex);
if (isIRGenerationDisabled()) {
assert(Cond == nullptr);
return;
}
if (Cond->getType() != Ice::IceType_i1) { if (Cond->getType() != Ice::IceType_i1) {
std::string Buffer; std::string Buffer;
raw_string_ostream StrBuf(Buffer); raw_string_ostream StrBuf(Buffer);
...@@ -2535,10 +2449,7 @@ void FunctionParser::ProcessRecord() { ...@@ -2535,10 +2449,7 @@ void FunctionParser::ProcessRecord() {
Ice::SizeT BitWidth = Ice::getScalarIntBitWidth(CondTy); Ice::SizeT BitWidth = Ice::getScalarIntBitWidth(CondTy);
Ice::Operand *Cond = getRelativeOperand(Values[1], BaseIndex); Ice::Operand *Cond = getRelativeOperand(Values[1], BaseIndex);
const bool isIRGenDisabled = isIRGenerationDisabled(); if (CondTy != Cond->getType()) {
if (isIRGenDisabled) {
assert(Cond == nullptr);
} else if (CondTy != Cond->getType()) {
std::string Buffer; std::string Buffer;
raw_string_ostream StrBuf(Buffer); raw_string_ostream StrBuf(Buffer);
StrBuf << "Case condition expects type " << CondTy StrBuf << "Case condition expects type " << CondTy
...@@ -2546,8 +2457,7 @@ void FunctionParser::ProcessRecord() { ...@@ -2546,8 +2457,7 @@ void FunctionParser::ProcessRecord() {
Error(StrBuf.str()); Error(StrBuf.str());
return; return;
} }
Ice::CfgNode *DefaultLabel = Ice::CfgNode *DefaultLabel = getBranchBasicBlock(Values[2]);
isIRGenDisabled ? nullptr : getBranchBasicBlock(Values[2]);
if (DefaultLabel == nullptr) if (DefaultLabel == nullptr)
return; return;
uint64_t NumCasesRaw = Values[3]; uint64_t NumCasesRaw = Values[3];
...@@ -2564,9 +2474,7 @@ void FunctionParser::ProcessRecord() { ...@@ -2564,9 +2474,7 @@ void FunctionParser::ProcessRecord() {
if (!isValidRecordSize(4 + NumCases * 4, "switch")) if (!isValidRecordSize(4 + NumCases * 4, "switch"))
return; return;
std::unique_ptr<Ice::InstSwitch> Switch( std::unique_ptr<Ice::InstSwitch> Switch(
isIRGenDisabled ? nullptr Ice::InstSwitch::create(Func.get(), NumCases, Cond, DefaultLabel));
: Ice::InstSwitch::create(Func.get(), NumCases, Cond,
DefaultLabel));
unsigned ValCaseIndex = 4; // index to beginning of case entry. unsigned ValCaseIndex = 4; // index to beginning of case entry.
for (uint32_t CaseIndex = 0; CaseIndex < NumCases; for (uint32_t CaseIndex = 0; CaseIndex < NumCases;
++CaseIndex, ValCaseIndex += 4) { ++CaseIndex, ValCaseIndex += 4) {
...@@ -2580,15 +2488,11 @@ void FunctionParser::ProcessRecord() { ...@@ -2580,15 +2488,11 @@ void FunctionParser::ProcessRecord() {
} }
BitcodeInt Value(BitWidth, BitcodeInt Value(BitWidth,
NaClDecodeSignRotatedValue(Values[ValCaseIndex + 2])); NaClDecodeSignRotatedValue(Values[ValCaseIndex + 2]));
if (isIRGenDisabled)
continue;
Ice::CfgNode *Label = getBranchBasicBlock(Values[ValCaseIndex + 3]); Ice::CfgNode *Label = getBranchBasicBlock(Values[ValCaseIndex + 3]);
if (Label == nullptr) if (Label == nullptr)
return; return;
Switch->addBranch(CaseIndex, Value.getSExtValue(), Label); Switch->addBranch(CaseIndex, Value.getSExtValue(), Label);
} }
if (isIRGenDisabled)
return;
CurrentNode->appendInst(Switch.release()); CurrentNode->appendInst(Switch.release());
return; return;
} }
...@@ -2597,8 +2501,6 @@ void FunctionParser::ProcessRecord() { ...@@ -2597,8 +2501,6 @@ void FunctionParser::ProcessRecord() {
InstIsTerminating = true; InstIsTerminating = true;
if (!isValidRecordSize(0, "unreachable")) if (!isValidRecordSize(0, "unreachable"))
return; return;
if (isIRGenerationDisabled())
return;
CurrentNode->appendInst(Ice::InstUnreachable::create(Func.get())); CurrentNode->appendInst(Ice::InstUnreachable::create(Func.get()));
return; return;
} }
...@@ -2620,15 +2522,6 @@ void FunctionParser::ProcessRecord() { ...@@ -2620,15 +2522,6 @@ void FunctionParser::ProcessRecord() {
Error("Phi record using type void not allowed"); Error("Phi record using type void not allowed");
return; return;
} }
if (isIRGenerationDisabled()) {
// Verify arguments are defined before quitting.
for (unsigned i = 1; i < Values.size(); i += 2) {
assert(getRelativeOperand(NaClDecodeSignRotatedValue(Values[i]),
BaseIndex) == nullptr);
}
setNextLocalInstIndex(nullptr);
return;
}
Ice::Variable *Dest = getNextInstVar(Ty); Ice::Variable *Dest = getNextInstVar(Ty);
Ice::InstPhi *Phi = Ice::InstPhi *Phi =
Ice::InstPhi::create(Func.get(), Values.size() >> 1, Dest); Ice::InstPhi::create(Func.get(), Values.size() >> 1, Dest);
...@@ -2655,11 +2548,6 @@ void FunctionParser::ProcessRecord() { ...@@ -2655,11 +2548,6 @@ void FunctionParser::ProcessRecord() {
return; return;
Ice::Operand *ByteCount = getRelativeOperand(Values[0], BaseIndex); Ice::Operand *ByteCount = getRelativeOperand(Values[0], BaseIndex);
uint32_t Alignment = Context->extractAlignment(this, "Alloca", Values[1]); uint32_t Alignment = Context->extractAlignment(this, "Alloca", Values[1]);
if (isIRGenerationDisabled()) {
assert(ByteCount == nullptr);
setNextLocalInstIndex(nullptr);
return;
}
Ice::Type PtrTy = Ice::getPointerType(); Ice::Type PtrTy = Ice::getPointerType();
if (ByteCount->getType() != Ice::IceType_i32) { if (ByteCount->getType() != Ice::IceType_i32) {
std::string Buffer; std::string Buffer;
...@@ -2680,11 +2568,6 @@ void FunctionParser::ProcessRecord() { ...@@ -2680,11 +2568,6 @@ void FunctionParser::ProcessRecord() {
Ice::Operand *Address = getRelativeOperand(Values[0], BaseIndex); Ice::Operand *Address = getRelativeOperand(Values[0], BaseIndex);
Ice::Type Ty = Context->getSimpleTypeByID(Values[2]); Ice::Type Ty = Context->getSimpleTypeByID(Values[2]);
uint32_t Alignment = Context->extractAlignment(this, "Load", Values[1]); uint32_t Alignment = Context->extractAlignment(this, "Load", Values[1]);
if (isIRGenerationDisabled()) {
assert(Address == nullptr);
setNextLocalInstIndex(nullptr);
return;
}
if (!isValidPointerType(Address, "Load")) { if (!isValidPointerType(Address, "Load")) {
appendErrorInstruction(Ty); appendErrorInstruction(Ty);
return; return;
...@@ -2704,10 +2587,6 @@ void FunctionParser::ProcessRecord() { ...@@ -2704,10 +2587,6 @@ void FunctionParser::ProcessRecord() {
Ice::Operand *Address = getRelativeOperand(Values[0], BaseIndex); Ice::Operand *Address = getRelativeOperand(Values[0], BaseIndex);
Ice::Operand *Value = getRelativeOperand(Values[1], BaseIndex); Ice::Operand *Value = getRelativeOperand(Values[1], BaseIndex);
uint32_t Alignment = Context->extractAlignment(this, "Store", Values[2]); uint32_t Alignment = Context->extractAlignment(this, "Store", Values[2]);
if (isIRGenerationDisabled()) {
assert(Address == nullptr && Value == nullptr);
return;
}
if (!isValidPointerType(Address, "Store")) if (!isValidPointerType(Address, "Store"))
return; return;
if (!isValidLoadStoreAlignment(Alignment, Value->getType(), "Store")) if (!isValidLoadStoreAlignment(Alignment, Value->getType(), "Store"))
...@@ -2785,19 +2664,17 @@ void FunctionParser::ProcessRecord() { ...@@ -2785,19 +2664,17 @@ void FunctionParser::ProcessRecord() {
} else { // Record.GetCode() == naclbitc::FUNC_CODE_INST_CALL_INDIRECT } else { // Record.GetCode() == naclbitc::FUNC_CODE_INST_CALL_INDIRECT
// There is no signature. Assume defined by parameter types. // There is no signature. Assume defined by parameter types.
ReturnType = Context->getSimpleTypeByID(Values[2]); ReturnType = Context->getSimpleTypeByID(Values[2]);
if (!isIRGenerationDisabled() && Callee != nullptr) if (Callee != nullptr)
isValidPointerType(Callee, "Call indirect"); isValidPointerType(Callee, "Call indirect");
} }
if (Callee == nullptr && !isIRGenerationDisabled()) if (Callee == nullptr)
return; return;
// Extract out the the call parameters. // Extract out the the call parameters.
SmallVector<Ice::Operand *, 8> Params; SmallVector<Ice::Operand *, 8> Params;
for (Ice::SizeT Index = ParamsStartIndex; Index < Values.size(); ++Index) { for (Ice::SizeT Index = ParamsStartIndex; Index < Values.size(); ++Index) {
Ice::Operand *Op = getRelativeOperand(Values[Index], BaseIndex); Ice::Operand *Op = getRelativeOperand(Values[Index], BaseIndex);
if (isIRGenerationDisabled())
continue;
if (Op == nullptr) { if (Op == nullptr) {
std::string Buffer; std::string Buffer;
raw_string_ostream StrBuf(Buffer); raw_string_ostream StrBuf(Buffer);
...@@ -2821,12 +2698,6 @@ void FunctionParser::ProcessRecord() { ...@@ -2821,12 +2698,6 @@ void FunctionParser::ProcessRecord() {
ReturnType = Ice::IceType_i32; ReturnType = Ice::IceType_i32;
} }
if (isIRGenerationDisabled()) {
if (ReturnType != Ice::IceType_void)
setNextLocalInstIndex(nullptr);
return;
}
// Type check call parameters. // Type check call parameters.
for (Ice::SizeT Index = 0; Index < Params.size(); ++Index) { for (Ice::SizeT Index = 0; Index < Params.size(); ++Index) {
Ice::Operand *Op = Params[Index]; Ice::Operand *Op = Params[Index];
...@@ -2883,8 +2754,7 @@ void FunctionParser::ProcessRecord() { ...@@ -2883,8 +2754,7 @@ void FunctionParser::ProcessRecord() {
if (!isValidRecordSize(2, "forward type ref")) if (!isValidRecordSize(2, "forward type ref"))
return; return;
Ice::Type OpType = Context->getSimpleTypeByID(Values[1]); Ice::Type OpType = Context->getSimpleTypeByID(Values[1]);
setOperand(Values[0], setOperand(Values[0], createInstVar(OpType));
isIRGenerationDisabled() ? nullptr : createInstVar(OpType));
return; return;
} }
default: default:
...@@ -2949,10 +2819,6 @@ void ConstantsParser::ProcessRecord() { ...@@ -2949,10 +2819,6 @@ void ConstantsParser::ProcessRecord() {
return; return;
if (!isValidNextConstantType()) if (!isValidNextConstantType())
return; return;
if (isIRGenerationDisabled()) {
FuncParser->setNextConstantID(nullptr);
return;
}
FuncParser->setNextConstantID( FuncParser->setNextConstantID(
getContext()->getConstantUndef(NextConstantType)); getContext()->getConstantUndef(NextConstantType));
return; return;
...@@ -2963,10 +2829,6 @@ void ConstantsParser::ProcessRecord() { ...@@ -2963,10 +2829,6 @@ void ConstantsParser::ProcessRecord() {
return; return;
if (!isValidNextConstantType()) if (!isValidNextConstantType())
return; return;
if (isIRGenerationDisabled()) {
FuncParser->setNextConstantID(nullptr);
return;
}
if (Ice::isScalarIntegerType(NextConstantType)) { if (Ice::isScalarIntegerType(NextConstantType)) {
BitcodeInt Value(Ice::getScalarIntBitWidth(NextConstantType), BitcodeInt Value(Ice::getScalarIntBitWidth(NextConstantType),
NaClDecodeSignRotatedValue(Values[0])); NaClDecodeSignRotatedValue(Values[0]));
...@@ -2989,10 +2851,6 @@ void ConstantsParser::ProcessRecord() { ...@@ -2989,10 +2851,6 @@ void ConstantsParser::ProcessRecord() {
return; return;
if (!isValidNextConstantType()) if (!isValidNextConstantType())
return; return;
if (isIRGenerationDisabled()) {
FuncParser->setNextConstantID(nullptr);
return;
}
switch (NextConstantType) { switch (NextConstantType) {
case Ice::IceType_f32: { case Ice::IceType_f32: {
const BitcodeInt Value(32, static_cast<uint32_t>(Values[0])); const BitcodeInt Value(32, static_cast<uint32_t>(Values[0]));
...@@ -3067,8 +2925,6 @@ void FunctionValuesymtabParser::setValueName(NaClBcIndexSize_t Index, ...@@ -3067,8 +2925,6 @@ void FunctionValuesymtabParser::setValueName(NaClBcIndexSize_t Index,
reportUnableToAssign("Global value", Index, Name); reportUnableToAssign("Global value", Index, Name);
return; return;
} }
if (isIRGenerationDisabled())
return;
Ice::Operand *Op = getFunctionParser()->getOperand(Index); Ice::Operand *Op = getFunctionParser()->getOperand(Index);
if (auto *V = dyn_cast<Ice::Variable>(Op)) { if (auto *V = dyn_cast<Ice::Variable>(Op)) {
if (Ice::BuildDefs::dump()) { if (Ice::BuildDefs::dump()) {
...@@ -3084,8 +2940,6 @@ void FunctionValuesymtabParser::setBbName(NaClBcIndexSize_t Index, ...@@ -3084,8 +2940,6 @@ void FunctionValuesymtabParser::setBbName(NaClBcIndexSize_t Index,
StringType &Name) { StringType &Name) {
if (!Ice::BuildDefs::dump()) if (!Ice::BuildDefs::dump())
return; return;
if (isIRGenerationDisabled())
return;
if (Index >= getFunctionParser()->getFunc()->getNumNodes()) { if (Index >= getFunctionParser()->getFunc()->getNumNodes()) {
reportUnableToAssign("Basic block", Index, Name); reportUnableToAssign("Basic block", Index, Name);
return; return;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
; REQUIRES: no_minimal_build ; REQUIRES: no_minimal_build
; RUN: not %pnacl_sz -bitcode-as-text %p/Inputs/bad-bb-size.tbc \ ; RUN: not %pnacl_sz -bitcode-as-text %p/Inputs/bad-bb-size.tbc \
; RUN: -bitcode-format=pnacl -notranslate -no-ir-gen -build-on-read \ ; RUN: -bitcode-format=pnacl -notranslate -build-on-read \
; RUN: -allow-externally-defined-symbols 2>&1 \ ; RUN: -allow-externally-defined-symbols 2>&1 \
; RUN: | FileCheck %s ; RUN: | FileCheck %s
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
; REQUIRES: no_minimal_build ; REQUIRES: no_minimal_build
; RUN: not %pnacl_sz -bitcode-as-text %p/Inputs/bad-global-alignment.tbc \ ; RUN: not %pnacl_sz -bitcode-as-text %p/Inputs/bad-global-alignment.tbc \
; RUN: -bitcode-format=pnacl -notranslate -no-ir-gen -build-on-read 2>&1 \ ; RUN: -bitcode-format=pnacl -notranslate -build-on-read 2>&1 \
; RUN: | FileCheck %s ; RUN: | FileCheck %s
; CHECK: Global variable alignment greater than 2**29. Found: 2**30 ; CHECK: Global variable alignment greater than 2**29. Found: 2**30
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
; REQUIRES: no_minimal_build ; REQUIRES: no_minimal_build
; RUN: not %pnacl_sz -bitcode-as-text %p/Inputs/bad-var-fwdref.tbc \ ; RUN: not %pnacl_sz -bitcode-as-text %p/Inputs/bad-var-fwdref.tbc \
; RUN: -bitcode-format=pnacl -notranslate -no-ir-gen -build-on-read \ ; RUN: -bitcode-format=pnacl -notranslate -build-on-read \
; RUN: -allow-externally-defined-symbols 2>&1 \ ; RUN: -allow-externally-defined-symbols 2>&1 \
; RUN: | FileCheck %s ; RUN: | FileCheck %s
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
; REQUIRES: no_minimal_build ; REQUIRES: no_minimal_build
; RUN: not %pnacl_sz -bitcode-as-text %p/Inputs/duplicate-fcn-name.tbc \ ; RUN: not %pnacl_sz -bitcode-as-text %p/Inputs/duplicate-fcn-name.tbc \
; RUN: -bitcode-format=pnacl -notranslate -no-ir-gen -build-on-read 2>&1 \ ; RUN: -bitcode-format=pnacl -notranslate -build-on-read 2>&1 \
; RUN: | FileCheck %s ; RUN: | FileCheck %s
; CHECK: Module valuesymtab defines duplicate value name: 'f' ; CHECK: Module valuesymtab defines duplicate value name: 'f'
......
; Test if we can read alloca instructions. ; Test if we can read alloca instructions.
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %p2i -i %s --args -notranslate -timing | \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
; RUN: | %if --need=allow_disable_ir_gen --command \
; RUN: FileCheck --check-prefix=NOIR %s ; RUN: FileCheck --check-prefix=NOIR %s
; Show examples where size is defined by a constant. ; Show examples where size is defined by a constant.
......
...@@ -3,9 +3,7 @@ ...@@ -3,9 +3,7 @@
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %l2i -i %s --insts | %ifl FileCheck %s ; RUN: %l2i -i %s --insts | %ifl FileCheck %s
; RUN: %lc2i -i %s --insts | %iflc FileCheck %s ; RUN: %lc2i -i %s --insts | %iflc FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %p2i -i %s --args -notranslate -timing | \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
; RUN: | %if --need=allow_disable_ir_gen --command \
; RUN: FileCheck --check-prefix=NOIR %s ; RUN: FileCheck --check-prefix=NOIR %s
; TODO(kschimpf): add i8/i16. Needs bitcasts. ; TODO(kschimpf): add i8/i16. Needs bitcasts.
......
; Tests if we handle a branch instructions. ; Tests if we handle a branch instructions.
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %p2i -i %s --args -notranslate -timing | \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
; RUN: | %if --need=allow_disable_ir_gen --command \
; RUN: FileCheck --check-prefix=NOIR %s ; RUN: FileCheck --check-prefix=NOIR %s
define internal void @SimpleBranch() { define internal void @SimpleBranch() {
......
...@@ -2,10 +2,8 @@ ...@@ -2,10 +2,8 @@
; RUN: %p2i -i %s --insts --args -allow-externally-defined-symbols \ ; RUN: %p2i -i %s --insts --args -allow-externally-defined-symbols \
; RUN: | FileCheck %s ; RUN: | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %p2i -i %s --args -notranslate -timing \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: -allow-externally-defined-symbols | \
; RUN: -allow-externally-defined-symbols \
; RUN: | %if --need=allow_disable_ir_gen --command \
; RUN: FileCheck --check-prefix=NOIR %s ; RUN: FileCheck --check-prefix=NOIR %s
define internal i32 @fib(i32 %n) { define internal i32 @fib(i32 %n) {
......
; Tests if we can read cast operations. ; Tests if we can read cast operations.
; RUN: %p2i -i %s --insts --no-local-syms | FileCheck %s ; RUN: %p2i -i %s --insts --no-local-syms | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %p2i -i %s --args -notranslate -timing | \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
; RUN: | %if --need=allow_disable_ir_gen --command \
; RUN: FileCheck --check-prefix=NOIR %s ; RUN: FileCheck --check-prefix=NOIR %s
; TODO(kschimpf) Find way to test pointer conversions (since they in general ; TODO(kschimpf) Find way to test pointer conversions (since they in general
......
; Test if we can read compare instructions. ; Test if we can read compare instructions.
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %p2i -i %s --args -notranslate -timing | \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
; RUN: | %if --need=allow_disable_ir_gen --command \
; RUN: FileCheck --check-prefix=NOIR %s ; RUN: FileCheck --check-prefix=NOIR %s
define internal i1 @IcmpI1(i32 %p1, i32 %p2) { define internal i1 @IcmpI1(i32 %p1, i32 %p2) {
......
; Test handling of constants in function blocks. ; Test handling of constants in function blocks.
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %p2i -i %s --args -notranslate -timing | \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
; RUN: | %if --need=allow_disable_ir_gen --command \
; RUN: FileCheck --check-prefix=NOIR %s ; RUN: FileCheck --check-prefix=NOIR %s
define internal void @TestIntegers() { define internal void @TestIntegers() {
......
...@@ -3,9 +3,7 @@ ...@@ -3,9 +3,7 @@
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: llvm-as < %s | pnacl-freeze | pnacl-bcdis -no-records \ ; RUN: llvm-as < %s | pnacl-freeze | pnacl-bcdis -no-records \
; RUN: | FileCheck --check-prefix=DUMP %s ; RUN: | FileCheck --check-prefix=DUMP %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %p2i -i %s --args -notranslate -timing | \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
; RUN: | %if --need=allow_disable_ir_gen --command \
; RUN: FileCheck --check-prefix=NOIR %s ; RUN: FileCheck --check-prefix=NOIR %s
define internal void @LoopCarriedDep() { define internal void @LoopCarriedDep() {
......
...@@ -6,10 +6,8 @@ ...@@ -6,10 +6,8 @@
; RUN: | %ifl FileCheck %s ; RUN: | %ifl FileCheck %s
; RUN: %lc2i -i %s --insts --args -allow-externally-defined-symbols \ ; RUN: %lc2i -i %s --insts --args -allow-externally-defined-symbols \
; RUN: | %iflc FileCheck %s ; RUN: | %iflc FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %p2i -i %s --args -notranslate -timing \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: -allow-externally-defined-symbols | \
; RUN: -allow-externally-defined-symbols \
; RUN: | %if --need=allow_disable_ir_gen --command \
; RUN: FileCheck --check-prefix=NOIR %s ; RUN: FileCheck --check-prefix=NOIR %s
@PrimitiveInit = internal global [4 x i8] c"\1B\00\00\00", align 4 @PrimitiveInit = internal global [4 x i8] c"\1B\00\00\00", align 4
......
...@@ -3,9 +3,7 @@ ...@@ -3,9 +3,7 @@
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %l2i -i %s --insts | %ifl FileCheck %s ; RUN: %l2i -i %s --insts | %ifl FileCheck %s
; RUN: %lc2i -i %s --insts | %iflc FileCheck %s ; RUN: %lc2i -i %s --insts | %iflc FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %p2i -i %s --args -notranslate -timing | \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
; RUN: | %if --need=allow_disable_ir_gen --command \
; RUN: FileCheck --check-prefix=NOIR %s ; RUN: FileCheck --check-prefix=NOIR %s
@bytes = internal global [7 x i8] c"abcdefg" @bytes = internal global [7 x i8] c"abcdefg"
......
...@@ -3,9 +3,7 @@ ...@@ -3,9 +3,7 @@
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %l2i -i %s --insts | %ifl FileCheck %s ; RUN: %l2i -i %s --insts | %ifl FileCheck %s
; RUN: %lc2i -i %s --insts | %iflc FileCheck %s ; RUN: %lc2i -i %s --insts | %iflc FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %p2i -i %s --args -notranslate -timing | \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
; RUN: | %if --need=allow_disable_ir_gen --command \
; RUN: FileCheck --check-prefix=NOIR %s ; RUN: FileCheck --check-prefix=NOIR %s
define internal void @ExtractV4xi1(<4 x i1> %v) { define internal void @ExtractV4xi1(<4 x i1> %v) {
......
; Test if we can read load instructions. ; Test if we can read load instructions.
; RUN: %p2i --no-local-syms -i %s --insts | FileCheck %s ; RUN: %p2i --no-local-syms -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %p2i -i %s --args -notranslate -timing | \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
; RUN: | %if --need=allow_disable_ir_gen --command \
; RUN: FileCheck --check-prefix=NOIR %s ; RUN: FileCheck --check-prefix=NOIR %s
define internal i32 @load_i8(i32 %addr) { define internal i32 @load_i8(i32 %addr) {
......
; Test parsing NaCl atomic instructions. ; Test parsing NaCl atomic instructions.
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %p2i -i %s --args -notranslate -timing | \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
; RUN: | %if --need=allow_disable_ir_gen --command \
; RUN: FileCheck --check-prefix=NOIR %s ; RUN: FileCheck --check-prefix=NOIR %s
declare i8 @llvm.nacl.atomic.load.i8(i8*, i32) declare i8 @llvm.nacl.atomic.load.i8(i8*, i32)
......
...@@ -2,10 +2,8 @@ ...@@ -2,10 +2,8 @@
; RUN: %p2i -i %s --insts --args -allow-externally-defined-symbols \ ; RUN: %p2i -i %s --insts --args -allow-externally-defined-symbols \
; RUN: | FileCheck %s ; RUN: | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %p2i -i %s --args -notranslate -timing \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: -allow-externally-defined-symbols | \
; RUN: -allow-externally-defined-symbols \
; RUN: | %if --need=allow_disable_ir_gen --command \
; RUN: FileCheck --check-prefix=NOIR %s ; RUN: FileCheck --check-prefix=NOIR %s
declare i8* @llvm.nacl.read.tp() declare i8* @llvm.nacl.read.tp()
......
; Test reading phi instructions. ; Test reading phi instructions.
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %p2i -i %s --args -notranslate -timing | \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
; RUN: | %if --need=allow_disable_ir_gen --command \
; RUN: FileCheck --check-prefix=NOIR %s ; RUN: FileCheck --check-prefix=NOIR %s
; TODO(kschimpf) Add forward reference examples. ; TODO(kschimpf) Add forward reference examples.
......
; Tests if we can read select instructions. ; Tests if we can read select instructions.
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %p2i -i %s --args -notranslate -timing | \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
; RUN: | %if --need=allow_disable_ir_gen --command \
; RUN: FileCheck --check-prefix=NOIR %s ; RUN: FileCheck --check-prefix=NOIR %s
define internal void @Seli1(i32 %p) { define internal void @Seli1(i32 %p) {
......
; Test if we can read store instructions. ; Test if we can read store instructions.
; RUN: %p2i -i %s --insts --no-local-syms | FileCheck %s ; RUN: %p2i -i %s --insts --no-local-syms | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %p2i -i %s --args -notranslate -timing | \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
; RUN: | %if --need=allow_disable_ir_gen --command \
; RUN: FileCheck --check-prefix=NOIR %s ; RUN: FileCheck --check-prefix=NOIR %s
define internal void @store_i8(i32 %addr) { define internal void @store_i8(i32 %addr) {
......
; Test switch instructions. ; Test switch instructions.
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %p2i -i %s --args -notranslate -timing | \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
; RUN: | %if --need=allow_disable_ir_gen --command \
; RUN: FileCheck --check-prefix=NOIR %s ; RUN: FileCheck --check-prefix=NOIR %s
define internal void @testDefaultSwitch(i32 %a) { define internal void @testDefaultSwitch(i32 %a) {
......
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
; RUN: -default-function-prefix=h -default-global-prefix=g \ ; RUN: -default-function-prefix=h -default-global-prefix=g \
; RUN: | FileCheck --check-prefix=BAD %s ; RUN: | FileCheck --check-prefix=BAD %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %p2i -i %s --args -notranslate -timing | \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
; RUN: | %if --need=allow_disable_ir_gen --command \
; RUN: FileCheck --check-prefix=NOIR %s ; RUN: FileCheck --check-prefix=NOIR %s
; TODO(kschimpf) Check global variable declarations, once generated. ; TODO(kschimpf) Check global variable declarations, once generated.
......
; Test parsing unreachable instruction. ; Test parsing unreachable instruction.
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %p2i -i %s --args -notranslate -timing | \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
; RUN: | %if --need=allow_disable_ir_gen --command \
; RUN: FileCheck --check-prefix=NOIR %s ; RUN: FileCheck --check-prefix=NOIR %s
define internal i32 @divide(i32 %num, i32 %den) { define internal i32 @divide(i32 %num, i32 %den) {
......
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