Commit 992f91dd by Jim Stichnoth

Subzero: Misc fixes/cleanup.

1. Fix MINIMAL build. (a) Add a void cast to a var only used in asserts. (b) Use "REQUIRES:" instead of "REQUIRES" in a .ll file. 2. Use StrError instead of StrDump for errors. 3. Use a lambda instead of a functor because C++11. 4. Explicit check for -filetype=obj in a non-dump-enabled build, to avoid cryptic downstream error messages. 5. Run "make format" which was neglected earlier. BUG= none R=kschimpf@google.com Review URL: https://codereview.chromium.org/1284493003.
parent c6acf08f
...@@ -671,6 +671,7 @@ void CfgNode::livenessAddIntervals(Liveness *Liveness, InstNumberT FirstInstNum, ...@@ -671,6 +671,7 @@ void CfgNode::livenessAddIntervals(Liveness *Liveness, InstNumberT FirstInstNum,
[](const LiveBeginEndMapEntry &A, const LiveBeginEndMapEntry &B) { [](const LiveBeginEndMapEntry &A, const LiveBeginEndMapEntry &B) {
return A.first == B.first; return A.first == B.first;
}; };
(void)ComparePair;
assert(std::adjacent_find(MapBegin.begin(), MapBegin.end(), ComparePair) == assert(std::adjacent_find(MapBegin.begin(), MapBegin.end(), ComparePair) ==
MapBegin.end()); MapBegin.end());
assert(std::adjacent_find(MapEnd.begin(), MapEnd.end(), ComparePair) == assert(std::adjacent_find(MapEnd.begin(), MapEnd.end(), ComparePair) ==
......
...@@ -93,8 +93,19 @@ void Compiler::run(const Ice::ClFlagsExtra &ExtraFlags, GlobalContext &Ctx, ...@@ -93,8 +93,19 @@ void Compiler::run(const Ice::ClFlagsExtra &ExtraFlags, GlobalContext &Ctx,
return Ctx.getErrorStatus()->assign(EC_None); return Ctx.getErrorStatus()->assign(EC_None);
if (!BuildDefs::disableIrGen() && Ctx.getFlags().getDisableIRGeneration()) { if (!BuildDefs::disableIrGen() && Ctx.getFlags().getDisableIRGeneration()) {
Ctx.getStrDump() << "Error: Build doesn't allow --no-ir-gen when not " Ctx.getStrError() << "Error: Build doesn't allow --no-ir-gen when not "
<< "ALLOW_DISABLE_IR_GEN!\n"; << "ALLOW_DISABLE_IR_GEN!\n";
return Ctx.getErrorStatus()->assign(EC_Args);
}
// The Minimal build (specifically, when dump()/emit() are not implemented)
// allows only --filetype=obj. Check here to avoid cryptic error messages
// downstream.
if (!BuildDefs::dump() && Ctx.getFlags().getOutFileType() != FT_Elf) {
// TODO(stichnot): Access the actual command-line argument via
// llvm::Option.ArgStr and .ValueStr .
Ctx.getStrError()
<< "Error: only --filetype=obj is supported in this build.\n";
return Ctx.getErrorStatus()->assign(EC_Args); return Ctx.getErrorStatus()->assign(EC_Args);
} }
...@@ -121,7 +132,7 @@ void Compiler::run(const Ice::ClFlagsExtra &ExtraFlags, GlobalContext &Ctx, ...@@ -121,7 +132,7 @@ void Compiler::run(const Ice::ClFlagsExtra &ExtraFlags, GlobalContext &Ctx,
Translator.reset(PTranslator.release()); Translator.reset(PTranslator.release());
} else if (BuildDefs::llvmIr()) { } else if (BuildDefs::llvmIr()) {
if (PNACL_BROWSER_TRANSLATOR) { if (PNACL_BROWSER_TRANSLATOR) {
Ctx.getStrDump() Ctx.getStrError()
<< "non BuildOnRead is not supported w/ PNACL_BROWSER_TRANSLATOR\n"; << "non BuildOnRead is not supported w/ PNACL_BROWSER_TRANSLATOR\n";
return Ctx.getErrorStatus()->assign(EC_Args); return Ctx.getErrorStatus()->assign(EC_Args);
} }
...@@ -142,8 +153,8 @@ void Compiler::run(const Ice::ClFlagsExtra &ExtraFlags, GlobalContext &Ctx, ...@@ -142,8 +153,8 @@ void Compiler::run(const Ice::ClFlagsExtra &ExtraFlags, GlobalContext &Ctx,
Converter->convertToIce(); Converter->convertToIce();
Translator.reset(Converter.release()); Translator.reset(Converter.release());
} else { } else {
Ctx.getStrDump() << "Error: Build doesn't allow LLVM IR, " Ctx.getStrError() << "Error: Build doesn't allow LLVM IR, "
<< "--build-on-read=0 not allowed\n"; << "--build-on-read=0 not allowed\n";
return Ctx.getErrorStatus()->assign(EC_Args); return Ctx.getErrorStatus()->assign(EC_Args);
} }
......
...@@ -479,7 +479,7 @@ template <> void InstARM32Vldr::emit(const Cfg *Func) const { ...@@ -479,7 +479,7 @@ template <> void InstARM32Vldr::emit(const Cfg *Func) const {
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1); assert(getSrcSize() == 1);
assert(getDest()->hasReg()); assert(getDest()->hasReg());
Str << "\t"<< Opcode << getPredicate() << "\t"; Str << "\t" << Opcode << getPredicate() << "\t";
getDest()->emit(Func); getDest()->emit(Func);
Str << ", "; Str << ", ";
getSrc(0)->emit(Func); getSrc(0)->emit(Func);
...@@ -649,7 +649,7 @@ template <> void InstARM32Ldr::emit(const Cfg *Func) const { ...@@ -649,7 +649,7 @@ template <> void InstARM32Ldr::emit(const Cfg *Func) const {
assert(getSrcSize() == 1); assert(getSrcSize() == 1);
assert(getDest()->hasReg()); assert(getDest()->hasReg());
Type Ty = getSrc(0)->getType(); Type Ty = getSrc(0)->getType();
Str << "\t"<< Opcode << getWidthString(Ty) << getPredicate() << "\t"; Str << "\t" << Opcode << getWidthString(Ty) << getPredicate() << "\t";
getDest()->emit(Func); getDest()->emit(Func);
Str << ", "; Str << ", ";
getSrc(0)->emit(Func); getSrc(0)->emit(Func);
......
...@@ -249,19 +249,17 @@ void LinearScan::init(RegAllocKind Kind) { ...@@ -249,19 +249,17 @@ void LinearScan::init(RegAllocKind Kind) {
break; break;
} }
struct CompareRanges { auto CompareRanges = [](const Variable *L, const Variable *R) {
bool operator()(const Variable *L, const Variable *R) {
InstNumberT Lstart = L->getLiveRange().getStart(); InstNumberT Lstart = L->getLiveRange().getStart();
InstNumberT Rstart = R->getLiveRange().getStart(); InstNumberT Rstart = R->getLiveRange().getStart();
if (Lstart == Rstart) if (Lstart == Rstart)
return L->getIndex() < R->getIndex(); return L->getIndex() < R->getIndex();
return Lstart < Rstart; return Lstart < Rstart;
}
}; };
// Do a reverse sort so that erasing elements (from the end) is fast. // Do a reverse sort so that erasing elements (from the end) is fast.
std::sort(Unhandled.rbegin(), Unhandled.rend(), CompareRanges()); std::sort(Unhandled.rbegin(), Unhandled.rend(), CompareRanges);
std::sort(UnhandledPrecolored.rbegin(), UnhandledPrecolored.rend(), std::sort(UnhandledPrecolored.rbegin(), UnhandledPrecolored.rend(),
CompareRanges()); CompareRanges);
Handled.reserve(Unhandled.size()); Handled.reserve(Unhandled.size());
Inactive.reserve(Unhandled.size()); Inactive.reserve(Unhandled.size());
......
...@@ -3622,7 +3622,7 @@ void TargetX86Base<Machine>::lowerMemset(Operand *Dest, Operand *Val, ...@@ -3622,7 +3622,7 @@ void TargetX86Base<Machine>::lowerMemset(Operand *Dest, Operand *Val,
Variable *VecReg = nullptr; Variable *VecReg = nullptr;
auto lowerSet = [this, &Base, SpreadValue, &VecReg](Type Ty, auto lowerSet = [this, &Base, SpreadValue, &VecReg](Type Ty,
uint32_t OffsetAmt) { uint32_t OffsetAmt) {
assert(Base != nullptr); assert(Base != nullptr);
Constant *Offset = OffsetAmt ? Ctx->getConstantInt32(OffsetAmt) : nullptr; Constant *Offset = OffsetAmt ? Ctx->getConstantInt32(OffsetAmt) : nullptr;
......
; Test that some errors trigger when the usage of NaCl atomic ; Test that some errors trigger when the usage of NaCl atomic
; intrinsics does not match the required ABI. ; intrinsics does not match the required ABI.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --args --verbose none --exit-success -threads=0 2>&1 \ ; RUN: %p2i -i %s --args --verbose none --exit-success -threads=0 2>&1 \
; RUN: | FileCheck %s ; RUN: | FileCheck %s
......
; Trivial smoke test of basic block reordering. Different random seeds should ; Trivial smoke test of basic block reordering. Different random seeds should
; generate different basic block layout. ; generate different basic block layout.
; REQUIRES allow_dump ; REQUIRES: allow_dump
; RUN: %p2i -i %s --filetype=asm --args -O2 -sz-seed=1 \ ; RUN: %p2i -i %s --filetype=asm --args -O2 -sz-seed=1 \
; RUN: -reorder-basic-blocks -threads=0 \ ; RUN: -reorder-basic-blocks -threads=0 \
......
...@@ -4,12 +4,14 @@ ...@@ -4,12 +4,14 @@
; RUN: | %if --need=allow_dump --command pnacl-freeze \ ; RUN: | %if --need=allow_dump --command pnacl-freeze \
; RUN: | %if --need=allow_dump --command not %pnacl_sz -notranslate \ ; RUN: | %if --need=allow_dump --command not %pnacl_sz -notranslate \
; RUN: -build-on-read -allow-pnacl-reader-error-recovery \ ; RUN: -build-on-read -allow-pnacl-reader-error-recovery \
; RUN: -filetype=obj -o /dev/null \
; RUN: | %if --need=allow_dump --command FileCheck %s ; RUN: | %if --need=allow_dump --command FileCheck %s
; RUN: %if --need=no_dump --command llvm-as < %s \ ; RUN: %if --need=no_dump --command llvm-as < %s \
; RUN: | %if --need=no_dump --command pnacl-freeze \ ; RUN: | %if --need=no_dump --command pnacl-freeze \
; RUN: | %if --need=no_dump --command not %pnacl_sz -notranslate \ ; RUN: | %if --need=no_dump --command not %pnacl_sz -notranslate \
; RUN: -build-on-read -allow-pnacl-reader-error-recovery \ ; RUN: -build-on-read -allow-pnacl-reader-error-recovery \
; RUN: -filetype=obj -o /dev/null \
; RUN: | %if --need=no_dump --command FileCheck %s --check-prefix=MIN ; RUN: | %if --need=no_dump --command FileCheck %s --check-prefix=MIN
define void @ExtractV4xi1(<4 x i1> %v, i32 %i) { define void @ExtractV4xi1(<4 x i1> %v, i32 %i) {
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
; RUN: -verbose=inst -build-on-read \ ; RUN: -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: -filetype=obj -o /dev/null \
; RUN: | %if --need=allow_dump --command FileCheck %s ; RUN: | %if --need=allow_dump --command FileCheck %s
; RUN: %if --need=no_dump --command llvm-as < %s \ ; RUN: %if --need=no_dump --command llvm-as < %s \
...@@ -19,6 +20,7 @@ ...@@ -19,6 +20,7 @@
; RUN: -verbose=inst -build-on-read \ ; RUN: -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: -filetype=obj -o /dev/null \
; RUN: | %if --need=no_dump --command FileCheck %s --check-prefix=MIN ; RUN: | %if --need=no_dump --command FileCheck %s --check-prefix=MIN
declare i32 @llvm.fake.i32(i32) declare i32 @llvm.fake.i32(i32)
......
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