[llvm-commits] [llvm] r75363 - in /llvm/trunk/lib: Analysis/ Analysis/IPA/ CodeGen/ CodeGen/AsmPrinter/ CodeGen/SelectionDAG/ ExecutionEngine/ ExecutionEngine/Interpreter/ ExecutionEngine/JIT/ Support/ Transforms/Scalar/ Transforms/Utils/ VMCore/

Chris Lattner clattner at apple.com
Sun Jul 12 12:46:19 PDT 2009


On Jul 11, 2009, at 6:10 AM, Torok Edwin wrote:
> Author: edwin
> Date: Sat Jul 11 08:10:19 2009
> New Revision: 75363
>
> URL: http://llvm.org/viewvc/llvm-project?rev=75363&view=rev
> Log:
> Convert more assert(0)+abort() -> LLVM_UNREACHABLE,
> and abort()/exit() -> llvm_report_error().

Ok.

> +++ llvm/trunk/lib/CodeGen/IfConversion.cpp Sat Jul 11 08:10:19 2009
> @@ -1130,8 +1132,10 @@
>     if (TII->isPredicated(I))
>       continue;
>     if (!TII->PredicateInstruction(I, Cond)) {
> -      cerr << "Unable to predicate " << *I << "!\n";
> -      abort();
> +      std::string msg;
> +      raw_string_ostream Msg(msg);
> +      Msg << "Unable to predicate " << *I << "!";
> +      llvm_report_error(Msg.str());

Should should be llvm_unreachable with the printout in #ifndef NDEBUG.

> @@ -1164,8 +1168,10 @@
>
>     if (!isPredicated)
>       if (!TII->PredicateInstruction(MI, Cond)) {
> -        cerr << "Unable to predicate " << *MI << "!\n";
> -        abort();
> +        std::string msg;
> +        raw_string_ostream Msg(msg);
> +        Msg << "Unable to predicate " << *MI << "!";
> +        llvm_report_error(Msg.str());

likewise.

> +++ llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp Sat Jul 11 08:10:19  
> 2009
> @@ -31,6 +31,7 @@
> #include "llvm/Target/TargetRegisterInfo.h"
> #include "llvm/Support/CommandLine.h"
> #include "llvm/Support/Debug.h"
> +#include "llvm/Support/ErrorHandling.h"
> #include "llvm/ADT/DenseMap.h"
> #include "llvm/ADT/DepthFirstIterator.h"
> #include "llvm/ADT/SmallPtrSet.h"
> @@ -1036,8 +1037,7 @@
>
>   if (ValNo->isUnused()) {
>     // Defined by a dead def? How can this be?
> -    assert(0 && "Val# is defined by a dead def?");
> -    abort();
> +    LLVM_UNREACHABLE("Val# is defined by a dead def?");

This should just be:

assert(!ValNo->isUnused() && "Val# is defined by a dead def?");

>
> +++ llvm/trunk/lib/CodeGen/RegisterScavenging.cpp Sat Jul 11  
> 08:10:19 2009
> @@ -20,6 +20,7 @@
> #include "llvm/CodeGen/MachineBasicBlock.h"
> #include "llvm/CodeGen/MachineInstr.h"
> #include "llvm/CodeGen/MachineRegisterInfo.h"
> +#include "llvm/Support/ErrorHandling.h"
> #include "llvm/Target/TargetRegisterInfo.h"
> #include "llvm/Target/TargetInstrInfo.h"
> #include "llvm/Target/TargetMachine.h"
> @@ -459,8 +460,7 @@
>   }
>
>   if (ScavengedReg != 0) {
> -    assert(0 && "Scavenger slot is live, unable to scavenge another  
> register!");
> -    abort();
> +    LLVM_UNREACHABLE("Scavenger slot is live, unable to scavenge  
> another register!");
>   }

assert(ScavengedReg == 0 && ...

> +++ llvm/trunk/lib/CodeGen/SelectionDAG/CallingConvLower.cpp Sat Jul  
> 11 08:10:19 2009
> @@ -13,6 +13,8 @@
> // 
> = 
> = 
> = 
> ----------------------------------------------------------------------= 
> ==//
>
> #include "llvm/CodeGen/CallingConvLower.h"
> +#include "llvm/Support/ErrorHandling.h"
> +#include "llvm/Support/raw_ostream.h"
> #include "llvm/Target/TargetRegisterInfo.h"
> #include "llvm/Target/TargetData.h"
> #include "llvm/Target/TargetMachine.h"
> @@ -65,9 +67,11 @@
>     ISD::ArgFlagsTy ArgFlags =
>       cast<ARG_FLAGSSDNode>(TheArgs->getOperand(3+i))->getArgFlags();
>     if (Fn(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, *this)) {
> -      cerr << "Formal argument #" << i << " has unhandled type "
> -           << ArgVT.getMVTString() << "\n";
> -      abort();
> +      std::string msg;
> +      raw_string_ostream Msg(msg);
> +      Msg << "Formal argument #" << i << " has unhandled type "
> +           << ArgVT.getMVTString();
> +      llvm_report_error(Msg.str());

This should be an assert.

> @@ -81,9 +85,11 @@
>     ISD::ArgFlagsTy ArgFlags =
>       cast<ARG_FLAGSSDNode>(TheRet->getOperand(i*2+2))->getArgFlags();
>     if (Fn(i, VT, VT, CCValAssign::Full, ArgFlags, *this)){
> -      cerr << "Return operand #" << i << " has unhandled type "
> -           << VT.getMVTString() << "\n";
> -      abort();
> +      std::string msg;
> +      raw_string_ostream Msg(msg);
> +      Msg << "Return operand #" << i << " has unhandled type "
> +           << VT.getMVTString();
> +      llvm_report_error(Msg.str());

> @@ -97,9 +103,11 @@
>     MVT ArgVT = TheCall->getArg(i).getValueType();
>     ISD::ArgFlagsTy ArgFlags = TheCall->getArgFlags(i);
>     if (Fn(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, *this)) {
> -      cerr << "Call operand #" << i << " has unhandled type "
> -           << ArgVT.getMVTString() << "\n";
> -      abort();
> +      std::string msg;
> +      raw_string_ostream Msg(msg);
> +      Msg << "Call operand #" << i << " has unhandled type "
> +           << ArgVT.getMVTString();
> +      llvm_report_error(Msg.str());
>     }
>   }
> }
> @@ -114,9 +122,11 @@
>     MVT ArgVT = ArgVTs[i];
>     ISD::ArgFlagsTy ArgFlags = Flags[i];
>     if (Fn(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, *this)) {
> -      cerr << "Call operand #" << i << " has unhandled type "
> -           << ArgVT.getMVTString() << "\n";
> -      abort();
> +      std::string msg;
> +      raw_string_ostream Msg(msg);
> +      Msg << "Call operand #" << i << " has unhandled type "
> +           << ArgVT.getMVTString();
> +      llvm_report_error(Msg.str());
>     }
>   }
> }
> @@ -130,9 +140,11 @@
>     if (TheCall->isInreg())
>       Flags.setInReg();
>     if (Fn(i, VT, VT, CCValAssign::Full, Flags, *this)) {
> -      cerr << "Call result #" << i << " has unhandled type "
> -           << VT.getMVTString() << "\n";
> -      abort();
> +      std::string msg;
> +      raw_string_ostream Msg(msg);
> +      Msg << "Call result #" << i << " has unhandled type "
> +           << VT.getMVTString();
> +      llvm_report_error(Msg.str());
>     }
>   }
> }
> @@ -141,8 +153,10 @@
> /// produce a single value.
> void CCState::AnalyzeCallResult(MVT VT, CCAssignFn Fn) {
>   if (Fn(0, VT, VT, CCValAssign::Full, ISD::ArgFlagsTy(), *this)) {
> -    cerr << "Call result has unhandled type "
> -         << VT.getMVTString() << "\n";
> -    abort();
> +    std::string msg;
> +    raw_string_ostream Msg(msg);
> +    Msg << "Call result has unhandled type "
> +         << VT.getMVTString();
> +    llvm_report_error(Msg.str());
>   }
> }

likewise for these.

> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Sat Jul  
> 11 08:10:19 2009
> @@ -47,6 +47,7 @@
> #include "llvm/Target/TargetOptions.h"
> #include "llvm/Support/Compiler.h"
> #include "llvm/Support/Debug.h"
> +#include "llvm/Support/ErrorHandling.h"
> #include "llvm/Support/MathExtras.h"
> #include "llvm/Support/Timer.h"
> #include <algorithm>
> @@ -151,10 +152,9 @@
> // basic blocks, and the scheduler passes ownership of it to this  
> method.
> MachineBasicBlock  
> *TargetLowering::EmitInstrWithCustomInserter(MachineInstr *MI,
>                                                  MachineBasicBlock  
> *MBB) const {
> -  cerr << "If a target marks an instruction with "
> -       << "'usesCustomDAGSchedInserter', it must implement "
> -       << "TargetLowering::EmitInstrWithCustomInserter!\n";
> -  abort();
> +  llvm_report_error("If a target marks an instruction with "
> +                    "'usesCustomDAGSchedInserter', it must  
> implement "
> +                    "TargetLowering::EmitInstrWithCustomInserter!");

This should be an unreachable with the printout in #ifndef.

> @@ -875,7 +875,7 @@
>           if (EnableFastISelAbort)
>             // The "fast" selector couldn't handle something and  
> bailed.
>             // For the purpose of debugging, just abort.
> -            assert(0 && "FastISel didn't select the entire block");
> +            LLVM_UNREACHABLE("FastISel didn't select the entire  
> block");

This should be: assert(! EnableFastISelAbort && ...)

-Chris




More information about the llvm-commits mailing list