[llvm-commits] [llvm] r123297 - /llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp
Nick Lewycky
nlewycky at google.com
Tue Jan 11 18:13:38 PST 2011
On 11 January 2011 17:47, Chris Lattner <clattner at apple.com> wrote:
>
> On Jan 11, 2011, at 5:42 PM, Matt Beaumont-Gay wrote:
>
> > Author: matthewbg
> > Date: Tue Jan 11 19:42:42 2011
> > New Revision: 123297
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=123297&view=rev
> > Log:
> > Prefer llvm_unreachable to assert(0)
>
> Hi Matt,
>
> Please use assert(0) unless we need the "does not fallthrough" behavior of
> llvm_unreachable.
>
The difference is that llvm_unreachable still generates code in a Release
build while assert() doesn't, right?
Matt made this commit because we were seeing:
llvm/lib/Target/ARM/ARMMCCodeEmitter.cpp:653: error: control reaches end
of non-void function [-Wreturn-type]
so it sounds like llvm_unreachable isn't the right tool, but we'd like to
fix this that doesn't generate warnings in release builds.
Nick
>
> -Chris
>
> >
> > Modified:
> > llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp
> >
> > Modified: llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp?rev=123297&r1=123296&r2=123297&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp (original)
> > +++ llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp Tue Jan 11 19:42:42
> 2011
> > @@ -129,7 +129,7 @@
> > SmallVectorImpl<MCFixup> &Fixups) const {
> > ARM_AM::AMSubMode Mode =
> (ARM_AM::AMSubMode)MI.getOperand(OpIdx).getImm();
> > switch (Mode) {
> > - default: assert(0 && "Unknown addressing sub-mode!");
> > + default: llvm_unreachable("Unknown addressing sub-mode!");
> > case ARM_AM::da: return 0;
> > case ARM_AM::ia: return 1;
> > case ARM_AM::db: return 2;
> > @@ -648,7 +648,7 @@
> > switch (Expr->getKind()) {
> > case MCExpr::SymbolRef: return false;
> > case MCExpr::Binary: return true;
> > - default: assert(0 && "Unexpected expression type");
> > + default: llvm_unreachable("Unexpected expression type");
> > }
> > }
> >
> > @@ -669,7 +669,7 @@
> > const MCExpr *OrigExpr = MO.getExpr();
> > MCFixupKind Kind;
> > switch (Expr->getKind()) {
> > - default: assert(0 && "Unsupported ARMFixup");
> > + default: llvm_unreachable("Unsupported ARMFixup");
> > case MCSymbolRefExpr::VK_ARM_HI16:
> > Kind = MCFixupKind(ARM::fixup_arm_movt_hi16);
> > if (EvaluateAsPCRel(OrigExpr))
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110111/005c5160/attachment.html>
More information about the llvm-commits
mailing list