Commit b6c96af1 by Karl Schimpf

Turn off dump/emit routines when building minimal subzero.

Remove the dump/emit routines when ALLOW_DUMP=0. Also fixes some verbosity messages to not print if ALLOW_DUMP=0. Note: emit routines needed for emitIAS are not turned off. BUG=None R=stichnot@chromium.org Review URL: https://codereview.chromium.org/686913005
parent 70d0a054
...@@ -14,6 +14,6 @@ include $(LEVEL)/Makefile.common ...@@ -14,6 +14,6 @@ include $(LEVEL)/Makefile.common
CXX.Flags += -std=c++11 CXX.Flags += -std=c++11
CPP.Defines += -DALLOW_TEXT_ASM=1 -DALLOW_DUMP=1 -DALLOW_LLVM_CL=1 \ CPP.Defines += -DALLOW_DUMP=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
...@@ -50,13 +50,11 @@ CXX_DEFINES = ...@@ -50,13 +50,11 @@ CXX_DEFINES =
ifdef MINIMAL ifdef MINIMAL
OBJDIR := $(OBJDIR)+Min OBJDIR := $(OBJDIR)+Min
CXX_DEFINES += -DALLOW_TEXT_ASM=0 -DALLOW_DUMP=0 -DALLOW_LLVM_CL=0 \ CXX_DEFINES += -DALLOW_DUMP=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_DISABLE_IR_GEN=0
else else
CXX_DEFINES += -DALLOW_TEXT_ASM=1 -DALLOW_DUMP=1 -DALLOW_LLVM_CL=1 \ CXX_DEFINES += -DALLOW_DUMP=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_DISABLE_IR_GEN=1
endif endif
ifdef NOASSERT ifdef NOASSERT
......
...@@ -396,6 +396,7 @@ void Cfg::doBranchOpt() { ...@@ -396,6 +396,7 @@ void Cfg::doBranchOpt() {
// ======================== Dump routines ======================== // // ======================== Dump routines ======================== //
void Cfg::emitTextHeader(const IceString &MangledName) { void Cfg::emitTextHeader(const IceString &MangledName) {
// Note: Still used by emit IAS.
Ostream &Str = Ctx->getStrEmit(); Ostream &Str = Ctx->getStrEmit();
Str << "\t.text\n"; Str << "\t.text\n";
if (Ctx->getFlags().FunctionSections) if (Ctx->getFlags().FunctionSections)
...@@ -412,6 +413,8 @@ void Cfg::emitTextHeader(const IceString &MangledName) { ...@@ -412,6 +413,8 @@ void Cfg::emitTextHeader(const IceString &MangledName) {
} }
void Cfg::emit() { void Cfg::emit() {
if (!ALLOW_DUMP)
return;
TimerMarker T(TimerStack::TT_emit, this); TimerMarker T(TimerStack::TT_emit, this);
if (Ctx->getFlags().DecorateAsm) { if (Ctx->getFlags().DecorateAsm) {
renumberInstructions(); renumberInstructions();
...@@ -449,6 +452,8 @@ void Cfg::emitIAS() { ...@@ -449,6 +452,8 @@ void Cfg::emitIAS() {
// Dumps the IR with an optional introductory message. // Dumps the IR with an optional introductory message.
void Cfg::dump(const IceString &Message) { void Cfg::dump(const IceString &Message) {
if (!ALLOW_DUMP)
return;
if (!Ctx->isVerbose()) if (!Ctx->isVerbose())
return; return;
Ostream &Str = Ctx->getStrDump(); Ostream &Str = Ctx->getStrDump();
......
...@@ -798,6 +798,8 @@ namespace { ...@@ -798,6 +798,8 @@ namespace {
void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node, void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node,
bool IsLiveIn, std::vector<SizeT> &LiveRegCount) { bool IsLiveIn, std::vector<SizeT> &LiveRegCount) {
if (!ALLOW_DUMP)
return;
Liveness *Liveness = Func->getLiveness(); Liveness *Liveness = Func->getLiveness();
const LivenessBV *Live; const LivenessBV *Live;
if (IsLiveIn) { if (IsLiveIn) {
...@@ -828,6 +830,8 @@ void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node, ...@@ -828,6 +830,8 @@ void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node,
void emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr, void emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr,
std::vector<SizeT> &LiveRegCount) { std::vector<SizeT> &LiveRegCount) {
if (!ALLOW_DUMP)
return;
bool First = true; bool First = true;
Variable *Dest = Instr->getDest(); Variable *Dest = Instr->getDest();
if (Dest && Dest->hasReg()) if (Dest && Dest->hasReg())
...@@ -873,6 +877,8 @@ void updateStats(Cfg *Func, const Inst *I) { ...@@ -873,6 +877,8 @@ void updateStats(Cfg *Func, const Inst *I) {
} // end of anonymous namespace } // end of anonymous namespace
void CfgNode::emit(Cfg *Func) const { void CfgNode::emit(Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Func->setCurrentNode(this); Func->setCurrentNode(this);
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
Liveness *Liveness = Func->getLiveness(); Liveness *Liveness = Func->getLiveness();
...@@ -930,6 +936,8 @@ void CfgNode::emitIAS(Cfg *Func) const { ...@@ -930,6 +936,8 @@ void CfgNode::emitIAS(Cfg *Func) const {
} }
void CfgNode::dump(Cfg *Func) const { void CfgNode::dump(Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Func->setCurrentNode(this); Func->setCurrentNode(this);
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Liveness *Liveness = Func->getLiveness(); Liveness *Liveness = Func->getLiveness();
......
...@@ -439,6 +439,8 @@ void GlobalContext::setTimerName(TimerStackIdT StackID, ...@@ -439,6 +439,8 @@ void GlobalContext::setTimerName(TimerStackIdT StackID,
} }
void GlobalContext::dumpStats(const IceString &Name, bool Final) { void GlobalContext::dumpStats(const IceString &Name, bool Final) {
if (!ALLOW_DUMP)
return;
if (Flags.DumpStats) { if (Flags.DumpStats) {
if (Final) { if (Final) {
StatsCumulative.dump(Name, getStrDump()); StatsCumulative.dump(Name, getStrDump());
...@@ -450,6 +452,8 @@ void GlobalContext::dumpStats(const IceString &Name, bool Final) { ...@@ -450,6 +452,8 @@ void GlobalContext::dumpStats(const IceString &Name, bool Final) {
} }
void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) { void GlobalContext::dumpTimers(TimerStackIdT StackID, bool DumpCumulative) {
if (!ALLOW_DUMP)
return;
assert(Timers.size() > StackID); assert(Timers.size() > StackID);
Timers[StackID].dump(getStrDump(), DumpCumulative); Timers[StackID].dump(getStrDump(), DumpCumulative);
} }
......
...@@ -48,6 +48,8 @@ public: ...@@ -48,6 +48,8 @@ public:
void updateSpills() { ++Spills; } void updateSpills() { ++Spills; }
void updateFills() { ++Fills; } void updateFills() { ++Fills; }
void dump(const IceString &Name, Ostream &Str) { void dump(const IceString &Name, Ostream &Str) {
if (!ALLOW_DUMP)
return;
Str << "|" << Name << "|Inst Count |" << InstructionsEmitted << "\n"; Str << "|" << Name << "|Inst Count |" << InstructionsEmitted << "\n";
Str << "|" << Name << "|Regs Saved |" << RegistersSaved << "\n"; Str << "|" << Name << "|Regs Saved |" << RegistersSaved << "\n";
Str << "|" << Name << "|Frame Bytes |" << FrameBytes << "\n"; Str << "|" << Name << "|Frame Bytes |" << FrameBytes << "\n";
......
...@@ -27,6 +27,8 @@ char hexdigit(unsigned X) { return X < 10 ? '0' + X : 'A' + X - 10; } ...@@ -27,6 +27,8 @@ char hexdigit(unsigned X) { return X < 10 ? '0' + X : 'A' + X - 10; }
void dumpLinkage(Ice::Ostream &Stream, void dumpLinkage(Ice::Ostream &Stream,
llvm::GlobalValue::LinkageTypes Linkage) { llvm::GlobalValue::LinkageTypes Linkage) {
if (!ALLOW_DUMP)
return;
switch (Linkage) { switch (Linkage) {
case llvm::GlobalValue::ExternalLinkage: case llvm::GlobalValue::ExternalLinkage:
Stream << "external"; Stream << "external";
...@@ -44,6 +46,8 @@ void dumpLinkage(Ice::Ostream &Stream, ...@@ -44,6 +46,8 @@ void dumpLinkage(Ice::Ostream &Stream,
} }
void dumpCallingConv(Ice::Ostream &, llvm::CallingConv::ID CallingConv) { void dumpCallingConv(Ice::Ostream &, llvm::CallingConv::ID CallingConv) {
if (!ALLOW_DUMP)
return;
if (CallingConv == llvm::CallingConv::C) if (CallingConv == llvm::CallingConv::C)
return; return;
std::string Buffer; std::string Buffer;
...@@ -65,10 +69,14 @@ FunctionDeclaration::create(GlobalContext *Ctx, const FuncSigType &Signature, ...@@ -65,10 +69,14 @@ FunctionDeclaration::create(GlobalContext *Ctx, const FuncSigType &Signature,
} }
void FunctionDeclaration::dumpType(Ostream &Stream) const { void FunctionDeclaration::dumpType(Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
Stream << Signature; Stream << Signature;
} }
void FunctionDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const { void FunctionDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
if (IsProto) if (IsProto)
Stream << "declare "; Stream << "declare ";
::dumpLinkage(Stream, Linkage); ::dumpLinkage(Stream, Linkage);
...@@ -95,6 +103,8 @@ VariableDeclaration::~VariableDeclaration() { ...@@ -95,6 +103,8 @@ VariableDeclaration::~VariableDeclaration() {
} }
void VariableDeclaration::dumpType(Ostream &Stream) const { void VariableDeclaration::dumpType(Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
if (Initializers.size() == 1) { if (Initializers.size() == 1) {
Initializers.front()->dumpType(Stream); Initializers.front()->dumpType(Stream);
} else { } else {
...@@ -113,6 +123,8 @@ void VariableDeclaration::dumpType(Ostream &Stream) const { ...@@ -113,6 +123,8 @@ void VariableDeclaration::dumpType(Ostream &Stream) const {
} }
void VariableDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const { void VariableDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
Stream << "@" << ((Ctx && !getSuppressMangling()) Stream << "@" << ((Ctx && !getSuppressMangling())
? Ctx->mangleName(Name) : Name) << " = "; ? Ctx->mangleName(Name) : Name) << " = ";
::dumpLinkage(Stream, Linkage); ::dumpLinkage(Stream, Linkage);
...@@ -143,11 +155,15 @@ void VariableDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const { ...@@ -143,11 +155,15 @@ void VariableDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const {
} }
void VariableDeclaration::Initializer::dumpType(Ostream &Stream) const { void VariableDeclaration::Initializer::dumpType(Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
Stream << "[" << getNumBytes() << " x " << Ice::IceType_i8 << "]"; Stream << "[" << getNumBytes() << " x " << Ice::IceType_i8 << "]";
} }
void VariableDeclaration::DataInitializer::dump( void VariableDeclaration::DataInitializer::dump(
GlobalContext *, Ostream &Stream) const { GlobalContext *, Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
dumpType(Stream); dumpType(Stream);
Stream << " c\""; Stream << " c\"";
// Code taken from PrintEscapedString() in AsmWriter.cpp. Keep // Code taken from PrintEscapedString() in AsmWriter.cpp. Keep
...@@ -164,16 +180,22 @@ void VariableDeclaration::DataInitializer::dump( ...@@ -164,16 +180,22 @@ void VariableDeclaration::DataInitializer::dump(
void VariableDeclaration::ZeroInitializer::dump( void VariableDeclaration::ZeroInitializer::dump(
GlobalContext *, Ostream &Stream) const { GlobalContext *, Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
dumpType(Stream); dumpType(Stream);
Stream << " zeroinitializer"; Stream << " zeroinitializer";
} }
void VariableDeclaration::RelocInitializer::dumpType(Ostream &Stream) const { void VariableDeclaration::RelocInitializer::dumpType(Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
Stream << Ice::IceType_i32; Stream << Ice::IceType_i32;
} }
void VariableDeclaration::RelocInitializer::dump( void VariableDeclaration::RelocInitializer::dump(
GlobalContext *Ctx, Ostream &Stream) const { GlobalContext *Ctx, Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
if (Offset != 0) { if (Offset != 0) {
dumpType(Stream); dumpType(Stream);
Stream << " add ("; Stream << " add (";
......
...@@ -61,6 +61,8 @@ public: ...@@ -61,6 +61,8 @@ public:
/// Prints out the global declaration. /// Prints out the global declaration.
virtual void dump(GlobalContext *Ctx, Ostream &Stream) const = 0; virtual void dump(GlobalContext *Ctx, Ostream &Stream) const = 0;
void dump(Ostream &Stream) const { void dump(Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
GlobalContext *const Ctx = nullptr; GlobalContext *const Ctx = nullptr;
dump(Ctx, Stream); dump(Ctx, Stream);
} }
...@@ -149,6 +151,7 @@ public: ...@@ -149,6 +151,7 @@ public:
virtual SizeT getNumBytes() const = 0; virtual SizeT getNumBytes() const = 0;
virtual void dump(GlobalContext *Ctx, Ostream &Stream) const = 0; virtual void dump(GlobalContext *Ctx, Ostream &Stream) const = 0;
void dump(Ostream &Stream) const { void dump(Ostream &Stream) const {
if (ALLOW_DUMP)
dump(nullptr, Stream); dump(nullptr, Stream);
} }
virtual void dumpType(Ostream &Stream) const; virtual void dumpType(Ostream &Stream) const;
......
...@@ -449,9 +449,17 @@ InstFakeUse::InstFakeUse(Cfg *Func, Variable *Src) ...@@ -449,9 +449,17 @@ InstFakeUse::InstFakeUse(Cfg *Func, Variable *Src)
InstFakeKill::InstFakeKill(Cfg *Func, const Inst *Linked) InstFakeKill::InstFakeKill(Cfg *Func, const Inst *Linked)
: InstHighLevel(Func, Inst::FakeKill, 0, NULL), Linked(Linked) {} : InstHighLevel(Func, Inst::FakeKill, 0, NULL), Linked(Linked) {}
Type InstCall::getReturnType() const {
if (Dest == NULL)
return IceType_void;
return Dest->getType();
}
// ======================== Dump routines ======================== // // ======================== Dump routines ======================== //
void Inst::dumpDecorated(const Cfg *Func) const { void Inst::dumpDecorated(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
if (!Func->getContext()->isVerbose(IceV_Deleted) && if (!Func->getContext()->isVerbose(IceV_Deleted) &&
(isDeleted() || isRedundantAssign())) (isDeleted() || isRedundantAssign()))
...@@ -474,6 +482,8 @@ void Inst::dumpDecorated(const Cfg *Func) const { ...@@ -474,6 +482,8 @@ void Inst::dumpDecorated(const Cfg *Func) const {
} }
void Inst::dump(const Cfg *Func) const { void Inst::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " =~ "; Str << " =~ ";
...@@ -481,6 +491,8 @@ void Inst::dump(const Cfg *Func) const { ...@@ -481,6 +491,8 @@ void Inst::dump(const Cfg *Func) const {
} }
void Inst::dumpExtras(const Cfg *Func) const { void Inst::dumpExtras(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
bool First = true; bool First = true;
// Print "LIVEEND={a,b,c}" for all source operands whose live ranges // Print "LIVEEND={a,b,c}" for all source operands whose live ranges
...@@ -507,6 +519,8 @@ void Inst::dumpExtras(const Cfg *Func) const { ...@@ -507,6 +519,8 @@ void Inst::dumpExtras(const Cfg *Func) const {
} }
void Inst::dumpSources(const Cfg *Func) const { void Inst::dumpSources(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
for (SizeT I = 0; I < getSrcSize(); ++I) { for (SizeT I = 0; I < getSrcSize(); ++I) {
if (I > 0) if (I > 0)
...@@ -516,6 +530,8 @@ void Inst::dumpSources(const Cfg *Func) const { ...@@ -516,6 +530,8 @@ void Inst::dumpSources(const Cfg *Func) const {
} }
void Inst::emitSources(const Cfg *Func) const { void Inst::emitSources(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
for (SizeT I = 0; I < getSrcSize(); ++I) { for (SizeT I = 0; I < getSrcSize(); ++I) {
if (I > 0) if (I > 0)
...@@ -525,11 +541,15 @@ void Inst::emitSources(const Cfg *Func) const { ...@@ -525,11 +541,15 @@ void Inst::emitSources(const Cfg *Func) const {
} }
void Inst::dumpDest(const Cfg *Func) const { void Inst::dumpDest(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
if (getDest()) if (getDest())
getDest()->dump(Func); getDest()->dump(Func);
} }
void InstAlloca::dump(const Cfg *Func) const { void InstAlloca::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = alloca i8, i32 "; Str << " = alloca i8, i32 ";
...@@ -539,6 +559,8 @@ void InstAlloca::dump(const Cfg *Func) const { ...@@ -539,6 +559,8 @@ void InstAlloca::dump(const Cfg *Func) const {
} }
void InstArithmetic::dump(const Cfg *Func) const { void InstArithmetic::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << InstArithmeticAttributes[getOp()].DisplayString << " " Str << " = " << InstArithmeticAttributes[getOp()].DisplayString << " "
...@@ -547,6 +569,8 @@ void InstArithmetic::dump(const Cfg *Func) const { ...@@ -547,6 +569,8 @@ void InstArithmetic::dump(const Cfg *Func) const {
} }
void InstAssign::dump(const Cfg *Func) const { void InstAssign::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << getDest()->getType() << " "; Str << " = " << getDest()->getType() << " ";
...@@ -554,6 +578,8 @@ void InstAssign::dump(const Cfg *Func) const { ...@@ -554,6 +578,8 @@ void InstAssign::dump(const Cfg *Func) const {
} }
void InstBr::dump(const Cfg *Func) const { void InstBr::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << "br "; Str << "br ";
...@@ -565,13 +591,9 @@ void InstBr::dump(const Cfg *Func) const { ...@@ -565,13 +591,9 @@ void InstBr::dump(const Cfg *Func) const {
Str << "label %" << getTargetFalse()->getName(); Str << "label %" << getTargetFalse()->getName();
} }
Type InstCall::getReturnType() const {
if (Dest == NULL)
return IceType_void;
return Dest->getType();
}
void InstCall::dump(const Cfg *Func) const { void InstCall::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
if (getDest()) { if (getDest()) {
dumpDest(Func); dumpDest(Func);
...@@ -595,6 +617,8 @@ void InstCall::dump(const Cfg *Func) const { ...@@ -595,6 +617,8 @@ void InstCall::dump(const Cfg *Func) const {
} }
void InstCast::dump(const Cfg *Func) const { void InstCast::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << InstCastAttributes[getCastKind()].DisplayString << " " Str << " = " << InstCastAttributes[getCastKind()].DisplayString << " "
...@@ -604,6 +628,8 @@ void InstCast::dump(const Cfg *Func) const { ...@@ -604,6 +628,8 @@ void InstCast::dump(const Cfg *Func) const {
} }
void InstIcmp::dump(const Cfg *Func) const { void InstIcmp::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = icmp " << InstIcmpAttributes[getCondition()].DisplayString << " " Str << " = icmp " << InstIcmpAttributes[getCondition()].DisplayString << " "
...@@ -612,6 +638,8 @@ void InstIcmp::dump(const Cfg *Func) const { ...@@ -612,6 +638,8 @@ void InstIcmp::dump(const Cfg *Func) const {
} }
void InstExtractElement::dump(const Cfg *Func) const { void InstExtractElement::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = extractelement "; Str << " = extractelement ";
...@@ -623,6 +651,8 @@ void InstExtractElement::dump(const Cfg *Func) const { ...@@ -623,6 +651,8 @@ void InstExtractElement::dump(const Cfg *Func) const {
} }
void InstInsertElement::dump(const Cfg *Func) const { void InstInsertElement::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = insertelement "; Str << " = insertelement ";
...@@ -637,6 +667,8 @@ void InstInsertElement::dump(const Cfg *Func) const { ...@@ -637,6 +667,8 @@ void InstInsertElement::dump(const Cfg *Func) const {
} }
void InstFcmp::dump(const Cfg *Func) const { void InstFcmp::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = fcmp " << InstFcmpAttributes[getCondition()].DisplayString << " " Str << " = fcmp " << InstFcmpAttributes[getCondition()].DisplayString << " "
...@@ -645,6 +677,8 @@ void InstFcmp::dump(const Cfg *Func) const { ...@@ -645,6 +677,8 @@ void InstFcmp::dump(const Cfg *Func) const {
} }
void InstLoad::dump(const Cfg *Func) const { void InstLoad::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Type Ty = getDest()->getType(); Type Ty = getDest()->getType();
...@@ -654,6 +688,8 @@ void InstLoad::dump(const Cfg *Func) const { ...@@ -654,6 +688,8 @@ void InstLoad::dump(const Cfg *Func) const {
} }
void InstStore::dump(const Cfg *Func) const { void InstStore::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Type Ty = getData()->getType(); Type Ty = getData()->getType();
Str << "store " << Ty << " "; Str << "store " << Ty << " ";
...@@ -664,6 +700,8 @@ void InstStore::dump(const Cfg *Func) const { ...@@ -664,6 +700,8 @@ void InstStore::dump(const Cfg *Func) const {
} }
void InstSwitch::dump(const Cfg *Func) const { void InstSwitch::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Type Ty = getComparison()->getType(); Type Ty = getComparison()->getType();
Str << "switch " << Ty << " "; Str << "switch " << Ty << " ";
...@@ -677,6 +715,8 @@ void InstSwitch::dump(const Cfg *Func) const { ...@@ -677,6 +715,8 @@ void InstSwitch::dump(const Cfg *Func) const {
} }
void InstPhi::dump(const Cfg *Func) const { void InstPhi::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = phi " << getDest()->getType() << " "; Str << " = phi " << getDest()->getType() << " ";
...@@ -690,6 +730,8 @@ void InstPhi::dump(const Cfg *Func) const { ...@@ -690,6 +730,8 @@ void InstPhi::dump(const Cfg *Func) const {
} }
void InstRet::dump(const Cfg *Func) const { void InstRet::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Type Ty = hasRetValue() ? getRetValue()->getType() : IceType_void; Type Ty = hasRetValue() ? getRetValue()->getType() : IceType_void;
Str << "ret " << Ty; Str << "ret " << Ty;
...@@ -700,6 +742,8 @@ void InstRet::dump(const Cfg *Func) const { ...@@ -700,6 +742,8 @@ void InstRet::dump(const Cfg *Func) const {
} }
void InstSelect::dump(const Cfg *Func) const { void InstSelect::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Operand *Condition = getCondition(); Operand *Condition = getCondition();
...@@ -714,11 +758,15 @@ void InstSelect::dump(const Cfg *Func) const { ...@@ -714,11 +758,15 @@ void InstSelect::dump(const Cfg *Func) const {
} }
void InstUnreachable::dump(const Cfg *Func) const { void InstUnreachable::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "unreachable"; Str << "unreachable";
} }
void InstFakeDef::emit(const Cfg *Func) const { void InstFakeDef::emit(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
// Go ahead and "emit" these for now, since they are relatively // Go ahead and "emit" these for now, since they are relatively
// rare. // rare.
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
...@@ -729,6 +777,8 @@ void InstFakeDef::emit(const Cfg *Func) const { ...@@ -729,6 +777,8 @@ void InstFakeDef::emit(const Cfg *Func) const {
} }
void InstFakeDef::dump(const Cfg *Func) const { void InstFakeDef::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = def.pseudo "; Str << " = def.pseudo ";
...@@ -738,6 +788,8 @@ void InstFakeDef::dump(const Cfg *Func) const { ...@@ -738,6 +788,8 @@ void InstFakeDef::dump(const Cfg *Func) const {
void InstFakeUse::emit(const Cfg *Func) const { (void)Func; } void InstFakeUse::emit(const Cfg *Func) const { (void)Func; }
void InstFakeUse::dump(const Cfg *Func) const { void InstFakeUse::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "use.pseudo "; Str << "use.pseudo ";
dumpSources(Func); dumpSources(Func);
...@@ -746,6 +798,8 @@ void InstFakeUse::dump(const Cfg *Func) const { ...@@ -746,6 +798,8 @@ void InstFakeUse::dump(const Cfg *Func) const {
void InstFakeKill::emit(const Cfg *Func) const { (void)Func; } void InstFakeKill::emit(const Cfg *Func) const { (void)Func; }
void InstFakeKill::dump(const Cfg *Func) const { void InstFakeKill::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
if (Linked->isDeleted()) if (Linked->isDeleted())
Str << "// "; Str << "// ";
...@@ -753,6 +807,8 @@ void InstFakeKill::dump(const Cfg *Func) const { ...@@ -753,6 +807,8 @@ void InstFakeKill::dump(const Cfg *Func) const {
} }
void InstTarget::dump(const Cfg *Func) const { void InstTarget::dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "[TARGET] "; Str << "[TARGET] ";
Inst::dump(Func); Inst::dump(Func);
......
...@@ -838,8 +838,8 @@ protected: ...@@ -838,8 +838,8 @@ protected:
// Override the default ilist traits so that Inst's private ctor and // Override the default ilist traits so that Inst's private ctor and
// deleted dtor aren't invoked. // deleted dtor aren't invoked.
template <> template <>
struct llvm::ilist_traits<Ice::Inst> : public llvm::ilist_default_traits< struct llvm::ilist_traits<Ice::Inst>
Ice::Inst> { : public llvm::ilist_default_traits<Ice::Inst> {
Ice::Inst *createSentinel() const { Ice::Inst *createSentinel() const {
return static_cast<Ice::Inst *>(&Sentinel); return static_cast<Ice::Inst *>(&Sentinel);
} }
......
...@@ -41,6 +41,7 @@ public: ...@@ -41,6 +41,7 @@ public:
}; };
using Operand::dump; using Operand::dump;
void dump(const Cfg *, Ostream &Str) const override { void dump(const Cfg *, Ostream &Str) const override {
if (ALLOW_DUMP)
Str << "<OperandX8632>"; Str << "<OperandX8632>";
} }
...@@ -465,6 +466,8 @@ public: ...@@ -465,6 +466,8 @@ public:
InstX8632InplaceopGPR(Func, SrcDest); InstX8632InplaceopGPR(Func, SrcDest);
} }
void emit(const Cfg *Func) const override { void emit(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1); assert(getSrcSize() == 1);
Str << "\t" << Opcode << "\t"; Str << "\t" << Opcode << "\t";
...@@ -477,6 +480,8 @@ public: ...@@ -477,6 +480,8 @@ public:
emitIASOpTyGPR(Func, Ty, Var, Emitter); emitIASOpTyGPR(Func, Ty, Var, Emitter);
} }
void dump(const Cfg *Func) const override { void dump(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " "; Str << " = " << Opcode << "." << getDest()->getType() << " ";
...@@ -513,6 +518,8 @@ public: ...@@ -513,6 +518,8 @@ public:
InstX8632UnaryopGPR(Func, Dest, Src); InstX8632UnaryopGPR(Func, Dest, Src);
} }
void emit(const Cfg *Func) const override { void emit(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1); assert(getSrcSize() == 1);
Type SrcTy = getSrc(0)->getType(); Type SrcTy = getSrc(0)->getType();
...@@ -536,6 +543,8 @@ public: ...@@ -536,6 +543,8 @@ public:
emitIASRegOpTyGPR(Func, Ty, Var, Src, Emitter); emitIASRegOpTyGPR(Func, Ty, Var, Src, Emitter);
} }
void dump(const Cfg *Func) const override { void dump(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << Opcode << "." << getSrc(0)->getType() << " "; Str << " = " << Opcode << "." << getSrc(0)->getType() << " ";
...@@ -568,6 +577,8 @@ public: ...@@ -568,6 +577,8 @@ public:
InstX8632UnaryopXmm(Func, Dest, Src); InstX8632UnaryopXmm(Func, Dest, Src);
} }
void emit(const Cfg *Func) const override { void emit(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1); assert(getSrcSize() == 1);
Str << "\t" << Opcode << "\t"; Str << "\t" << Opcode << "\t";
...@@ -581,6 +592,8 @@ public: ...@@ -581,6 +592,8 @@ public:
emitIASRegOpTyXMM(Func, Ty, getDest(), getSrc(0), Emitter); emitIASRegOpTyXMM(Func, Ty, getDest(), getSrc(0), Emitter);
} }
void dump(const Cfg *Func) const override { void dump(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " "; Str << " = " << Opcode << "." << getDest()->getType() << " ";
...@@ -620,6 +633,8 @@ public: ...@@ -620,6 +633,8 @@ public:
InstX8632BinopGPRShift(Func, Dest, Source); InstX8632BinopGPRShift(Func, Dest, Source);
} }
void emit(const Cfg *Func) const override { void emit(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
const bool ShiftHack = true; const bool ShiftHack = true;
emitTwoAddress(Opcode, this, Func, ShiftHack); emitTwoAddress(Opcode, this, Func, ShiftHack);
} }
...@@ -629,6 +644,8 @@ public: ...@@ -629,6 +644,8 @@ public:
emitIASGPRShift(Func, Ty, getDest(), getSrc(1), Emitter); emitIASGPRShift(Func, Ty, getDest(), getSrc(1), Emitter);
} }
void dump(const Cfg *Func) const override { void dump(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " "; Str << " = " << Opcode << "." << getDest()->getType() << " ";
...@@ -659,6 +676,8 @@ public: ...@@ -659,6 +676,8 @@ public:
InstX8632BinopGPR(Func, Dest, Source); InstX8632BinopGPR(Func, Dest, Source);
} }
void emit(const Cfg *Func) const override { void emit(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
const bool ShiftHack = false; const bool ShiftHack = false;
emitTwoAddress(Opcode, this, Func, ShiftHack); emitTwoAddress(Opcode, this, Func, ShiftHack);
} }
...@@ -668,6 +687,8 @@ public: ...@@ -668,6 +687,8 @@ public:
emitIASRegOpTyGPR(Func, Ty, getDest(), getSrc(1), Emitter); emitIASRegOpTyGPR(Func, Ty, getDest(), getSrc(1), Emitter);
} }
void dump(const Cfg *Func) const override { void dump(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " "; Str << " = " << Opcode << "." << getDest()->getType() << " ";
...@@ -698,6 +719,8 @@ public: ...@@ -698,6 +719,8 @@ public:
InstX8632BinopXmm(Func, Dest, Source); InstX8632BinopXmm(Func, Dest, Source);
} }
void emit(const Cfg *Func) const override { void emit(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
const bool ShiftHack = false; const bool ShiftHack = false;
emitTwoAddress(Opcode, this, Func, ShiftHack); emitTwoAddress(Opcode, this, Func, ShiftHack);
} }
...@@ -709,6 +732,8 @@ public: ...@@ -709,6 +732,8 @@ public:
emitIASRegOpTyXMM(Func, Ty, getDest(), getSrc(1), Emitter); emitIASRegOpTyXMM(Func, Ty, getDest(), getSrc(1), Emitter);
} }
void dump(const Cfg *Func) const override { void dump(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " "; Str << " = " << Opcode << "." << getDest()->getType() << " ";
...@@ -744,6 +769,8 @@ public: ...@@ -744,6 +769,8 @@ public:
InstX8632BinopXmmShift(Func, Dest, Source); InstX8632BinopXmmShift(Func, Dest, Source);
} }
void emit(const Cfg *Func) const override { void emit(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
const bool ShiftHack = false; const bool ShiftHack = false;
emitTwoAddress(Opcode, this, Func, ShiftHack); emitTwoAddress(Opcode, this, Func, ShiftHack);
} }
...@@ -756,6 +783,8 @@ public: ...@@ -756,6 +783,8 @@ public:
emitIASXmmShift(Func, ElementTy, getDest(), getSrc(1), Emitter); emitIASXmmShift(Func, ElementTy, getDest(), getSrc(1), Emitter);
} }
void dump(const Cfg *Func) const override { void dump(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " "; Str << " = " << Opcode << "." << getDest()->getType() << " ";
...@@ -786,6 +815,8 @@ public: ...@@ -786,6 +815,8 @@ public:
InstX8632Ternop(Func, Dest, Source1, Source2); InstX8632Ternop(Func, Dest, Source1, Source2);
} }
void emit(const Cfg *Func) const override { void emit(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 3); assert(getSrcSize() == 3);
Str << "\t" << Opcode << "\t"; Str << "\t" << Opcode << "\t";
...@@ -797,6 +828,8 @@ public: ...@@ -797,6 +828,8 @@ public:
} }
void emitIAS(const Cfg *Func) const override; void emitIAS(const Cfg *Func) const override;
void dump(const Cfg *Func) const override { void dump(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " "; Str << " = " << Opcode << "." << getDest()->getType() << " ";
...@@ -828,6 +861,8 @@ public: ...@@ -828,6 +861,8 @@ public:
InstX8632ThreeAddressop(Func, Dest, Source0, Source1); InstX8632ThreeAddressop(Func, Dest, Source0, Source1);
} }
void emit(const Cfg *Func) const override { void emit(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 2); assert(getSrcSize() == 2);
Str << "\t" << Opcode << "\t"; Str << "\t" << Opcode << "\t";
...@@ -839,6 +874,8 @@ public: ...@@ -839,6 +874,8 @@ public:
} }
void emitIAS(const Cfg *Func) const override; void emitIAS(const Cfg *Func) const override;
void dump(const Cfg *Func) const override { void dump(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
dumpDest(Func); dumpDest(Func);
Str << " = " << Opcode << "." << getDest()->getType() << " "; Str << " = " << Opcode << "." << getDest()->getType() << " ";
...@@ -877,6 +914,8 @@ public: ...@@ -877,6 +914,8 @@ public:
void emit(const Cfg *Func) const override; void emit(const Cfg *Func) const override;
void emitIAS(const Cfg *Func) const override; void emitIAS(const Cfg *Func) const override;
void dump(const Cfg *Func) const override { void dump(const Cfg *Func) const override {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << Opcode << "." << getDest()->getType() << " "; Str << Opcode << "." << getDest()->getType() << " ";
dumpDest(Func); dumpDest(Func);
......
...@@ -427,10 +427,13 @@ const InstDefList VariablesMetadata::NoDefinitions; ...@@ -427,10 +427,13 @@ const InstDefList VariablesMetadata::NoDefinitions;
// ======================== dump routines ======================== // // ======================== dump routines ======================== //
void Variable::emit(const Cfg *Func) const { void Variable::emit(const Cfg *Func) const {
if (ALLOW_DUMP)
Func->getTarget()->emitVariable(this); Func->getTarget()->emitVariable(this);
} }
void Variable::dump(const Cfg *Func, Ostream &Str) const { void Variable::dump(const Cfg *Func, Ostream &Str) const {
if (!ALLOW_DUMP)
return;
if (Func == NULL) { if (Func == NULL) {
Str << "%" << getName(); Str << "%" << getName();
return; return;
...@@ -458,6 +461,8 @@ void Variable::dump(const Cfg *Func, Ostream &Str) const { ...@@ -458,6 +461,8 @@ void Variable::dump(const Cfg *Func, Ostream &Str) const {
} }
void ConstantRelocatable::emitWithoutDollar(GlobalContext *Ctx) const { void ConstantRelocatable::emitWithoutDollar(GlobalContext *Ctx) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Ctx->getStrEmit(); Ostream &Str = Ctx->getStrEmit();
if (SuppressMangling) if (SuppressMangling)
Str << Name; Str << Name;
...@@ -471,12 +476,16 @@ void ConstantRelocatable::emitWithoutDollar(GlobalContext *Ctx) const { ...@@ -471,12 +476,16 @@ void ConstantRelocatable::emitWithoutDollar(GlobalContext *Ctx) const {
} }
void ConstantRelocatable::emit(GlobalContext *Ctx) const { void ConstantRelocatable::emit(GlobalContext *Ctx) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Ctx->getStrEmit(); Ostream &Str = Ctx->getStrEmit();
Str << "$"; Str << "$";
emitWithoutDollar(Ctx); emitWithoutDollar(Ctx);
} }
void ConstantRelocatable::dump(const Cfg *Func, Ostream &Str) const { void ConstantRelocatable::dump(const Cfg *Func, Ostream &Str) const {
if (!ALLOW_DUMP)
return;
Str << "@"; Str << "@";
if (Func && !SuppressMangling) { if (Func && !SuppressMangling) {
Str << Func->getContext()->mangleName(Name); Str << Func->getContext()->mangleName(Name);
...@@ -488,6 +497,8 @@ void ConstantRelocatable::dump(const Cfg *Func, Ostream &Str) const { ...@@ -488,6 +497,8 @@ void ConstantRelocatable::dump(const Cfg *Func, Ostream &Str) const {
} }
void LiveRange::dump(Ostream &Str) const { void LiveRange::dump(Ostream &Str) const {
if (!ALLOW_DUMP)
return;
Str << "(weight=" << Weight << ") "; Str << "(weight=" << Weight << ") ";
bool First = true; bool First = true;
for (const RangeElementType &I : Range) { for (const RangeElementType &I : Range) {
...@@ -499,11 +510,15 @@ void LiveRange::dump(Ostream &Str) const { ...@@ -499,11 +510,15 @@ void LiveRange::dump(Ostream &Str) const {
} }
Ostream &operator<<(Ostream &Str, const LiveRange &L) { Ostream &operator<<(Ostream &Str, const LiveRange &L) {
if (!ALLOW_DUMP)
return Str;
L.dump(Str); L.dump(Str);
return Str; return Str;
} }
Ostream &operator<<(Ostream &Str, const RegWeight &W) { Ostream &operator<<(Ostream &Str, const RegWeight &W) {
if (!ALLOW_DUMP)
return Str;
if (W.getWeight() == RegWeight::Inf) if (W.getWeight() == RegWeight::Inf)
Str << "Inf"; Str << "Inf";
else else
......
...@@ -65,10 +65,15 @@ public: ...@@ -65,10 +65,15 @@ public:
// situation where Func==NULL. // situation where Func==NULL.
virtual void dump(const Cfg *Func, Ostream &Str) const = 0; virtual void dump(const Cfg *Func, Ostream &Str) const = 0;
void dump(const Cfg *Func) const { void dump(const Cfg *Func) const {
if (!ALLOW_DUMP)
return;
assert(Func); assert(Func);
dump(Func, Func->getContext()->getStrDump()); dump(Func, Func->getContext()->getStrDump());
} }
void dump(Ostream &Str) const { dump(NULL, Str); } void dump(Ostream &Str) const {
if (ALLOW_DUMP)
dump(NULL, Str);
}
// Query whether this object was allocated in isolation, or added to // Query whether this object was allocated in isolation, or added to
// some higher-level pool. This determines whether a containing // some higher-level pool. This determines whether a containing
...@@ -148,7 +153,10 @@ public: ...@@ -148,7 +153,10 @@ public:
// specialization. // specialization.
void emit(GlobalContext *Ctx) const override; void emit(GlobalContext *Ctx) const override;
using Constant::dump; using Constant::dump;
void dump(const Cfg *, Ostream &Str) const override { Str << getValue(); } void dump(const Cfg *, Ostream &Str) const override {
if (ALLOW_DUMP)
Str << getValue();
}
static bool classof(const Operand *Operand) { static bool classof(const Operand *Operand) {
return Operand->getKind() == K; return Operand->getKind() == K;
...@@ -167,6 +175,8 @@ typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; ...@@ -167,6 +175,8 @@ typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat;
typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble;
template <> inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const { template <> inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const {
if (!ALLOW_DUMP)
return;
if (getType() == IceType_i1) if (getType() == IceType_i1)
Str << (getValue() ? "true" : "false"); Str << (getValue() ? "true" : "false");
else else
...@@ -174,6 +184,8 @@ template <> inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const ...@@ -174,6 +184,8 @@ template <> inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const
} }
template <> inline void ConstantInteger64::dump(const Cfg *, Ostream &Str) const { template <> inline void ConstantInteger64::dump(const Cfg *, Ostream &Str) const {
if (!ALLOW_DUMP)
return;
assert(getType() == IceType_i64); assert(getType() == IceType_i64);
Str << static_cast<int64_t>(getValue()); Str << static_cast<int64_t>(getValue());
} }
...@@ -259,7 +271,10 @@ public: ...@@ -259,7 +271,10 @@ public:
using Constant::dump; using Constant::dump;
// The target needs to implement this. // The target needs to implement this.
void emit(GlobalContext *Ctx) const override; void emit(GlobalContext *Ctx) const override;
void dump(const Cfg *, Ostream &Str) const override { Str << "undef"; } void dump(const Cfg *, Ostream &Str) const override {
if (ALLOW_DUMP)
Str << "undef";
}
static bool classof(const Operand *Operand) { static bool classof(const Operand *Operand) {
return Operand->getKind() == kConstUndef; return Operand->getKind() == kConstUndef;
......
...@@ -46,6 +46,8 @@ bool overlapsDefs(const Cfg *Func, const Variable *Item, const Variable *Var) { ...@@ -46,6 +46,8 @@ bool overlapsDefs(const Cfg *Func, const Variable *Item, const Variable *Var) {
void dumpDisableOverlap(const Cfg *Func, const Variable *Var, void dumpDisableOverlap(const Cfg *Func, const Variable *Var,
const char *Reason) { const char *Reason) {
if (!ALLOW_DUMP)
return;
if (Func->getContext()->isVerbose(IceV_LinearScan)) { if (Func->getContext()->isVerbose(IceV_LinearScan)) {
VariablesMetadata *VMetadata = Func->getVMetadata(); VariablesMetadata *VMetadata = Func->getVMetadata();
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
...@@ -62,6 +64,8 @@ void dumpDisableOverlap(const Cfg *Func, const Variable *Var, ...@@ -62,6 +64,8 @@ void dumpDisableOverlap(const Cfg *Func, const Variable *Var,
} }
void dumpLiveRange(const Variable *Var, const Cfg *Func) { void dumpLiveRange(const Variable *Var, const Cfg *Func) {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
const static size_t BufLen = 30; const static size_t BufLen = 30;
char buf[BufLen]; char buf[BufLen];
...@@ -252,7 +256,8 @@ void LinearScan::scan(const llvm::SmallBitVector &RegMaskFull) { ...@@ -252,7 +256,8 @@ void LinearScan::scan(const llvm::SmallBitVector &RegMaskFull) {
TimerMarker T(TimerStack::TT_linearScan, Func); TimerMarker T(TimerStack::TT_linearScan, Func);
assert(RegMaskFull.any()); // Sanity check assert(RegMaskFull.any()); // Sanity check
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
bool Verbose = Func->getContext()->isVerbose(IceV_LinearScan); const bool Verbose =
ALLOW_DUMP && Func->getContext()->isVerbose(IceV_LinearScan);
Func->resetCurrentNode(); Func->resetCurrentNode();
VariablesMetadata *VMetadata = Func->getVMetadata(); VariablesMetadata *VMetadata = Func->getVMetadata();
...@@ -691,6 +696,8 @@ void LinearScan::scan(const llvm::SmallBitVector &RegMaskFull) { ...@@ -691,6 +696,8 @@ void LinearScan::scan(const llvm::SmallBitVector &RegMaskFull) {
// ======================== Dump routines ======================== // // ======================== Dump routines ======================== //
void LinearScan::dump(Cfg *Func) const { void LinearScan::dump(Cfg *Func) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
if (!Func->getContext()->isVerbose(IceV_LinearScan)) if (!Func->getContext()->isVerbose(IceV_LinearScan))
return; return;
......
...@@ -898,7 +898,7 @@ void TargetX8632::addProlog(CfgNode *Node) { ...@@ -898,7 +898,7 @@ void TargetX8632::addProlog(CfgNode *Node) {
Var->setStackOffset(Linked->getStackOffset()); Var->setStackOffset(Linked->getStackOffset());
} }
if (Func->getContext()->isVerbose(IceV_Frame)) { if (ALLOW_DUMP && Func->getContext()->isVerbose(IceV_Frame)) {
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "Stack layout:\n"; Str << "Stack layout:\n";
...@@ -996,6 +996,7 @@ const char *PoolTypeConverter<double>::AsmTag = ".quad"; ...@@ -996,6 +996,7 @@ const char *PoolTypeConverter<double>::AsmTag = ".quad";
const char *PoolTypeConverter<double>::PrintfString = "0x%llx"; const char *PoolTypeConverter<double>::PrintfString = "0x%llx";
template <typename T> void TargetX8632::emitConstantPool() const { template <typename T> void TargetX8632::emitConstantPool() const {
// Note: Still used by emit IAS.
Ostream &Str = Ctx->getStrEmit(); Ostream &Str = Ctx->getStrEmit();
Type Ty = T::Ty; Type Ty = T::Ty;
SizeT Align = typeAlignInBytes(Ty); SizeT Align = typeAlignInBytes(Ty);
...@@ -1024,6 +1025,7 @@ template <typename T> void TargetX8632::emitConstantPool() const { ...@@ -1024,6 +1025,7 @@ template <typename T> void TargetX8632::emitConstantPool() const {
} }
void TargetX8632::emitConstants() const { void TargetX8632::emitConstants() const {
// Note: Still used by emit IAS.
emitConstantPool<PoolTypeConverter<float> >(); emitConstantPool<PoolTypeConverter<float> >();
emitConstantPool<PoolTypeConverter<double> >(); emitConstantPool<PoolTypeConverter<double> >();
...@@ -3561,6 +3563,8 @@ bool isAdd(const Inst *Inst) { ...@@ -3561,6 +3563,8 @@ bool isAdd(const Inst *Inst) {
void dumpAddressOpt(const Cfg *Func, const Variable *Base, void dumpAddressOpt(const Cfg *Func, const Variable *Base,
const Variable *Index, uint16_t Shift, int32_t Offset, const Variable *Index, uint16_t Shift, int32_t Offset,
const Inst *Reason) { const Inst *Reason) {
if (!ALLOW_DUMP)
return;
if (!Func->getContext()->isVerbose(IceV_AddrOpt)) if (!Func->getContext()->isVerbose(IceV_AddrOpt))
return; return;
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
...@@ -4528,6 +4532,8 @@ void TargetX8632::postLower() { ...@@ -4528,6 +4532,8 @@ void TargetX8632::postLower() {
} }
template <> void ConstantInteger32::emit(GlobalContext *Ctx) const { template <> void ConstantInteger32::emit(GlobalContext *Ctx) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Ctx->getStrEmit(); Ostream &Str = Ctx->getStrEmit();
Str << "$" << (int32_t)getValue(); Str << "$" << (int32_t)getValue();
} }
...@@ -4537,11 +4543,15 @@ template <> void ConstantInteger64::emit(GlobalContext *) const { ...@@ -4537,11 +4543,15 @@ template <> void ConstantInteger64::emit(GlobalContext *) const {
} }
template <> void ConstantFloat::emit(GlobalContext *Ctx) const { template <> void ConstantFloat::emit(GlobalContext *Ctx) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Ctx->getStrEmit(); Ostream &Str = Ctx->getStrEmit();
Str << ".L$" << IceType_f32 << "$" << getPoolEntryID(); Str << ".L$" << IceType_f32 << "$" << getPoolEntryID();
} }
template <> void ConstantDouble::emit(GlobalContext *Ctx) const { template <> void ConstantDouble::emit(GlobalContext *Ctx) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Ctx->getStrEmit(); Ostream &Str = Ctx->getStrEmit();
Str << ".L$" << IceType_f64 << "$" << getPoolEntryID(); Str << ".L$" << IceType_f64 << "$" << getPoolEntryID();
} }
......
...@@ -127,6 +127,8 @@ typedef std::multimap<double, IceString> DumpMapType; ...@@ -127,6 +127,8 @@ typedef std::multimap<double, IceString> DumpMapType;
// Dump the Map items in reverse order of their time contribution. // Dump the Map items in reverse order of their time contribution.
void dumpHelper(Ostream &Str, const DumpMapType &Map, double TotalTime) { void dumpHelper(Ostream &Str, const DumpMapType &Map, double TotalTime) {
if (!ALLOW_DUMP)
return;
// TODO(stichnot): Use llvm::make_range with LLVM 3.5. // TODO(stichnot): Use llvm::make_range with LLVM 3.5.
for (auto I = Map.rbegin(), E = Map.rend(); I != E; ++I) { for (auto I = Map.rbegin(), E = Map.rend(); I != E; ++I) {
char buf[80]; char buf[80];
...@@ -142,6 +144,8 @@ void dumpHelper(Ostream &Str, const DumpMapType &Map, double TotalTime) { ...@@ -142,6 +144,8 @@ void dumpHelper(Ostream &Str, const DumpMapType &Map, double TotalTime) {
// MaxVal=5 ==> "[%1lu] " // MaxVal=5 ==> "[%1lu] "
// MaxVal=9876 ==> "[%4lu] " // MaxVal=9876 ==> "[%4lu] "
void makePrintfFormatString(char *Buf, size_t BufLen, size_t MaxVal) { void makePrintfFormatString(char *Buf, size_t BufLen, size_t MaxVal) {
if (!ALLOW_DUMP)
return;
int NumDigits = 0; int NumDigits = 0;
do { do {
++NumDigits; ++NumDigits;
...@@ -153,6 +157,8 @@ void makePrintfFormatString(char *Buf, size_t BufLen, size_t MaxVal) { ...@@ -153,6 +157,8 @@ void makePrintfFormatString(char *Buf, size_t BufLen, size_t MaxVal) {
} // end of anonymous namespace } // end of anonymous namespace
void TimerStack::dump(Ostream &Str, bool DumpCumulative) { void TimerStack::dump(Ostream &Str, bool DumpCumulative) {
if (!ALLOW_DUMP)
return;
const bool UpdateCounts = true; const bool UpdateCounts = true;
update(UpdateCounts); update(UpdateCounts);
double TotalTime = LastTimestamp - FirstTimestamp; double TotalTime = LastTimestamp - FirstTimestamp;
......
...@@ -106,8 +106,8 @@ void Translator::lowerGlobals( ...@@ -106,8 +106,8 @@ void Translator::lowerGlobals(
llvm::OwningPtr<TargetGlobalInitLowering> GlobalLowering( llvm::OwningPtr<TargetGlobalInitLowering> GlobalLowering(
TargetGlobalInitLowering::createLowering(Ctx->getTargetArch(), Ctx)); TargetGlobalInitLowering::createLowering(Ctx->getTargetArch(), Ctx));
bool DisableTranslation = Ctx->getFlags().DisableTranslation; bool DisableTranslation = Ctx->getFlags().DisableTranslation;
bool DumpGlobalVariables = const bool DumpGlobalVariables =
Ctx->isVerbose() && Ctx->getFlags().VerboseFocusOn.empty(); ALLOW_DUMP && Ctx->isVerbose() && Ctx->getFlags().VerboseFocusOn.empty();
Ostream &Stream = Ctx->getStrDump(); Ostream &Stream = Ctx->getStrDump();
const IceString &TranslateOnly = Ctx->getFlags().TranslateOnly; const IceString &TranslateOnly = Ctx->getFlags().TranslateOnly;
for (const Ice::VariableDeclaration *Global : VariableDeclarations) { for (const Ice::VariableDeclaration *Global : VariableDeclarations) {
......
...@@ -260,6 +260,8 @@ const char *typeString(Type Ty) { ...@@ -260,6 +260,8 @@ const char *typeString(Type Ty) {
} }
void FuncSigType::dump(Ostream &Stream) const { void FuncSigType::dump(Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
Stream << ReturnType << " ("; Stream << ReturnType << " (";
bool IsFirst = true; bool IsFirst = true;
for (const Type ArgTy : ArgList) { for (const Type ArgTy : ArgList) {
......
...@@ -87,11 +87,15 @@ private: ...@@ -87,11 +87,15 @@ private:
}; };
Ice::Ostream &operator<<(Ice::Ostream &Stream, const ExtendedType &Ty) { Ice::Ostream &operator<<(Ice::Ostream &Stream, const ExtendedType &Ty) {
if (!ALLOW_DUMP)
return Stream;
Ty.dump(Stream); Ty.dump(Stream);
return Stream; return Stream;
} }
Ice::Ostream &operator<<(Ice::Ostream &Stream, ExtendedType::TypeKind Kind) { Ice::Ostream &operator<<(Ice::Ostream &Stream, ExtendedType::TypeKind Kind) {
if (!ALLOW_DUMP)
return Stream;
Stream << "ExtendedType::"; Stream << "ExtendedType::";
switch (Kind) { switch (Kind) {
case ExtendedType::Undefined: case ExtendedType::Undefined:
...@@ -138,6 +142,8 @@ public: ...@@ -138,6 +142,8 @@ public:
}; };
void ExtendedType::dump(Ice::Ostream &Stream) const { void ExtendedType::dump(Ice::Ostream &Stream) const {
if (!ALLOW_DUMP)
return;
Stream << Kind; Stream << Kind;
switch (Kind) { switch (Kind) {
case Simple: { case Simple: {
...@@ -545,7 +551,13 @@ protected: ...@@ -545,7 +551,13 @@ protected:
std::string Buffer; std::string Buffer;
raw_string_ostream StrBuf(Buffer); raw_string_ostream StrBuf(Buffer);
StrBuf << "(" << format("%" PRIu64 ":%u", (Bit / 8), StrBuf << "(" << format("%" PRIu64 ":%u", (Bit / 8),
static_cast<unsigned>(Bit % 8)) << ") " << Message; static_cast<unsigned>(Bit % 8)) << ") ";
// Note: If dump routines have been turned off, the error messages
// will not be readable. Hence, replace with simple error.
if (ALLOW_DUMP)
StrBuf << Message;
else
StrBuf << "Invalid input record";
return Context->Error(StrBuf.str()); return Context->Error(StrBuf.str());
} }
...@@ -1394,6 +1406,8 @@ private: ...@@ -1394,6 +1406,8 @@ private:
void dumpVectorIndexCheckValue(raw_ostream &Stream, void dumpVectorIndexCheckValue(raw_ostream &Stream,
VectorIndexCheckValue Value) const { VectorIndexCheckValue Value) const {
if (!ALLOW_DUMP)
return;
switch (Value) { switch (Value) {
default: default:
report_fatal_error("Unknown VectorIndexCheckValue"); report_fatal_error("Unknown VectorIndexCheckValue");
......
...@@ -192,8 +192,7 @@ static int GetReturnValue(int Val) { ...@@ -192,8 +192,7 @@ static int GetReturnValue(int Val) {
static struct { static struct {
const char *FlagName; const char *FlagName;
int FlagValue; int FlagValue;
} ConditionalBuildAttributes[] = {{"text_asm", ALLOW_TEXT_ASM}, } ConditionalBuildAttributes[] = {{"dump", ALLOW_DUMP},
{"dump", ALLOW_DUMP},
{"llvm_cl", ALLOW_LLVM_CL}, {"llvm_cl", ALLOW_LLVM_CL},
{"llvm_ir", ALLOW_LLVM_IR}, {"llvm_ir", ALLOW_LLVM_IR},
{"llvm_ir_as_input", ALLOW_LLVM_IR_AS_INPUT}, {"llvm_ir_as_input", ALLOW_LLVM_IR_AS_INPUT},
...@@ -236,8 +235,12 @@ int main(int argc, char **argv) { ...@@ -236,8 +235,12 @@ int main(int argc, char **argv) {
DisableTranslation = true; 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 available.
if (ALLOW_DUMP) {
for (unsigned i = 0; i != VerboseList.size(); ++i) for (unsigned i = 0; i != VerboseList.size(); ++i)
VMask |= VerboseList[i]; VMask |= VerboseList[i];
}
std::ofstream Ofs; std::ofstream Ofs;
if (OutputFilename != "-") { if (OutputFilename != "-") {
......
; This is a very early test that just checks the representation of i32 ; This is a very early test that just checks the representation of i32
; arithmetic instructions. No assembly tests are done. ; arithmetic instructions. No assembly tests are done.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --args --verbose inst -ias=0 | FileCheck %s ; RUN: %p2i -i %s --args --verbose inst -ias=0 | FileCheck %s
define i32 @Add(i32 %a, i32 %b) { define i32 @Add(i32 %a, i32 %b) {
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
; we don't lower to a cmp instructions with an immediate as the first ; we don't lower to a cmp instructions with an immediate as the first
; source operand. ; source operand.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --args -O2 --verbose inst | FileCheck %s ; RUN: %p2i -i %s --args -O2 --verbose inst | FileCheck %s
; RUN: %p2i -i %s --args -Om1 --verbose inst | FileCheck %s ; RUN: %p2i -i %s --args -Om1 --verbose inst | FileCheck %s
......
; Test of global initializers. ; Test of global initializers.
; REQUIRES: allow_dump
; Test -ias=0 to test the lea "hack" until we are fully confident in -ias=1 ; Test -ias=0 to test the lea "hack" until we are fully confident in -ias=1
; RUN: %p2i -i %s --args --verbose none -ias=0 | FileCheck %s ; RUN: %p2i -i %s --args --verbose none -ias=0 | FileCheck %s
......
; Tests if we handle global variables with relocation initializers. ; Tests if we handle global variables with relocation initializers.
; REQUIRES: allow_dump
; Test that we handle it in the ICE converter. ; Test that we handle it in the ICE converter.
; RUN: %lc2i -i %s --args -verbose inst | %iflc FileCheck %s ; RUN: %lc2i -i %s --args -verbose inst | %iflc FileCheck %s
......
; Simple test of the load instruction. ; Simple test of the load instruction.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --args --verbose inst | FileCheck %s ; RUN: %p2i -i %s --args --verbose inst | FileCheck %s
define void @load_i64(i32 %addr_arg) { define void @load_i64(i32 %addr_arg) {
......
; This is a smoke test of nop insertion. ; This is a smoke test of nop insertion.
; REQUIRES: allow_dump
; Don't use integrated-as because this currently depends on the # variant ; Don't use integrated-as because this currently depends on the # variant
; assembler comment. ; assembler comment.
; RUN: %p2i -i %s -a -rng-seed=1 -nop-insertion -nop-insertion-percentage=50 \ ; RUN: %p2i -i %s -a -rng-seed=1 -nop-insertion -nop-insertion-percentage=50 \
......
; Simple test of the store instruction. ; Simple test of the store instruction.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --args --verbose inst | FileCheck %s ; RUN: %p2i -i %s --args --verbose inst | FileCheck %s
define void @store_i64(i32 %addr_arg) { define void @store_i64(i32 %addr_arg) {
......
; Test if we can read alloca instructions. ; Test if we can read alloca instructions.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Tests if we can read binary operators. ; Tests if we can read binary operators.
; REQUIRES: allow_dump
; 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
......
; Tests if we handle a branch instructions. ; Tests if we handle a branch instructions.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Test parsing indirect calls in Subzero. ; Test parsing indirect calls in Subzero.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Test handling of call instructions. ; Test handling of call instructions.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Tests if we can read cast operations. ; Tests if we can read cast operations.
; REQUIRES: allow_dump
; 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: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Test if we can read compare instructions. ; Test if we can read compare instructions.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Test handling of constants in function blocks. ; Test handling of constants in function blocks.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Test use forward type references in function blocks. ; Test use forward type references in function blocks.
; REQUIRES: allow_dump
; 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
......
; Test of global initializers. ; Test of global initializers.
; REQUIRES: allow_dump
; 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
......
; Tests if we handle global variables with relocation initializers. ; Tests if we handle global variables with relocation initializers.
; REQUIRES: allow_dump
; 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
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
; errors when malformed. Note: We can only test literal indexing since ; errors when malformed. Note: We can only test literal indexing since
; llvm-as will not allow other bad forms of these instructions. ; llvm-as will not allow other bad forms of these instructions.
; RUN: llvm-as < %s | pnacl-freeze | not %llvm2ice -notranslate \ ; REQUIRES: allow_dump
; RUN: llvm-as < %s | pnacl-freeze \
; RUN: | not %llvm2ice -notranslate -build-on-read \
; RUN: -allow-pnacl-reader-error-recovery | FileCheck %s ; RUN: -allow-pnacl-reader-error-recovery | FileCheck %s
define void @ExtractV4xi1(<4 x i1> %v, i32 %i) { define void @ExtractV4xi1(<4 x i1> %v, i32 %i) {
......
; Tests insertelement and extractelement vector instructions. ; Tests insertelement and extractelement vector instructions.
; REQUIRES: allow_dump
; 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
......
; Test if we can read load instructions. ; Test if we can read load instructions.
; REQUIRES: allow_dump
; 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: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Test parsing NaCl atomic instructions. ; Test parsing NaCl atomic instructions.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
...@@ -3,11 +3,26 @@ ...@@ -3,11 +3,26 @@
; TODO(kschimpf) Find way to run this through p2i. Note: Can't do this ; TODO(kschimpf) Find way to run this through p2i. Note: Can't do this
; currently because run-llvm2ice.py raises exception on error, ; currently because run-llvm2ice.py raises exception on error,
; and output is lost. ; and output is lost.
; RUN: llvm-as < %s | pnacl-freeze -allow-local-symbol-tables \ ; RUN: %if --need=allow_dump --command \
; RUN: | not %llvm2ice -notranslate -verbose=inst \ ; RUN: llvm-as < %s \
; RUN: | %if --need=allow_dump --command \
; RUN: pnacl-freeze -allow-local-symbol-tables \
; RUN: | %if --need=allow_dump --command \
; RUN: not %llvm2ice -notranslate -verbose=inst -build-on-read \
; RUN: -allow-pnacl-reader-error-recovery \ ; RUN: -allow-pnacl-reader-error-recovery \
; RUN: -allow-local-symbol-tables \ ; RUN: -allow-local-symbol-tables \
; RUN: | FileCheck %s ; RUN: | %if --need=allow_dump --command \
; RUN: FileCheck %s
; RUN: %if --need=no_dump --command \
; RUN: llvm-as < %s \
; RUN: | %if --need=no_dump --command \
; RUN: pnacl-freeze -allow-local-symbol-tables \
; RUN: | %if --need=no_dump --command \
; RUN: not %llvm2ice -notranslate -verbose=inst -build-on-read \
; RUN: -allow-pnacl-reader-error-recovery -allow-local-symbol-tables \
; RUN: | %if --need=no_dump --command \
; RUN: FileCheck --check-prefix=MIN %s
declare i32 @llvm.fake.i32(i32) declare i32 @llvm.fake.i32(i32)
...@@ -16,5 +31,6 @@ define i32 @testFake(i32 %v) { ...@@ -16,5 +31,6 @@ define i32 @testFake(i32 %v) {
ret i32 %r ret i32 %r
} }
; CHECK: Error: (218:6) Invalid PNaCl intrinsic call to llvm.fake.i32 ; CHECK: Error: ({{.*}}) Invalid PNaCl intrinsic call to llvm.fake.i32
; MIN: Error: ({{.*}}) Invalid input record
; This tests parsing NaCl intrinsics not related to atomic operations. ; This tests parsing NaCl intrinsics not related to atomic operations.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Test reading phi instructions. ; Test reading phi instructions.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Tests if we can read select instructions. ; Tests if we can read select instructions.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Test if we can read store instructions. ; Test if we can read store instructions.
; REQUIRES: allow_dump
; 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: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Test switch instructions. ; Test switch instructions.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
; Tests that we name unnamed global addresses. ; Tests that we name unnamed global addresses.
; REQUIRES: allow_dump
; Check that Subzero's bitcode reader handles renaming correctly. ; Check that Subzero's bitcode reader handles renaming correctly.
; RUN: %p2i --no-local-syms -i %s --insts | FileCheck %s ; RUN: %p2i --no-local-syms -i %s --insts | FileCheck %s
; RUN: %l2i --no-local-syms -i %s --insts | %ifl FileCheck %s ; RUN: %l2i --no-local-syms -i %s --insts | %ifl FileCheck %s
......
; Test parsing unreachable instruction. ; Test parsing unreachable instruction.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --insts | FileCheck %s ; RUN: %p2i -i %s --insts | FileCheck %s
; RUN: %if --need=allow_disable_ir_gen --command \ ; RUN: %if --need=allow_disable_ir_gen --command \
; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \ ; RUN: %p2i -i %s --args -notranslate -timing -no-ir-gen \
......
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