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,
[](const LiveBeginEndMapEntry &A, const LiveBeginEndMapEntry &B) {
return A.first == B.first;
};
(void)ComparePair;
assert(std::adjacent_find(MapBegin.begin(), MapBegin.end(), ComparePair) ==
MapBegin.end());
assert(std::adjacent_find(MapEnd.begin(), MapEnd.end(), ComparePair) ==
......
......@@ -93,11 +93,22 @@ void Compiler::run(const Ice::ClFlagsExtra &ExtraFlags, GlobalContext &Ctx,
return Ctx.getErrorStatus()->assign(EC_None);
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";
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);
}
// Force -build-on-read=0 for .ll files.
const std::string LLSuffix = ".ll";
const IceString &IRFilename = ExtraFlags.getIRFilename();
......@@ -121,7 +132,7 @@ void Compiler::run(const Ice::ClFlagsExtra &ExtraFlags, GlobalContext &Ctx,
Translator.reset(PTranslator.release());
} else if (BuildDefs::llvmIr()) {
if (PNACL_BROWSER_TRANSLATOR) {
Ctx.getStrDump()
Ctx.getStrError()
<< "non BuildOnRead is not supported w/ PNACL_BROWSER_TRANSLATOR\n";
return Ctx.getErrorStatus()->assign(EC_Args);
}
......@@ -142,7 +153,7 @@ void Compiler::run(const Ice::ClFlagsExtra &ExtraFlags, GlobalContext &Ctx,
Converter->convertToIce();
Translator.reset(Converter.release());
} 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";
return Ctx.getErrorStatus()->assign(EC_Args);
}
......
......@@ -479,7 +479,7 @@ template <> void InstARM32Vldr::emit(const Cfg *Func) const {
Ostream &Str = Func->getContext()->getStrEmit();
assert(getSrcSize() == 1);
assert(getDest()->hasReg());
Str << "\t"<< Opcode << getPredicate() << "\t";
Str << "\t" << Opcode << getPredicate() << "\t";
getDest()->emit(Func);
Str << ", ";
getSrc(0)->emit(Func);
......@@ -649,7 +649,7 @@ template <> void InstARM32Ldr::emit(const Cfg *Func) const {
assert(getSrcSize() == 1);
assert(getDest()->hasReg());
Type Ty = getSrc(0)->getType();
Str << "\t"<< Opcode << getWidthString(Ty) << getPredicate() << "\t";
Str << "\t" << Opcode << getWidthString(Ty) << getPredicate() << "\t";
getDest()->emit(Func);
Str << ", ";
getSrc(0)->emit(Func);
......
......@@ -249,19 +249,17 @@ void LinearScan::init(RegAllocKind Kind) {
break;
}
struct CompareRanges {
bool operator()(const Variable *L, const Variable *R) {
auto CompareRanges = [](const Variable *L, const Variable *R) {
InstNumberT Lstart = L->getLiveRange().getStart();
InstNumberT Rstart = R->getLiveRange().getStart();
if (Lstart == Rstart)
return L->getIndex() < R->getIndex();
return Lstart < Rstart;
}
};
// 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(),
CompareRanges());
CompareRanges);
Handled.reserve(Unhandled.size());
Inactive.reserve(Unhandled.size());
......
; Test that some errors trigger when the usage of NaCl atomic
; intrinsics does not match the required ABI.
; REQUIRES: allow_dump
; RUN: %p2i -i %s --args --verbose none --exit-success -threads=0 2>&1 \
; RUN: | FileCheck %s
......
; Trivial smoke test of basic block reordering. Different random seeds should
; generate different basic block layout.
; REQUIRES allow_dump
; REQUIRES: allow_dump
; RUN: %p2i -i %s --filetype=asm --args -O2 -sz-seed=1 \
; RUN: -reorder-basic-blocks -threads=0 \
......
......@@ -4,12 +4,14 @@
; RUN: | %if --need=allow_dump --command pnacl-freeze \
; RUN: | %if --need=allow_dump --command not %pnacl_sz -notranslate \
; 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=no_dump --command llvm-as < %s \
; RUN: | %if --need=no_dump --command pnacl-freeze \
; RUN: | %if --need=no_dump --command not %pnacl_sz -notranslate \
; 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
define void @ExtractV4xi1(<4 x i1> %v, i32 %i) {
......
......@@ -10,6 +10,7 @@
; RUN: -verbose=inst -build-on-read \
; RUN: -allow-pnacl-reader-error-recovery \
; RUN: -allow-local-symbol-tables \
; RUN: -filetype=obj -o /dev/null \
; RUN: | %if --need=allow_dump --command FileCheck %s
; RUN: %if --need=no_dump --command llvm-as < %s \
......@@ -19,6 +20,7 @@
; RUN: -verbose=inst -build-on-read \
; RUN: -allow-pnacl-reader-error-recovery \
; RUN: -allow-local-symbol-tables \
; RUN: -filetype=obj -o /dev/null \
; RUN: | %if --need=no_dump --command FileCheck %s --check-prefix=MIN
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