[llvm] r251266 - Convert assert(false) into llvm_unreachable where it makes sense.
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 26 11:43:28 PDT 2015
On Mon, Oct 26, 2015 at 2:43 AM, Benjamin Kramer <benny.kra at gmail.com>
wrote:
> On Mon, Oct 26, 2015 at 6:12 AM, David Blaikie <dblaikie at gmail.com> wrote:
> >
> > On Oct 25, 2015 3:30 PM, "Benjamin Kramer via llvm-commits"
> > <llvm-commits at lists.llvm.org> wrote:
> >>
> >> Author: d0k
> >> Date: Sun Oct 25 17:28:27 2015
> >> New Revision: 251266
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=251266&view=rev
> >> Log:
> >> Convert assert(false) into llvm_unreachable where it makes sense.
> >
> > What sort of places didn't make sense?
>
> There are some rather strange asserts like
> lib/CodeGen/Analysis.cpp:655 that I was too afraid to touch :|
>
Heh - fair. Though I figure any codepath like that is clearly untested &
I'd just turn it into an assertion:
if (FuncletMembership.count(MBB) > 0) {
assert(FuncletMembership[MBB] == Funclet && "...");
return;
}
Bonus points because this removes the redundant map lookup in a non-asserts
build (the redundant lookup could be removed from an asserts build too)
Oh, it looks like there's a 3rd lookup right after this 'if' anyway, which
should be removed...
Changed that all in r251327
>
> - Ben
>
> >
> >>
> >> Modified:
> >> llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp
> >> llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp
> >> llvm/trunk/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp
> >> llvm/trunk/lib/Target/PowerPC/PPCVSXSwapRemoval.cpp
> >> llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
> >> llvm/trunk/lib/Transforms/Scalar/LoopInterchange.cpp
> >>
> >> Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=251266&r1=251265&r2=251266&view=diff
> >>
> >>
> ==============================================================================
> >> --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original)
> >> +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Sun Oct 25 17:28:27
> >> 2015
> >> @@ -97,7 +97,7 @@ ARMBaseInstrInfo::ARMBaseInstrInfo(const
> >> Subtarget(STI) {
> >> for (unsigned i = 0, e = array_lengthof(ARM_MLxTable); i != e; ++i) {
> >> if (!MLxEntryMap.insert(std::make_pair(ARM_MLxTable[i].MLxOpc,
> >> i)).second)
> >> - assert(false && "Duplicated entries?");
> >> + llvm_unreachable("Duplicated entries?");
> >> MLxHazardOpcodes.insert(ARM_MLxTable[i].AddSubOpc);
> >> MLxHazardOpcodes.insert(ARM_MLxTable[i].MulOpc);
> >> }
> >>
> >> Modified: llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp?rev=251266&r1=251265&r2=251266&view=diff
> >>
> >>
> ==============================================================================
> >> --- llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp (original)
> >> +++ llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp Sun Oct 25
> 17:28:27
> >> 2015
> >> @@ -213,7 +213,7 @@ Thumb2SizeReduce::Thumb2SizeReduce(std::
> >> for (unsigned i = 0, e = array_lengthof(ReduceTable); i != e; ++i) {
> >> unsigned FromOpc = ReduceTable[i].WideOpc;
> >> if (!ReduceOpcodeMap.insert(std::make_pair(FromOpc, i)).second)
> >> - assert(false && "Duplicated entries?");
> >> + llvm_unreachable("Duplicated entries?");
> >> }
> >> }
> >>
> >>
> >> Modified: llvm/trunk/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp?rev=251266&r1=251265&r2=251266&view=diff
> >>
> >>
> ==============================================================================
> >> --- llvm/trunk/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp (original)
> >> +++ llvm/trunk/lib/Target/NVPTX/NVPTXGenericToNVVM.cpp Sun Oct 25
> 17:28:27
> >> 2015
> >> @@ -316,8 +316,8 @@ Value *GenericToNVVM::remapConstantExpr(
> >> NewOperands[0], NewOperands[1]);
> >> case Instruction::FCmp:
> >> // CompareConstantExpr (fcmp)
> >> - assert(false && "Address space conversion should have no effect "
> >> - "on float point CompareConstantExpr (fcmp)!");
> >> + llvm_unreachable("Address space conversion should have no effect "
> >> + "on float point CompareConstantExpr (fcmp)!");
> >> return C;
> >
> > Drop the unreachable return?
> >
> >> case Instruction::ExtractElement:
> >> // ExtractElementConstantExpr
> >> @@ -362,7 +362,7 @@ Value *GenericToNVVM::remapConstantExpr(
> >> return Builder.CreateCast(Instruction::CastOps(C->getOpcode()),
> >> NewOperands[0], C->getType());
> >> }
> >> - assert(false && "GenericToNVVM encountered an unsupported
> >> ConstantExpr");
> >> + llvm_unreachable("GenericToNVVM encountered an unsupported
> >> ConstantExpr");
> >> return C;
> >
> > And here
> >
> >> }
> >> }
> >>
> >> Modified: llvm/trunk/lib/Target/PowerPC/PPCVSXSwapRemoval.cpp
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCVSXSwapRemoval.cpp?rev=251266&r1=251265&r2=251266&view=diff
> >>
> >>
> ==============================================================================
> >> --- llvm/trunk/lib/Target/PowerPC/PPCVSXSwapRemoval.cpp (original)
> >> +++ llvm/trunk/lib/Target/PowerPC/PPCVSXSwapRemoval.cpp Sun Oct 25
> >> 17:28:27 2015
> >> @@ -789,7 +789,7 @@ void PPCVSXSwapRemoval::handleSpecialSwa
> >> switch (SwapVector[EntryIdx].SpecialHandling) {
> >>
> >> default:
> >> - assert(false && "Unexpected special handling type");
> >> + llvm_unreachable("Unexpected special handling type");
> >> break;
> >
> > Unreachable break
> >
> >>
> >> // For splats based on an index into a vector, add N/2 modulo N
> >> @@ -803,7 +803,7 @@ void PPCVSXSwapRemoval::handleSpecialSwa
> >>
> >> switch (MI->getOpcode()) {
> >> default:
> >> - assert(false && "Unexpected splat opcode");
> >> + llvm_unreachable("Unexpected splat opcode");
> >> case PPC::VSPLTB: NElts = 16; break;
> >> case PPC::VSPLTH: NElts = 8; break;
> >> case PPC::VSPLTW: NElts = 4; break;
> >>
> >> Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=251266&r1=251265&r2=251266&view=diff
> >>
> >>
> ==============================================================================
> >> --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
> >> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sun Oct 25 17:28:27
> 2015
> >> @@ -10957,8 +10957,7 @@ static SDValue lower1BitVectorShuffle(SD
> >> EVT ExtVT;
> >> switch (VT.SimpleTy) {
> >> default:
> >> - assert(false && "Expected a vector of i1 elements");
> >> - break;
> >> + llvm_unreachable("Expected a vector of i1 elements");
> >> case MVT::v2i1:
> >> ExtVT = MVT::v2i64;
> >> break;
> >>
> >> Modified: llvm/trunk/lib/Transforms/Scalar/LoopInterchange.cpp
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopInterchange.cpp?rev=251266&r1=251265&r2=251266&view=diff
> >>
> >>
> ==============================================================================
> >> --- llvm/trunk/lib/Transforms/Scalar/LoopInterchange.cpp (original)
> >> +++ llvm/trunk/lib/Transforms/Scalar/LoopInterchange.cpp Sun Oct 25
> >> 17:28:27 2015
> >> @@ -996,7 +996,7 @@ void LoopInterchangeTransform::removeChi
> >> return;
> >> }
> >> }
> >> - assert(false && "Couldn't find loop");
> >> + llvm_unreachable("Couldn't find loop");
> >> }
> >>
> >> void LoopInterchangeTransform::restructureLoops(Loop *InnerLoop,
> >>
> >>
> >> _______________________________________________
> >> llvm-commits mailing list
> >> llvm-commits at lists.llvm.org
> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151026/875a2a32/attachment.html>
More information about the llvm-commits
mailing list