[llvm-commits] [llvm] r75018 - in /llvm/trunk: include/llvm/Support/ lib/Target/ARM/ lib/Target/X86/ lib/Target/X86/AsmPrinter/ lib/VMCore/
Chris Lattner
clattner at apple.com
Wed Jul 8 12:50:08 PDT 2009
On Jul 8, 2009, at 11:01 AM, Torok Edwin wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=75018&view=rev
> Log:
> Start converting to new error handling API.
> cerr+abort -> llvm_report_error
> assert(0)+abort -> LLVM_UNREACHABLE (assert(0)+llvm_unreachable->
> abort() included)
Thanks Edwin, most of this looks great. Several of these below are
assertions that have a message: the preferred style is something like:
#ifndef NDEBUG
cerr << "WHATEVER\n";
#endif
unreachable();
>
> +++ llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Wed Jul 8 13:01:40
> 2009
> @@ -255,8 +257,10 @@
> else if (MO.isMBB())
> emitMachineBasicBlock(MO.getMBB(), ARM::reloc_arm_branch);
> else {
> - cerr << "ERROR: Unknown type of MachineOperand: " << MO << "\n";
> - abort();
> + std::string msg;
> + raw_string_ostream Msg(msg);
> + Msg << "ERROR: Unknown type of MachineOperand: " << MO;
> + llvm_report_error(Msg.str());
This should be an assertion.
> @@ -586,13 +588,12 @@
> unsigned Opcode = MI.getDesc().Opcode;
> switch (Opcode) {
> default:
> - abort(); // FIXME:
> + llvm_report_error("ARMCodeEmitter::emitPseudoInstruction");//
> FIXME:
This should be an assertion.
> @@ -1120,7 +1120,7 @@
> const TargetInstrDesc &TID = MI.getDesc();
>
> if (TID.Opcode == ARM::TPsoft)
> - abort(); // FIXME
> + llvm_report_error("ARM::TPsoft FIXME"); // FIXME
This should be an assertion.
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/Target/ARM/ARMJITInfo.cpp (original)
> +++ llvm/trunk/lib/Target/ARM/ARMJITInfo.cpp Wed Jul 8 13:01:40 2009
> @@ -123,14 +123,12 @@
> // ldr pc, [pc,#-4]
> // <addr>
> if (!sys::Memory::setRangeWritable((void*)StubAddr, 8)) {
> - cerr << "ERROR: Unable to mark stub writable\n";
> - abort();
> + llvm_report_error("ERROR: Unable to mark stub writable");
> }
> *(intptr_t *)StubAddr = 0xe51ff004; // ldr pc, [pc, #-4]
> *(intptr_t *)(StubAddr+4) = NewVal;
> if (!sys::Memory::setRangeExecutable((void*)StubAddr, 8)) {
> - cerr << "ERROR: Unable to mark stub executable\n";
> - abort();
> + llvm_report_error("ERROR: Unable to mark stub executable");
> }
> }
These should be assertions.
> +++ llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Wed Jul 8
> 13:01:40 2009
> @@ -29,6 +29,7 @@
> #include "llvm/Target/TargetMachine.h"
> #include "llvm/Target/TargetRegisterInfo.h"
> #include "llvm/Support/Compiler.h"
> +#include "llvm/Support/ErrorHandling.h"
> #include "llvm/ADT/DenseMap.h"
> #include "llvm/ADT/STLExtras.h"
> #include "llvm/ADT/SmallPtrSet.h"
> @@ -119,7 +120,7 @@
> case ARM::FSTD:
> NumFSTMGened++;
> return ARM::FSTMD;
> - default: abort();
> + default: llvm_report_error("Unhandled opcode!");
> }
> return 0;
> }
> @@ -441,7 +442,7 @@
> case ARM::FLDD: return ARM::FLDMD;
> case ARM::FSTS: return ARM::FSTMS;
> case ARM::FSTD: return ARM::FSTMD;
> - default: abort();
> + default: llvm_report_error("Unhandled opcode!");
> }
> return 0;
> }
> @@ -454,7 +455,7 @@
> case ARM::FLDD: return ARM::FLDMD;
> case ARM::FSTS: return ARM::FSTMS;
> case ARM::FSTD: return ARM::FSTMD;
> - default: abort();
> + default: llvm_report_error("Unhandled opcode!");
> }
These should be assertions.
> +++ llvm/trunk/lib/Target/ARM/Thumb2RegisterInfo.cpp Wed Jul 8
> 13:01:40 2009
> @@ -30,6 +30,7 @@
> #include "llvm/ADT/BitVector.h"
> #include "llvm/ADT/SmallVector.h"
> #include "llvm/Support/CommandLine.h"
> +#include "llvm/Support/ErrorHandling.h"
> using namespace llvm;
>
> static cl::opt<bool>
> @@ -452,8 +453,7 @@
> break;
> }
> default:
> - assert(0 && "Unsupported addressing mode!");
> - abort();
> + llvm_report_error("Unsupported addressing mode!");
Should be an assertion.
> +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Wed
> Jul 8 13:01:40 2009
> @@ -16,6 +16,7 @@
> #include "llvm/MC/MCInst.h"
> #include "X86ATTAsmPrinter.h"
> #include "llvm/Target/TargetAsmInfo.h"
> +#include "llvm/Support/ErrorHandling.h"
> #include "llvm/Support/raw_ostream.h"
> using namespace llvm;
>
> @@ -103,7 +104,7 @@
> if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg()))
> O << DispVal;
> } else {
> - abort();
> + llvm_report_error("non-immediate displacement for LEA?");
Assertion. This file is not production quality yet anyway.
> +++ llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp Wed Jul 8 13:01:40
> 2009
> @@ -805,10 +806,10 @@
> }
>
> if (!Desc->isVariadic() && CurOp != NumOps) {
> - cerr << "Cannot encode: ";
> - MI.dump();
> - cerr << '\n';
> - abort();
> + std::string msg;
> + raw_string_ostream Msg(msg);
> + Msg << "Cannot encode: " << MI;
> + llvm_report_error(Msg.str());
This should be an assertion.
> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Jul 8
> 13:01:40 2009
> @@ -33,6 +33,7 @@
> #include "llvm/CodeGen/PseudoSourceValue.h"
> #include "llvm/Support/MathExtras.h"
> #include "llvm/Support/Debug.h"
> +#include "llvm/Support/ErrorHandling.h"
> #include "llvm/Target/TargetOptions.h"
> #include "llvm/ADT/SmallSet.h"
> #include "llvm/ADT/StringExtras.h"
> @@ -6054,8 +6055,7 @@
> SDValue SrcPtr = Op.getOperand(1);
> SDValue SrcSV = Op.getOperand(2);
>
> - assert(0 && "VAArgInst is not yet implemented for x86-64!");
> - abort();
> + LLVM_UNREACHABLE("VAArgInst is not yet implemented for x86-64!");
> return SDValue();
This should be a report_error.
>
> @@ -3196,10 +3196,10 @@
> }
>
> if (!Desc->isVariadic() && CurOp != NumOps) {
> - cerr << "Cannot determine size: ";
> - MI.dump();
> - cerr << '\n';
> - abort();
> + std::string msg;
> + raw_string_ostream Msg(msg);
> + Msg << "Cannot determine size: " << MI;
> + llvm_report_error(Msg.str());
> }
assertion.
>
> +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Wed Jul 8 13:01:40 2009
> @@ -31,6 +31,7 @@
> #include "llvm/ADT/StringExtras.h"
> #include "llvm/ADT/STLExtras.h"
> #include "llvm/Support/CFG.h"
> +#include "llvm/Support/ErrorHandling.h"
> #include "llvm/Support/MathExtras.h"
> #include "llvm/Support/raw_ostream.h"
> #include <algorithm>
> @@ -1234,8 +1235,7 @@
> case GlobalValue::ExternalWeakLinkage: Out << "extern_weak "; break;
> case GlobalValue::ExternalLinkage: break;
> case GlobalValue::GhostLinkage:
> - Out << "GhostLinkage not allowed in AsmWriter!\n";
> - abort();
> + llvm_report_error("GhostLinkage not allowed in AsmWriter!");
assertion.
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/VMCore/Type.cpp (original)
> +++ llvm/trunk/lib/VMCore/Type.cpp Wed Jul 8 13:01:40 2009
> @@ -20,6 +20,7 @@
> #include "llvm/ADT/STLExtras.h"
> #include "llvm/Support/Compiler.h"
> #include "llvm/Support/Debug.h"
> +#include "llvm/Support/ErrorHandling.h"
> #include "llvm/Support/ManagedStatic.h"
> #include "llvm/Support/MathExtras.h"
> #include "llvm/Support/raw_ostream.h"
> @@ -264,10 +265,10 @@
> }
>
> void Type::refineAbstractType(const DerivedType *OldTy, const Type
> *NewTy) {
> - abort();
> + llvm_report_error("Attempting to refine a derived type!");
> }
> void Type::typeBecameConcrete(const DerivedType *AbsTy) {
> - abort();
> + llvm_report_error("DerivedType is already a concrete type!");
> }
assertion.
> +++ llvm/trunk/lib/VMCore/Value.cpp Wed Jul 8 13:01:40 2009
> @@ -19,6 +19,7 @@
> #include "llvm/Module.h"
> #include "llvm/ValueSymbolTable.h"
> #include "llvm/Support/Debug.h"
> +#include "llvm/Support/ErrorHandling.h"
> #include "llvm/Support/LeakDetector.h"
> #include "llvm/Support/ManagedStatic.h"
> #include "llvm/Support/ValueHandle.h"
> @@ -514,8 +515,8 @@
> cerr << "While deleting: " << *V->getType() << " %" << V-
> >getNameStr()
> << "\n";
> #endif
> - cerr << "An asserting value handle still pointed to this
> value!\n";
> - abort();
> + llvm_report_error("An asserting value handle still pointed to
> this"
> + "value!");
Assertion.
> +++ llvm/trunk/lib/VMCore/Verifier.cpp Wed Jul 8 13:01:40 2009
> @@ -62,6 +62,7 @@
> #include "llvm/ADT/StringExtras.h"
> #include "llvm/ADT/STLExtras.h"
> #include "llvm/Support/Compiler.h"
> +#include "llvm/Support/ErrorHandling.h"
> #include "llvm/Support/raw_ostream.h"
> #include <algorithm>
> #include <sstream>
> @@ -93,7 +94,7 @@
> }
>
> if (Broken)
> - abort();
> + llvm_report_error("Broken module, no Basic Block
> terminator!");
>
> return false;
> }
> @@ -210,8 +211,7 @@
> default: assert(0 && "Unknown action");
> case AbortProcessAction:
> msgs << "compilation aborted!\n";
> - cerr << msgs.str();
> - abort();
> + llvm_report_error(msgs.str());
> case PrintMessageAction:
> msgs << "verification continues.\n";
> cerr << msgs.str();
The verifier really should abort when the action is
AbortProcessAction. Clients that want to use the verifier in other
modes can pick a different reaction.
-Chris
More information about the llvm-commits
mailing list